Example #1
0
QMenu* VCFrame::customMenu(QMenu* parentMenu)
{
	/* No point coming here if there is no VC */
	VirtualConsole* vc = VirtualConsole::instance();
	if (vc == NULL)
		return NULL;

	/* Basically, just returning VC::addMenu() would suffice here, but
	   since the returned menu will be deleted when the current widget
	   changes, we have to copy the menu's contents into a new menu. */
	QMenu* menu = new QMenu(parentMenu);
	menu->setTitle(tr("Add"));
	QListIterator <QAction*> it(vc->addMenu()->actions());
	while (it.hasNext() == true)
		menu->addAction(it.next());
	return menu;
}
void InputField::contextMenuEvent(QContextMenuEvent *event)
{
    QMenu *editMenu = createStandardContextMenu();
    editMenu->setTitle(tr("Edit"));
    QMenu* menu = new QMenu(QString::fromAscii("InputFieldContextmenu"));

    menu->addMenu(editMenu);
    menu->addSeparator();

    // datastructure to remember actions for values
    std::vector<QString> values;
    std::vector<QAction *> actions;

    // add the history menu part...
    std::vector<QString> history = getHistory();

    for(std::vector<QString>::const_iterator it = history.begin();it!= history.end();++it){
        actions.push_back(menu->addAction(*it));
        values.push_back(*it);
    }

    // add the save value portion of the menu
    menu->addSeparator();
    QAction *SaveValueAction = menu->addAction(tr("Save value"));
    std::vector<QString> savedValues = getSavedValues();

    for(std::vector<QString>::const_iterator it = savedValues.begin();it!= savedValues.end();++it){
        actions.push_back(menu->addAction(*it));
        values.push_back(*it);
    }

    // call the menu and wait until its back
    QAction *saveAction = menu->exec(event->globalPos());

    // look what the user has choosen
    if(saveAction == SaveValueAction)
        pushToSavedValues();
    else{
        int i=0;
        for(std::vector<QAction *>::const_iterator it = actions.begin();it!=actions.end();++it,i++)
            if(*it == saveAction)
                this->setText(values[i]);
    }

    delete menu;
}
Example #3
0
QMenu* EventCanvas::genItemPopup(CItem* item)/*{{{*/
{
    QMenu* notePopup = new QMenu(this);
    QMenu* colorPopup = notePopup->addMenu(tr("Part Color"));

    QMenu* colorSub;
    for (int i = 0; i < NUM_PARTCOLORS; ++i)
    {
        QString colorname(config.partColorNames[i]);
        if(colorname.contains("menu:", Qt::CaseSensitive))
        {
            colorSub = colorPopup->addMenu(colorname.replace("menu:", ""));
        }
        else
        {
            if(item->part()->colorIndex() == i)
            {
                colorname = QString(config.partColorNames[i]);
                colorPopup->setIcon(partColorIcons.at(i));
                colorPopup->setTitle(colorSub->title()+": "+colorname);

                colorname = QString("* "+config.partColorNames[i]);
                QAction *act_color = colorSub->addAction(partColorIcons.at(i), colorname);
                act_color->setData(20 + i);
            }
            else
            {
                colorname = QString("     "+config.partColorNames[i]);
                QAction *act_color = colorSub->addAction(partColorIcons.at(i), colorname);
                act_color->setData(20 + i);
            }
        }
    }

    notePopup->addSeparator();
    for (unsigned i = 0; i < 9; ++i)
    {
        if ((_canvasTools & (1 << i)) == 0)
            continue;
        QAction* act = notePopup->addAction(QIcon(*toolList[i].icon), tr(toolList[i].tip));
        act->setData(1 << i);
    }

    return notePopup;
}/*}}}*/
Example #4
0
/*! Initializes the plugin. Returns true on success.
    Plugins want to register objects with the plugin manager here.

    \a errorMessage can be used to pass an error message to the plugin system,
       if there was any.
*/
bool HelloWorldPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
    Q_UNUSED(arguments)
    Q_UNUSED(errorMessage)

    // Get the primary access point to the workbench.
    Core::ICore *core = Core::ICore::instance();

    // Create a unique context for our own view, that will be used for the
    // menu entry later.
    Core::Context context("HelloWorld.MainView");

    // Create an action to be triggered by a menu entry
    QAction *helloWorldAction = new QAction(tr("Say \"&Hello World!\""), this);
    connect(helloWorldAction, SIGNAL(triggered()), SLOT(sayHelloWorld()));

    // Register the action with the action manager
    Core::ActionManager *actionManager = core->actionManager();
    Core::Command *command =
            actionManager->registerAction(
                    helloWorldAction, "HelloWorld.HelloWorldAction", context);

    // Create our own menu to place in the Tools menu
    Core::ActionContainer *helloWorldMenu =
            actionManager->createMenu("HelloWorld.HelloWorldMenu");
    QMenu *menu = helloWorldMenu->menu();
    menu->setTitle(tr("&Hello World"));
    menu->setEnabled(true);

    // Add the Hello World action command to the menu
    helloWorldMenu->addAction(command);

    // Request the Tools menu and add the Hello World menu to it
    Core::ActionContainer *toolsMenu =
            actionManager->actionContainer(Core::Constants::M_TOOLS);
    toolsMenu->addMenu(helloWorldMenu);

    // Add a mode with a push button based on BaseMode. Like the BaseView,
    // it will unregister itself from the plugin manager when it is deleted.
    Core::IMode *helloMode = new HelloMode;
    addAutoReleasedObject(helloMode);

    return true;
}
void BazaarPlugin::createMenu()
{
    Core::Context context(Core::Constants::C_GLOBAL);

    // Create menu item for Bazaar
    m_bazaarContainer = m_actionManager->createMenu(Core::Id("Bazaar.BazaarMenu"));
    QMenu *menu = m_bazaarContainer->menu();
    menu->setTitle(tr("Bazaar"));

    createFileActions(context);
    createSeparator(context, Core::Id("Bazaar.FileDirSeperator"));
    createDirectoryActions(context);
    createSeparator(context, Core::Id("Bazaar.DirRepoSeperator"));
    createRepositoryActions(context);
    createSeparator(context, Core::Id("Bazaar.Repository Management"));

    // Request the Tools menu and add the Bazaar menu to it
    Core::ActionContainer *toolsMenu = m_actionManager->actionContainer(Core::Id(Core::Constants::M_TOOLS));
    toolsMenu->addMenu(m_bazaarContainer);
    m_menuAction = m_bazaarContainer->menu()->menuAction();
}
Example #6
0
void MetamenuPlugin::shot() {
	QWidget* window = oneOfChatWindows();

	if(!m_menuBar && window)
		QMetaObject::invokeMethod(window, "getMenuBar", Q_RETURN_ARG(QMenuBar*, m_menuBar));

	QMenu* mainMenu = m_menu->menu(false);

	mainMenu->setTitle("&qutIM");

	if(m_menuBar && !m_added) {
		qDebug() << mainMenu;
		m_menuBar->addMenu(mainMenu);
		m_added = true;
	 }

	if(!m_added)
		QTimer::singleShot(1000, this, SLOT(shot()));
	else
		connect(window, SIGNAL(destroyed()), this, SLOT(onDestroyed()));
}
Example #7
0
void MainWindow::mountImage(bool changedTo)
{
	// The image interface index was assigned to the QAction's data memeber
	const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt();
	image_interface_iterator iter(m_machine->root_device());
	device_image_interface *img = iter.byindex(imageIndex);
	if (img == nullptr)
	{
		m_machine->debugger().console().printf("Something is wrong with the mount menu.\n");
		refreshAll();
		return;
	}

	// File dialog
	QString filename = QFileDialog::getOpenFileName(this,
													"Select an image file",
													QDir::currentPath(),
													tr("All files (*.*)"));

	if (img->load(filename.toUtf8().data()) != image_init_result::PASS)
	{
		m_machine->debugger().console().printf("Image could not be mounted.\n");
		refreshAll();
		return;
	}

	// Activate the unmount menu option
	QAction* unmountAct = sender()->parent()->findChild<QAction*>("unmount");
	unmountAct->setEnabled(true);

	// Set the mount name
	QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent());
	QString baseString = parentMenuItem->title();
	baseString.truncate(baseString.lastIndexOf(QString(" : ")));
	const QString newTitle = baseString + QString(" : ") + QString(img->filename());
	parentMenuItem->setTitle(newTitle);

	m_machine->debugger().console().printf("Image %s mounted successfully.\n", filename.toUtf8().data());
	refreshAll();
}
Example #8
0
void MainWindow::unmountImage(bool changedTo)
{
	// The image interface index was assigned to the QAction's data memeber
	const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt();
	image_interface_iterator iter(m_machine->root_device());
	device_image_interface *img = iter.byindex(imageIndex);

	img->unload();

	// Deactivate the unmount menu option
	dynamic_cast<QAction*>(sender())->setEnabled(false);

	// Set the mount name
	QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent());
	QString baseString = parentMenuItem->title();
	baseString.truncate(baseString.lastIndexOf(QString(" : ")));
	const QString newTitle = baseString + QString(" : ") + QString("[empty slot]");
	parentMenuItem->setTitle(newTitle);

	m_machine->debugger().console().printf("Image successfully unmounted.\n");
	refreshAll();
}
void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
{
    QMenu myFilesLlistMenu;
    const QModelIndexList selectedRows = ui->contentTreeView->selectionModel()->selectedRows(0);
    QAction *actRename = 0;
    if (selectedRows.size() == 1) {
        actRename = myFilesLlistMenu.addAction(GuiIconProvider::instance()->getIcon("edit-rename"), tr("Rename..."));
        myFilesLlistMenu.addSeparator();
    }
    QMenu subMenu;
    subMenu.setTitle(tr("Priority"));
    subMenu.addAction(ui->actionNot_downloaded);
    subMenu.addAction(ui->actionNormal);
    subMenu.addAction(ui->actionHigh);
    subMenu.addAction(ui->actionMaximum);
    myFilesLlistMenu.addMenu(&subMenu);
    // Call menu
    QAction *act = myFilesLlistMenu.exec(QCursor::pos());
    if (act) {
        if (act == actRename) {
            renameSelectedFile();
        }
        else {
            int prio = prio::NORMAL;
            if (act == ui->actionHigh)
                prio = prio::HIGH;
            else if (act == ui->actionMaximum)
                prio = prio::MAXIMUM;
            else if (act == ui->actionNot_downloaded)
                prio = prio::IGNORED;

            qDebug("Setting files priority");
            foreach (const QModelIndex &index, selectedRows) {
                qDebug("Setting priority(%d) for file at row %d", prio, index.row());
                m_contentModel->setData(m_contentModel->index(index.row(), PRIORITY, index.parent()), prio);
            }
        }
    }
void QDesignerMenuBar::leaveEditMode(LeaveEditMode mode)
{
    m_editor->releaseKeyboard();

    if (mode == Default)
        return;

    if (m_editor->text().isEmpty())
        return;

    QAction *action = 0;

    QDesignerFormWindowInterface *fw = formWindow();
    Q_ASSERT(fw);

    if (m_currentIndex >= 0 && m_currentIndex < realActionCount()) {
        action = safeActionAt(m_currentIndex);
        fw->beginCommand(QApplication::translate("Command", "Change Title"));
    } else {
        fw->beginCommand(QApplication::translate("Command", "Insert Menu"));
        const QString niceObjectName = ActionEditor::actionTextToName(m_editor->text(), QStringLiteral("menu"));
        QMenu *menu = qobject_cast<QMenu*>(fw->core()->widgetFactory()->createWidget(QStringLiteral("QMenu"), this));
        fw->core()->widgetFactory()->initialize(menu);
        menu->setObjectName(niceObjectName);
        menu->setTitle(tr("Menu"));
        fw->ensureUniqueObjectName(menu);
        action = menu->menuAction();
        AddMenuActionCommand *cmd = new AddMenuActionCommand(fw);
        cmd->init(action, m_addMenu, this, this);
        fw->commandHistory()->push(cmd);
    }

    SetPropertyCommand *cmd = new SetPropertyCommand(fw);
    cmd->init(action, QStringLiteral("text"), m_editor->text());
    fw->commandHistory()->push(cmd);
    fw->endCommand();
}
bool ColorPickerPlugin::initialize(const QStringList &arguments,
                                   QString *errorMessage)
{
    Q_UNUSED(arguments);
    Q_UNUSED(errorMessage);

    auto optionsPage = new ColorPickerOptionsPage;
    d->generalSettings = optionsPage->generalSettings();

    connect(optionsPage, &ColorPickerOptionsPage::generalSettingsChanged,
            this, &ColorPickerPlugin::onGeneralSettingsChanged);

    // Register the plugin actions
    ActionContainer *toolsContainer = ActionManager::actionContainer(Core::Constants::M_TOOLS);

    ActionContainer *myContainer = ActionManager::createMenu("ColorPicker");
    QMenu *myMenu = myContainer->menu();
    myMenu->setTitle(tr("&ColorPicker"));
    myMenu->setEnabled(true);

    auto triggerColorEditAction = new QAction(tr(Constants::ACTION_NAME_TRIGGER_COLOR_EDIT), this);
    Command *command = ActionManager::registerAction(triggerColorEditAction,
                                                     Constants::TRIGGER_COLOR_EDIT);
    command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+C")));

    myContainer->addAction(command);

    connect(triggerColorEditAction, &QAction::triggered,
            this, &ColorPickerPlugin::onColorEditTriggered);

    toolsContainer->addMenu(myContainer);

    // Register objects
    addAutoReleasedObject(optionsPage);

    return true;
}
Example #12
0
File: menus.cpp Project: Kafay/vlc
/**
 * Service Discovery SubMenu
 **/
QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf, QWidget *parent )
{
    QMenu *menu = new QMenu( parent );
    menu->setTitle( qtr( I_PL_SD ) );

    char **ppsz_longnames;
    char **ppsz_names = vlc_sd_GetNames( &ppsz_longnames );
    if( !ppsz_names )
        return menu;

    char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
    for( ; *ppsz_name; ppsz_name++, ppsz_longname++ )
    {
        QAction *a = new QAction( qfu( *ppsz_longname ), menu );
        a->setCheckable( true );
        if( playlist_IsServicesDiscoveryLoaded( THEPL, *ppsz_name ) )
            a->setChecked( true );
        CONNECT( a, triggered(), THEDP->SDMapper, map() );
        THEDP->SDMapper->setMapping( a, QString( *ppsz_name ) );
        menu->addAction( a );

        /* Special case for podcast */
        if( !strcmp( *ppsz_name, "podcast" ) )
        {
            QAction *b = new QAction( qtr( "Configure podcasts..." ), menu );
            //b->setEnabled( a->isChecked() );
            menu->addAction( b );
            CONNECT( b, triggered(), THEDP, podcastConfigureDialog() );
        }
        free( *ppsz_name );
        free( *ppsz_longname );
    }
    free( ppsz_names );
    free( ppsz_longnames );
    return menu;
}
Example #13
0
QMenu *BtMenuView::newMenu(QMenu *parentMenu, const QModelIndex &itemIndex) {
    QVariant displayData(m_model->data(itemIndex, Qt::DisplayRole));
    QVariant iconData(m_model->data(itemIndex, Qt::DecorationRole));
    QVariant toolTipData(m_model->data(itemIndex, Qt::ToolTipRole));
    QVariant statusTipData(m_model->data(itemIndex, Qt::StatusTipRole));
    QVariant whatsThisData(m_model->data(itemIndex, Qt::WhatsThisRole));

    QMenu *childMenu = new QMenu(parentMenu);

    // Set text:
    if (displayData.canConvert(QVariant::String)) {
        childMenu->setTitle(displayData.toString());
    }

    // Set icon:
    if (iconData.canConvert(QVariant::Icon)) {
        childMenu->setIcon(iconData.value<QIcon>());
    }

    // Set tooltip:
    if (toolTipData.canConvert(QVariant::String)) {
        childMenu->setToolTip(toolTipData.toString());
    }

    // Set status tip:
    if (statusTipData.canConvert(QVariant::String)) {
        childMenu->setStatusTip(statusTipData.toString());
    }

    // Set whatsthis:
    if (whatsThisData.canConvert(QVariant::String)) {
        childMenu->setWhatsThis(whatsThisData.toString());
    }

    return childMenu;
}
Example #14
0
void pdp::MainWindow::setupUi() {
	// Add back button
	QPushButton* back = new QPushButton(QIcon(":/common/res/common/back.png"), QApplication::translate("MainWindow", "Zur\303\274ck", 0, QApplication::UnicodeUTF8));
    ui_main.tabWidget->setCornerWidget(back, Qt::TopRightCorner);
    QObject::connect(back, SIGNAL(clicked()), this, SLOT(onBack()));
	
    // Add the "start" tab.
    new pdp::Home(this->ui_main.tabWidget, this);

	// Creates progressDialog
	m_progressDialog = new QProgressDialog("", QString(), 0, 100, this);
	m_progressDialog->setMinimumDuration(0);
	//m_progressDialog->setWindowModality(Qt::WindowModal);

	// Correction of automatic segmentation via 3d interactive segmentation	
	m_NumberOfInstancesOfThreeDEditing = 0;
	QMenu *menuWerkzeug;
	menuWerkzeug = new QMenu(ui_main.menubar);
    menuWerkzeug->setObjectName(QString::fromUtf8("menuWerkzeug"));
	menuWerkzeug->setTitle(QApplication::translate("MainWindow", "Werkzeug", 0, QApplication::UnicodeUTF8));
	ui_main.menubar->addMenu(menuWerkzeug);
    
	QAction *actionThreeDEditing = new QAction(this);
	actionThreeDEditing->setObjectName(QString::fromUtf8("actionThreeDEditing"));
	actionThreeDEditing->setIconText("3DEditing");
	QIcon icn_menu;
	icn_menu.addFile(":/threeDEditing/res/threeDEditing/Rubber-32.png");
	actionThreeDEditing->setIcon(icn_menu);
	menuWerkzeug->addAction(actionThreeDEditing);

	QObject::connect(actionThreeDEditing, SIGNAL(triggered()), this, SLOT(CreateThreeDEditing()));
	
	// AutoRun
	if(AUTO_IMPORT == 1)
		CreateThreeDEditing();
}
Example #15
0
void MercurialPlugin::createMenu()
{
    Core::Context context(Core::Constants::C_GLOBAL);

    // Create menu item for Mercurial
    mercurialContainer = actionManager->createMenu(Core::Id("Mercurial.MercurialMenu"));
    QMenu *menu = mercurialContainer->menu();
    menu->setTitle(tr("Mercurial"));

    createFileActions(context);
    createSeparator(context, Core::Id("Mercurial.FileDirSeperator"));
    createDirectoryActions(context);
    createSeparator(context, Core::Id("Mercurial.DirRepoSeperator"));
    createRepositoryActions(context);
    createSeparator(context, Core::Id("Mercurial.Repository Management"));
    createRepositoryManagementActions(context);
    createSeparator(context, Core::Id("Mercurial.LessUsedfunctionality"));
    createLessUsedActions(context);

    // Request the Tools menu and add the Mercurial menu to it
    Core::ActionContainer *toolsMenu = actionManager->actionContainer(Core::Id(Core::Constants::M_TOOLS));
    toolsMenu->addMenu(mercurialContainer);
    m_menuAction = mercurialContainer->menu()->menuAction();
}
Example #16
0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::createMenus()
{
    caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance();

    // File menu
    QMenu* fileMenu = new RiuToolTipMenu(menuBar());
    fileMenu->setTitle("&File");

    menuBar()->addMenu(fileMenu);

    fileMenu->addAction(cmdFeatureMgr->action("RicOpenProjectFeature"));
    fileMenu->addAction(cmdFeatureMgr->action("RicOpenLastUsedFileFeature"));
    fileMenu->addSeparator();

    QMenu* importMenu = fileMenu->addMenu("&Import");

    QMenu* importEclipseMenu = importMenu->addMenu(QIcon(":/Case48x48.png"), "Eclipse Cases");
    importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature"));
    importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature"));
    importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature"));
    importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature"));
    importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature"));

#ifdef USE_ODB_API
    importMenu->addSeparator();
    QMenu* importGeoMechMenu = importMenu->addMenu(QIcon(":/GeoMechCase48x48.png"), "Geo Mechanical Cases");
    importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature"));
    importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature"));
#endif

    importMenu->addSeparator();
    QMenu* importSummaryMenu = importMenu->addMenu(QIcon(":/SummaryCase48x48.png"), "Summary Cases");
    importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature"));
    importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature"));
    importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryGroupFeature"));
    importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature"));

    importMenu->addSeparator();
    QMenu* importWellMenu = importMenu->addMenu(QIcon(":/Well.png"), "Well Data");
    importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature"));
    importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature"));
    importWellMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature"));
    importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature"));

    importMenu->addSeparator();
    importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature"));
    importMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature"));

    QMenu* exportMenu = fileMenu->addMenu("&Export");
    exportMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature"));
    exportMenu->addAction(cmdFeatureMgr->action("RicSnapshotAllPlotsToFileFeature"));
    exportMenu->addAction(cmdFeatureMgr->action("RicSaveEclipseInputActiveVisibleCellsFeature"));

    fileMenu->addSeparator();
    fileMenu->addAction(cmdFeatureMgr->action("RicSaveProjectFeature"));
    fileMenu->addAction(cmdFeatureMgr->action("RicSaveProjectAsFeature"));

    std::vector<QAction*> recentFileActions = RiaApplication::instance()->recentFileActions();
    for (auto act : recentFileActions)
    {
        fileMenu->addAction(act);
    }

    fileMenu->addSeparator();
    fileMenu->addAction(cmdFeatureMgr->action("RicCloseProjectFeature"));
    fileMenu->addSeparator();
    fileMenu->addAction(cmdFeatureMgr->action("RicExitApplicationFeature"));

    // Edit menu
    QMenu* editMenu = menuBar()->addMenu("&Edit");
    editMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToClipboardFeature"));
    editMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature"));
    editMenu->addSeparator();
    editMenu->addAction(cmdFeatureMgr->action("RicEditPreferencesFeature"));

    // View menu
    QMenu* viewMenu = menuBar()->addMenu("&View");
    viewMenu->addAction(cmdFeatureMgr->action("RicViewZoomAllFeature"));

    // Windows menu
    m_windowMenu = menuBar()->addMenu("&Windows");
    connect(m_windowMenu, SIGNAL(aboutToShow()), SLOT(slotBuildWindowActions()));

    // Help menu
    QMenu* helpMenu = menuBar()->addMenu("&Help");
    helpMenu->addAction(cmdFeatureMgr->action("RicHelpAboutFeature"));
    helpMenu->addAction(cmdFeatureMgr->action("RicHelpCommandLineFeature"));
    helpMenu->addSeparator();
    helpMenu->addAction(cmdFeatureMgr->action("RicHelpOpenUsersGuideFeature"));
}
Example #17
0
void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label)
{
    QAction *qtAction = GetActionAt( m_qtMenuBar, pos );
    QMenu *qtMenu = qtAction->menu();
    qtMenu->setTitle( wxQtConvertString( label ));
}
Example #18
0
void Plot::createMenu ()
{
  setContextMenuPolicy(Qt::CustomContextMenu);
  connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showContextMenu()));

  _menu = new QMenu(this);
  
  _dateAction = new QAction(QIcon(date_xpm), tr("&Date"), this);
  _dateAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
  _dateAction->setToolTip(tr("Date"));
  _dateAction->setStatusTip(tr("Date"));
  _dateAction->setCheckable(TRUE);
  _dateAction->setChecked(TRUE);
  connect(_dateAction, SIGNAL(triggered(bool)), this, SLOT(showDate(bool)));
  _menu->addAction(_dateAction);

  _gridAction = new QAction(QIcon(grid_xpm), tr("&Grid"), this);
  _gridAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
  _gridAction->setToolTip(tr("Grid"));
  _gridAction->setStatusTip(tr("Grid"));
  _gridAction->setCheckable(TRUE);
  _gridAction->setChecked(TRUE);
  connect(_gridAction, SIGNAL(triggered(bool)), this, SLOT(setGrid(bool)));
  _menu->addAction(_gridAction);

  _infoAction = new QAction(QIcon(about_xpm), tr("Bar &Info"), this);
  _infoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_I));
  _infoAction->setToolTip(tr("Bar Info"));
  _infoAction->setStatusTip(tr("Bar Info"));
  _infoAction->setCheckable(TRUE);
  _infoAction->setChecked(TRUE);
  connect(_infoAction, SIGNAL(triggered(bool)), this, SLOT(setInfo(bool)));
  _menu->addAction(_infoAction);

  _menu->addSeparator();
  
  // create the chart object menu
  QMenu *mm = new QMenu(this);
  mm->setTitle(tr("New Plot Marker..."));
  connect(mm, SIGNAL(triggered(QAction *)), this, SLOT(markerMenuSelected(QAction *)));
  _menu->addMenu(mm);
  
  // buy
  QAction *a = new QAction(QIcon(buyarrow_xpm), tr("&Buy"), this);
  a->setToolTip(tr("Create Buy Arrow Plot Marker"));
  a->setStatusTip(QString(tr("Create Buy Arrow Plot Marker")));
  a->setData(QVariant("MarkerBuy"));
  mm->addAction(a);

  // hline
  a = new QAction(QIcon(horizontal_xpm), tr("&HLine"), this);
  a->setToolTip(tr("Create Horizontal Line Plot Marker"));
  a->setStatusTip(QString(tr("Create Horizontal Line Plot Marker")));
  a->setData(QVariant("MarkerHLine"));
  mm->addAction(a);

  // retracement
  a = new QAction(QIcon(fib_xpm), tr("&Retracement"), this);
  a->setToolTip(tr("Create Retracement Levels Plot Marker"));
  a->setStatusTip(QString(tr("Create Retracement Levels Plot Marker")));
  a->setData(QVariant("MarkerRetracement"));
  mm->addAction(a);

  // sell
  a = new QAction(QIcon(sellarrow_xpm), tr("&Sell"), this);
  a->setToolTip(tr("Create Sell Arrow Plot Marker"));
  a->setStatusTip(QString(tr("Create Sell Arrow Plot Marker")));
  a->setData(QVariant("MarkerSell"));
  mm->addAction(a);

  // text
  a = new QAction(QIcon(text_xpm), tr("&Text"), this);
  a->setToolTip(tr("Create Text Plot Marker"));
  a->setStatusTip(QString(tr("Create Text Plot Marker")));
  a->setData(QVariant("MarkerText"));
  mm->addAction(a);

  // tline
  a = new QAction(QIcon(trend_xpm), tr("T&Line"), this);
  a->setToolTip(tr("Create Trend Line Plot Marker"));
  a->setStatusTip(QString(tr("Create Trend Line Plot Marker")));
  a->setData(QVariant("MarkerTLine"));
  mm->addAction(a);

  // vline
  a = new QAction(QIcon(vertical_xpm), tr("&VLine"), this);
  a->setToolTip(tr("Create Vertical Line Plot Marker"));
  a->setStatusTip(QString(tr("Create Vertical Line Plot Marker")));
  a->setData(QVariant("MarkerVLine"));
  mm->addAction(a);
  
  // delete all chart objects
  a = new QAction(QIcon(delete_xpm), tr("Delete All Plot &Markers"), this);
  a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
  a->setToolTip(tr("Delete All Plot Markers"));
  a->setStatusTip(tr("Delete All Plot Markers"));
  connect(a, SIGNAL(triggered(bool)), this, SLOT(deleteAllMarkersDialog()));
  _menu->addAction(a);

  // marker menu
  _markerMenu = new QMenu(this);
  _markerMenu->addAction(QIcon(edit_xpm), QObject::tr("&Edit"), this, SLOT(markerDialog()), QKeySequence(Qt::ALT+Qt::Key_E));
  _markerMenu->addAction(QIcon(delete_xpm), QObject::tr("&Delete"), this, SLOT(deleteMarker()), QKeySequence(Qt::ALT+Qt::Key_D));
}
Example #19
0
void ZoneViewerWindow::initMenus()
{
    QMenu *fileMenu = new QMenu(this);
    fileMenu->setTitle("&File");

    QAction *openAction = new QAction("&Open S3D archive...", this);
    openAction->setShortcut(QKeySequence::Open);
    QAction *clearAction = new QAction("&Clear", this);
    QAction *selectDirAction = new QAction("Select Asset Directory...", this);

    QAction *quitAction = new QAction("&Quit", this);
    quitAction->setShortcut(QKeySequence::Quit);

    fileMenu->addAction(openAction);
    fileMenu->addAction(clearAction);
    fileMenu->addAction(selectDirAction);
    fileMenu->addSeparator();
    fileMenu->addAction(quitAction);

    QMenu *renderMenu = new QMenu(this);
    renderMenu->setTitle("&Render");

    m_noLightingAction = new QAction("No Lighting", this);
    m_bakedLightingAction = new QAction("Baked Lighting", this);
    m_debugVertexColorAction = new QAction("Show Vertex Color", this);
    m_debugTextureFactorAction = new QAction("Show Texture Blend Factor", this);
    m_debugDiffuseAction = new QAction("Show Diffuse Factor", this);
    m_noLightingAction->setCheckable(true);
    m_bakedLightingAction->setCheckable(true);
    m_debugVertexColorAction->setCheckable(true);
    m_debugTextureFactorAction->setCheckable(true);
    m_debugDiffuseAction->setCheckable(true);
    m_bakedLightingAction->setEnabled(false);
    m_debugDiffuseAction->setEnabled(false);
    QActionGroup *lightingActions = new QActionGroup(this);
    lightingActions->addAction(m_noLightingAction);
    lightingActions->addAction(m_bakedLightingAction);
    lightingActions->addAction(m_debugVertexColorAction);
    lightingActions->addAction(m_debugTextureFactorAction);
    lightingActions->addAction(m_debugDiffuseAction);

    m_showFpsAction = new QAction("Show Stats", this);
    m_showFpsAction->setCheckable(true);
    m_showZoneAction = new QAction("Show Zone", this);
    m_showZoneAction->setCheckable(true);
    m_showZoneAction->setChecked(m_scene->game()->showZone());
    m_showZoneObjectsAction = new QAction("Show Zone Objects", this);
    m_showZoneObjectsAction->setCheckable(true);
    m_showFogAction = new QAction("Show Fog", this);
    m_showFogAction->setCheckable(true);
    m_showFogAction->setChecked(m_scene->game()->showFog());
    m_showZoneObjectsAction->setChecked(m_scene->game()->showObjects());
    m_cullZoneObjectsAction = new QAction("Frustum Culling of Zone Objects", this);
    m_cullZoneObjectsAction->setCheckable(true);
    m_cullZoneObjectsAction->setChecked(m_scene->game()->cullObjects());
    m_showSoundTriggersAction = new QAction("Show Sound Triggers", this);
    m_showSoundTriggersAction->setCheckable(true);

    renderMenu->addAction(m_noLightingAction);
    renderMenu->addAction(m_bakedLightingAction);
    renderMenu->addAction(m_debugVertexColorAction);
    renderMenu->addAction(m_debugTextureFactorAction);
    renderMenu->addAction(m_debugDiffuseAction);
    renderMenu->addSeparator();
    renderMenu->addAction(m_showFpsAction);
    renderMenu->addAction(m_showZoneAction);
    renderMenu->addAction(m_showZoneObjectsAction);
    renderMenu->addAction(m_cullZoneObjectsAction);
    renderMenu->addAction(m_showFogAction);
    renderMenu->addAction(m_showSoundTriggersAction);

    menuBar()->addMenu(fileMenu);
    menuBar()->addMenu(renderMenu);

    updateMenus();

    connect(openAction, SIGNAL(triggered()), this, SLOT(openArchive()));
    connect(clearAction, SIGNAL(triggered()), this, SLOT(clearZone()));
    connect(selectDirAction, SIGNAL(triggered()), this, SLOT(selectAssetDir()));
    connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));

    connect(m_noLightingAction, SIGNAL(triggered()), this, SLOT(setNoLighting()));
    connect(m_bakedLightingAction, SIGNAL(triggered()), this, SLOT(setBakedLighting()));
    connect(m_debugVertexColorAction, SIGNAL(triggered()), this, SLOT(setDebugVertexColor()));
    connect(m_debugTextureFactorAction, SIGNAL(triggered()), this, SLOT(setDebugTextureFactor()));
    connect(m_debugDiffuseAction, SIGNAL(triggered()), this, SLOT(setDebugDiffuse()));
    connect(m_showFpsAction, SIGNAL(toggled(bool)), m_viewport, SLOT(setShowStats(bool)));
    connect(m_showZoneAction, SIGNAL(toggled(bool)), m_scene, SLOT(showZone(bool)));
    connect(m_showZoneObjectsAction, SIGNAL(toggled(bool)), m_scene, SLOT(showZoneObjects(bool)));
    connect(m_showFogAction, SIGNAL(toggled(bool)), m_scene, SLOT(showFog(bool)));
    connect(m_cullZoneObjectsAction, SIGNAL(toggled(bool)), m_scene, SLOT(setFrustumCulling(bool)));
    connect(m_showSoundTriggersAction, SIGNAL(toggled(bool)), m_scene, SLOT(showSoundTriggers(bool)));
}
Example #20
0
void KSPopupMenu::initPopupMenu( SkyObject *obj, QString name, QString type, QString info,
                                 bool showDetails, bool showObsList, bool showFlags )
{
    KStarsData* data = KStarsData::Instance();
    SkyMap * map = SkyMap::Instance();

    clear();
    bool showLabel = name != i18n("star") && !name.isEmpty();
    if( name.isEmpty() )
        name = i18n( "Empty sky" );

    addFancyLabel( name );
    addFancyLabel( type );
    addFancyLabel( info );
    addFancyLabel( KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( obj ) );

    //Insert Rise/Set/Transit labels
    SkyObject* o = obj->clone();
    addSeparator();
    addFancyLabel( riseSetTimeLabel(o, true),  -2 );
    addFancyLabel( riseSetTimeLabel(o, false), -2 );
    addFancyLabel( transitTimeLabel(o),        -2 );
    addSeparator();
    delete o;

    // Show 'Select this object' item when in object pointing mode and when obj is not empty sky
    if(map->isInObjectPointingMode() && obj->type() != 21)
    {
        addAction( i18n( "Select this object"), map, SLOT(slotObjectSelected()));
    }

    //Insert item for centering on object
    addAction( i18n( "Center && Track" ), map, SLOT( slotCenter() ) );

    if ( showFlags )
    {
        //Insert actions for flag operations
        initFlagActions( obj );
    }

    //Insert item for measuring distances
    //FIXME: add key shortcut to menu items properly!
    addAction( i18n( "Angular Distance To...            [" ), map, SLOT(slotBeginAngularDistance()) );
    addAction( i18n( "Starhop from here to...            " ), map, SLOT(slotBeginStarHop()) );

    //Insert item for Showing details dialog
    if ( showDetails )
        addAction( i18nc( "Show Detailed Information Dialog", "Details" ), map, SLOT( slotDetail() ) );
    //Insert "Add/Remove Label" item
    if ( showLabel )
    {
        if ( map->isObjectLabeled( obj ) ) {
            addAction( i18n( "Remove Label" ), map, SLOT( slotRemoveObjectLabel() ) );
        } else {
            addAction( i18n( "Attach Label" ), map, SLOT( slotAddObjectLabel() ) );
        }
    }
    // Should show observing list
    if( showObsList ) {
        if ( data->observingList()->contains( obj ) )
            addAction( i18n("Remove From Observing WishList"), data->observingList(), SLOT( slotRemoveObject() ) );
        else
            addAction( i18n("Add to Observing WishList"), data->observingList(), SLOT( slotAddObject() ) );
    }
    // Should we show trail actions
    TrailObject* t = dynamic_cast<TrailObject*>( obj );
    if( t ) {
        if( t->hasTrail() )
            addAction( i18n( "Remove Trail" ), map, SLOT( slotRemovePlanetTrail() ) );
        else
            addAction( i18n( "Add Trail" ), map, SLOT( slotAddPlanetTrail() ) );
    }

    addAction( i18n("Simulate eyepiece view"), map, SLOT( slotEyepieceView() ) );

    addSeparator();
#ifdef HAVE_XPLANET
    if ( obj->isSolarSystem() && obj->type() != SkyObject::COMET ) { // FIXME: We now have asteroids -- so should this not be isMajorPlanet() || Pluto?
        QMenu *xplanetSubmenu = new QMenu();
        xplanetSubmenu->setTitle( i18n( "Print Xplanet view" ) );
        xplanetSubmenu->addAction( i18n( "To screen" ), map, SLOT( slotXplanetToScreen() ) );
        xplanetSubmenu->addAction( i18n( "To file..." ), map, SLOT( slotXplanetToFile() ) );
        addMenu( xplanetSubmenu );
    }
#endif
    addSeparator();
    addINDI();
}
Example #21
0
 void setTitle(const QString& title)
 {
   if (menu)
     menu->setTitle(title);
 }
Example #22
0
void KrBookmarkHandler::buildMenu(KrBookmark *parent, QMenu *menu)
{
    static int inSecondaryMenu = 0; // used to know if we're on the top menu

    // run the loop twice, in order to put the folders on top. stupid but easy :-)
    // note: this code drops the separators put there by the user
    QListIterator<KrBookmark *> it(parent->children());
    while (it.hasNext()) {
        KrBookmark *bm = it.next();

        if (!bm->isFolder()) continue;
        QMenu *newMenu = new QMenu(menu);
        newMenu->setIcon(QIcon(krLoader->loadIcon(bm->iconName(), KIconLoader::Small)));
        newMenu->setTitle(bm->text());
        QAction *menuAction = menu->addMenu(newMenu);
        QVariant v;
        v.setValue<KrBookmark *>(bm);
        menuAction->setData(v);

        ++inSecondaryMenu;
        buildMenu(bm, newMenu);
        --inSecondaryMenu;
    }

    it.toFront();
    while (it.hasNext()) {
        KrBookmark *bm = it.next();
        if (bm->isFolder()) continue;
        if (bm->isSeparator()) {
            menu->addSeparator();
            continue;
        }
        menu->addAction(bm);
        CONNECT_BM(bm);
    }

    if (!inSecondaryMenu) {
        KConfigGroup group(krConfig, "Private");
        bool hasPopularURLs = group.readEntry("BM Popular URLs", true);
        bool hasTrash       = group.readEntry("BM Trash",        true);
        bool hasLan         = group.readEntry("BM Lan",          true);
        bool hasVirtualFS   = group.readEntry("BM Virtual FS",   true);
        bool hasJumpback    = group.readEntry("BM Jumpback",     true);

        if (hasPopularURLs) {
            menu->addSeparator();

            // add the popular links submenu
            QMenu *newMenu = new QMenu(menu);
            newMenu->setTitle(i18n("Popular URLs"));
            newMenu->setIcon(QIcon(krLoader->loadIcon("folder-bookmark", KIconLoader::Small)));
            QAction *bmfAct  = menu->addMenu(newMenu);
            _specialBookmarks.append(bmfAct);
            // add the top 15 urls
#define MAX 15
            QList<QUrl> list = _mainWindow->popularUrls()->getMostPopularUrls(MAX);
            QList<QUrl>::Iterator it;
            for (it = list.begin(); it != list.end(); ++it) {
                QString name;
                if ((*it).isLocalFile()) name = (*it).path();
                else name = (*it).toDisplayString();
                // note: these bookmark are put into the private collection
                // as to not spam the general collection
                KrBookmark *bm = KrBookmark::getExistingBookmark(name, _privateCollection);
                if (!bm)
                    bm = new KrBookmark(name, *it, _privateCollection);
                newMenu->addAction(bm);
                CONNECT_BM(bm);
            }

            newMenu->addSeparator();
            newMenu->addAction(krPopularUrls);
            newMenu->installEventFilter(this);
        }

        // do we need to add special bookmarks?
        if (SPECIAL_BOOKMARKS) {
            if (hasTrash || hasLan || hasVirtualFS || hasJumpback)
                menu->addSeparator();

            KrBookmark *bm;

            // note: special bookmarks are not kept inside the _bookmarks list and added ad-hoc
            if (hasTrash) {
                bm = KrBookmark::trash(_collection);
                menu->addAction(bm);
                _specialBookmarks.append(bm);
                CONNECT_BM(bm);
            }

            if (hasLan) {
                bm = KrBookmark::lan(_collection);
                menu->addAction(bm);
                _specialBookmarks.append(bm);
                CONNECT_BM(bm);
            }

            if (hasVirtualFS) {
                bm = KrBookmark::virt(_collection);
                menu->addAction(bm);
                _specialBookmarks.append(bm);
                CONNECT_BM(bm);
            }

            if (hasJumpback) {
                // add the jump-back button
                ListPanelActions *actions = _mainWindow->listPanelActions();
                menu->addAction(actions->actJumpBack);
                _specialBookmarks.append(actions->actJumpBack);
                menu->addSeparator();
                menu->addAction(actions->actSetJumpBack);
                _specialBookmarks.append(actions->actSetJumpBack);
            }
        }

        if (!hasJumpback)
            menu->addSeparator();

        menu->addAction(KrActions::actAddBookmark);
        _specialBookmarks.append(KrActions::actAddBookmark);
        QAction *bmAct = menu->addAction(krLoader->loadIcon("bookmarks", KIconLoader::Small),
                                         i18n("Manage Bookmarks"), manager, SLOT(slotEditBookmarks()));
        _specialBookmarks.append(bmAct);

        // make sure the menu is connected to us
        disconnect(menu, SIGNAL(triggered(QAction *)), 0, 0);
    }
Example #23
0
void ServiceTree::showServicePopup(const QPoint &iPosition)
{
    selectedServices.clear();
    for (int i = 0; i < selectedItems().size(); ++i)
    {
        QTreeWidgetItem *item=selectedItems().at(i);
        QStringList hostAndService;
        hostAndService << item->text(0) << item->text(1);
        qDebug() << "Selected Items  " << hostAndService;
        selectedServices << hostAndService;
    }



    lastRightClickedItem = 0 ;
      lastRightClickedItem = itemAt(iPosition) ;
      if ( 0 == lastRightClickedItem )
      {
        qDebug() << "No item selected" ;
      }
      else
      {
        qDebug() << "Item clicked" + lastRightClickedItem->text(0);
        QMenu menu(this);
        QMenu* hostMenu = new QMenu(this);
        hostMenu->setTitle("&Host");

        QAction *hostSearchLogRightAction   = new QAction("&Log Search", this);
            hostSearchLogRightAction->setIcon(QPixmap(search_xpm));
            hostSearchLogRightAction->setObjectName("LogSearch");
                connect(hostSearchLogRightAction, SIGNAL(triggered(bool)), this, SLOT(menuRightSlot(bool)));
        hostMenu->addAction(hostSearchLogRightAction);

        QAction *hostDetailRightAction = new QAction("&Detail", this);
            hostDetailRightAction->setIcon(QPixmap(info_xpm));
            hostDetailRightAction->setObjectName("HostDetail");
                connect(hostDetailRightAction, SIGNAL(triggered(bool)), this, SLOT(menuRightSlot(bool)));
        hostMenu->addAction(hostDetailRightAction);

        QMenu* serviceMenu = new QMenu(this);
        serviceMenu->setTitle("&Service");

        QAction *reschedRightAction   = new QAction("&Reschedule", this);
            reschedRightAction->setIcon(QPixmap(reschedule_xpm));
            reschedRightAction->setObjectName("Reschedule");
                connect(reschedRightAction, SIGNAL(triggered(bool)), this, SLOT(menuRightSlot(bool)));
        serviceMenu->addAction(reschedRightAction);

         // not soft and not ack and not ok
        if ((lastRightClickedItem->text(4) != "0") && (lastRightClickedItem->text(5) == "0") && (lastRightClickedItem->text(2) != "0"))
        {
        QAction *ackRightAction   = new QAction("&Acknowledge", this);
            ackRightAction->setIcon(QPixmap(ack_xpm));
            ackRightAction->setObjectName("Acknowledge");
                connect(ackRightAction, SIGNAL(triggered(bool)), this, SLOT(menuRightSlot(bool)));
        serviceMenu->addAction(ackRightAction);
        }

        QAction *downtimeRightAction   = new QAction("&Downtime", this);
            downtimeRightAction->setIcon(QPixmap(downtime_xpm));
            downtimeRightAction->setObjectName("Downtime");
                connect(downtimeRightAction, SIGNAL(triggered(bool)), this, SLOT(menuRightSlot(bool)));
        serviceMenu->addAction(downtimeRightAction);

        QMenu* contactMenu = new QMenu(this);
            contactMenu->setTitle("Contacts");
        QStringList list = lastRightClickedItem->text(15).split(',');
        for (int i = 0; i < list.size(); ++i)
         {
             QAction* cAction = new QAction(list.at(i), this);
                 cAction->setEnabled(false);
             contactMenu->addAction(cAction);
         }
        menu.addMenu(hostMenu);
        menu.addMenu(serviceMenu);
    //    menu.addSeparator();
    // we dont need that anymore    menu.addMenu(contactMenu);

        menu.exec(mapToGlobal(iPosition));
      }
Example #24
0
void TrayMenu::addTorrent(RTorrent * torrent)
{
	no_torrent->setVisible(false);
	InfoAction * action = 0;
	QWidgetAction * waction = 0;
	QMenu * tmenu = new QMenu(menu);
	tmenu->setTitle(tr("Loading..."));

	//Add caption
	QLabel * lbl =  new QLabel(tr("<b>Torrent's info</b>"));
	lbl->setAlignment(Qt::AlignHCenter);
	waction = new QWidgetAction(tmenu);
	waction->setDefaultWidget(lbl);
	tmenu->addAction(waction);
	connect(torrent,SIGNAL(changeName(QString)),
		this,SLOT(changeName(QString)));

	//Add rate status
	action = new InfoAction(tmenu);
	action->setText(tr("%1, %2"));
	action->setText1(tr("UP: %1 kb/s"));
	action->setText2(tr("DOWN: %1 kb/s"));

	action->setParam1(tr("N/A"));
	action->setParam2(tr("N/A"));

	action->setIcon(QIcon(":/img/updown.png"));

	connect(torrent,SIGNAL(changeDownRate(double)),
		action,SLOT(setParam2(double)));

	connect(torrent,SIGNAL(changeUpRate(double)),
		action,SLOT(setParam1(double)));
	
	tmenu->addAction(action);

	//Add rateio status
	action = new InfoAction(tmenu);
	action->setText(tr("%1"));
	action->setText1(tr("Rateio: %1"));
	action->setParam1(tr("N/A"));

	connect(torrent,SIGNAL(changeRatio(double)),
		action,SLOT(setParam1(double)));
	tmenu->addAction(action);

	//Add progress
	QProgressBar * bar = new QProgressBar(tmenu);
	bar->setAlignment(Qt::AlignHCenter);
	waction = new QWidgetAction(tmenu);
	waction->setDefaultWidget(bar);
	tmenu->addAction(waction);

	connect(torrent,SIGNAL(changeCompletedChunks(int)),
		bar,SLOT(setValue(int)));

	connect(torrent,SIGNAL(changeSizeChunks(int)),
		bar,SLOT(setMaximum(int)));
	connect(torrent,SIGNAL(changeCompletedChunks(int)),
		this,SLOT(changeCompletedChunks(int)));

	//Add priority
	QComboBox * combo =  new QComboBox(tmenu);
	combo->addItem(QIcon(),tr("Idle"));
	combo->addItem(QIcon(),tr("Low"));
	combo->addItem(QIcon(),tr("Normal"));
	combo->addItem(QIcon(),tr("High"));
	combo->setEditable(false);

	waction = new QWidgetAction(tmenu);
	waction->setDefaultWidget(combo);
	tmenu->addAction(waction);

	connect(torrent,SIGNAL(changePriority(int)),
		combo,SLOT(setCurrentIndex (int)));
	connect(combo,SIGNAL(activated(int)),
		torrent,SLOT(setPriority(int)));
	
	//Other
	connect(torrent,SIGNAL(changeChunkSize(long)),
		this,SLOT(changeChunkSize(long)));
	connect(torrent,SIGNAL(changeState(int)),
		this,SLOT(changeState(int)));

	tmenu->addSeparator();
	QAction * command = 0;

	//control action
	command = tmenu->addAction(QIcon(":/img/close.png"),tr("Close"));
	connect(command,SIGNAL(triggered (bool)),
		torrent,SLOT(close(bool)));
	command = tmenu->addAction(QIcon(":/img/open.png"),tr("Start"));
	connect(command,SIGNAL(triggered (bool)),
		torrent,SLOT(start(bool)));
	command = tmenu->addAction(QIcon(":/img/stop.png"),tr("Stop"));
	connect(command,SIGNAL(triggered (bool)),
		torrent,SLOT(stop(bool)));
	command = tmenu->addAction(QIcon(":/img/rehash0.png"),tr("Rehash"));
	connect(command,SIGNAL(triggered (bool)),
		torrent,SLOT(check_hash(bool)));
	command = tmenu->addAction(QIcon(":/img/erase.png"),tr("Erase"));
	connect(command,SIGNAL(triggered (bool)),
		torrent,SLOT(erase(bool)));

	//connect AutoUpdate when menu visible
	connect(tmenu,SIGNAL(aboutToShow()),
		torrent, SLOT(fullUpdate()));
	connect(tmenu,SIGNAL(aboutToShow()),
		torrent,SLOT(enableAutoUpdate()));
	connect(tmenu,SIGNAL(aboutToHide()),
		torrent,SLOT(disableAutoUpdate()));

	torrents[torrent->getId()] = tmenu;
	menu->insertMenu(sep,tmenu);
}
Example #25
0
void VirtualConsole::initMenuBar()
{
    /* Add menu */
    m_addMenu = new QMenu(this);
    m_addMenu->setTitle(tr("&Add"));
    m_addMenu->addAction(m_addButtonAction);
    m_addMenu->addAction(m_addButtonMatrixAction);
    m_addMenu->addSeparator();
    m_addMenu->addAction(m_addSliderAction);
    m_addMenu->addAction(m_addSliderMatrixAction);
    m_addMenu->addAction(m_addSpeedDialAction);
    m_addMenu->addSeparator();
    m_addMenu->addAction(m_addXYPadAction);
    m_addMenu->addAction(m_addCueListAction);
    m_addMenu->addSeparator();
    m_addMenu->addAction(m_addFrameAction);
    m_addMenu->addAction(m_addSoloFrameAction);
    m_addMenu->addAction(m_addLabelAction);

    /* Edit menu */
    m_editMenu = new QMenu(this);
    m_editMenu->setTitle(tr("&Edit"));
    m_editMenu->addAction(m_editCutAction);
    m_editMenu->addAction(m_editCopyAction);
    m_editMenu->addAction(m_editPasteAction);
    m_editMenu->addAction(m_editDeleteAction);
    m_editMenu->addSeparator();
    m_editMenu->addAction(m_editPropertiesAction);
    m_editMenu->addAction(m_editRenameAction);
    m_editMenu->addSeparator();

    /* Background Menu */
    QMenu* bgMenu = new QMenu(m_editMenu);
    bgMenu->setTitle(tr("&Background"));
    m_editMenu->addMenu(bgMenu);
    bgMenu->addAction(m_bgColorAction);
    bgMenu->addAction(m_bgImageAction);
    bgMenu->addAction(m_bgDefaultAction);

    /* Foreground menu */
    QMenu* fgMenu = new QMenu(m_editMenu);
    fgMenu->setTitle(tr("&Foreground"));
    m_editMenu->addMenu(fgMenu);
    fgMenu->addAction(m_fgColorAction);
    fgMenu->addAction(m_fgDefaultAction);

    /* Font menu */
    QMenu* fontMenu = new QMenu(m_editMenu);
    fontMenu->setTitle(tr("F&ont"));
    m_editMenu->addMenu(fontMenu);
    fontMenu->addAction(m_fontAction);
    fontMenu->addAction(m_resetFontAction);

    /* Frame menu */
    QMenu* frameMenu = new QMenu(m_editMenu);
    frameMenu->setTitle(tr("F&rame"));
    m_editMenu->addMenu(frameMenu);
    frameMenu->addAction(m_frameSunkenAction);
    frameMenu->addAction(m_frameRaisedAction);
    frameMenu->addAction(m_frameNoneAction);

    /* Stacking order menu */
    QMenu* stackMenu = new QMenu(m_editMenu);
    stackMenu->setTitle(tr("Stacking &order"));
    m_editMenu->addMenu(stackMenu);
    stackMenu->addAction(m_stackingRaiseAction);
    stackMenu->addAction(m_stackingLowerAction);

    /* Add a separator that separates the common edit items from a custom
       widget menu that gets appended to the edit menu when a selected
       widget provides one. */
    m_editMenu->addSeparator();

    /* Toolbar */
    m_toolbar = new QToolBar(this);
    m_contentsLayout->addWidget(m_toolbar);

    m_toolbar->addAction(m_addButtonAction);
    m_toolbar->addAction(m_addButtonMatrixAction);
    m_toolbar->addAction(m_addSliderAction);
    m_toolbar->addAction(m_addSliderMatrixAction);
    m_toolbar->addAction(m_addSpeedDialAction);
    m_toolbar->addAction(m_addXYPadAction);
    m_toolbar->addAction(m_addCueListAction);
    m_toolbar->addAction(m_addFrameAction);
    m_toolbar->addAction(m_addSoloFrameAction);
    m_toolbar->addAction(m_addLabelAction);
    m_toolbar->addSeparator();
    m_toolbar->addAction(m_editCutAction);
    m_toolbar->addAction(m_editCopyAction);
    m_toolbar->addAction(m_editPasteAction);
    m_toolbar->addSeparator();
    m_toolbar->addAction(m_editDeleteAction);
    m_toolbar->addSeparator();
    m_toolbar->addAction(m_editPropertiesAction);
    m_toolbar->addAction(m_editRenameAction);
    m_toolbar->addSeparator();
    m_toolbar->addAction(m_stackingRaiseAction);
    m_toolbar->addAction(m_stackingLowerAction);
    m_toolbar->addSeparator();
    m_toolbar->addAction(m_bgColorAction);
    m_toolbar->addAction(m_bgImageAction);
    m_toolbar->addAction(m_fgColorAction);
    m_toolbar->addAction(m_fontAction);
    m_toolbar->addSeparator();
    m_toolbar->addAction(m_toolsSettingsAction);
}
bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *error_message)
{
    Core::ICore *core = Core::ICore::instance();
    if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/qmljseditor/QmlJSEditor.mimetypes.xml"), error_message))
        return false;

    m_modelManager = QmlJS::ModelManagerInterface::instance();
    addAutoReleasedObject(new QmlJSSnippetProvider);

    Core::Context context(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);

    m_editor = new QmlJSEditorFactory(this);
    addObject(m_editor);

    Core::BaseFileWizardParameters qmlWizardParameters(Core::IWizard::FileWizard);
    qmlWizardParameters.setCategory(QLatin1String(Constants::WIZARD_CATEGORY_QML));
    qmlWizardParameters.setDisplayCategory(QCoreApplication::translate("QmlJsEditor", Constants::WIZARD_TR_CATEGORY_QML));
    qmlWizardParameters.setDescription(tr("Creates a QML file."));
    qmlWizardParameters.setDisplayName(tr("QML File"));
    qmlWizardParameters.setId(QLatin1String("Q.Qml"));
    addAutoReleasedObject(new QmlFileWizard(qmlWizardParameters, core));

    Core::BaseFileWizardParameters jsWizardParameters(Core::IWizard::FileWizard);
    jsWizardParameters.setCategory(QLatin1String(Constants::WIZARD_CATEGORY_QML));
    jsWizardParameters.setDisplayCategory(QCoreApplication::translate("QmlJsEditor", Constants::WIZARD_TR_CATEGORY_QML));
    jsWizardParameters.setDescription(tr("Creates a JavaScript file."));
    jsWizardParameters.setDisplayName(tr("JS File"));
    jsWizardParameters.setId(QLatin1String("Z.Js"));
    addAutoReleasedObject(new JsFileWizard(jsWizardParameters, core));

    m_actionHandler = new TextEditor::TextEditorActionHandler(QmlJSEditor::Constants::C_QMLJSEDITOR_ID,
          TextEditor::TextEditorActionHandler::Format
        | TextEditor::TextEditorActionHandler::UnCommentSelection
        | TextEditor::TextEditorActionHandler::UnCollapseAll);
    m_actionHandler->initializeActions();

    Core::ActionManager *am =  core->actionManager();
    Core::ActionContainer *contextMenu = am->createMenu(QmlJSEditor::Constants::M_CONTEXT);
    Core::ActionContainer *qmlToolsMenu = am->createMenu(Core::Id(Constants::M_TOOLS_QML));
    qmlToolsMenu->setOnAllDisabledBehavior(Core::ActionContainer::Hide);
    QMenu *menu = qmlToolsMenu->menu();
    //: QML sub-menu in the Tools menu
    menu->setTitle(tr("QML"));
    am->actionContainer(Core::Constants::M_TOOLS)->addMenu(qmlToolsMenu);

    Core::Command *cmd;
    QAction *followSymbolUnderCursorAction = new QAction(tr("Follow Symbol Under Cursor"), this);
    cmd = am->registerAction(followSymbolUnderCursorAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, context);
    cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
    connect(followSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(followSymbolUnderCursor()));
    contextMenu->addAction(cmd);
    qmlToolsMenu->addAction(cmd);

    QAction *findUsagesAction = new QAction(tr("Find Usages"), this);
    cmd = am->registerAction(findUsagesAction, Constants::FIND_USAGES, context);
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U")));
    connect(findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages()));
    contextMenu->addAction(cmd);
    qmlToolsMenu->addAction(cmd);

    QAction *showQuickToolbar = new QAction(tr("Show Qt Quick Toolbar"), this);
    cmd = am->registerAction(showQuickToolbar, Constants::SHOW_QT_QUICK_HELPER, context);
#ifdef Q_WS_MACX
    cmd->setDefaultKeySequence(QKeySequence(Qt::META + Qt::ALT + Qt::Key_Space));
#else
    cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Space));
#endif
    connect(showQuickToolbar, SIGNAL(triggered()), this, SLOT(showContextPane()));
    contextMenu->addAction(cmd);
    qmlToolsMenu->addAction(cmd);

    // Insert marker for "Refactoring" menu:
    Core::Context globalContext(Core::Constants::C_GLOBAL);
    Core::Command *sep = createSeparator(am, this, globalContext,
                                         Constants::SEPARATOR1);
    sep->action()->setObjectName(Constants::M_REFACTORING_MENU_INSERTION_POINT);
    contextMenu->addAction(sep);
    contextMenu->addAction(createSeparator(am, this, globalContext,
                                           Constants::SEPARATOR2));

    cmd = am->command(TextEditor::Constants::AUTO_INDENT_SELECTION);
    contextMenu->addAction(cmd);

    cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
    contextMenu->addAction(cmd);

    CodeCompletion *completion = new CodeCompletion(m_modelManager);
    addAutoReleasedObject(completion);

    addAutoReleasedObject(new HoverHandler);

    // Set completion settings and keep them up to date
    TextEditor::TextEditorSettings *textEditorSettings = TextEditor::TextEditorSettings::instance();
    completion->setCompletionSettings(textEditorSettings->completionSettings());
    connect(textEditorSettings, SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)),
            completion, SLOT(setCompletionSettings(TextEditor::CompletionSettings)));

    error_message->clear();

    Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
    iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(":/qmljseditor/images/qmlfile.png")), "qml");

    m_quickFixCollector = new QmlJSQuickFixCollector;
    addAutoReleasedObject(m_quickFixCollector);
    QmlJSQuickFixCollector::registerQuickFixes(this);

    addAutoReleasedObject(new QmlJSOutlineWidgetFactory);

    m_qmlTaskManager = new QmlTaskManager;
    addAutoReleasedObject(m_qmlTaskManager);

    connect(m_modelManager, SIGNAL(documentChangedOnDisk(QmlJS::Document::Ptr)),
            m_qmlTaskManager, SLOT(documentChangedOnDisk(QmlJS::Document::Ptr)));
    connect(m_modelManager, SIGNAL(aboutToRemoveFiles(QStringList)),
            m_qmlTaskManager, SLOT(documentsRemoved(QStringList)));

    addAutoReleasedObject(new QuickToolBar);
    addAutoReleasedObject(new Internal::QuickToolBarSettingsPage);

    connect(core->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(currentEditorChanged(Core::IEditor*)));

    return true;
}
Example #27
0
MainWindow::MainWindow() :
	mFullScreenAction(NULL),
	mStandard3DViewActions(new QActionGroup(this)),
	mControlPanel(NULL),
	mDockWidgets(new DynamicMainWindowWidgets(this)),
	mActions(NULL)
{
	this->setObjectName("MainWindow");

	mServices = VisServices::create(logicManager()->getPluginContext());
	mLayoutInteractor.reset(new LayoutInteractor());

    this->setCentralWidget(viewService()->createLayoutWidget(this, 0));

	mActions = new MainWindowActions(mServices, this);

	this->createActions();
	this->createMenus();
	this->createToolBars();
	this->setStatusBar(new StatusBar());

	reporter()->setAudioSource(AudioPtr(new AudioImpl()));

	connect(stateService().get(), &StateService::applicationStateChanged, this, &MainWindow::onApplicationStateChangedSlot);
	connect(stateService().get(), &StateService::workflowStateChanged, this, &MainWindow::onWorkflowStateChangedSlot);
	connect(stateService().get(), &StateService::workflowStateAboutToChange, this, &MainWindow::saveDesktopSlot);

	this->updateWindowTitle();

	this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);

	this->addAsDockWidget(new PlaybackWidget(this), "Browsing");
	this->addAsDockWidget(new VideoConnectionWidget(mServices, this), "Utility");
	this->addAsDockWidget(new EraserWidget(mServices->patient(), mServices->view(), this), "Properties");
	this->addAsDockWidget(new MetricWidget(mServices->view(), mServices->patient(), this), "Utility");
	this->addAsDockWidget(new SlicePropertiesWidget(mServices->patient(), mServices->view(), this), "Properties");
	this->addAsDockWidget(new VolumePropertiesWidget(mServices, this), "Properties");
	this->addAsDockWidget(new ActiveMeshPropertiesWidget(mServices, this), "Properties");
	this->addAsDockWidget(new StreamPropertiesWidget(mServices->patient(), mServices->view(), this), "Properties");
	this->addAsDockWidget(new TrackPadWidget(this), "Utility");
	this->addAsDockWidget(new ActiveToolPropertiesWidget(mServices->tracking(), mServices->spaceProvider(), this), "Properties");
	this->addAsDockWidget(new NavigationWidget(this), "Properties");
	this->addAsDockWidget(new ConsoleWidget(this, "ConsoleWidget", "Console"), "Utility");
	this->addAsDockWidget(new ConsoleWidget(this, "ConsoleWidget2", "Extra Console"), "Utility");
//	this->addAsDockWidget(new ConsoleWidgetCollection(this, "ConsoleWidgets", "Consoles"), "Utility");
	this->addAsDockWidget(new FrameTreeWidget(mServices->patient(), this), "Browsing");
	this->addAsDockWidget(new ToolManagerWidget(this), "Debugging");
	this->addAsDockWidget(new PluginFrameworkWidget(this), "Browsing");
    this->addAsDockWidget(new FiltersWidget(VisServices::create(logicManager()->getPluginContext()), this), "Algorithms");
	this->addAsDockWidget(new ClippingPropertiesWidget(mServices, this), "Properties");

	this->addAsDockWidget(new BrowserWidget(this, mServices), "Browsing");

	connect(patientService().get(), &PatientModelService::patientChanged, this, &MainWindow::patientChangedSlot);
	connect(qApp, &QApplication::focusChanged, this, &MainWindow::focusChanged);

	this->setupGUIExtenders();

	// window menu must be created after all dock widgets are created
	QMenu* popupMenu = this->createPopupMenu();
	popupMenu->setTitle("Window");
	this->menuBar()->insertMenu(mHelpMenuAction, popupMenu);

	// show after window has been initialized
	QTimer::singleShot(0, this, SLOT(delayedShow()));
}
bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *error_message)
{
    Core::ICore *core = Core::ICore::instance();
    if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/glsleditor/GLSLEditor.mimetypes.xml"), error_message))
        return false;

    parseGlslFile(QLatin1String("glsl_120.frag"), &m_glsl_120_frag);
    parseGlslFile(QLatin1String("glsl_120.vert"), &m_glsl_120_vert);
    parseGlslFile(QLatin1String("glsl_120_common.glsl"), &m_glsl_120_common);
    parseGlslFile(QLatin1String("glsl_es_100.frag"), &m_glsl_es_100_frag);
    parseGlslFile(QLatin1String("glsl_es_100.vert"), &m_glsl_es_100_vert);
    parseGlslFile(QLatin1String("glsl_es_100_common.glsl"), &m_glsl_es_100_common);


//    m_modelManager = new ModelManager(this);
//    addAutoReleasedObject(m_modelManager);

    addAutoReleasedObject(new GLSLHoverHandler(this));

    Core::Context context(GLSLEditor::Constants::C_GLSLEDITOR_ID);

    m_editor = new GLSLEditorFactory(this);
    addObject(m_editor);

    addAutoReleasedObject(new GLSLCompletionAssistProvider);

    m_actionHandler = new TextEditor::TextEditorActionHandler(GLSLEditor::Constants::C_GLSLEDITOR_ID,
                                                              TextEditor::TextEditorActionHandler::Format
                                                              | TextEditor::TextEditorActionHandler::UnCommentSelection
                                                              | TextEditor::TextEditorActionHandler::UnCollapseAll);
    m_actionHandler->initializeActions();

    Core::ActionManager *am =  core->actionManager();
    Core::ActionContainer *contextMenu = am->createMenu(GLSLEditor::Constants::M_CONTEXT);
    Core::ActionContainer *glslToolsMenu = am->createMenu(Core::Id(Constants::M_TOOLS_GLSL));
    glslToolsMenu->setOnAllDisabledBehavior(Core::ActionContainer::Hide);
    QMenu *menu = glslToolsMenu->menu();
    //: GLSL sub-menu in the Tools menu
    menu->setTitle(tr("GLSL"));
    am->actionContainer(Core::Constants::M_TOOLS)->addMenu(glslToolsMenu);

    Core::Command *cmd = 0;

    // Insert marker for "Refactoring" menu:
    Core::Context globalContext(Core::Constants::C_GLOBAL);
    Core::Command *sep = createSeparator(am, this, globalContext,
                                         Constants::SEPARATOR1);
    sep->action()->setObjectName(Constants::M_REFACTORING_MENU_INSERTION_POINT);
    contextMenu->addAction(sep);
    contextMenu->addAction(createSeparator(am, this, globalContext,
                                           Constants::SEPARATOR2));

    cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
    contextMenu->addAction(cmd);

    error_message->clear();

    Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
    Core::MimeDatabase *mimeDatabase = Core::ICore::instance()->mimeDatabase();
    iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
                                                 mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE)));
    iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
                                                 mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_VERT)));
    iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
                                                 mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG)));
    iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
                                                 mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_VERT_ES)));
    iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
                                                 mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG_ES)));

    Core::BaseFileWizardParameters fragWizardParameters(Core::IWizard::FileWizard);
    fragWizardParameters.setCategory(QLatin1String(Constants::WIZARD_CATEGORY_GLSL));
    fragWizardParameters.setDisplayCategory(QCoreApplication::translate("GLSLEditor", Constants::WIZARD_TR_CATEGORY_GLSL));
    fragWizardParameters.setDescription
        (tr("Creates a fragment shader in the OpenGL/ES 2.0 Shading "
            "Language (GLSL/ES). Fragment shaders generate the final "
            "pixel colors for triangles, points and lines rendered "
            "with OpenGL."));
    fragWizardParameters.setDisplayName(tr("Fragment Shader (OpenGL/ES 2.0)"));
    fragWizardParameters.setId(QLatin1String("F.GLSL"));
    addAutoReleasedObject(new GLSLFileWizard(fragWizardParameters, GLSLFileWizard::FragmentShaderES, core));

    Core::BaseFileWizardParameters vertWizardParameters(Core::IWizard::FileWizard);
    vertWizardParameters.setCategory(QLatin1String(Constants::WIZARD_CATEGORY_GLSL));
    vertWizardParameters.setDisplayCategory(QCoreApplication::translate("GLSLEditor", Constants::WIZARD_TR_CATEGORY_GLSL));
    vertWizardParameters.setDescription
        (tr("Creates a vertex shader in the OpenGL/ES 2.0 Shading "
            "Language (GLSL/ES). Vertex shaders transform the "
            "positions, normals and texture co-ordinates of "
            "triangles, points and lines rendered with OpenGL."));
    vertWizardParameters.setDisplayName(tr("Vertex Shader (OpenGL/ES 2.0)"));
    vertWizardParameters.setId(QLatin1String("G.GLSL"));
    addAutoReleasedObject(new GLSLFileWizard(vertWizardParameters, GLSLFileWizard::VertexShaderES, core));

    fragWizardParameters.setDescription
        (tr("Creates a fragment shader in the Desktop OpenGL Shading "
            "Language (GLSL). Fragment shaders generate the final "
            "pixel colors for triangles, points and lines rendered "
            "with OpenGL."));
    fragWizardParameters.setDisplayName(tr("Fragment Shader (Desktop OpenGL)"));
    fragWizardParameters.setId(QLatin1String("J.GLSL"));
    addAutoReleasedObject(new GLSLFileWizard(fragWizardParameters, GLSLFileWizard::FragmentShaderDesktop, core));

    vertWizardParameters.setDescription
        (tr("Creates a vertex shader in the Desktop OpenGL Shading "
            "Language (GLSL). Vertex shaders transform the "
            "positions, normals and texture co-ordinates of "
            "triangles, points and lines rendered with OpenGL."));
    vertWizardParameters.setDisplayName(tr("Vertex Shader (Desktop OpenGL)"));
    vertWizardParameters.setId(QLatin1String("K.GLSL"));
    addAutoReleasedObject(new GLSLFileWizard(vertWizardParameters, GLSLFileWizard::VertexShaderDesktop, core));

    return true;
}
Example #29
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QAction *qaAction;
    QMenu *menMain = new QMenu();

    QMenu *menPref = new QMenu();
    QMenu *menAcc = new QMenu();
    QMenu *menDevel = new QMenu();
    QMenu *menEdu = new QMenu();
    QMenu *menGraph = new QMenu();
    QMenu *menHam = new QMenu();
    QMenu *menInter = new QMenu();
    QMenu *menMulti = new QMenu();
    QMenu *menOffic = new QMenu();
    QMenu *menOth = new QMenu();
    QMenu *menSci = new QMenu();
    QMenu *menSys = new QMenu();

    QDesktopWidget *qDesktop = new QDesktopWidget();
    QRect qrDesktop = qDesktop->availableGeometry();
    QFile file(QDir::homePath() + "/.qtmenu");
    QString strProcess;
    QString strForeColor;
    QString strBackColor;
    int nLeft = -1;
    int nTop = -1;

    QDir qdDir = QDir(strSysApps);
    QFileInfoList qflList = qdDir.entryInfoList();

    QString strRunCommand = "fbrun -nearmouse";
    QString strExitCommand = "fluxbox-remote quit";
    QString strRebootCommand = "sudo reboot";
    QString strPoweroffCommand = "sudo poweroff";
    QStringList strlistCustoms;
    QString strTheme;

    bool blShowGNOME = true;
    bool blShowLXDE = true;
    bool blShowKDE = true;
    bool blShowMATE = true;
    bool blShowXFCE = true;


    QList<MenuListItem> mliList;
    MenuListItem mliListTemp;
    QMenu *menTemp;
    int nCount = qflList.count() - 1;
    bool blFirstLoop = true;
    bool blHasCustoms = false;

    bool blIconHasPath = false;
    bool blIconHasExt = false;

    // process config file
    if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        while (!file.atEnd())
        {
            strProcess = file.readLine().trimmed();

            // left positioning
            if (strProcess.toLower().startsWith("left=")) {
                strProcess.remove(0, 5);
                nLeft = strProcess.toInt();
            } else
            // top positioning
            if (strProcess.toLower().startsWith("top=")) {
                strProcess.remove(0, 4);
                nTop = strProcess.toInt();
            } else
            // custom menu items
            if (strProcess.toLower().startsWith("custom=")) {
                strProcess.remove(0, 7);
                strlistCustoms.append(strProcess);
            } else
            // theme
            if (strProcess.toLower().startsWith("icontheme=")) {
                strProcess.remove(0, 10);
                strTheme = strProcess;
            } else
            // foreground
            if (strProcess.toLower().startsWith("fg=")) {
                strProcess.remove(0, 3);
                if (strProcess != "") {
                    strForeColor = strProcess;
                }
            } else
            // background
            if (strProcess.toLower().startsWith("bg=")) {
                strProcess.remove(0, 3);
                if (strProcess != "") {
                    strBackColor = strProcess;
                }
            } else
            // show gnome items?
            if (strProcess.toLower().startsWith("showgnomeitems=")) {
                strProcess.remove(0, 15);
                if (strProcess.contains("true") ) {
                    blShowGNOME = true;
                } else {
                    blShowGNOME = false;
                }
            } else
            // show lxde items?
            if (strProcess.toLower().startsWith("showlxdeitems=")) {
                strProcess.remove(0, 14);
                if (strProcess.contains("true") ) {
                    blShowLXDE = true;
                } else {
                    blShowLXDE = false;
                }
            } else
            // show kde items?
            if (strProcess.toLower().startsWith("showkdeitems=")) {
                strProcess.remove(0, 14);
                if (strProcess.contains("true") ) {
                    blShowKDE = true;
                } else {
                    blShowKDE = false;
                }
            } else
            // show mate items?
            if (strProcess.toLower().startsWith("showmateitems=")) {
                strProcess.remove(0, 14);
                if (strProcess.contains("true") ) {
                    blShowMATE = true;
                } else {
                    blShowMATE = false;
                }
            } else
            // show xfce items?
            if (strProcess.toLower().startsWith("showxfceitems=")) {
                strProcess.remove(0, 14);
                if (strProcess.contains("true") ) {
                    blShowXFCE = true;
                } else {
                    blShowXFCE = false;
                }
            } else
            // run command
            if (strProcess.toLower().startsWith("runcommand=")) {
                strProcess.remove(0, 11);
                if (strProcess != "") {
                    strRunCommand = strProcess;
                }
            } else
            // exit command
            if (strProcess.toLower().startsWith("exitcommand=")) {
                strProcess.remove(0, 12);
                if (strProcess != "") {
                    strExitCommand = strProcess;
                }
            } else
            // reboot command
            if (strProcess.toLower().startsWith("restartcommand=")) {
                strProcess.remove(0, 15);
                if (strProcess != "") {
                    strRebootCommand = strProcess;
                }
            } else
            // poweroff command
            if (strProcess.toLower().startsWith("poweroffcommand=")) {
                strProcess.remove(0, 16);
                if (strProcess != "") {
                    strPoweroffCommand = strProcess;
                }
            }
        }
    }

    // set icon theme
    if (strTheme != "") {
        QIcon::setThemeName(strTheme);
    } else {
        QIcon::setThemeName("hicolor");
    }

    // custom menu items from config file
    for (int n = 0; n < strlistCustoms.count(); n++)
    {
        MenuListItem mi;

        strProcess = strlistCustoms.at(n);
        mi.strName = strProcess.section("|", 0, 0);
        mi.strExec = strProcess.section("|", 1, 1);
        mi.strIcon = strProcess.section("|", 2, 2);
        mi.strCategory = "CustomItems";

        mliList.append(mi);

        blHasCustoms = true;
    }

    // read desktop files and insert menu items
    for (int n = 0; n < nCount;)
    {
        QFileInfo fileInfo = qflList.at(n);
        QFile qfFile(fileInfo.absoluteFilePath());
        MenuListItem mi;
        bool blNoShow = false;
        bool blOkToParse = false;

        if (qfFile.open(QIODevice::ReadOnly|QIODevice::Text)) {
            while (!qfFile.atEnd())
            {
                strProcess = qfFile.readLine();

                // set parse flag if we are in the Desktop Entry section
                if (strProcess.startsWith("[") && strProcess.contains("Desktop Entry")) {
                    blOkToParse = true;
                }
                if (blOkToParse) {
                    // app name
                    if (strProcess.startsWith("Name=")) {
                        strProcess.remove(0,5);
                        mi.strName = strProcess.trimmed().remove("_");
                    } else
                    // app icon
                    if (strProcess.startsWith("Icon=")) {
                        strProcess.remove(0,5);
                        mi.strIcon = strProcess.trimmed();
                    } else
                    // app exec line
                    if (strProcess.startsWith("Exec=")) {
                        strProcess.remove(0,5);
                        mi.strExec = strProcess.trimmed();
                        mi.strExec.remove("%F");
                        mi.strExec.remove("%f");
                        mi.strExec.remove("%U");
                        mi.strExec.remove("%u");
                    } else
                    // app category
                    if (strProcess.startsWith("Categories=")) {
                        if (blFirstLoop) {
                            strProcess.remove(0,11);
                            mi.strCategory = strProcess.trimmed();
                        } else {
                            mi.strCategory = "Other";
                        }
                    } else
                    // needs terminal?
                    if (strProcess.startsWith("Terminal=")) {
                        strProcess.remove(0,9);

                        if (strProcess.toLower().contains("true")) {
                            mi.blNeedsTerminal = true;
                        } else {
                            mi.blNeedsTerminal = false;
                        }
                    } else
                    // don't display?
                    if (strProcess.startsWith("NoDisplay=")) {
                        strProcess.remove(0,10);
                        if (strProcess.contains("True") ||
                           strProcess.contains("true")
                           ) {
                            blNoShow = true;
                        }
                    } else
                    // show gnome stuff?
                    if (strProcess.contains("OnlyShowIn=GNOME")) {
                        if (blShowGNOME == true) {
                            blNoShow = false;
                        } else {
                            blNoShow = true;
                        }
                    } else
                    // show lxde stuff?
                    if (strProcess.contains("OnlyShowIn=LXDE")) {
                        if (blShowLXDE == true) {
                            blNoShow = false;
                        } else {
                            blNoShow = true;
                        }
                    } else
                    // show kde stuff?
                    if (strProcess.contains("OnlyShowIn=KDE")) {
                        if (blShowKDE == true) {
                            blNoShow = false;
                        } else {
                            blNoShow = true;
                        }
                    } else
                    // show mate stuff?
                    if (strProcess.contains("OnlyShowIn=MATE")) {
                        if (blShowMATE == true) {
                            blNoShow = false;
                        } else {
                            blNoShow = true;
                        }
                    } else
                    // show xfce stuff?
                    if (strProcess.contains("OnlyShowIn=XFCE")) {
                        if (blShowXFCE == true) {
                            blNoShow = false;
                        } else {
                            blNoShow = true;
                        }
                    } else
                    // stop parsing if there are other sections
                    if (strProcess.startsWith("[") && !strProcess.contains("Desktop Entry")) {
                        break;
                    }
                }
            }

            if (mi.strName != "" && !blNoShow) {
                if (mi.blNeedsTerminal) {
                    mi.strExec = "x-terminal-emulator -e " + mi.strExec;
                }
                mliList.append(mi);
            }

        }

        if (qfFile.isOpen()) {
            qfFile.close();
        }

        // switch to local app folder and start over
        if (n == (nCount - 1) && blFirstLoop) {
            qdDir = QDir(QDir::homePath() + "/.local/share/applications");
            qflList = qdDir.entryInfoList();
            nCount = qflList.count() - 1;
            n = 0;
            blFirstLoop = false;
            QApplication::beep();
        } else {
            n++;
        }
    }


    // sort items alphabetically
    qSort(mliList);

    // set up category sub-menus
    menPref->setIcon(QIcon::fromTheme("preferences-desktop", QIcon::fromTheme("document-send")));
    menPref->setTitle("Preferences");
    menAcc->setIcon(QIcon::fromTheme("applications-accessories", QIcon::fromTheme("document-send")));
    menAcc->setTitle("Accessories");
    menDevel->setIcon(QIcon::fromTheme("applications-development", QIcon::fromTheme("document-send")));
    menDevel->setTitle("Development");
    menEdu->setIcon(QIcon::fromTheme("applications-science", QIcon::fromTheme("document-send")));
    menEdu->setTitle("Education");
    menGraph->setIcon(QIcon::fromTheme("applications-graphics", QIcon::fromTheme("document-send")));
    menGraph->setTitle("Graphics");
    menHam->setIcon(QIcon::fromTheme("applications-other", QIcon::fromTheme("document-send")));
    menHam->setTitle("Ham Radio");
    menInter->setIcon(QIcon::fromTheme("applications-internet", QIcon::fromTheme("document-send")));
    menInter->setTitle("Network");
    menMulti->setIcon(QIcon::fromTheme("applications-multimedia", QIcon::fromTheme("document-send")));
    menMulti->setTitle("Multimedia");
    menOffic->setIcon(QIcon::fromTheme("applications-office", QIcon::fromTheme("document-send")));
    menOffic->setTitle("Office");
    menOth->setIcon(QIcon::fromTheme("applications-other", QIcon::fromTheme("document-send")));
    menOth->setTitle("Other");
    menSci->setIcon(QIcon::fromTheme("applications-science", QIcon::fromTheme("document-send")));
    menSci->setTitle("Science");
    menSys->setIcon(QIcon::fromTheme("applications-system", QIcon::fromTheme("document-send")));
    menSys->setTitle("System");


    // *** collate by standard categories ***
    for (int i = mliList.size() - 1; i > -1; --i) {

        menTemp = menOth;

        mliListTemp = mliList.at(i);

        // custom items
        if (mliListTemp.strCategory.contains("CustomItems")) {
            menTemp = menMain;
        } else
        // settings / preferences
        if (mliListTemp.strCategory.contains("=Settings") ||
            mliListTemp.strCategory.contains(";Settings")
           ) {
            menTemp = menPref;
        } else
        // system
        if (mliListTemp.strCategory.contains("System")) {
            menTemp = menSys;
        } else
        // hamradio
        if (mliListTemp.strCategory.contains("HamRadio")) {
            menTemp = menHam;
        } else
        // science
        if (mliListTemp.strCategory.contains("Science")) {
            menTemp = menSci;
        } else
        // accessories / utility
        if (mliListTemp.strCategory.contains("Accessories") ||
            mliListTemp.strCategory.contains("Utility")
           ) {
            menTemp = menAcc;
        } else
        // development / programming
        if (mliListTemp.strCategory.contains("Development")) {
            menTemp = menDevel;
        } else
        // education / science
        if (mliListTemp.strCategory.contains("Education") ||
            mliListTemp.strCategory.contains("Science")
           ) {
            menTemp = menEdu;
        } else
        // graphics
        if (mliListTemp.strCategory.contains("Graphics")) {
            menTemp = menGraph;
        } else
        // internet / network
        if (mliListTemp.strCategory.contains("Internet") ||
                mliListTemp.strCategory.contains("WebBrowser") ||
                mliListTemp.strCategory.contains("Network")
                )
        {
            menTemp = menInter;
        } else

        // multimedia / sound/video
        if (mliListTemp.strCategory.contains("Audio") ||
                mliListTemp.strCategory.contains("AudioVideo") ||
                mliListTemp.strCategory.contains("Multimedia")
                )
        {
            menTemp = menMulti;
        } else
        // office / productivity
        if (mliListTemp.strCategory.contains("Office")  ||
                mliListTemp.strCategory.contains("Productivity")  ||
                mliListTemp.strCategory.contains("WordProcessor")
                )
        {
            menTemp = menOffic;
        }

        /* insert into menu */
        qaAction = new QAction(mliListTemp.strName, NULL);

        // figure out icon
        blIconHasExt = false;
        blIconHasPath = false;

        // has path
        if (mliListTemp.strIcon.contains("/")) {
            blIconHasPath = true;
        }

        // has extension
        if (mliListTemp.strIcon.contains(".png") ||
            mliListTemp.strIcon.contains(".xpm") ||
            mliListTemp.strIcon.contains(".svg")
            ) {
                blIconHasExt = true;
        }

        // no path and no extension
        if (blIconHasExt == false && blIconHasPath == false) {
            qaAction->setIcon(QIcon::fromTheme(mliListTemp.strIcon));
        } else
        // path
        if (blIconHasPath == true) {
            qaAction->setIcon(QIcon(mliListTemp.strIcon));
        } else
        // extension but no path
        if (blIconHasExt == true && blIconHasPath == false) {
            qaAction->setIcon(QIcon::fromTheme(mliListTemp.strIcon));
        }

        if (qaAction->icon().isNull()) {
            if (file.exists(strSysPix + "/" + mliListTemp.strIcon)) {
                qaAction->setIcon(QIcon(strSysPix + "/" + mliListTemp.strIcon));
            } else
            if (file.exists(strSysIco + "/" + mliListTemp.strIcon + ".png")) {
                qaAction->setIcon(QIcon(strSysIco + "/" + mliListTemp.strIcon + ".png"));
            } else
            if (file.exists(strSysIco + "/hicolor/scalable/apps/" + mliListTemp.strIcon + ".svg")) {
                qaAction->setIcon(QIcon(strSysIco + "/hicolor/scalable/apps/" + mliListTemp.strIcon + ".svg"));
            } else
            if (file.exists(strSysPix + "/" + mliListTemp.strIcon + ".png")) {
                qaAction->setIcon(QIcon(strSysPix + "/" + mliListTemp.strIcon + ".png"));
            } else
            if (file.exists(strSysPix + "/" + mliListTemp.strIcon + ".xpm")) {
                qaAction->setIcon(QIcon(strSysPix + "/" + mliListTemp.strIcon + ".xpm"));
            } else
            if (file.exists(strSysPix + "/" + mliListTemp.strIcon + ".svg")) {
                qaAction->setIcon(QIcon(strSysPix + "/" + mliListTemp.strIcon + ".svg"));
            }
        }

        qaAction->setIconVisibleInMenu(true);
        qaAction->setData(mliListTemp.strExec);

        menTemp->addAction(qaAction);
    }


    // add separator if there are customs
    if (blHasCustoms) {
        menMain->addSeparator();
    }

    // preferences
    if (menPref->actions().count() > 0) {
        menMain->addMenu(menPref);
        menMain->addSeparator();
    }

    // accessories
    if (menAcc->actions().count() > 0) {
        menMain->addMenu(menAcc);
    }

    // development
    if (menDevel->actions().count() > 0) {
        menMain->addMenu(menDevel);
    }

    // education
    if (menEdu->actions().count() > 0) {
        menMain->addMenu(menEdu);
    }

    // graphics
    if (menGraph->actions().count() > 0) {
        menMain->addMenu(menGraph);
    }

    // ham radio
    if (menHam->actions().count() > 0) {
        menMain->addMenu(menHam);
    }

    // internet/networking
    if (menInter->actions().count() > 0) {
        menMain->addMenu(menInter);
    }

    // multimedia / sound/video
    if (menMulti->actions().count() > 0) {
        menMain->addMenu(menMulti);
    }

    // office
    if (menOffic->actions().count() > 0) {
        menMain->addMenu(menOffic);
    }

    // other
    if (menOth->actions().count() > 0) {
        menMain->addMenu(menOth);
    }

    // science
    if (menSci->actions().count() > 0) {
        menMain->addMenu(menSci);
    }

    // system
    if (menSys->actions().count() > 0) {
        menMain->addMenu(menSys);
    }

    menMain->addSeparator();

    qaAction = new QAction("About...", NULL);
    qaAction->setData("...about...");
    qaAction->setIcon(QIcon::fromTheme("dialog-information"));
    menMain->addAction(qaAction);

    menMain->addSeparator();

    qaAction = new QAction("Run...", NULL);
    qaAction->setData(strRunCommand);
    menMain->addAction(qaAction);

    menMain->addSeparator();

    qaAction = new QAction("Exit", NULL);
    qaAction->setData(strExitCommand);
    qaAction->setIcon(QIcon::fromTheme("system-log-out"));
    menMain->addAction(qaAction);

    qaAction = new QAction("Reboot", NULL);
    qaAction->setData(strRebootCommand);
    qaAction->setIcon(QIcon::fromTheme("view-refresh"));
    menMain->addAction(qaAction);

    qaAction = new QAction("Shutdown", NULL);
    qaAction->setData(strPoweroffCommand);
    qaAction->setIcon(QIcon::fromTheme("system-shutdown"));
    menMain->addAction(qaAction);

    // set correct positioning
    if (nLeft == -1) {
        nLeft = qrDesktop.left();
    }

    if (nTop == -1) {
        nTop = qrDesktop.bottom();
    }

    // show menu
    qaAction = menMain->exec(QPoint(nLeft, nTop));

    // perform/run selected action
    if (qaAction != 0) {
        QString qsExec = qaAction->data().toString();
        if (qsExec == "...about...") {
            QMessageBox::about(NULL,
                               "About Qt Menu - Standalone",
                                "<h3>Qt Menu - Standalone</h3><br><br>"
                                "Copyright 2014 - Will Brokenbourgh<br>"
                                "Blog: http://www.pismotek.com/brainout/<br><br>"
                                "Version 0.1.1");
        } else {
            QProcess *qp = new QProcess();
            qp->setWorkingDirectory(QDir::homePath());
            qp->start(qsExec);
        }
    }
}
Example #30
0
void QMenuProto::setTitle(const QString &title)
{
  QMenu *item = qscriptvalue_cast<QMenu*>(thisObject());
  if (item)
    item->setTitle(title);
}