Example #1
0
/*! Shows a plugins dialog to enable the user to add a network */
void NetworksWidget::addNetworks(){
	try{
		PluginsDialog* pluginsDialog = new PluginsDialog(this, "/plugins/networks", "Add Network");
		pluginsDialog->exec();
		delete pluginsDialog;
	}
	catch(SpikeStreamException& ex){
		qCritical()<<ex.getMessage();
	}
}
void MainWindow::setupMenu()
{
    //Setup menu
    menuBar = new QMenuBar(centralWidget());
    this->setMenuBar(menuBar);

    QMenu* fileMenu = new QMenu(tr("File"), menuBar);

    QAction *exitAction = new QAction(tr("Exit"), this);
    connect(exitAction, &QAction::triggered, this, &MainWindow::close);

    fileMenu->addAction(exitAction);

    // Profiles

    QMenu* profilesMenu = new QMenu(tr("Profiles"));

    QAction *backToMainPage = new QAction(tr("Back to main page"), this);
    connect(backToMainPage, &QAction::triggered, []() {
        SDK::ProfileManager::instance()->backToMainPage();
    });

    profilesMenu->addAction(backToMainPage);
    profilesMenu->addSection(tr("Profiles"));

    connect(profilesMenu, &QMenu::triggered, [=](QAction* action) {
        SDK::Profile* profile = SDK::ProfileManager::instance()->findById(action->data().toString());
        if(profile != NULL)
            SDK::ProfileManager::instance()->setActiveProfile(profile);
        else
            WARN() << qPrintable(QString("Can't load profile %1 from profiles menu!").arg(action->data().toString()));
    });

    connect(SDK::ProfileManager::instance(), &SDK::ProfileManager::profileChanged, [=](SDK::Profile* profile){
        for(QAction* action: profilesMenu->actions())
        {
            if(action->data().toString() == profile->getId())
            {
                action->setChecked(true);
                profilesMenu->setActiveAction(action);
            }
            else
            {
                action->setChecked(false);
            }
        }
    });

    for(const SDK::Profile* profile: SDK::ProfileManager::instance()->getProfiles())
    {
        if(!profile->hasFlag(SDK::Profile::HIDDEN))
        {
            QAction* loadProfile = new QAction(profile->getName(), profilesMenu);
            loadProfile->setData(profile->getId());
            loadProfile->setCheckable(true);
            loadProfile->setChecked(false);
            profilesMenu->addAction(loadProfile);
        }
    }

    // Video menu
    QMenu* videoMenu = new QMenu(tr("Video"), menuBar);

    QMenu* aspectRatioMenu = new QMenu(tr("Aspect ratio"), videoMenu);

    connect(aspectRatioMenu, &QMenu::triggered, [=](QAction* action){
        if(player())
            player()->setAspectRatio((SDK::AspectRatio) action->data().toInt());
        aspectRatioMenu->setActiveAction(action);
        for(QAction* a: aspectRatioMenu->actions())
        {
            a->setChecked(a == action && player());
        }

    });

    connect(aspectRatioMenu, &QMenu::aboutToShow, [=]{
        if(!player())
            return;

        SDK::AspectRatio current_ratio = player()->getAspectRatio();
        for(QAction* action: aspectRatioMenu->actions())
        {
            SDK::AspectRatio ratio = (SDK::AspectRatio) action->data().toInt();
            if(ratio == current_ratio)
            {
                action->setChecked(true);
            }
            else
            {
                action->setChecked(false);
            }
        }
    });

    QList<QPair<QString, SDK::AspectRatio>> ratios;
    ratios.append(QPair<QString, SDK::AspectRatio>(tr("Auto"),     SDK::ASPECT_RATIO_AUTO));
    ratios.append(QPair<QString, SDK::AspectRatio>(tr("1:1"),      SDK::ASPECT_RATIO_1_1));
    ratios.append(QPair<QString, SDK::AspectRatio>(tr("5:4"),      SDK::ASPECT_RATIO_5_4));
    ratios.append(QPair<QString, SDK::AspectRatio>(tr("4:3"),      SDK::ASPECT_RATIO_4_3));
    ratios.append(QPair<QString, SDK::AspectRatio>(tr("11:8"),     SDK::ASPECT_RATIO_11_8));
    ratios.append(QPair<QString, SDK::AspectRatio>(tr("14:10"),    SDK::ASPECT_RATIO_14_10));
    ratios.append(QPair<QString, SDK::AspectRatio>(tr("3:2"),      SDK::ASPECT_RATIO_3_2));
    ratios.append(QPair<QString, SDK::AspectRatio>(tr("14:9"),     SDK::ASPECT_RATIO_14_9));
    ratios.append(QPair<QString, SDK::AspectRatio>(tr("16:10"),    SDK::ASPECT_RATIO_16_10));
    ratios.append(QPair<QString, SDK::AspectRatio>(tr("16:9"),     SDK::ASPECT_RATIO_16_9));
    ratios.append(QPair<QString, SDK::AspectRatio>(tr("2.35:1"),   SDK::ASPECT_RATIO_2_35_1));

    for(QPair<QString, SDK::AspectRatio> pair: ratios)
    {
        QString name = pair.first;
        SDK::AspectRatio ratio = pair.second;
        QAction* action = new QAction(name, aspectRatioMenu);
        action->setData(ratio);
        action->setCheckable(true);
        action->setChecked(false);
        aspectRatioMenu->addAction(action);
    }

    videoMenu->addMenu(aspectRatioMenu);

    // Audio menu
    QMenu* audioMenu = new QMenu(tr("Audio"), menuBar);
    QMenu* audioTrackMenu = new QMenu(tr("Track"), audioMenu);

    connect(audioTrackMenu, &QMenu::triggered, [=](QAction* action){
        if(!player())
            return;

        player()->setAudioLanguage(action->data().toInt());
        audioTrackMenu->setActiveAction(action);
        for(QAction* a: audioTrackMenu->actions())
        {
            action->setChecked(a == action);
        }
    });

    connect(audioTrackMenu, &QMenu::aboutToShow, [=]{
        audioTrackMenu->clear();
        if(!player())
            return;

        int index = player()->getAudioPID();
        QList<AudioLangInfo> languages = player()->getAudioLanguages();
        for(const AudioLangInfo &lang: languages)
        {
            QAction* action = new QAction(lang.m_code3, audioTrackMenu);
            action->setData(lang.m_pid);
            action->setCheckable(true);
            action->setChecked(lang.m_pid == index);
            audioTrackMenu->addAction(action);
        }
    });

    audioMenu->addMenu(audioTrackMenu);

    // Settings

    QMenu* settingsMenu = new QMenu(tr("Settings"));
    QAction* settingsAction = new QAction(tr("Settings..."), settingsMenu);
    settingsAction->setMenuRole(QAction::PreferencesRole);
    connect(settingsAction, &QAction::triggered, [=]() {
        SettingsDialog* dialog = new SettingsDialog(this);
        dialog->setAttribute( Qt::WA_DeleteOnClose, true );
        dialog->show();
    });
    settingsMenu->addAction(settingsAction);

    QAction* showDevTools = new QAction(tr("Developer tools..."), settingsMenu);
    connect(showDevTools, &QAction::triggered, SDK::Browser::instance(), &SDK::Browser::showDeveloperTools);
    settingsMenu->addAction(showDevTools);

    QAction* toggleFullscreenAction = new QAction(tr("Fullscreen mode"), settingsMenu);
    toggleFullscreenAction->setCheckable(true);
    connect(this, &MainWindow::fullScreenModeToggled, [=](bool fullscreen){
        toggleFullscreenAction->setChecked(fullscreen);
    });
    connect(toggleFullscreenAction, &QAction::triggered, [=]() {
         setAppFullscreen(!isFullScreen());
    });
    settingsMenu->addAction(toggleFullscreenAction);

    //About

    QMenu* aboutMenu = new QMenu(tr("About"));

    QAction* aboutAppAction = new QAction(tr("About application..."), aboutMenu);
    aboutAppAction->setMenuRole(QAction::AboutRole);
    connect(aboutAppAction, &QAction::triggered, [=]() {
       AboutAppDialog dialog;
       dialog.exec();
       dialog.show();
    });


    QAction* aboutPluginsAction = new QAction(tr("About plugins..."), aboutMenu);
    aboutPluginsAction->setMenuRole(QAction::ApplicationSpecificRole);
    connect(aboutPluginsAction, &QAction::triggered, [=]() {
       PluginsDialog dialog;
       dialog.exec();
       dialog.show();
    });

    aboutMenu->addAction(aboutAppAction);
    aboutMenu->addAction(aboutPluginsAction);

    menuBar->addMenu(fileMenu);
    menuBar->addMenu(videoMenu);
    menuBar->addMenu(audioMenu);
    menuBar->addMenu(profilesMenu);
    menuBar->addMenu(settingsMenu);
    menuBar->addMenu(aboutMenu);

    m_menuItems.append(fileMenu);
    m_menuItems.append(videoMenu);
    m_menuItems.append(audioMenu);
    m_menuItems.append(profilesMenu);
    m_menuItems.append(settingsMenu);
}
Example #3
0
void LiteApp::aboutPlugins()
{
    PluginsDialog *dlg = new PluginsDialog(this,m_mainwindow);
    foreach (LiteApi::IPluginFactory *factory, pluginManager()->factoryList()) {
        dlg->appendInfo(factory->info());
    }