Example #1
0
void LaunchyWidget::executeStartupCommand(int command)
{
	if (command & ResetPosition)
	{
		QRect r = geometry();
		int primary = qApp->desktop()->primaryScreen();
		QRect scr = qApp->desktop()->availableGeometry(primary);

		QPoint pt(scr.width()/2 - r.width()/2, scr.height()/2 - r.height()/2);
		move(pt);
	}

	if (command & ResetSkin)
	{
		setOpaqueness(100);
		showTrayIcon();
		applySkin("Default");
	}

	if (command & ShowLaunchy)
		showLaunchy();

	if (command & ShowOptions)
		showOptionsDialog();

	if (command & Rescan)
		buildCatalog();

	if (command & Exit)
		close();
}
Example #2
0
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);
}
/// Initialise dialog window components.
///
/// @param componentWidth width of content component
///
/// @param componentHeight height of content component
///
/// @param numberOfInputChannels current number of audio input
///        channels
///
/// @param sampleRate current audio sample rate
///
/// @param selectedChannel current audio channel used for validation
///        (starting at 0; -1 designates all channels)
///
/// @param validationFile current audio file used for validation
///
void WindowValidationContent::initialise(
    int componentWidth,
    int componentHeight,
    int numberOfInputChannels,
    int sampleRate,
    int selectedChannel,
    const File &validationFile)

{
    // call method of super class
    frut::widgets::WindowValidationContent::initialise(
        componentWidth,
        componentHeight,
        numberOfInputChannels,
        sampleRate,
        selectedChannel,
        validationFile);


    // initialise button for selecting the validation output format
    buttonDumpCSV_.setButtonText("CSV format");

    buttonDumpCSV_.setToggleState(
        audioProcessor->getBoolean(
            KmeterPluginParameters::selValidationCSVFormat),
        dontSendNotification);

    addAndMakeVisible(buttonDumpCSV_);


    // initialise channel selection slider
    sliderSelectChannel_.setValue(
        audioProcessor->getRealInteger(
            KmeterPluginParameters::selValidationSelectedChannel),
        dontSendNotification);

    addAndMakeVisible(sliderSelectChannel_);


    // initialise button for average level logging
    buttonDumpAverageLevel_.setButtonText("Average meter level");

    buttonDumpAverageLevel_.setToggleState(
        audioProcessor->getBoolean(
            KmeterPluginParameters::selValidationAverageMeterLevel),
        dontSendNotification);

    addAndMakeVisible(buttonDumpAverageLevel_);


    // initialise button for peak level logging
    buttonDumpPeakLevel_.setButtonText("Peak meter level");

    buttonDumpPeakLevel_.setToggleState(
        audioProcessor->getBoolean(
            KmeterPluginParameters::selValidationPeakMeterLevel),
        dontSendNotification);

    addAndMakeVisible(buttonDumpPeakLevel_);


    // initialise button for true peak level logging
    buttonDumpTruePeakLevel_.setButtonText("True peak meter level");

    buttonDumpTruePeakLevel_.setToggleState(
        audioProcessor->getBoolean(
            KmeterPluginParameters::selValidationTruePeakMeterLevel),
        dontSendNotification);

    addAndMakeVisible(buttonDumpTruePeakLevel_);


    // initialise button for maximum peak level logging
    buttonDumpMaximumPeakLevel_.setButtonText("Maximum peak level");

    buttonDumpMaximumPeakLevel_.setToggleState(
        audioProcessor->getBoolean(
            KmeterPluginParameters::selValidationMaximumPeakLevel),
        dontSendNotification);

    addAndMakeVisible(buttonDumpMaximumPeakLevel_);


    // initialise button for maximum true peak level logging
    buttonDumpMaximumTruePeakLevel_.setButtonText("Max. true peak level");

    buttonDumpMaximumTruePeakLevel_.setToggleState(
        audioProcessor->getBoolean(
            KmeterPluginParameters::selValidationMaximumTruePeakLevel),
        dontSendNotification);

    addAndMakeVisible(buttonDumpMaximumTruePeakLevel_);


    // initialise button for stereo meter logging
    buttonDumpStereoMeter_.setButtonText("Stereo meter value");

    buttonDumpStereoMeter_.setToggleState(
        audioProcessor->getBoolean(
            KmeterPluginParameters::selValidationStereoMeterValue),
        dontSendNotification);

    addAndMakeVisible(buttonDumpStereoMeter_);


    // initialise button for phase correlation logging
    buttonDumpPhaseCorrelation_.setButtonText("Phase correlation");

    buttonDumpPhaseCorrelation_.setToggleState(
        audioProcessor->getBoolean(
            KmeterPluginParameters::selValidationPhaseCorrelation),
        dontSendNotification);

    addAndMakeVisible(buttonDumpPhaseCorrelation_);


    // style and place the dialog window's components
    applySkin();
}