コード例 #1
0
std::shared_ptr<ScrollBar> SimpleScrollableAreaSkin::createScrollBar(
    const std::shared_ptr<FloatValue>& controlledValue,
    Direction::Enum direction) const
{
    if (!m_scrollBarEnabled[direction])
        return nullptr;
    auto skin = std::make_shared<CommonScrollBarSkin>(
        createScrollBarBox(direction, m_scrollBarWidth),
        createDragBarBox(direction, m_scrollBarWidth),
        direction);
    skin->setAlwaysShow(false);
    skin->setStep(m_scrollStep);

    auto scrollBarBackground = std::make_shared<StaticFilledRect>(
        std::make_shared<RelativeBox>(RelativeValue(), RelativeValue()));
    scrollBarBackground->setColor(m_backgroundColor);
    skin->addElement(scrollBarBackground);
    
    auto decButtonSkin = std::make_shared<ArrowButtonSkin>(std::make_shared<SquareBox>());
    fillSkin(decButtonSkin.get());
    decButtonSkin->setArrowType(direction == Direction::Horizontal
        ? ArrowButtonSkin::Left : ArrowButtonSkin::Down);
    decButtonSkin->setArrowColor(m_arrowColor);
    decButtonSkin->setArrowPadding(m_arrowPadding);
    skin->setDecButtonSkin(decButtonSkin);

    auto incButtonSkin = std::make_shared<ArrowButtonSkin>(std::make_shared<SquareBox>());
    fillSkin(incButtonSkin.get());
    incButtonSkin->setArrowType(direction == Direction::Horizontal
        ? ArrowButtonSkin::Right : ArrowButtonSkin::Up);
    incButtonSkin->setArrowColor(m_arrowColor);
    incButtonSkin->setArrowPadding(m_arrowPadding);
    skin->setIncButtonSkin(incButtonSkin);

    auto dragBar = std::make_shared<SimpleRectangleButtonSkin>(
        std::make_shared<RelativeBox>(RelativeValue(), RelativeValue()));
    fillSkin(dragBar.get());
    skin->setDragBarSkin(dragBar);

    auto scrollBar = std::make_shared<ScrollBar>(skin, createScrollBarOffset(direction));
    scrollBar->setControlledValue(controlledValue);
    return scrollBar;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: stream009/launchy
LaunchyWidget::LaunchyWidget(CommandFlags command) :
#ifdef Q_WS_WIN
	QWidget(NULL, Qt::FramelessWindowHint | Qt::Tool),
#endif
#ifdef Q_WS_X11
        QWidget(NULL, Qt::FramelessWindowHint),
#endif
#ifdef Q_WS_MAC
        QWidget(NULL, Qt::FramelessWindowHint),
#endif

	frameGraphic(NULL),
	trayIcon(NULL),
	alternatives(NULL),
	updateTimer(NULL),
	dropTimer(NULL),
	condensedTempIcon(NULL)
{
	setObjectName("launchy");
	setWindowTitle(tr("Launchy"));
#ifdef Q_WS_WIN
	setWindowIcon(QIcon(":/resources/launchy128.png"));
#endif
#ifdef Q_WS_MAC
        setWindowIcon(QIcon("../Resources/launchy_icon_mac.icns"));
        //setAttribute(Qt::WA_MacAlwaysShowToolWindow);
#endif

	setAttribute(Qt::WA_AlwaysShowToolTips);
	setAttribute(Qt::WA_InputMethodEnabled);
	if (platform->supportsAlphaBorder())
	{
		setAttribute(Qt::WA_TranslucentBackground);
	}
	setFocusPolicy(Qt::ClickFocus);

	createActions();

	gMainWidget = this;
	menuOpen = false;
	optionsOpen = false;
	dragging = false;
	gSearchText = "";

	alwaysShowLaunchy = false;

	connect(&iconExtractor, SIGNAL(iconExtracted(int, QIcon)), this, SLOT(iconExtracted(int, QIcon)));

	fader = new Fader(this);
	connect(fader, SIGNAL(fadeLevel(double)), this, SLOT(setFadeLevel(double)));

	optionsButton = new QPushButton(this);
	optionsButton->setObjectName("opsButton");
	optionsButton->setToolTip(tr("Launchy Options"));
	optionsButton->setGeometry(QRect());
	connect(optionsButton, SIGNAL(clicked()), this, SLOT(showOptionsDialog()));

	closeButton = new QPushButton(this);
	closeButton->setObjectName("closeButton");
	closeButton->setToolTip(tr("Close Launchy"));
	closeButton->setGeometry(QRect());
	connect(closeButton, SIGNAL(clicked()), qApp, SLOT(quit()));

	output = new QLabel(this);
	output->setObjectName("output");
	output->setAlignment(Qt::AlignHCenter);

	input = new CharLineEdit(this);
#ifdef Q_WS_MAC
        QMacStyle::setFocusRectPolicy(input, QMacStyle::FocusDisabled);
#endif
	input->setObjectName("input");
	connect(input, SIGNAL(keyPressed(QKeyEvent*)), this, SLOT(inputKeyPressEvent(QKeyEvent*)));
	connect(input, SIGNAL(focusIn(QFocusEvent*)), this, SLOT(focusInEvent(QFocusEvent*)));
	connect(input, SIGNAL(focusOut(QFocusEvent*)), this, SLOT(focusOutEvent(QFocusEvent*)));
	connect(input, SIGNAL(inputMethod(QInputMethodEvent*)), this, SLOT(inputMethodEvent(QInputMethodEvent*)));

	outputIcon = new QLabel(this);
	outputIcon->setObjectName("outputIcon");

	workingAnimation = new AnimationLabel(this);
	workingAnimation->setObjectName("workingAnimation");
	workingAnimation->setGeometry(QRect());

	// Load settings
	settings.load();

	// If this is the first time running or a new version, call updateVersion
	if (gSettings->value("version", 0).toInt() != LAUNCHY_VERSION)
	{
		updateVersion(gSettings->value("version", 0).toInt());
		command |= ShowLaunchy;
	}

	alternatives = new CharListWidget(this);
	alternatives->setObjectName("alternatives");
	alternatives->setWindowFlags(Qt::Window | Qt::Tool | Qt::FramelessWindowHint);
	alternatives->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	alternatives->setTextElideMode(Qt::ElideLeft);
	alternatives->setUniformItemSizes(true);
	listDelegate = new IconDelegate(this);
	defaultListDelegate = alternatives->itemDelegate();
	setSuggestionListMode(gSettings->value("GenOps/condensedView", 0).toInt());
	altScroll = alternatives->verticalScrollBar();
	altScroll->setObjectName("altScroll");
	connect(alternatives, SIGNAL(currentRowChanged(int)), this, SLOT(alternativesRowChanged(int)));
	connect(alternatives, SIGNAL(keyPressed(QKeyEvent*)), this, SLOT(alternativesKeyPressEvent(QKeyEvent*)));
	connect(alternatives, SIGNAL(focusOut(QFocusEvent*)), this, SLOT(focusOutEvent(QFocusEvent*)));

	alternativesPath = new QLabel(alternatives);
	alternativesPath->setObjectName("alternativesPath");
	alternativesPath->hide();
	listDelegate->setAlternativesPathWidget(alternativesPath);

	// Load the plugins
	plugins.loadPlugins();

	// Set the general options
	if (setAlwaysShow(gSettings->value("GenOps/alwaysshow", false).toBool()))
		command |= ShowLaunchy;
	setAlwaysTop(gSettings->value("GenOps/alwaystop", false).toBool());

	// Check for udpates?
	if (gSettings->value("GenOps/updatecheck", true).toBool())
	{
		checkForUpdate();
	}

	// Set the hotkey
	QKeySequence hotkey = getHotkey();
	if (!setHotkey(hotkey))
	{
		QMessageBox::warning(this, tr("Launchy"), tr("The hotkey %1 is already in use, please select another.").arg(hotkey.toString()));
		command = ShowLaunchy | ShowOptions;
	}

	// Set the timers
	updateTimer = new QTimer(this);
	dropTimer = new QTimer(this);
	dropTimer->setSingleShot(true);
	connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateTimeout()));
	connect(dropTimer, SIGNAL(timeout()), this, SLOT(dropTimeout()));
	int time = gSettings->value("GenOps/updatetimer", 10).toInt();
	if (time > 0)
		updateTimer->start(time * 60000);

	// Load the catalog
	catalog.reset(CatalogBuilder::createCatalog());
	catalog->load(settings.catalogFilename());

	// Load the history
	history.load(settings.historyFilename());

	// Load the skin
	applySkin(gSettings->value("GenOps/skin", "Default").toString());

	// Move to saved position
	loadPosition(gSettings->value("Display/pos", QPoint(0,0)).toPoint());
	loadOptions();

	executeStartupCommand(command);
}