当前位置: 首页>>代码示例>>C++>>正文


C++ QMenu::addMenu方法代码示例

本文整理汇总了C++中QMenu::addMenu方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::addMenu方法的具体用法?C++ QMenu::addMenu怎么用?C++ QMenu::addMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMenu的用法示例。


在下文中一共展示了QMenu::addMenu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QMainWindow

BlitzMainWindow::BlitzMainWindow()
    : QMainWindow()
{
    setWindowTitle(tr("Blitz Effect Test"));
    QScrollArea *sa = new QScrollArea(this);
    lbl = new QLabel;
    sa->setWidget(lbl);
    setCentralWidget(sa);

    QToolBar *tBar = addToolBar(tr("Effect Options"));
    QAction *openAct = tBar->addAction(tr("Open"), this, SLOT(slotOpen()));
    QAction *revertAct = tBar->addAction(tr("Revert"), this, SLOT(slotRevert()));
    qualityCB = new QCheckBox(tr("High Quality"), tBar);
    qualityCB->setChecked(true);
    tBar->addWidget(qualityCB);

    QMenuBar *mBar = menuBar();
    QMenu *fileMnu = mBar->addMenu(tr("File"));
    fileMnu->addAction(openAct);
    fileMnu->addAction(revertAct);
    fileMnu->addSeparator();
    fileMnu->addAction(tr("Close"), this, SLOT(close()));

    QMenu *effectMnu = mBar->addMenu(tr("Effects"));
    effectMnu->addAction(tr("Grayscale (MMX)"), this, SLOT(slotGrayscale()));
    effectMnu->addAction(tr("Invert (MMX)"), this, SLOT(slotInvert()));

    QMenu *subMnu = effectMnu->addMenu(tr("Threshold"));
    subMnu->addAction(tr("Threshold (Default)"), this, SLOT(slotThreshold()));
    subMnu->addAction(tr("Threshold (Red)"), this, SLOT(slotThresholdRed()));
    subMnu->addAction(tr("Threshold (Green)"), this, SLOT(slotThresholdGreen()));
    subMnu->addAction(tr("Threshold (Blue)"), this, SLOT(slotThresholdBlue()));
    subMnu->addAction(tr("Threshold (Alpha)"), this, SLOT(slotThresholdAlpha()));
    subMnu = effectMnu->addMenu(tr("Intensity (MMX)"));
    subMnu->addAction(tr("Increment Intensity"), this, SLOT(slotIncIntensity()));
    subMnu->addAction(tr("Decrement Intensity"), this, SLOT(slotDecIntensity()));
    subMnu->addSeparator();
    subMnu->addAction(tr("Increment Red Intensity"), this, SLOT(slotIncRedIntensity()));
    subMnu->addAction(tr("Decrement Red Intensity"), this, SLOT(slotDecRedIntensity()));
    subMnu->addAction(tr("Increment Green Intensity"), this, SLOT(slotIncGreenIntensity()));
    subMnu->addAction(tr("Decrement Green Intensity"), this, SLOT(slotDecGreenIntensity()));
    subMnu->addAction(tr("Increment Blue Intensity"), this, SLOT(slotIncBlueIntensity()));
    subMnu->addAction(tr("Decrement Blue Intensity"), this, SLOT(slotDecBlueIntensity()));
    effectMnu->addSeparator();

    effectMnu->addAction(tr("Spiff"), this, SLOT(slotSpiff()));
    effectMnu->addAction(tr("Dull"), this, SLOT(slotDull()));
    effectMnu->addSeparator();
    effectMnu->addAction(tr("Desaturate"), this, SLOT(slotDesaturate()));
    effectMnu->addAction(tr("Fade"), this, SLOT(slotFade()));
    effectMnu->addAction(tr("Flatten"), this, SLOT(slotFlatten()));
    effectMnu->addSeparator();
    effectMnu->addAction(tr("Sharpen"), this, SLOT(slotSharpen()));
    effectMnu->addAction(tr("Blur"), this, SLOT(slotBlur()));
    effectMnu->addAction(tr("Gaussian Sharpen (MMX)"), this, SLOT(slotGaussianSharpen()));
    effectMnu->addAction(tr("Gaussian Blur (MMX)"), this, SLOT(slotGaussianBlur()));
    effectMnu->addSeparator();

    effectMnu->addAction(tr("Sobel Edge (MMX)"), this, SLOT(slotEdge()));
    effectMnu->addAction(tr("Convolve Edge (MMX)"), this, SLOT(slotConvolveEdge()));
    effectMnu->addSeparator();

    effectMnu->addAction(tr("Equalize"), this, SLOT(slotEqualize()));
    effectMnu->addAction(tr("Normalize"), this, SLOT(slotNormalize()));
    effectMnu->addAction(tr("Despeckle"), this, SLOT(slotDespeckle()));
    effectMnu->addSeparator();

    effectMnu->addAction(tr("Charcoal"), this, SLOT(slotCharcoal()));
    effectMnu->addAction(tr("Swirl"), this, SLOT(slotSwirl()));
    effectMnu->addAction(tr("Implode"), this, SLOT(slotImplode()));
    effectMnu->addAction(tr("Wave"), this, SLOT(slotWave()));
    effectMnu->addAction(tr("Oil Paint"), this, SLOT(slotOilpaint()));
    effectMnu->addAction(tr("Emboss"), this, SLOT(slotEmboss()));
    effectMnu->addSeparator();

    effectMnu->addAction(tr("Smoothscale (MMX)..."), this, SLOT(slotSmoothscale()));
    effectMnu->addAction(tr("Smoothscale Filtered..."), this, SLOT(slotSmoothscaleFiltered()));
    effectMnu->addSeparator();
    effectMnu->addAction(tr("Modulate..."), this, SLOT(slotModulate()));
    effectMnu->addSeparator();

    effectMnu->addAction(tr("Gradient..."), this, SLOT(slotGradient()));
    effectMnu->addAction(tr("Unbalanced Gradient..."), this, SLOT(slotUnbalancedGradient()));
    effectMnu->addAction(tr("8bpp Gradient..."), this, SLOT(slotGrayscaleGradient()));
    effectMnu->addAction(tr("8bpp Unbalanced Gradient..."), this, SLOT(slotGrayscaleUnbalancedGradient()));

    resize(sizeHint());
}
开发者ID:mylxiaoyi,项目名称:qimageblitz,代码行数:88,代码来源:mainwindow.cpp

示例2: collectionTreeContextMenuRequested

// Context menu requested for CollectionTree
void UChromaWindow::collectionTreeContextMenuRequested(const QPoint& point)
{
	// Build the context menu to display
	QMenu contextMenu;
	QAction* action;
	// -- Main 'edit' functions
	QAction* deleteAction = contextMenu.addAction("&Delete");
	QAction* duplicateAction = contextMenu.addAction("Du&plicate");
	// -- "Display..." pane menu
	contextMenu.addSeparator();
	QMenu paneMenu, removeFromPaneMenu, addToPaneMenu;
	RefList<ViewPane,bool> displayPanes = UChromaSession::viewLayout().panes(ViewPane::StandardRole);
	RefList<ViewPane,bool> currentPanes = UChromaSession::viewLayout().panes(UChromaSession::currentCollection(), ViewPane::StandardRole);
	QList<QAction*> addToPaneActions, removeFromPaneActions;
	// -- ... Populate removeFromPaneMenu first...
	for (RefListItem<ViewPane,bool>* ri = currentPanes.first(); ri != NULL; ri = ri->next)
	{
		action = removeFromPaneMenu.addAction(ri->item->name());
		action->setData(VariantPointer<ViewPane>(ri->item));
		removeFromPaneActions << action;
	}
	// -- ... Now populate addToPaneMenu...
	for (RefListItem<ViewPane,bool>* ri = displayPanes.first(); ri != NULL; ri = ri->next)
	{
		if (currentPanes.contains(ri->item)) continue;
		action = addToPaneMenu.addAction(ri->item->name());
		action->setData(VariantPointer<ViewPane>(ri->item));
		addToPaneActions << action;
	}
	// -- Construct parent paneMenu for these submenus, and add them to it
	action = paneMenu.addMenu(&addToPaneMenu);
	action->setText("Add to pane...");
	action = paneMenu.addMenu(&removeFromPaneMenu);
	action->setText("Remove from pane...");
	action = contextMenu.addMenu(&paneMenu);
	action->setText("Display...");
	// -- Analysis
	contextMenu.addSeparator();
	QAction* fitAction = contextMenu.addAction("New &Fit Equation...");
	QAction* editFitAction = contextMenu.addAction("&Edit Fit E&quation...");
	QAction* updateFitAction = contextMenu.addAction("&Update/Continue Fit");

	// Show it
	QAction* menuResult = contextMenu.exec(QCursor::pos());

	// What was clicked?
	if (menuResult == deleteAction) on_actionCollectionDelete_triggered(false);
	else if (menuResult == duplicateAction) on_actionCollectionDuplicate_triggered(false);
	else if (removeFromPaneActions.contains(menuResult))
	{
		ViewPane* pane = VariantPointer<ViewPane>(menuResult->data());
		if (pane) pane->removeCollectionTarget(UChromaSession::currentCollection());

		// Update the item
		updateCollectionTreeItem(ui.CollectionTree->currentItem());

		updateDisplay();
	}
	else if (addToPaneActions.contains(menuResult))
	{
		ViewPane* pane = VariantPointer<ViewPane>(menuResult->data());
		if (pane) pane->addCollectionTarget(UChromaSession::currentCollection());

		// Update the item
		updateCollectionTreeItem(ui.CollectionTree->currentItem());

		updateDisplay();
	}
	else if (menuResult == fitAction) on_actionAnalyseNewFit_triggered(false);
	else if (menuResult == editFitAction) on_actionAnalyseEditFit_triggered(false);
	else if (menuResult == updateFitAction) on_actionAnalyseUpdateFit_triggered(false);
}
开发者ID:trisyoungs,项目名称:uchroma,代码行数:73,代码来源:uchroma_collection.cpp

示例3: QMenuBar

QMenuBar*
ActionCollection::createMenuBar( QWidget *parent )
{
    QMenuBar* menuBar = new QMenuBar( parent );
    menuBar->setFont( TomahawkUtils::systemFont() );

    QMenu* controlsMenu = new QMenu( tr( "&Controls" ), menuBar );
    controlsMenu->setFont( TomahawkUtils::systemFont() );
    controlsMenu->addAction( m_actionCollection[ "playPause" ] );
    controlsMenu->addAction( m_actionCollection[ "previousTrack" ] );
    controlsMenu->addAction( m_actionCollection[ "nextTrack" ] );
    controlsMenu->addSeparator();
    controlsMenu->addAction( m_actionCollection[ "togglePrivacy" ] );
    controlsMenu->addAction( m_actionCollection[ "showOfflineSources" ] );
    controlsMenu->addSeparator();
    controlsMenu->addAction( m_actionCollection[ "importPlaylist" ] );
    controlsMenu->addAction( m_actionCollection[ "updateCollection" ] );
    controlsMenu->addAction( m_actionCollection[ "rescanCollection" ] );
    controlsMenu->addSeparator();
    controlsMenu->addAction( m_actionCollection[ "quit" ] );

    QMenu* settingsMenu = new QMenu( tr( "&Settings" ), menuBar );
    settingsMenu->setFont( TomahawkUtils::systemFont() );
#ifndef Q_OS_MAC
    settingsMenu->addAction( m_actionCollection[ "toggleMenuBar" ] );
#endif
    settingsMenu->addAction( m_actionCollection[ "preferences" ] );

    QMenu* helpMenu = new QMenu( tr( "&Help" ), menuBar );
    helpMenu->setFont( TomahawkUtils::systemFont() );
    helpMenu->addAction( m_actionCollection[ "diagnostics" ] );
    helpMenu->addAction( m_actionCollection[ "openLogfile" ] );
    helpMenu->addAction( m_actionCollection[ "legalInfo" ] );
    helpMenu->addAction( m_actionCollection["getSupport"] );
    helpMenu->addAction( m_actionCollection["reportBug"] );
    helpMenu->addAction( m_actionCollection["helpTranslate"] );
    helpMenu->addSeparator();
    QMenu* whatsNew = helpMenu->addMenu( ImageRegistry::instance()->icon( RESPATH "images/whatsnew.svg" ), tr( "What's New in ..." ) );
    whatsNew->setFont( TomahawkUtils::systemFont() );
    whatsNew->addAction( m_actionCollection[ "whatsnew_0_8" ] );
    helpMenu->addAction( m_actionCollection[ "aboutTomahawk" ] );

    // Setup update check
#ifndef Q_OS_MAC
    helpMenu->insertSeparator( m_actionCollection[ "legalInfo" ] );
#endif

#if defined( Q_OS_MAC ) && defined( HAVE_SPARKLE )
    helpMenu->addAction( m_actionCollection[ "checkForUpdates" ] );
#elif defined( Q_OS_WIN )
    helpMenu->addSeparator();
    helpMenu->addAction( m_actionCollection[ "checkForUpdates" ] );
#endif
    if ( qApp->arguments().contains( "--debug" ) )
    {
        helpMenu->addSeparator();
        helpMenu->addAction( m_actionCollection[ "crashNow" ] );
    }

    menuBar->addMenu( controlsMenu );
    menuBar->addMenu( settingsMenu );

#if defined( Q_OS_MAC )
    QMenu* windowMenu = new QMenu( tr( "&Window" ), menuBar );
    windowMenu->setFont( TomahawkUtils::systemFont() );
    windowMenu->addAction( m_actionCollection[ "minimize" ] );
    windowMenu->addAction( m_actionCollection[ "zoom" ] );
    windowMenu->addAction( m_actionCollection[ "fullscreen" ] );

    menuBar->addMenu( windowMenu );
#endif

    menuBar->addMenu( helpMenu );
    return menuBar;
}
开发者ID:pmpontes,项目名称:tomahawk,代码行数:75,代码来源:ActionCollection.cpp

示例4: on_FilesView__customContextMenuRequested

void TorrentTabFilesWidget::on_FilesView__customContextMenuRequested (const QPoint& pos)
{
    const auto itm = Core::Instance ()->GetProxy ()->GetIconThemeManager ();

    QMenu menu;

    const auto& selected = GetSelectedIndexes ();
    const auto& openable = Util::Filter (selected,
                                         [] (const QModelIndex& idx)
    {
        const auto progress = idx.data (TorrentFilesModel::RoleProgress).toDouble ();
        return idx.model ()->rowCount (idx) ||
               std::abs (progress - 1) < std::numeric_limits<double>::epsilon ();
    });
    if (!openable.isEmpty ())
    {
        const auto& openActName = openable.size () == 1 ?
                                  tr ("Open file") :
                                  tr ("Open %n file(s)", 0, openable.size ());
        const auto openAct = menu.addAction (openActName);
        openAct->setIcon (itm->GetIcon ("document-open"));
        new Util::SlotClosure<Util::DeleteLaterPolicy>
        {
            [openable, this]
            {
                for (const auto& idx : openable)
                    CurrentFilesModel_->HandleFileActivated (ProxyModel_->mapToSource (idx));
            },
            openAct,
            SIGNAL (triggered ()),
            openAct
        };

        menu.addSeparator ();
    }

    const auto& cachedRoots = Util::Map (selected,
                                         [] (const QModelIndex& idx)
    {
        return qMakePair (idx, idx.data (TorrentFilesModel::RoleFullPath).toString ());
    });
    const auto& priorityRoots = Util::Map (Util::Filter (cachedRoots,
                                           [&cachedRoots] (const QPair<QModelIndex, QString>& idxPair)
    {
        return std::none_of (cachedRoots.begin (), cachedRoots.end (),
                             [&idxPair] (const QPair<QModelIndex, QString>& existing)
        {
            return idxPair.first != existing.first &&
                   idxPair.second.startsWith (existing.second);
        });
    }),
    [] (const QPair<QModelIndex, QString>& idxPair)
    {
        return idxPair.first
               .sibling (idxPair.first.row (), TorrentFilesModel::ColumnPriority);
    });
    if (!priorityRoots.isEmpty ())
    {
        const auto subMenu = menu.addMenu (tr ("Change priority"));
        const QList<QPair<int, QString>> descrs
        {
            { 0, tr ("File is not downloaded.") },
            { 1, tr ("Normal priority, download order depends on availability.") },
            { 2, tr ("Pieces are preferred over the pieces with same availability.") },
            { 3, tr ("Empty pieces are preferred just as much as partial pieces.") },
            { 4, tr ("Empty pieces are preferred over partial pieces with the same availability.") },
            { 5, tr ("Same as previous.") },
            { 6, tr ("Pieces are considered to have highest availability.") },
            { 7, tr ("Maximum file priority.") }
        };

        for (const auto& descr : descrs)
        {
            const auto prio = descr.first;

            const auto act = subMenu->addAction (QString::number (prio) + " " + descr.second);

            new Util::SlotClosure<Util::DeleteLaterPolicy>
            {
                [this, prio, priorityRoots]
                {
                    for (const auto& idx : priorityRoots)
                        ProxyModel_->setData (idx, prio);
                },
                act,
                SIGNAL (triggered ()),
                act
            };
        }
    }

    menu.addAction (tr ("Expand all"), Ui_.FilesView_, SLOT (expandAll ()));
    menu.addAction (tr ("Collapse all"), Ui_.FilesView_, SLOT (collapseAll ()));

    menu.exec (Ui_.FilesView_->viewport ()->mapToGlobal (pos));
}
开发者ID:,项目名称:,代码行数:96,代码来源:

示例5: mousePressEvent

void TupPaintArea::mousePressEvent(QMouseEvent *event)
{
    #ifdef K_DEBUG
           T_FUNCINFO;
    #endif

    // SQA: Temporal solution for cases when there's no current frame defined
    if (!graphicsScene()->currentFrame()) {
        return;
    }

    if (graphicsScene()->currentFrame()->isLocked()) {
        #ifdef K_DEBUG
               tFatal() << "TupPaintArea::mousePressEvent() - Frame is locked!";
        #endif
        return;
    }

    if (k->currentTool.compare(tr("Line Selection")) == 0) {
        // If a node is the target... abort!
        if (event->buttons() == Qt::RightButton) {
            if (qgraphicsitem_cast<TControlNode *>(scene()->itemAt(mapToScene(event->pos()))))
                return;
        }
    }

    if (k->currentTool.compare(tr("Object Selection")) == 0) {

        if (event->buttons() == Qt::RightButton) {

            // If a node is the target... abort!
            if (qgraphicsitem_cast<Node *>(scene()->itemAt(mapToScene(event->pos()))))
                return;

            if (QGraphicsItem *item = scene()->itemAt(mapToScene(event->pos()))) {
                if (item->opacity() == 1) {
                    item->setFlag(QGraphicsItem::ItemIsSelectable, true);
                    item->setSelected(true);
                } else {
                    return;
                }
            }

            QMenu *menu = new QMenu(tr("Drawing area"));
            menu->addAction(kApp->findGlobalAction("undo"));
            menu->addAction(kApp->findGlobalAction("redo"));
            menu->addSeparator();

            QAction *cut = menu->addAction(tr("Cut"), this, SLOT(cutItems()), QKeySequence(tr("Ctrl+X")));
            QAction *copy = menu->addAction(tr("Copy"), this, SLOT(copyItems()), QKeySequence(tr("Ctrl+C")));
            QAction *paste = menu->addAction(tr("Paste"), this, SLOT(pasteItems()), QKeySequence(tr("Ctrl+V")));
            QAction *del = menu->addAction(tr("Delete"), this, SLOT(deleteItems()), QKeySequence(Qt::Key_Delete));

            menu->addSeparator();
            QMenu *order = new QMenu(tr("Order"));

            connect(order, SIGNAL(triggered(QAction*)), this, SLOT(requestMoveSelectedItems(QAction*)));
            order->addAction(tr("Send to back"))->setData(MoveBack);
            order->addAction(tr("Bring to front"))->setData(MoveFront);
            order->addAction(tr("Send backwards"))->setData(MoveBackwards);
            order->addAction(tr("Brind forwards"))->setData(MoveForwards);

            menu->addMenu(order);
            order->setDisabled(true);
            menu->addSeparator();

            // Code commented temporary while SQA is done
            QAction *addItem = menu->addAction(tr("Add to library..."), this, SLOT(addSelectedItemsToLibrary()));
            menu->addSeparator();

            if (scene()->selectedItems().isEmpty()) {
                del->setEnabled(false);
                cut->setEnabled(false);
                copy->setEnabled(false);
                addItem->setEnabled(false);
            } else {
                QList<QGraphicsItem *> selected = scene()->selectedItems();
                foreach (QGraphicsItem *item, selected) {
                         QDomDocument dom;
                         dom.appendChild(dynamic_cast<TupAbstractSerializable *>(item)->toXml(dom));
		         QDomElement root = dom.documentElement();

                         if (root.tagName() == "symbol") {
                             QString key = root.attribute("id").toUpper();
                             if (key.endsWith("JPG") || key.endsWith("PNG") || key.endsWith("GIF") || key.endsWith("XPM")) {
                                 addItem->setEnabled(false);
                                 break;
                             }
                         } else if (root.tagName() == "svg") {
                                    addItem->setEnabled(false);
                                    break;
                         }
                }
            }

            if (k->copiesXml.isEmpty())
                paste->setEnabled(false);

            if (QMenu *toolMenu = graphicsScene()->currentTool()->menu()) {
                menu->addSeparator();
//.........这里部分代码省略.........
开发者ID:hpsaturn,项目名称:tupi,代码行数:101,代码来源:tuppaintarea.cpp

示例6: createContextMenu

QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
{
  QMenu* menu = new QMenu;

  QgsLayerTreeViewDefaultActions* actions = mView->defaultActions();

  QModelIndex idx = mView->currentIndex();
  if ( !idx.isValid() )
  {
    // global menu
    menu->addAction( actions->actionAddGroup( menu ) );

    menu->addAction( QgsApplication::getThemeIcon( "/mActionExpandTree.svg" ), tr( "&Expand All" ), mView, SLOT( expandAll() ) );
    menu->addAction( QgsApplication::getThemeIcon( "/mActionCollapseTree.svg" ), tr( "&Collapse All" ), mView, SLOT( collapseAll() ) );

    // TODO: update drawing order
  }
  else if ( QgsLayerTreeNode* node = mView->layerTreeModel()->index2node( idx ) )
  {
    // layer or group selected
    if ( QgsLayerTree::isGroup( node ) )
    {
      menu->addAction( actions->actionZoomToGroup( mCanvas, menu ) );

      menu->addAction( QgsApplication::getThemeIcon( "/mActionRemoveLayer.svg" ), tr( "&Remove" ), QgisApp::instance(), SLOT( removeLayer() ) );

      menu->addAction( QgsApplication::getThemeIcon( "/mActionSetCRS.png" ),
                       tr( "&Set Group CRS" ), QgisApp::instance(), SLOT( legendGroupSetCRS() ) );

      menu->addAction( actions->actionRenameGroupOrLayer( menu ) );

      menu->addAction( actions->actionMutuallyExclusiveGroup( menu ) );

      if ( mView->selectedNodes( true ).count() >= 2 )
        menu->addAction( actions->actionGroupSelected( menu ) );

      menu->addAction( tr( "Save As Layer Definition File..." ), QgisApp::instance(), SLOT( saveAsLayerDefinition() ) );

      menu->addAction( actions->actionAddGroup( menu ) );
    }
    else if ( QgsLayerTree::isLayer( node ) )
    {
      QgsMapLayer *layer = QgsLayerTree::toLayer( node )->layer();
      QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( layer );
      QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );

      menu->addAction( actions->actionZoomToLayer( mCanvas, menu ) );
      menu->addAction( actions->actionShowInOverview( menu ) );

      if ( rlayer )
      {
        menu->addAction( QgsApplication::getThemeIcon( "/mActionZoomActual.svg" ), tr( "&Zoom to Native Resolution (100%)" ), QgisApp::instance(), SLOT( legendLayerZoomNative() ) );

        if ( rlayer->rasterType() != QgsRasterLayer::Palette )
          menu->addAction( tr( "&Stretch Using Current Extent" ), QgisApp::instance(), SLOT( legendLayerStretchUsingCurrentExtent() ) );
      }

      menu->addAction( QgsApplication::getThemeIcon( "/mActionRemoveLayer.svg" ), tr( "&Remove" ), QgisApp::instance(), SLOT( removeLayer() ) );

      // duplicate layer
      QAction* duplicateLayersAction = menu->addAction( QgsApplication::getThemeIcon( "/mActionDuplicateLayer.svg" ), tr( "&Duplicate" ), QgisApp::instance(), SLOT( duplicateLayers() ) );

      if ( !vlayer || vlayer->geometryType() != QGis::NoGeometry )
      {
        // set layer scale visibility
        menu->addAction( tr( "&Set Layer Scale Visibility" ), QgisApp::instance(), SLOT( setLayerScaleVisibility() ) );

        // set layer crs
        menu->addAction( QgsApplication::getThemeIcon( "/mActionSetCRS.png" ), tr( "&Set Layer CRS" ), QgisApp::instance(), SLOT( setLayerCRS() ) );

        // assign layer crs to project
        menu->addAction( QgsApplication::getThemeIcon( "/mActionSetProjectCRS.png" ), tr( "Set &Project CRS from Layer" ), QgisApp::instance(), SLOT( setProjectCRSFromLayer() ) );
      }

      // style-related actions
      if ( layer && mView->selectedLayerNodes().count() == 1 )
      {
        QMenu *menuStyleManager = new QMenu( tr( "Styles" ), menu );

        QgisApp *app = QgisApp::instance();
        menuStyleManager->addAction( tr( "Copy Style" ), app, SLOT( copyStyle() ) );
        if ( app->clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) )
        {
          menuStyleManager->addAction( tr( "Paste Style" ), app, SLOT( pasteStyle() ) );
        }

        menuStyleManager->addSeparator();
        QgsMapLayerStyleGuiUtils::instance()->addStyleManagerActions( menuStyleManager, layer );

        menu->addMenu( menuStyleManager );
      }

      menu->addSeparator();

      if ( vlayer )
      {
        QAction *toggleEditingAction = QgisApp::instance()->actionToggleEditing();
        QAction *saveLayerEditsAction = QgisApp::instance()->actionSaveActiveLayerEdits();
        QAction *allEditsAction = QgisApp::instance()->actionAllEdits();

//.........这里部分代码省略.........
开发者ID:dakcarto,项目名称:QGIS,代码行数:101,代码来源:qgsapplayertreeviewmenuprovider.cpp

示例7: ShowContextMenu


//.........这里部分代码省略.........

      menu->addSeparator();
    }

    if (platform == DiscIO::Platform::WiiDisc)
    {
      auto* perform_disc_update = menu->addAction(tr("Perform System Update"), this,
                                                  [this, file_path = game->GetFilePath()] {
                                                    WiiUpdate::PerformDiscUpdate(file_path, this);
                                                  });
      perform_disc_update->setEnabled(!Core::IsRunning() || !SConfig::GetInstance().bWii);
    }

    if (platform == DiscIO::Platform::WiiWAD)
    {
      QAction* wad_install_action = new QAction(tr("Install to the NAND"), menu);
      QAction* wad_uninstall_action = new QAction(tr("Uninstall from the NAND"), menu);

      connect(wad_install_action, &QAction::triggered, this, &GameList::InstallWAD);
      connect(wad_uninstall_action, &QAction::triggered, this, &GameList::UninstallWAD);

      for (QAction* a : {wad_install_action, wad_uninstall_action})
      {
        a->setEnabled(!Core::IsRunning());
        menu->addAction(a);
      }
      if (!Core::IsRunning())
        wad_uninstall_action->setEnabled(WiiUtils::IsTitleInstalled(game->GetTitleID()));

      connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu,
              [=](Core::State state) {
                wad_install_action->setEnabled(state == Core::State::Uninitialized);
                wad_uninstall_action->setEnabled(state == Core::State::Uninitialized &&
                                                 WiiUtils::IsTitleInstalled(game->GetTitleID()));
              });

      menu->addSeparator();
    }

    if (platform == DiscIO::Platform::WiiWAD || platform == DiscIO::Platform::WiiDisc)
    {
      menu->addAction(tr("Open Wii &Save Folder"), this, &GameList::OpenWiiSaveFolder);
      menu->addAction(tr("Export Wii Save (Experimental)"), this, &GameList::ExportWiiSave);
      menu->addSeparator();
    }

    if (platform == DiscIO::Platform::GameCubeDisc)
    {
      menu->addAction(tr("Open GameCube &Save Folder"), this, &GameList::OpenGCSaveFolder);
      menu->addSeparator();
    }

    menu->addAction(tr("Open &Containing Folder"), this, &GameList::OpenContainingFolder);
    menu->addAction(tr("Delete File..."), this, &GameList::DeleteFile);

    menu->addSeparator();

    auto* model = Settings::Instance().GetGameListModel();

    auto* tags_menu = menu->addMenu(tr("Tags"));

    auto path = game->GetFilePath();
    auto game_tags = model->GetGameTags(path);

    for (const auto& tag : model->GetAllTags())
    {
      auto* tag_action = tags_menu->addAction(tag);

      tag_action->setCheckable(true);
      tag_action->setChecked(game_tags.contains(tag));

      connect(tag_action, &QAction::toggled, [path, tag, model](bool checked) {
        if (!checked)
          model->RemoveGameTag(path, tag);
        else
          model->AddGameTag(path, tag);
      });
    }

    menu->addAction(tr("New Tag..."), this, &GameList::NewTag);
    menu->addAction(tr("Remove Tag..."), this, &GameList::DeleteTag);

    menu->addSeparator();

    QAction* netplay_host = new QAction(tr("Host with NetPlay"), menu);

    connect(netplay_host, &QAction::triggered, [this, game] {
      emit NetPlayHost(QString::fromStdString(game->GetUniqueIdentifier()));
    });

    connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu, [=](Core::State state) {
      netplay_host->setEnabled(state == Core::State::Uninitialized);
    });
    netplay_host->setEnabled(!Core::IsRunning());

    menu->addAction(netplay_host);
  }

  menu->exec(QCursor::pos());
}
开发者ID:booto,项目名称:dolphin,代码行数:101,代码来源:GameList.cpp

示例8: file

/****** Main menu constructor ******/
main_menu::main_menu(QWidget *parent) : QWidget(parent)
{
	//Setup actions
	QAction* open = new QAction("Open", this);
	QAction* quit = new QAction ("Quit", this);

	QAction* pause = new QAction("Pause", this);
	QAction* reset = new QAction("Reset", this);
	QAction* fullscreen = new QAction("Fullscreen", this);
	QAction* screenshot = new QAction("Screenshot", this);
	QAction* nplay_start = new QAction("Start Netplay", this);
	QAction* nplay_stop = new QAction("Stop Netplay", this);

	QAction* general = new QAction("General Settings...", this);
	QAction* display = new QAction("Display", this);
	QAction* sound = new QAction("Sound", this);
	QAction* controls = new QAction("Controls", this);
	QAction* netplay = new QAction("Netplay", this);
	QAction* paths = new QAction("Paths", this);

	QAction* custom_gfx = new QAction("Custom Graphics...", this);
	QAction* debugging = new QAction("Debugger", this);

	QAction* about = new QAction("About", this);

	//Set shortcuts for actions
	open->setShortcut(tr("CTRL+O"));
	quit->setShortcut(tr("CTRL+Q"));

	pause->setShortcut(tr("CTRL+P"));
	reset->setShortcut(tr("F8"));
	fullscreen->setShortcut(tr("F12"));
	screenshot->setShortcut(tr("F9"));
	nplay_start->setShortcut(tr("F5"));
	nplay_stop->setShortcut(tr("F6"));

	pause->setCheckable(true);
	pause->setObjectName("pause_action");
	fullscreen->setCheckable(true);
	fullscreen->setObjectName("fullscreen_action");

	menu_bar = new QMenuBar(this);

	//Setup File menu
	QMenu* file;

	file = new QMenu(tr("File"), this);
	file->addAction(open);
	recent_list = file->addMenu(tr("Recent Files"));
	file->addSeparator();
	state_save_list = file->addMenu(tr("Save State"));
	state_load_list = file->addMenu(tr("Load State"));
	file->addSeparator();
	file->addAction(quit);
	menu_bar->addMenu(file);

	//Setup Emulation menu
	QMenu* emulation;

	emulation = new QMenu(tr("Emulation"), this);
	emulation->addAction(pause);
	emulation->addAction(reset);
	emulation->addSeparator();
	emulation->addAction(fullscreen);
	emulation->addAction(screenshot);
	emulation->addSeparator();
	emulation->addAction(nplay_start);
	emulation->addAction(nplay_stop);
	menu_bar->addMenu(emulation);

	//Setup Options menu
	QMenu* options;
	
	options = new QMenu(tr("Options"), this);
	options->addAction(general);
	options->addSeparator();
	options->addAction(display);
	options->addAction(sound);
	options->addAction(controls);
	options->addAction(netplay);
	options->addAction(paths);
	menu_bar->addMenu(options);

	//Advanced menu
	QMenu* advanced;

	advanced = new QMenu(tr("Advanced"), this);
	advanced->addAction(custom_gfx);
	advanced->addAction(debugging);
	menu_bar->addMenu(advanced);

	//Setup Help menu
	QMenu* help;

	help = new QMenu(tr("Help"), this);
	help->addAction(about);
	menu_bar->addMenu(help);

	//Setup signals
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例9: main

int main(int argc, char * argv[])
{
    QList<QWidget*> widgets;
    QApplication app(argc, argv);

    QMainWindow mainWindow;
    mainWindow.setWindowTitle("Test");
    QMenu *fileMenu = mainWindow.menuBar()->addMenu("File");
    QMenu *editMenu = mainWindow.menuBar()->addMenu("Edit");
    QMenu *viewMenu = mainWindow.menuBar()->addMenu("View");
    QMenu *toolsMenu = mainWindow.menuBar()->addMenu("Tools");
    QMenu *optionsMenu = mainWindow.menuBar()->addMenu("Options");
    QMenu *helpMenu = mainWindow.menuBar()->addMenu("Help");

    qApp->processEvents();

    fileMenu->addAction("Open");
    QAction *close = fileMenu->addAction("Close");
    fileMenu->addSeparator();
    fileMenu->addAction("Exit");

    close->setEnabled(false);

    editMenu->addAction("Cut");
    editMenu->addAction("Pase");
    editMenu->addAction("Copy");
    editMenu->addSeparator();
    editMenu->addAction("Find");

    viewMenu->addAction("Hide");
    viewMenu->addAction("Show");
    viewMenu->addAction("Explore");
    QAction *visible = viewMenu->addAction("Visible");
    visible->setCheckable(true);
    visible->setChecked(true);

    toolsMenu->addMenu("Hammer");
    toolsMenu->addMenu("Caliper");
    toolsMenu->addMenu("Helm");

    optionsMenu->addMenu("Settings");
    optionsMenu->addMenu("Standard");
    optionsMenu->addMenu("Extended");
    
    QMenu *subMenu = helpMenu->addMenu("Help");
    subMenu->addAction("Index");
    subMenu->addSeparator();
    subMenu->addAction("Vodoo Help");
    helpMenu->addAction("Contens");
    helpMenu->addSeparator();
    helpMenu->addAction("About");

    QToolBar toolbar;
    mainWindow.addToolBar(&toolbar);
    toolbar.addAction(QIcon(qApp->style()->standardPixmap(QStyle::SP_FileIcon)), QString("textAction"));

    QTextEdit textEdit;
    mainWindow.setCentralWidget(&textEdit);

    mainWindow.showMaximized();

    app.exec();
}
开发者ID:maxxant,项目名称:qt,代码行数:63,代码来源:main.cpp

示例10: QHBoxLayout

QLayout *ZDLInterface::getButtonPane(){
	QHBoxLayout *box = new QHBoxLayout();

	QPushButton *btnExit = new QPushButton("Exit", this);
	btnZDL = new QPushButton("ZDL", this);
	QPushButton *btnMSet = new QPushButton("Multi Settings", this);
	btnEpr = new QPushButton(this);
	QPushButton *btnLaunch = new QPushButton("Launch", this);

	QMenu *context = new QMenu(btnZDL);
	QMenu *actions = new QMenu("Actions",context);

	QAction *showCommandline = actions->addAction("Show Command Line");
	QAction *clearAllPWadsAction = actions->addAction("Clear PWAD list");
	QAction *clearAllFieldsAction = actions->addAction("Clear all fields");
	clearAllFieldsAction->setShortcut(QKeySequence::New);
	QAction *clearEverythingAction = actions->addAction("Clear everything");
	actions->addSeparator();
#if !defined(NO_IMPORT)
	QAction *actImportCurrentConfig = actions->addAction("Import current config");
#endif
	QAction *clearCurrentGlobalConfig = actions->addAction("Clear current global config");
	clearCurrentGlobalConfig->setEnabled(false);	

	//QAction *newDMFlagger = actions->addAction("New DMFlag picker");

	context->addMenu(actions);
	context->addSeparator();
	QAction *loadZdlFileAction = context->addAction("Load .zdl");
	loadZdlFileAction->setShortcut(QKeySequence::Open);
	QAction *saveZdlFileAction = context->addAction("Save .zdl");
	saveZdlFileAction->setShortcut(QKeySequence::Save);
	context->addSeparator();
	QAction *loadAction = context->addAction("Load .ini");
	QAction *saveAction = context->addAction("Save .ini");
	context->addSeparator();
	QAction *aboutAction = context->addAction("About");
	aboutAction->setShortcut(QKeySequence::HelpContents);

	connect(loadAction, SIGNAL(triggered()), this, SLOT(loadConfigFile()));
	connect(saveAction, SIGNAL(triggered()), this, SLOT(saveConfigFile()));
	connect(loadZdlFileAction, SIGNAL(triggered()), this, SLOT(loadZdlFile()));
	connect(saveZdlFileAction, SIGNAL(triggered()), this, SLOT(saveZdlFile()));
	connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClick()));
#if !defined(NO_IMPORT)
	connect(actImportCurrentConfig, SIGNAL(triggered()), this, SLOT(importCurrentConfig()));
#endif

	connect(clearAllPWadsAction, SIGNAL(triggered()), this, SLOT(clearAllPWads()));
	connect(clearAllFieldsAction, SIGNAL(triggered()), this, SLOT(clearAllFields()));
	connect(clearEverythingAction, SIGNAL(triggered()), this, SLOT(clearEverything()));

	connect(showCommandline, SIGNAL(triggered()),this,SLOT(showCommandline()));
	//connect(newDMFlagger, SIGNAL(triggered()),this,SLOT(showNewDMFlagger()));
	connect(btnExit, SIGNAL(clicked()), this, SLOT(exitzdl()));

	btnZDL->setMenu(context);

	int minBtnWidth = 50;

	btnExit->setMinimumWidth(minBtnWidth-15);
	btnZDL->setMinimumWidth(minBtnWidth-15);
	btnMSet->setMinimumWidth(minBtnWidth+30);
	btnEpr->setMinimumWidth(20);
	btnLaunch->setMinimumWidth(minBtnWidth);

	connect(btnLaunch, SIGNAL( clicked() ), this, SLOT(launch()));

	setContentsMargins(0,0,0,0);
	layout()->setContentsMargins(0,0,0,0);
	box->setSpacing(2);
	box->addWidget(btnExit);
	box->addWidget(btnZDL);
	box->addWidget(btnMSet);
	box->addWidget(btnEpr);
	box->addWidget(btnLaunch);
	box->setSpacing(1);
	connect(btnEpr, SIGNAL(clicked()), this, SLOT(mclick()));

	connect(btnMSet, SIGNAL(clicked()), this, SLOT(ampclick()));
	return box;
}
开发者ID:adihodos,项目名称:qzdl,代码行数:82,代码来源:ZDLInterface.cpp

示例11: contextMenuEvent

void LXQtTaskButton::contextMenuEvent(QContextMenuEvent* event)
{
    if (event->modifiers().testFlag(Qt::ControlModifier))
    {
        event->ignore();
        return;
    }

    KWindowInfo info(mWindow, 0, NET::WM2AllowedActions);
    unsigned long state = KWindowInfo(mWindow, NET::WMState).state();

    QMenu * menu = new QMenu(tr("Application"));
    menu->setAttribute(Qt::WA_DeleteOnClose);
    QAction* a;

    /* KDE menu *******

      + To &Desktop >
      +     &All Desktops
      +     ---
      +     &1 Desktop 1
      +     &2 Desktop 2
      + &To Current Desktop
        &Move
        Re&size
      + Mi&nimize
      + Ma&ximize
      + &Shade
        Ad&vanced >
            Keep &Above Others
            Keep &Below Others
            Fill screen
        &Layer >
            Always on &top
            &Normal
            Always on &bottom
      ---
      + &Close
    */

    /********** Desktop menu **********/
    int deskNum = KWindowSystem::numberOfDesktops();
    if (deskNum > 1)
    {
        int winDesk = KWindowInfo(mWindow, NET::WMDesktop).desktop();
        QMenu* deskMenu = menu->addMenu(tr("To &Desktop"));

        a = deskMenu->addAction(tr("&All Desktops"));
        a->setData(NET::OnAllDesktops);
        a->setEnabled(winDesk != NET::OnAllDesktops);
        connect(a, SIGNAL(triggered(bool)), this, SLOT(moveApplicationToDesktop()));
        deskMenu->addSeparator();

        for (int i = 0; i < deskNum; ++i)
        {
            a = deskMenu->addAction(tr("Desktop &%1").arg(i + 1));
            a->setData(i + 1);
            a->setEnabled(i + 1 != winDesk);
            connect(a, SIGNAL(triggered(bool)), this, SLOT(moveApplicationToDesktop()));
        }

        int curDesk = KWindowSystem::currentDesktop();
        a = menu->addAction(tr("&To Current Desktop"));
        a->setData(curDesk);
        a->setEnabled(curDesk != winDesk);
        connect(a, SIGNAL(triggered(bool)), this, SLOT(moveApplicationToDesktop()));
    }
开发者ID:jubalh,项目名称:lxqt-panel,代码行数:67,代码来源:lxqttaskbutton.cpp

示例12: contextMenuEvent

void SCgView::contextMenuEvent(QContextMenuEvent *event)
{
    if (event->reason() == QContextMenuEvent::Keyboard || event->reason() == QContextMenuEvent::Other)
        return;
    // get scg-object under mouse
    QPointF mousePos = mapToScene(event->pos());/* +
                                QPointF(horizontalScrollBar()->value(), verticalScrollBar()->value()) -
                                scene()->sceneRect().topLeft();*/

    SCgObject *object = static_cast<SCgScene*>(scene())->objectAt(mousePos);

    // create context menu
    if (mContextMenu)
    {
        delete mContextMenu;
        mContextMenu = 0;
    }

    // selection by right mouse click
    if(object && !object->isSelected())
    {
        scene()->clearSelection();
        object->setSelected(true);
    }

    // create new context menu
    mContextMenu = new QMenu;

    if (mContextObject)
    {
        // creating menu actions depending on object type
        if (mContextObject->type() == SCgNode::Type || mContextObject->type() == SCgPair::Type)
        {
            // type changing
            QMenu *menu = mContextMenu->addMenu(tr("Change type"));

            connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(changeType(QAction*)));

            QMenu* constSub = menu->addMenu(tr("Const"));
            QMenu* varSub = menu->addMenu(tr("Var"));

            QString stype;
            SCgAlphabet::SCgObjectTypesMap types;
            SCgAlphabet::SCgObjectTypesMap::const_iterator iter;

            if (mContextObject->type() == SCgNode::Type)
                stype = "node";
            else if (mContextObject->type() == SCgPair::Type)
                stype = "pair";

            SCgAlphabet::getInstance().getObjectTypes(stype, SCgAlphabet::Const, types);
            for (iter = types.begin(); iter != types.end(); ++iter)
                constSub->addAction(iter.value(), iter.key())->setData(QVariant(iter.key()));
            types.clear();
            SCgAlphabet::getInstance().getObjectTypes(stype, SCgAlphabet::Var, types);
            for (iter = types.begin(); iter != types.end(); ++iter)
                varSub->addAction(iter.value(), iter.key())->setData(QVariant(iter.key()));
            types.clear();

            SCgAlphabet::getInstance().getObjectTypes(stype, SCgAlphabet::ConstUnknown, types);
            for (iter = types.begin(); iter != types.end(); ++iter)
                menu->addAction(iter.value(), iter.key())->setData(QVariant(iter.key()));
            types.clear();
        }
    }
开发者ID:YuryMyshkevich,项目名称:kbe,代码行数:65,代码来源:scgview.cpp

示例13: createMenus

//! [8]
void MainWindow::createMenus()
{
    QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
    fileMenu->addAction(tr("&Open..."), this, &MainWindow::load, QKeySequence::Open);
    fileMenu->addAction(tr("&Save As..."), this, &MainWindow::save, QKeySequence::SaveAs);
    fileMenu->addAction(tr("E&xit"), this, &MainWindow::close, QKeySequence::Quit);

    QMenu *brushMenu = menuBar()->addMenu(tr("&Brush"));
    brushMenu->addAction(tr("&Brush Color..."), this, &MainWindow::setBrushColor, tr("Ctrl+B"));
//! [8]

    QMenu *tabletMenu = menuBar()->addMenu(tr("&Tablet"));
    QMenu *lineWidthMenu = tabletMenu->addMenu(tr("&Line Width"));

    QAction *lineWidthPressureAction = lineWidthMenu->addAction(tr("&Pressure"));
    lineWidthPressureAction->setData(TabletCanvas::PressureValuator);
    lineWidthPressureAction->setCheckable(true);
    lineWidthPressureAction->setChecked(true);

    QAction *lineWidthTiltAction = lineWidthMenu->addAction(tr("&Tilt"));
    lineWidthTiltAction->setData(TabletCanvas::TiltValuator);
    lineWidthTiltAction->setCheckable(true);

    QAction *lineWidthFixedAction = lineWidthMenu->addAction(tr("&Fixed"));
    lineWidthFixedAction->setData(TabletCanvas::NoValuator);
    lineWidthFixedAction->setCheckable(true);

    QActionGroup *lineWidthGroup = new QActionGroup(this);
    lineWidthGroup->addAction(lineWidthPressureAction);
    lineWidthGroup->addAction(lineWidthTiltAction);
    lineWidthGroup->addAction(lineWidthFixedAction);
    connect(lineWidthGroup, &QActionGroup::triggered, this,
            &MainWindow::setLineWidthValuator);

//! [9]
    QMenu *alphaChannelMenu = tabletMenu->addMenu(tr("&Alpha Channel"));
    QAction *alphaChannelPressureAction = alphaChannelMenu->addAction(tr("&Pressure"));
    alphaChannelPressureAction->setData(TabletCanvas::PressureValuator);
    alphaChannelPressureAction->setCheckable(true);

    QAction *alphaChannelTangentialPressureAction = alphaChannelMenu->addAction(tr("T&angential Pressure"));
    alphaChannelTangentialPressureAction->setData(TabletCanvas::TangentialPressureValuator);
    alphaChannelTangentialPressureAction->setCheckable(true);
    alphaChannelTangentialPressureAction->setChecked(true);

    QAction *alphaChannelTiltAction = alphaChannelMenu->addAction(tr("&Tilt"));
    alphaChannelTiltAction->setData(TabletCanvas::TiltValuator);
    alphaChannelTiltAction->setCheckable(true);

    QAction *noAlphaChannelAction = alphaChannelMenu->addAction(tr("No Alpha Channel"));
    noAlphaChannelAction->setData(TabletCanvas::NoValuator);
    noAlphaChannelAction->setCheckable(true);

    QActionGroup *alphaChannelGroup = new QActionGroup(this);
    alphaChannelGroup->addAction(alphaChannelPressureAction);
    alphaChannelGroup->addAction(alphaChannelTangentialPressureAction);
    alphaChannelGroup->addAction(alphaChannelTiltAction);
    alphaChannelGroup->addAction(noAlphaChannelAction);
    connect(alphaChannelGroup, &QActionGroup::triggered,
            this, &MainWindow::setAlphaValuator);
//! [9]

    QMenu *colorSaturationMenu = tabletMenu->addMenu(tr("&Color Saturation"));

    QAction *colorSaturationVTiltAction = colorSaturationMenu->addAction(tr("&Vertical Tilt"));
    colorSaturationVTiltAction->setData(TabletCanvas::VTiltValuator);
    colorSaturationVTiltAction->setCheckable(true);

    QAction *colorSaturationHTiltAction = colorSaturationMenu->addAction(tr("&Horizontal Tilt"));
    colorSaturationHTiltAction->setData(TabletCanvas::HTiltValuator);
    colorSaturationHTiltAction->setCheckable(true);

    QAction *colorSaturationPressureAction = colorSaturationMenu->addAction(tr("&Pressure"));
    colorSaturationPressureAction->setData(TabletCanvas::PressureValuator);
    colorSaturationPressureAction->setCheckable(true);

    QAction *noColorSaturationAction = colorSaturationMenu->addAction(tr("&No Color Saturation"));
    noColorSaturationAction->setData(TabletCanvas::NoValuator);
    noColorSaturationAction->setCheckable(true);
    noColorSaturationAction->setChecked(true);

    QActionGroup *colorSaturationGroup = new QActionGroup(this);
    colorSaturationGroup->addAction(colorSaturationVTiltAction);
    colorSaturationGroup->addAction(colorSaturationHTiltAction);
    colorSaturationGroup->addAction(colorSaturationPressureAction);
    colorSaturationGroup->addAction(noColorSaturationAction);
    connect(colorSaturationGroup, &QActionGroup::triggered,
            this, &MainWindow::setSaturationValuator);

    QMenu *helpMenu = menuBar()->addMenu("&Help");
    helpMenu->addAction(tr("A&bout"), this, &MainWindow::about);
    helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:94,代码来源:mainwindow.cpp

示例14: buildMenuBar

void MainWindow::buildMenuBar()
{
    QMenu * fileMenu = menuBar()->addMenu("File");
    QAction * newAction = new QAction(QIcon("Icons/New.png"), "New", this);
    connect(newAction, SIGNAL(triggered()), m_system, SLOT(newSystem()));
    QAction * openAction = new QAction(QIcon("Icons/Open.png"), "Open", this);
    connect(openAction, SIGNAL(triggered()), m_system, SLOT(openSystem()));
    QAction * saveAction = new QAction(QIcon("Icons/Save.png"), "Save", this);
    connect(saveAction, SIGNAL(triggered()), m_system, SLOT(saveSystem()));
    QAction * saveAsAction = new QAction(QIcon("Icons/SaveAs.png"), "Save As...", this);
    connect(saveAsAction, SIGNAL(triggered()), m_system, SLOT(saveSystemAs()));
    fileMenu->addAction(newAction);
    fileMenu->addAction(openAction);
    fileMenu->addAction(saveAction);
    fileMenu->addAction(saveAsAction);

    QMenu * deviceMenu = menuBar()->addMenu("Device");
    QAction * addPlaneMirrorAction = new QAction(QIcon("Icons/PlaneMirror.png"), "Add Plane Mirror", this);
    connect(addPlaneMirrorAction, SIGNAL(triggered()), m_system, SLOT(addPlaneMirror()));
    QAction * addConcaveMirrorAction = new QAction(QIcon("Icons/ConcaveMirror.png"), "Add Concave Mirror", this);
    connect(addConcaveMirrorAction, SIGNAL(triggered()), m_system, SLOT(addConcaveMirror()));
    QAction * addDiffractionGratingAction = new QAction(QIcon("Icons/DiffractionGrating.png"), "Add Diffraction Grating", this);
    connect(addDiffractionGratingAction, SIGNAL(triggered()), m_system, SLOT(addDiffractionGrating()));
    QAction * addSlitAction = new QAction(QIcon("Icons/Slit.png"), "Add Slit", this);
    connect(addSlitAction, SIGNAL(triggered()), m_system, SLOT(addSlit()));
    QAction * addPointSourceAction = new QAction(QIcon("Icons/PointSource.png"), "Add Point Source", this);
    connect(addPointSourceAction, SIGNAL(triggered()), m_system, SLOT(addPointSource()));
    QAction * removeReflectorAction = new QAction(QIcon("Icons/RemoveReflector.png"), "Remove Reflector", this);
    connect(removeReflectorAction, SIGNAL(triggered()), m_system, SLOT(removeReflector()));
    QAction * removeLightSourceAction = new QAction(QIcon("Icons/RemoveLightSource.png"), "Remove Light Source", this);
    connect(removeLightSourceAction, SIGNAL(triggered()), m_system, SLOT(removeLightSource()));
    deviceMenu->addAction(addPlaneMirrorAction);
    deviceMenu->addAction(addConcaveMirrorAction);
    deviceMenu->addAction(addDiffractionGratingAction);
    deviceMenu->addAction(addSlitAction);
    deviceMenu->addSeparator();
    deviceMenu->addAction(addPointSourceAction);
    deviceMenu->addSeparator();
    deviceMenu->addAction(removeReflectorAction);
    deviceMenu->addAction(removeLightSourceAction);

    QMenu * viewMenu = menuBar()->addMenu("View");
    QMenu * toolbarsMenu = new QMenu("Toolbars", this);
    QAction * fileAction = new QAction("File", this);
    fileAction->setCheckable(true);
    fileAction->setChecked(true);
    connect(fileAction, SIGNAL(triggered(bool)), this, SLOT(toggleFileToolBar(bool)));
    connect(m_fileToolBar, SIGNAL(visibilityChanged(bool)), fileAction, SLOT(setChecked(bool)));
    QAction * deviceAction = new QAction("Device", this);
    deviceAction->setCheckable(true);
    deviceAction->setChecked(true);
    connect(deviceAction, SIGNAL(triggered(bool)), this, SLOT(toggleDeviceToolBar(bool)));
    connect(m_deviceToolBar, SIGNAL(visibilityChanged(bool)), deviceAction, SLOT(setChecked(bool)));
    QAction * zoomAction = new QAction("Zoom", this);
    zoomAction->setCheckable(true);
    zoomAction->setChecked(true);
    connect(zoomAction, SIGNAL(triggered(bool)), this, SLOT(toggleZoomToolBar(bool)));
    connect(m_zoomToolBar, SIGNAL(visibilityChanged(bool)), zoomAction, SLOT(setChecked(bool)));
    QAction * reflectorsAction = new QAction("Reflectors", this);
    reflectorsAction->setCheckable(true);
    reflectorsAction->setChecked(true);
    connect(reflectorsAction, SIGNAL(triggered(bool)), this, SLOT(toggleReflectorsDockWidget(bool)));
    connect(m_reflectorsDockWidget, SIGNAL(visibilityChanged(bool)), reflectorsAction, SLOT(setChecked(bool)));
    QAction * lightSourcesAction = new QAction("Light Sources", this);
    lightSourcesAction->setCheckable(true);
    lightSourcesAction->setChecked(true);
    connect(lightSourcesAction, SIGNAL(triggered(bool)), this, SLOT(toggleLightSourcesDockWidget(bool)));
    connect(m_lightSourcesDockWidget, SIGNAL(visibilityChanged(bool)), lightSourcesAction, SLOT(setChecked(bool)));
    QAction * optionsAction = new QAction("Options...", this);
    connect(optionsAction, SIGNAL(triggered()), m_system, SLOT(options()));
    toolbarsMenu->addAction(fileAction);
    toolbarsMenu->addAction(deviceAction);
    toolbarsMenu->addAction(zoomAction);
    viewMenu->addMenu(toolbarsMenu);
    viewMenu->addSeparator();
    viewMenu->addAction(reflectorsAction);
    viewMenu->addAction(lightSourcesAction);
    viewMenu->addSeparator();
    viewMenu->addAction(optionsAction);
}
开发者ID:TKaczorek,项目名称:OpticalSimulator,代码行数:80,代码来源:mainwindow.cpp

示例15: createMenu

QMenu* VCWidget::createMenu()
{
	QAction* action;

	// Create edit menu here so that all submenus can be its children
	/* DO NOT set this as the menu's parent object. Otherwise deleting this
	   thru the menu will crash the whole program. */
	QMenu* editMenu = new QMenu(NULL);
	action = editMenu->addAction(QIcon(":/editcut.png"), "Cut",
				     this, SLOT(slotCut()));
	action->setEnabled(false);
	action = editMenu->addAction(QIcon(":/editcopy.png"), "Copy",
				     this, SLOT(slotCopy()));
	action->setEnabled(false);
	action = editMenu->addAction(QIcon(":/editpaste.png"), "Paste",
				     this, SLOT(slotPaste()));
	action->setEnabled(false);
	editMenu->addAction(QIcon(":/editdelete.png"), "Delete",
			    this, SLOT(slotDelete()));
	editMenu->addSeparator();
	editMenu->addAction(QIcon(":/configure.png"), "Properties...",
			    this, SLOT(slotProperties()));
	editMenu->addAction(QIcon(":/editclear.png"), "Rename...",
			    this, SLOT(slotRename()));
	editMenu->addSeparator();

	// Background menu
	QMenu* bgMenu = new QMenu(editMenu);
	bgMenu->setTitle("Background");
	bgMenu->addAction(QIcon(":/color.png"), "Color...",
			  this, SLOT(slotChooseBackgroundColor()));
	bgMenu->addAction(QIcon(":/image.png"), "Image...",
			  this, SLOT(slotChooseBackgroundImage()));
	bgMenu->addAction(QIcon(":/undo.png"), "Default",
			  this, SLOT(slotResetBackgroundColor()));

	// Foreground menu
	QMenu* fgMenu = new QMenu(editMenu);
	fgMenu->setTitle("Foreground");
	fgMenu->addAction(QIcon(":/color.png"), "Color...",
			  this, SLOT(slotChooseForegroundColor()));
	fgMenu->addAction(QIcon(":/undo.png"), "Default",
			  this, SLOT(slotResetForegroundColor()));

	// Font menu
	QMenu* fontMenu = new QMenu(editMenu);
	fontMenu->setTitle("Font");
	fontMenu->addAction(QIcon(":/fonts.png"), "Font...",
			   this, SLOT(slotChooseFont()));
	fontMenu->addAction(QIcon(":/undo.png"), "Default",
			    this, SLOT(slotResetFont()));

	// Frame menu
	QMenu* frameMenu = new QMenu(editMenu);
	frameMenu->setTitle("Frame");
	frameMenu->addAction(QIcon(":/framesunken.png"), "Sunken",
			     this, SLOT(slotSetFrameSunken()));
	frameMenu->addAction(QIcon(":/frameraised.png"), "Raised",
			     this, SLOT(slotSetFrameRaised()));
	frameMenu->addAction(QIcon(":/framenone.png"), "None",
			     this, SLOT(slotResetFrame()));

	// Stacking order menu
	QMenu* stackMenu = new QMenu(editMenu);
	stackMenu->setTitle("Stacking order");
	stackMenu->addAction(QIcon(":/up.png"), "Raise",
			     this, SLOT(raise()));
	stackMenu->addAction(QIcon(":/down.png"), "Lower",
			     this, SLOT(lower()));

	// Menu construction
	editMenu->addMenu(bgMenu);
	editMenu->addMenu(fgMenu);
	editMenu->addMenu(fontMenu);
	editMenu->addMenu(frameMenu);
	editMenu->addMenu(stackMenu);

	return editMenu;
}
开发者ID:speakman,项目名称:qlc,代码行数:79,代码来源:vcwidget.cpp


注:本文中的QMenu::addMenu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。