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()); }
// 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); }
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; }
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)); }
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(); menu->addMenu(toolMenu); } k->position = viewPosition(); k->menuOn = true; menu->exec(event->globalPos()); } }
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(); // attribute table menu->addAction( QgsApplication::getThemeIcon( "/mActionOpenTable.png" ), tr( "&Open Attribute Table" ), QgisApp::instance(), SLOT( attributeTable() ) ); // allow editing int cap = vlayer->dataProvider()->capabilities(); if ( cap & QgsVectorDataProvider::EditingCapabilities ) { if ( toggleEditingAction ) { menu->addAction( toggleEditingAction ); toggleEditingAction->setChecked( vlayer->isEditable() ); } if ( saveLayerEditsAction && vlayer->isModified() ) { menu->addAction( saveLayerEditsAction ); } } if ( allEditsAction->isEnabled() ) menu->addAction( allEditsAction ); // disable duplication of memory layers if ( vlayer->storageType() == "Memory storage" && mView->selectedLayerNodes().count() == 1 ) duplicateLayersAction->setEnabled( false ); // save as vector file menu->addAction( tr( "Save As..." ), QgisApp::instance(), SLOT( saveAsFile() ) ); menu->addAction( tr( "Save As Layer Definition File..." ), QgisApp::instance(), SLOT( saveAsLayerDefinition() ) ); if ( vlayer->dataProvider()->supportsSubsetString() ) { QAction *action = menu->addAction( tr( "&Filter..." ), QgisApp::instance(), SLOT( layerSubsetString() ) ); action->setEnabled( !vlayer->isEditable() ); } menu->addAction( actions->actionShowFeatureCount( menu ) ); menu->addSeparator(); } else if ( rlayer ) { menu->addAction( tr( "Save As..." ), QgisApp::instance(), SLOT( saveAsRasterFile() ) ); menu->addAction( tr( "Save As Layer Definition File..." ), QgisApp::instance(), SLOT( saveAsLayerDefinition() ) ); } else if ( layer && layer->type() == QgsMapLayer::PluginLayer && mView->selectedLayerNodes().count() == 1 ) { // disable duplication of plugin layers duplicateLayersAction->setEnabled( false ); } addCustomLayerActions( menu, layer ); if ( layer && QgsProject::instance()->layerIsEmbedded( layer->id() ).isEmpty() ) menu->addAction( tr( "&Properties" ), QgisApp::instance(), SLOT( layerProperties() ) ); if ( node->parent() != mView->layerTreeModel()->rootGroup() ) menu->addAction( actions->actionMakeTopLevel( menu ) ); menu->addAction( actions->actionRenameGroupOrLayer( menu ) ); if ( mView->selectedNodes( true ).count() >= 2 ) menu->addAction( actions->actionGroupSelected( menu ) ); } } else { // symbology item? } return menu; }
void GameList::ShowContextMenu(const QPoint&) { if (!GetSelectedGame()) return; QMenu* menu = new QMenu(this); if (HasMultipleSelected()) { bool wii_saves = true; bool compress = false; bool decompress = false; for (const auto& game : GetSelectedGames()) { DiscIO::Platform platform = game->GetPlatform(); if (platform == DiscIO::Platform::GameCubeDisc || platform == DiscIO::Platform::WiiDisc) { const auto blob_type = game->GetBlobType(); if (blob_type == DiscIO::BlobType::GCZ) decompress = true; else if (blob_type == DiscIO::BlobType::PLAIN) compress = true; } if (platform != DiscIO::Platform::WiiWAD && platform != DiscIO::Platform::WiiDisc) wii_saves = false; } if (compress) menu->addAction(tr("Compress Selected ISOs..."), this, [this] { CompressISO(false); }); if (decompress) menu->addAction(tr("Decompress Selected ISOs..."), this, [this] { CompressISO(true); }); if (compress || decompress) menu->addSeparator(); if (wii_saves) { menu->addAction(tr("Export Wii Saves (Experimental)"), this, &GameList::ExportWiiSave); menu->addSeparator(); } menu->addAction(tr("Delete Selected Files..."), this, &GameList::DeleteFile); } else { const auto game = GetSelectedGame(); DiscIO::Platform platform = game->GetPlatform(); if (platform != DiscIO::Platform::ELFOrDOL) { menu->addAction(tr("&Properties"), this, &GameList::OpenProperties); menu->addAction(tr("&Wiki"), this, &GameList::OpenWiki); menu->addSeparator(); } if (platform == DiscIO::Platform::GameCubeDisc || platform == DiscIO::Platform::WiiDisc) { menu->addAction(tr("Set as &Default ISO"), this, &GameList::SetDefaultISO); const auto blob_type = game->GetBlobType(); if (blob_type == DiscIO::BlobType::GCZ) menu->addAction(tr("Decompress ISO..."), this, [this] { CompressISO(true); }); else if (blob_type == DiscIO::BlobType::PLAIN) menu->addAction(tr("Compress ISO..."), this, [this] { CompressISO(false); }); QAction* change_disc = menu->addAction(tr("Change &Disc"), this, &GameList::ChangeDisc); connect(&Settings::Instance(), &Settings::EmulationStateChanged, change_disc, [change_disc] { change_disc->setEnabled(Core::IsRunning()); }); change_disc->setEnabled(Core::IsRunning()); 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()); }
/****** 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 connect(quit, SIGNAL(triggered()), this, SLOT(quit())); connect(open, SIGNAL(triggered()), this, SLOT(open_file())); connect(pause, SIGNAL(triggered()), this, SLOT(pause())); connect(fullscreen, SIGNAL(triggered()), this, SLOT(fullscreen())); connect(screenshot, SIGNAL(triggered()), this, SLOT(screenshot())); connect(nplay_start, SIGNAL(triggered()), this, SLOT(start_netplay())); connect(nplay_stop, SIGNAL(triggered()), this, SLOT(stop_netplay())); connect(reset, SIGNAL(triggered()), this, SLOT(reset())); connect(general, SIGNAL(triggered()), this, SLOT(show_settings())); connect(display, SIGNAL(triggered()), this, SLOT(show_display_settings())); connect(sound, SIGNAL(triggered()), this, SLOT(show_sound_settings())); connect(controls, SIGNAL(triggered()), this, SLOT(show_control_settings())); connect(netplay, SIGNAL(triggered()), this, SLOT(show_netplay_settings())); connect(paths, SIGNAL(triggered()), this, SLOT(show_paths_settings())); connect(custom_gfx, SIGNAL(triggered()), this, SLOT(show_cgfx())); connect(debugging, SIGNAL(triggered()), this, SLOT(show_debugger())); connect(about, SIGNAL(triggered()), this, SLOT(show_about())); sw_screen = new soft_screen(); hw_screen = new hard_screen(); QVBoxLayout* layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, -1); layout->addWidget(sw_screen); layout->addWidget(hw_screen); layout->setMenuBar(menu_bar); setLayout(layout); config::scaling_factor = 2; hw_screen->hide(); hw_screen->setEnabled(false); //Parse .ini options parse_ini_file(); //Parse cheats file if(config::use_cheats) { parse_cheats_file(); } //Parse command-line arguments //These will override .ini options! if(!parse_cli_args()) { exit(0); } //Some command-line arguments are invalid for the Qt version config::use_debugger = false; //Setup Recent Files list_mapper = new QSignalMapper(this); for(int x = (config::recent_files.size() - 1); x >= 0; x--) { QString path = QString::fromStdString(config::recent_files[x]); QFileInfo file(path); path = file.fileName(); QAction* temp = new QAction(path, this); recent_list->addAction(temp); connect(temp, SIGNAL(triggered()), list_mapper, SLOT(map())); list_mapper->setMapping(temp, x); } connect(list_mapper, SIGNAL(mapped(int)), this, SLOT(load_recent(int))); //Setup Save States QSignalMapper* save_mapper = new QSignalMapper(this); for(int x = 0; x < 10; x++) { QAction* temp; if(x == 0) { temp = new QAction(tr("Quick Save"), this); temp->setShortcut(tr("F1")); } else { std::string slot_id = "Slot " + util::to_str(x); QString slot_name = QString::fromStdString(slot_id); temp = new QAction(slot_name, this); } state_save_list->addAction(temp); connect(temp, SIGNAL(triggered()), save_mapper, SLOT(map())); save_mapper->setMapping(temp, x); } connect(save_mapper, SIGNAL(mapped(int)), this, SLOT(save_state(int))); //Setup Load States QSignalMapper* load_mapper = new QSignalMapper(this); for(int x = 0; x < 10; x++) { QAction* temp; if(x == 0) { temp = new QAction(tr("Quick Load"), this); temp->setShortcut(tr("F2")); } else { std::string slot_id = "Slot " + util::to_str(x); QString slot_name = QString::fromStdString(slot_id); temp = new QAction(slot_name, this); } state_load_list->addAction(temp); connect(temp, SIGNAL(triggered()), load_mapper, SLOT(map())); load_mapper->setMapping(temp, x); } connect(load_mapper, SIGNAL(mapped(int)), this, SLOT(load_state(int))); //Set up settings dialog settings = new gen_settings(); settings->set_ini_options(); //Set up custom graphics dialog cgfx = new gbe_cgfx(); cgfx->hide(); cgfx->advanced->setChecked(true); //Set up DMG-GBC debugger main_menu::dmg_debugger = new dmg_debug(); main_menu::dmg_debugger->hide(); //Setup About pop-up about_box = new QWidget(); about_box->resize(300, 250); about_box->setWindowTitle("About GBE+"); QDialogButtonBox* about_button = new QDialogButtonBox(QDialogButtonBox::Close); connect(about_button->button(QDialogButtonBox::Close), SIGNAL(clicked()), about_box, SLOT(close())); QLabel* emu_title = new QLabel("GBE+ 1.0"); QFont font = emu_title->font(); font.setPointSize(18); font.setBold(true); emu_title->setFont(font); QImage logo(QString::fromStdString(config::cfg_path + "data/icons/gbe_plus.png")); logo = logo.scaled(128, 128); QLabel* emu_desc = new QLabel("A GB/GBC/GBA emulator with enhancements"); QLabel* emu_copyright = new QLabel("Copyright D.S. Baxter 2014-2016"); QLabel* emu_proj_copyright = new QLabel("Copyright GBE+ Team 2014-2016"); QLabel* emu_license = new QLabel("This program is licensed under the GNU GPLv2"); QLabel* emu_site = new QLabel("<a href=\"https://github.com/shonumi/gbe-plus/\">GBE+ on GitHub</a>"); emu_site->setOpenExternalLinks(true); QLabel* emu_logo = new QLabel; emu_logo->setPixmap(QPixmap::fromImage(logo)); QVBoxLayout* about_layout = new QVBoxLayout; about_layout->addWidget(emu_title, 0, Qt::AlignCenter | Qt::AlignTop); about_layout->addWidget(emu_desc, 0, Qt::AlignCenter | Qt::AlignTop); about_layout->addWidget(emu_copyright, 0, Qt::AlignCenter | Qt::AlignTop); about_layout->addWidget(emu_proj_copyright, 0, Qt::AlignCenter | Qt::AlignTop); about_layout->addWidget(emu_license, 0, Qt::AlignCenter | Qt::AlignTop); about_layout->addWidget(emu_site, 0, Qt::AlignCenter | Qt::AlignTop); about_layout->addWidget(emu_logo, 0, Qt::AlignCenter | Qt::AlignTop); about_layout->addWidget(about_button); about_box->setLayout(about_layout); about_box->setWindowIcon(QIcon(QString::fromStdString(config::cfg_path + "data/icons/gbe_plus.png"))); about_box->hide(); //Setup warning message box warning_box = new QMessageBox; QPushButton* warning_box_ok = warning_box->addButton("OK", QMessageBox::AcceptRole); warning_box->setIcon(QMessageBox::Warning); warning_box->hide(); display_width = QApplication::desktop()->screenGeometry().width(); display_height = QApplication::desktop()->screenGeometry().height(); fullscreen_mode = false; }
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(); }
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; }
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())); }
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(); } }
//! [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); }
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); }
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; }
void EffectsListWidget::initList(QMenu *effectsMenu, KActionCategory *effectActions, QString categoryFile, bool transitionMode) { QString current; QString currentFolder; bool found = false; effectsMenu->clear(); if (currentItem()) { current = currentItem()->text(0); if (currentItem()->parent()) currentFolder = currentItem()->parent()->text(0); else if (currentItem()->data(0, TypeRole) == EffectsList::EFFECT_FOLDER) currentFolder = currentItem()->text(0); } QTreeWidgetItem *misc = NULL; QTreeWidgetItem *audio = NULL; QTreeWidgetItem *custom = NULL; QList <QTreeWidgetItem *> folders; if (!categoryFile.isEmpty()) { QDomDocument doc; QFile file(categoryFile); doc.setContent(&file, false); file.close(); QStringList folderNames; QDomNodeList groups = doc.documentElement().elementsByTagName(QStringLiteral("group")); for (int i = 0; i < groups.count(); ++i) { folderNames << i18n(groups.at(i).firstChild().firstChild().nodeValue().toUtf8().constData()); } for (int i = 0; i < topLevelItemCount(); ++i) { topLevelItem(i)->takeChildren(); QString currentName = topLevelItem(i)->text(0); if (currentName != i18n("Misc") && currentName != i18n("Audio") && currentName != i18nc("Folder Name", "Custom") && !folderNames.contains(currentName)) { takeTopLevelItem(i); --i; } } for (int i = 0; i < groups.count(); ++i) { QTreeWidgetItem *item = findFolder(folderNames.at(i)); if (item) { item->setData(0, IdRole, groups.at(i).toElement().attribute(QStringLiteral("list"))); } else { item = new QTreeWidgetItem((QTreeWidget*)0, QStringList(folderNames.at(i))); item->setData(0, TypeRole, QString::number((int) EffectsList::EFFECT_FOLDER)); item->setData(0, IdRole, groups.at(i).toElement().attribute(QStringLiteral("list"))); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); insertTopLevelItem(0, item); } folders.append(item); } misc = findFolder(i18n("Misc")); if (misc == NULL) { misc = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18n("Misc"))); misc->setData(0, TypeRole, QString::number((int) EffectsList::EFFECT_FOLDER)); misc->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); insertTopLevelItem(0, misc); } audio = findFolder(i18n("Audio")); if (audio == NULL) { audio = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18n("Audio"))); audio->setData(0, TypeRole, QString::number((int) EffectsList::EFFECT_FOLDER)); audio->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); insertTopLevelItem(0, audio); } custom = findFolder(i18nc("Folder Name", "Custom")); if (custom == NULL) { custom = new QTreeWidgetItem((QTreeWidget*)0, QStringList(i18nc("Folder Name", "Custom"))); custom->setData(0, TypeRole, QString::number((int) EffectsList::EFFECT_FOLDER)); custom->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); insertTopLevelItem(0, custom); } } //insertTopLevelItems(0, folders); if (transitionMode) { loadEffects(&MainWindow::transitions, misc, &folders, EffectsList::TRANSITION_TYPE, current, &found); } else { loadEffects(&MainWindow::videoEffects, misc, &folders, EffectsList::EFFECT_VIDEO, current, &found); loadEffects(&MainWindow::audioEffects, audio, &folders, EffectsList::EFFECT_AUDIO, current, &found); loadEffects(&MainWindow::customEffects, custom, static_cast<QList<QTreeWidgetItem *> *>(0), EffectsList::EFFECT_CUSTOM, current, &found); if (!found && !currentFolder.isEmpty()) { // previously selected effect was removed, focus on its parent folder for (int i = 0; i < topLevelItemCount(); ++i) { if (topLevelItem(i)->text(0) == currentFolder) { setCurrentItem(topLevelItem(i)); break; } } } } setSortingEnabled(true); sortByColumn(0, Qt::AscendingOrder); // populate effects menu QMenu *sub1 = NULL; QMenu *sub2 = NULL; QMenu *sub3 = NULL; QMenu *sub4 = NULL; for (int i = 0; i < topLevelItemCount(); ++i) { if (topLevelItem(i)->data(0, TypeRole) == EffectsList::TRANSITION_TYPE) { QTreeWidgetItem *item = topLevelItem(i); QAction *a = new QAction(item->icon(0), item->text(0), effectsMenu); QStringList data = item->data(0, IdRole).toStringList(); QString id = data.at(1); if (id.isEmpty()) id = data.at(0); a->setData(data); a->setIconVisibleInMenu(false); effectsMenu->addAction(a); effectActions->addAction("transition_" + id, a); continue; } if (!topLevelItem(i)->childCount()) continue; QMenu *sub = new QMenu(topLevelItem(i)->text(0), effectsMenu); effectsMenu->addMenu(sub); int effectsInCategory = topLevelItem(i)->childCount(); bool hasSubCategories = false; if (effectsInCategory > 60) { // create subcategories if there are too many effects hasSubCategories = true; sub1 = new QMenu(i18nc("menu name for effects names between these 2 letters", "0 - F"), sub); sub->addMenu(sub1); sub2 = new QMenu(i18nc("menu name for effects names between these 2 letters", "G - L"), sub); sub->addMenu(sub2); sub3 = new QMenu(i18nc("menu name for effects names between these 2 letters", "M - R"), sub); sub->addMenu(sub3); sub4 = new QMenu(i18nc("menu name for effects names between these 2 letters", "S - Z"), sub); sub->addMenu(sub4); } for (int j = 0; j < effectsInCategory; ++j) { QTreeWidgetItem *item = topLevelItem(i)->child(j); QAction *a = new QAction(item->icon(0), item->text(0), sub); QStringList data = item->data(0, IdRole).toStringList(); QString id = data.at(1); if (id.isEmpty()) id = data.at(0); a->setData(data); a->setIconVisibleInMenu(false); if (hasSubCategories) { // put action in sub category QRegExp rx("^[s-z].+"); if (rx.exactMatch(item->text(0).toLower())) { sub4->addAction(a); } else { rx.setPattern(QStringLiteral("^[m-r].+")); if (rx.exactMatch(item->text(0).toLower())) { sub3->addAction(a); } else { rx.setPattern(QStringLiteral("^[g-l].+")); if (rx.exactMatch(item->text(0).toLower())) { sub2->addAction(a); } else sub1->addAction(a); } } } else sub->addAction(a); effectActions->addAction("video_effect_" + id, a); } } }
PointViewerMainWindow::PointViewerMainWindow(const QGLFormat& format) : m_progressBar(0), m_pointView(0), m_shaderEditor(0), m_helpDialog(0), m_logTextView(0), m_maxPointCount(200*1000*1000), // 200 million m_geometries(0), m_ipcServer(0), m_hookManager(0) { setWindowTitle("Displaz"); setAcceptDrops(true); m_helpDialog = new HelpDialog(this); m_geometries = new GeometryCollection(this); connect(m_geometries, SIGNAL(layoutChanged()), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(updateTitle())); //-------------------------------------------------- // Set up file loader in a separate thread // // Some subtleties regarding qt thread usage are discussed here: // http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation // // Main point: each QObject has a thread affinity which determines which // thread its slots will execute on, when called via a connected signal. QThread* loaderThread = new QThread(); m_fileLoader = new FileLoader(m_maxPointCount); m_fileLoader->moveToThread(loaderThread); connect(loaderThread, SIGNAL(finished()), m_fileLoader, SLOT(deleteLater())); connect(loaderThread, SIGNAL(finished()), loaderThread, SLOT(deleteLater())); //connect(m_fileLoader, SIGNAL(finished()), this, SIGNAL(fileLoadFinished())); connect(m_fileLoader, SIGNAL(geometryLoaded(std::shared_ptr<Geometry>, bool, bool)), m_geometries, SLOT(addGeometry(std::shared_ptr<Geometry>, bool, bool))); loaderThread->start(); //-------------------------------------------------- // Menus menuBar()->setNativeMenuBar(false); // OS X doesn't activate the native menu bar under Qt5 // File menu QMenu* fileMenu = menuBar()->addMenu(tr("&File")); QAction* openAct = fileMenu->addAction(tr("&Open")); openAct->setToolTip(tr("Open a data set")); openAct->setShortcuts(QKeySequence::Open); connect(openAct, SIGNAL(triggered()), this, SLOT(openFiles())); QAction* addAct = fileMenu->addAction(tr("&Add")); addAct->setToolTip(tr("Add a data set")); connect(addAct, SIGNAL(triggered()), this, SLOT(addFiles())); QAction* reloadAct = fileMenu->addAction(tr("&Reload")); reloadAct->setStatusTip(tr("Reload point files from disk")); reloadAct->setShortcut(Qt::Key_F5); connect(reloadAct, SIGNAL(triggered()), this, SLOT(reloadFiles())); fileMenu->addSeparator(); QAction* screenShotAct = fileMenu->addAction(tr("Scree&nshot")); screenShotAct->setStatusTip(tr("Save screen shot of 3D window")); screenShotAct->setShortcut(Qt::Key_F9); connect(screenShotAct, SIGNAL(triggered()), this, SLOT(screenShot())); fileMenu->addSeparator(); QAction* quitAct = fileMenu->addAction(tr("&Quit")); quitAct->setStatusTip(tr("Exit the application")); quitAct->setShortcuts(QKeySequence::Quit); connect(quitAct, SIGNAL(triggered()), this, SLOT(close())); // View menu QMenu* viewMenu = menuBar()->addMenu(tr("&View")); QAction* trackballMode = viewMenu->addAction(tr("Use &Trackball camera")); trackballMode->setCheckable(true); trackballMode->setChecked(false); // Background sub-menu QMenu* backMenu = viewMenu->addMenu(tr("Set &Background")); QSignalMapper* mapper = new QSignalMapper(this); // Selectable backgrounds (svg_names from SVG standard - see QColor docs) const char* backgroundNames[] = {/* "Display Name", "svg_name", */ "Default", "#3C3232", "Black", "black", "Dark Grey", "dimgrey", "Slate Grey", "#858C93", "Light Grey", "lightgrey", "White", "white" }; for(size_t i = 0; i < sizeof(backgroundNames)/sizeof(const char*); i+=2) { QAction* backgroundAct = backMenu->addAction(tr(backgroundNames[i])); QPixmap pixmap(50,50); QString colName = backgroundNames[i+1]; pixmap.fill(QColor(colName)); QIcon icon(pixmap); backgroundAct->setIcon(icon); mapper->setMapping(backgroundAct, colName); connect(backgroundAct, SIGNAL(triggered()), mapper, SLOT(map())); } connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setBackground(QString))); backMenu->addSeparator(); QAction* backgroundCustom = backMenu->addAction(tr("&Custom")); connect(backgroundCustom, SIGNAL(triggered()), this, SLOT(chooseBackground())); // Check boxes for drawing various scene elements by category viewMenu->addSeparator(); QAction* drawBoundingBoxes = viewMenu->addAction(tr("Draw Bounding bo&xes")); drawBoundingBoxes->setCheckable(true); drawBoundingBoxes->setChecked(true); QAction* drawCursor = viewMenu->addAction(tr("Draw 3D &Cursor")); drawCursor->setCheckable(true); drawCursor->setChecked(true); QAction* drawAxes = viewMenu->addAction(tr("Draw &Axes")); drawAxes->setCheckable(true); drawAxes->setChecked(true); QAction* drawGrid = viewMenu->addAction(tr("Draw &Grid")); drawGrid->setCheckable(true); drawGrid->setChecked(false); // Shader menu QMenu* shaderMenu = menuBar()->addMenu(tr("&Shader")); QAction* openShaderAct = shaderMenu->addAction(tr("&Open")); openShaderAct->setToolTip(tr("Open a shader file")); connect(openShaderAct, SIGNAL(triggered()), this, SLOT(openShaderFile())); QAction* editShaderAct = shaderMenu->addAction(tr("&Edit")); editShaderAct->setToolTip(tr("Open shader editor window")); QAction* saveShaderAct = shaderMenu->addAction(tr("&Save")); saveShaderAct->setToolTip(tr("Save current shader file")); connect(saveShaderAct, SIGNAL(triggered()), this, SLOT(saveShaderFile())); shaderMenu->addSeparator(); // Help menu QMenu* helpMenu = menuBar()->addMenu(tr("&Help")); QAction* helpAct = helpMenu->addAction(tr("User &Guide")); connect(helpAct, SIGNAL(triggered()), this, SLOT(helpDialog())); helpMenu->addSeparator(); QAction* aboutAct = helpMenu->addAction(tr("&About")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(aboutDialog())); //-------------------------------------------------- // Point viewer m_pointView = new View3D(m_geometries, format, this); setCentralWidget(m_pointView); connect(drawBoundingBoxes, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawBoundingBoxes())); connect(drawCursor, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawCursor())); connect(drawAxes, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawAxes())); connect(drawGrid, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawGrid())); connect(trackballMode, SIGNAL(triggered()), m_pointView, SLOT(toggleCameraMode())); connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(geometryRowsInserted(QModelIndex,int,int))); //-------------------------------------------------- // Docked widgets // Shader parameters UI QDockWidget* shaderParamsDock = new QDockWidget(tr("Shader Parameters"), this); shaderParamsDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable); QWidget* shaderParamsUI = new QWidget(shaderParamsDock); shaderParamsDock->setWidget(shaderParamsUI); m_pointView->setShaderParamsUIWidget(shaderParamsUI); // Shader editor UI QDockWidget* shaderEditorDock = new QDockWidget(tr("Shader Editor"), this); shaderEditorDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); QWidget* shaderEditorUI = new QWidget(shaderEditorDock); m_shaderEditor = new ShaderEditor(shaderEditorUI); QGridLayout* shaderEditorLayout = new QGridLayout(shaderEditorUI); shaderEditorLayout->setContentsMargins(2,2,2,2); shaderEditorLayout->addWidget(m_shaderEditor, 0, 0, 1, 1); connect(editShaderAct, SIGNAL(triggered()), shaderEditorDock, SLOT(show())); shaderEditorDock->setWidget(shaderEditorUI); shaderMenu->addAction(m_shaderEditor->compileAction()); connect(m_shaderEditor->compileAction(), SIGNAL(triggered()), this, SLOT(compileShaderFile())); // TODO: check if this is needed - test shader update functionality //connect(m_shaderEditor, SIGNAL(sendShader(QString)), // &m_pointView->shaderProgram(), SLOT(setShader(QString))); // Log viewer UI QDockWidget* logDock = new QDockWidget(tr("Log"), this); logDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable); QWidget* logUI = new QWidget(logDock); m_logTextView = new LogViewer(logUI); m_logTextView->setReadOnly(true); m_logTextView->setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse); m_logTextView->connectLogger(&g_logger); // connect to global logger m_progressBar = new QProgressBar(logUI); m_progressBar->setRange(0,100); m_progressBar->setValue(0); m_progressBar->hide(); connect(m_fileLoader, SIGNAL(loadStepStarted(QString)), this, SLOT(setProgressBarText(QString))); connect(m_fileLoader, SIGNAL(loadProgress(int)), m_progressBar, SLOT(setValue(int))); connect(m_fileLoader, SIGNAL(resetProgress()), m_progressBar, SLOT(hide())); QVBoxLayout* logUILayout = new QVBoxLayout(logUI); //logUILayout->setContentsMargins(2,2,2,2); logUILayout->addWidget(m_logTextView); logUILayout->addWidget(m_progressBar); //m_logTextView->setLineWrapMode(QPlainTextEdit::NoWrap); logDock->setWidget(logUI); // Data set list UI QDockWidget* dataSetDock = new QDockWidget(tr("Data Sets"), this); dataSetDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); DataSetUI* dataSetUI = new DataSetUI(this); dataSetDock->setWidget(dataSetUI); QAbstractItemView* dataSetOverview = dataSetUI->view(); dataSetOverview->setModel(m_geometries); connect(dataSetOverview, SIGNAL(doubleClicked(const QModelIndex&)), m_pointView, SLOT(centerOnGeometry(const QModelIndex&))); m_pointView->setSelectionModel(dataSetOverview->selectionModel()); // Set up docked widgets addDockWidget(Qt::RightDockWidgetArea, shaderParamsDock); addDockWidget(Qt::LeftDockWidgetArea, shaderEditorDock); addDockWidget(Qt::RightDockWidgetArea, logDock); addDockWidget(Qt::RightDockWidgetArea, dataSetDock); tabifyDockWidget(logDock, dataSetDock); logDock->raise(); shaderEditorDock->setVisible(false); // Add dock widget toggles to view menu viewMenu->addSeparator(); viewMenu->addAction(shaderParamsDock->toggleViewAction()); viewMenu->addAction(logDock->toggleViewAction()); viewMenu->addAction(dataSetDock->toggleViewAction()); // Create custom hook events from CLI at runtime m_hookManager = new HookManager(this); }
void ProtobufTree::contextMenuEvent(QContextMenuEvent* e) { QMenu menu; QAction* expandItemAction = nullptr, * collapseItemAction = nullptr; QTreeWidgetItem* item = itemAt(e->pos()); if (item) { expandItemAction = menu.addAction("Expand"); collapseItemAction = menu.addAction("Collapse"); menu.addSeparator(); } QAction* expandMessagesAction = menu.addAction("Expand Only Messages"); menu.addSeparator(); QAction* expandAction = menu.addAction("Expand All"); QAction* collapseAction = menu.addAction("Collapse All"); menu.addSeparator(); QAction* showTags = menu.addAction("Show tags"); showTags->setCheckable(true); showTags->setChecked(!isColumnHidden(Column_Tag)); menu.addSeparator(); QAction* chartAction = nullptr; QAction* exportAction = nullptr; QList<QAction*> chartMenuActions; QList<QDockWidget*> dockWidgets; const FieldDescriptor* field = nullptr; if (mainWindow && item) { field = item->data(Column_Tag, FieldDescriptorRole) .value<const FieldDescriptor*>(); if (field) { int t = field->type(); if (t == FieldDescriptor::TYPE_FLOAT || t == FieldDescriptor::TYPE_DOUBLE || (t == FieldDescriptor::TYPE_MESSAGE && field->message_type()->name() == "Point")) { dockWidgets = mainWindow->findChildren<QDockWidget*>(); if (!dockWidgets.isEmpty()) { QMenu* chartMenu = menu.addMenu("Chart"); chartAction = chartMenu->addAction("New Chart"); exportAction = chartMenu->addAction("Export Chart"); chartMenu->addSeparator(); for (int i = 0; i < dockWidgets.size(); ++i) { chartMenuActions.append(chartMenu->addAction( QString("Add to '%1'") .arg(dockWidgets[0]->windowTitle()))); } } else { chartAction = menu.addAction("New Chart"); } } } } QAction* act = menu.exec(mapToGlobal(e->pos())); if (act == expandMessagesAction) { collapseAll(); expandMessages(); } else if (act == expandAction) { expandAll(); } else if (act == collapseAction) { collapseAll(); } else if (act == showTags) { setColumnHidden(Column_Tag, !showTags->isChecked()); } else if (expandItemAction && act == expandItemAction) { expandSubtree(item); } else if (collapseItemAction && act == collapseItemAction) { collapseSubtree(item); } else if (chartAction && act == chartAction) { // Find the path from LogFrame to the chosen item QVector<int> path; QStringList names; for (QTreeWidgetItem* i = item; i; i = i->parent()) { int tag = i->data(Column_Tag, Qt::DisplayRole).toInt(); path.push_back(tag); names.append(i->text(Column_Field)); } reverse(path.begin(), path.end()); reverse(names.begin(), names.end()); QDockWidget* dock = new QDockWidget(names.join("."), mainWindow); StripChart* chart = new StripChart(dock); chart->history(_history); if (field->type() == FieldDescriptor::TYPE_MESSAGE) { Chart::PointMagnitude* f = new Chart::PointMagnitude; f->path = path; f->name = names.join("."); chart->function(f); } else { Chart::NumericField* f = new Chart::NumericField; f->path = path; f->name = names.join("."); chart->function(f); } dock->setAttribute(Qt::WA_DeleteOnClose); dock->setWidget(chart); mainWindow->addDockWidget(Qt::BottomDockWidgetArea, dock); if (updateTimer) { connect(updateTimer, SIGNAL(timeout()), chart, SLOT(update())); } } else if (exportAction && act == exportAction) { // If export button was pressed StripChart* chart = new StripChart(); chart->history(_history); // Loop through all open charts and add their data to one chart for (int i = 0; i < dockWidgets.size(); i++) { StripChart* cChart = (StripChart*)dockWidgets[i]->widget(); QList<Chart::Function*> functions = cChart->getFunctions(); for (int j = 0; j < functions.size(); j++) { chart->function(functions[j]); } } // export that chart chart->exportChart(); } else if (chartMenuActions.size() > 0) { int i = chartMenuActions.indexOf(act); if (i != -1) { StripChart* chart = (StripChart*)dockWidgets[i]->widget(); QVector<int> path; QStringList names; for (QTreeWidgetItem* i = item; i; i = i->parent()) { int tag = i->data(Column_Tag, Qt::DisplayRole).toInt(); path.push_back(tag); names.append(i->text(Column_Field)); } reverse(path.begin(), path.end()); reverse(names.begin(), names.end()); dockWidgets[i]->setWindowTitle(dockWidgets[i]->windowTitle() + ", " + names.join(".")); chart->history(_history); if (field->type() == FieldDescriptor::TYPE_MESSAGE) { Chart::PointMagnitude* f = new Chart::PointMagnitude; f->path = path; f->name = names.join("."); chart->function(f); } else { Chart::NumericField* f = new Chart::NumericField; f->path = path; f->name = names.join("."); chart->function(f); } if (updateTimer) { connect(updateTimer, SIGNAL(timeout()), chart, SLOT(update())); } } } }
QMenu *QWidgetTextControl::createStandardContextMenu(const QPointF &pos, QWidget *parent) { Q_D(QWidgetTextControl); const bool showTextSelectionActions = d->interactionFlags & (Qt::TextEditable | Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse); d->linkToCopy = QString(); if (!pos.isNull()) d->linkToCopy = anchorAt(pos); if (d->linkToCopy.isEmpty() && !showTextSelectionActions) return 0; QMenu *menu = new QMenu(parent); QAction *a; if (d->interactionFlags & Qt::TextEditable) { a = menu->addAction(tr("&Undo") + ACCEL_KEY(QKeySequence::Undo), this, SLOT(undo())); a->setEnabled(d->doc->isUndoAvailable()); setActionIcon(a, QStringLiteral("edit-undo")); a = menu->addAction(tr("&Redo") + ACCEL_KEY(QKeySequence::Redo), this, SLOT(redo())); a->setEnabled(d->doc->isRedoAvailable()); setActionIcon(a, QStringLiteral("edit-redo")); menu->addSeparator(); a = menu->addAction(tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut), this, SLOT(cut())); a->setEnabled(d->cursor.hasSelection()); setActionIcon(a, QStringLiteral("edit-cut")); } if (showTextSelectionActions) { a = menu->addAction(tr("&Copy") + ACCEL_KEY(QKeySequence::Copy), this, SLOT(copy())); a->setEnabled(d->cursor.hasSelection()); setActionIcon(a, QStringLiteral("edit-copy")); } if ((d->interactionFlags & Qt::LinksAccessibleByKeyboard) || (d->interactionFlags & Qt::LinksAccessibleByMouse)) { a = menu->addAction(tr("Copy &Link Location"), this, SLOT(_q_copyLink())); a->setEnabled(!d->linkToCopy.isEmpty()); } if (d->interactionFlags & Qt::TextEditable) { #if !defined(QT_NO_CLIPBOARD) a = menu->addAction(tr("&Paste") + ACCEL_KEY(QKeySequence::Paste), this, SLOT(paste())); a->setEnabled(canPaste()); setActionIcon(a, QStringLiteral("edit-paste")); #endif a = menu->addAction(tr("Delete"), this, SLOT(_q_deleteSelected())); a->setEnabled(d->cursor.hasSelection()); setActionIcon(a, QStringLiteral("edit-delete")); } if (showTextSelectionActions) { menu->addSeparator(); a = menu->addAction(tr("Select All") + ACCEL_KEY(QKeySequence::SelectAll), this, SLOT(selectAll())); a->setEnabled(!d->doc->isEmpty()); } if ((d->interactionFlags & Qt::TextEditable) && qApp->styleHints()->useRtlExtensions()) { menu->addSeparator(); QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, menu); menu->addMenu(ctrlCharacterMenu); } return menu; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { // Setup the User Interface of the application. ui->setupUi(this); // Retrieve intel about the computer. QDesktopWidget dw; //this->setWindowTitle("DesignerEditor"); // Set application window's size fixed and width button not pressed. this->setFixedSize(dw.width() * 0.8, dw.height() * 0.8); this->widthButtonPressed = false; //this->move(dw.width() / 7, dw.height() / 8); //statusBar(); QMenuBar * menuB = this->menuBar(); QMenu * menuFichier = menuB->addMenu(tr("File")); QAction * open = new QAction(QIcon(":icons/images/open.png"), tr("&Open"), this); open->setToolTip(tr("Open existing file")); open->setStatusTip(tr("Open existing file")); open->setShortcut(tr("CTRL+O")); QAction * save = new QAction(QIcon(":icons/images/save.png"), tr("&Save"), this); save->setToolTip(tr("Save file")); save->setStatusTip(tr("Save file")); save->setShortcut(tr("CTRL+S")); QAction * exit = new QAction(QIcon(":icons/images/quit.png"), tr("&Exit"), this); exit->setToolTip(tr("Exit")); exit->setStatusTip(tr("Exit")); exit->setShortcut(tr("CTRL+E")); menuFichier->addAction(open); menuFichier->addAction(save); menuFichier->addAction(exit); QMenu * Tools = menuB->addMenu(tr("Tools")); //TODO The Polygon this->selectShape = new QActionGroup(this); selectShape->addAction(tr(CIRCLE_TEXT)); selectShape->actions().back()->setToolTip(tr("Draw a Circle")); selectShape->actions().back()->setStatusTip(tr("Draw a Circle")); selectShape->actions().back()->setShortcut(tr("ALT+W")); //Circle reserved for the next release. There are still bugs to be fixed. selectShape->actions().back()->setEnabled(false); selectShape->addAction(tr(RECTANGLE_TEXT)); selectShape->actions().back()->setToolTip(tr("Draw a Rectangle")); selectShape->actions().back()->setStatusTip(tr("Draw a Rectangle")); selectShape->actions().back()->setShortcut(tr("ALT+Z")); selectShape->addAction(tr(LINE_TEXT)); selectShape->actions().back()->setToolTip(tr("Draw a Line")); selectShape->actions().back()->setStatusTip(tr("Draw a Line")); selectShape->actions().back()->setShortcut(tr("ALT+A")); selectShape->addAction(tr(ELLIPSE_TEXT)); selectShape->actions().back()->setToolTip(tr("Draw an Ellipse")); selectShape->actions().back()->setStatusTip(tr("Draw an Ellipse")); selectShape->actions().back()->setShortcut(tr("ALT+Q")); selectShape->addAction(tr(POLYLINE_TEXT)); selectShape->actions().back()->setToolTip(tr("Draw a Polyline")); selectShape->actions().back()->setStatusTip(tr("Draw a Polyline")); selectShape->actions().back()->setShortcut(tr("ALT+D")); selectShape->addAction(tr(SQUARE_TEXT)); selectShape->actions().back()->setToolTip(tr("Draw a Square")); selectShape->actions().back()->setStatusTip(tr("Draw a Square")); selectShape->actions().back()->setShortcut(tr("ALT+X")); //Square reserved for the next release. There are still bugs to be fixed. selectShape->actions().back()->setEnabled(false); QMenu * Shapes = Tools->addMenu(tr("Shape")); Shapes->addActions(selectShape->actions()); this->selectColor = new QActionGroup(this); selectColor->addAction(tr(RED_TEXT)); selectColor->actions().back()->setToolTip(tr("Black ink")); selectColor->actions().back()->setStatusTip(tr("Red ink")); selectColor->actions().back()->setShortcut(tr("SHIFT+R")); selectColor->addAction(tr(BLACK_TEXT)); selectColor->actions().back()->setToolTip(tr("Red ink")); selectColor->actions().back()->setStatusTip(tr("Black ink")); selectColor->actions().back()->setShortcut(tr("SHIFT+Z")); selectColor->addAction(tr(BLUE_TEXT)); selectColor->actions().back()->setToolTip(tr("Blue ink")); selectColor->actions().back()->setStatusTip(tr("Blue ink")); selectColor->actions().back()->setShortcut(tr("SHIFT+E")); selectColor->addAction(tr(YELLOW_TEXT)); selectColor->actions().back()->setToolTip(tr("Yellow ink")); selectColor->actions().back()->setStatusTip(tr("Yellow ink")); selectColor->actions().back()->setShortcut(tr("SHIFT+Q")); selectColor->addAction(tr(CYAN_TEXT)); selectColor->actions().back()->setToolTip(tr("Cyan ink")); selectColor->actions().back()->setStatusTip(tr("Cyan ink")); selectColor->actions().back()->setShortcut(tr("SHIFT+S")); selectColor->addAction(tr(MAGENTA_TEXT)); selectColor->actions().back()->setToolTip(tr("Magenta ink")); selectColor->actions().back()->setStatusTip(tr("Magenta ink")); selectColor->actions().back()->setShortcut(tr("SHIFT+D")); selectColor->addAction(tr(DARK_BLUE_TEXT)); selectColor->actions().back()->setToolTip(tr("Dark Blue ink")); selectColor->actions().back()->setStatusTip(tr("Dark Blue ink")); selectColor->actions().back()->setShortcut(tr("SHIFT+W")); selectColor->addAction(tr(DARK_RED_TEXT)); selectColor->actions().back()->setToolTip(tr("Dark Red ink")); selectColor->actions().back()->setStatusTip(tr("Dark Red ink")); selectColor->actions().back()->setShortcut(tr("SHIFT+X")); selectColor->addAction(tr(GREEN_TEXT)); selectColor->actions().back()->setToolTip(tr("Green ink")); selectColor->actions().back()->setStatusTip(tr("Green ink")); selectColor->actions().back()->setShortcut(tr("SHIFT+C")); selectColor->addAction(tr(DARK_GREEN_TEXT)); selectColor->actions().back()->setToolTip(tr("Dark Green ink")); selectColor->actions().back()->setStatusTip(tr("Dark Green ink")); selectColor->actions().back()->setShortcut(tr("SHIFT+F")); selectColor->addAction(tr(DARK_GREY_TEXT)); selectColor->actions().back()->setToolTip(tr("Dark Gray ink")); selectColor->actions().back()->setStatusTip(tr("Dark Gray ink")); selectColor->actions().back()->setShortcut(tr("SHIFT+A")); selectColor->addAction(tr(GRAY_TEXT)); selectColor->actions().back()->setToolTip(tr("Gray ink")); selectColor->actions().back()->setStatusTip(tr("Gray ink")); selectColor->actions().back()->setShortcut(tr("SHIFT+V")); const QStringList colorIdentifiers = (QStringList()<<"Black"<<"Red"<<"Blue" <<"Yellow"<<"Cyan"<<"Magenta" <<"Dark Blue"<<"Dark Red"<<"Green" <<"Dark Green"<<"Dark Gray"<<"Gray"); this->ui->colorBox->addItems(colorIdentifiers); QObject::connect(this->ui->colorBox, SIGNAL(currentIndexChanged(int)), this, SLOT(colorBox_currentIndexChanged(int))); QMenu * Colors = Tools->addMenu(tr("Ink Color")); Colors->addActions(selectColor->actions()); this->selectWidthPen = new QActionGroup(this); selectWidthPen->addAction(tr("Increase Width")); selectWidthPen->actions().back()->setToolTip(tr("Increase the width of the outline")); selectWidthPen->actions().back()->setStatusTip(tr("Increase the width of the outline")); selectWidthPen->actions().back()->setShortcut(Qt::Key_Up); selectWidthPen->addAction(tr("Decrease Width")); selectWidthPen->actions().back()->setToolTip(tr("Decrease the width of the outline")); selectWidthPen->actions().back()->setStatusTip(tr("Decrease the width of the outline")); selectWidthPen->actions().back()->setShortcut(Qt::Key_Down); selectWidthPen->addAction(tr("Increase Width Quickly")); selectWidthPen->actions().back()->setToolTip(tr("Increase the width of the outline quickly")); selectWidthPen->actions().back()->setStatusTip(tr("Increase the width of the outline quickly")); selectWidthPen->actions().back()->setShortcut(tr("Q")); selectWidthPen->addAction(tr("Decrease Width Quickly")); selectWidthPen->actions().back()->setToolTip(tr("Increase the width of the outline quickly")); selectWidthPen->actions().back()->setStatusTip(tr("Increase the width of the outline quickly")); selectWidthPen->actions().back()->setShortcut(tr("S")); QObject::connect(this->ui->WidthSlider, SIGNAL(valueChanged(int)), this, SLOT(widthSlider_valueChanged(int))); QMenu * widthControl = Tools->addMenu(tr("Outline Width Editor")); widthControl->addActions(selectWidthPen->actions()); this->widthActions = selectWidthPen->actions(); for(int i = 0; i < widthActions.count(); i++ ) QObject::connect(widthActions.at(i), SIGNAL(triggered()), this, SLOT(updateWidth())); this->selectBrushStyle = new QActionGroup(this); selectBrushStyle->addAction(tr("No Brush")); selectBrushStyle->actions().back()->setToolTip(tr("No Brush")); selectBrushStyle->actions().back()->setStatusTip(tr("No Brush")); selectBrushStyle->actions().back()->setShortcut(tr("A")); selectBrushStyle->addAction(tr("Solid Pattern")); selectBrushStyle->actions().back()->setToolTip(tr("Uniform color")); selectBrushStyle->actions().back()->setStatusTip(tr("Uniform color")); selectBrushStyle->actions().back()->setShortcut(tr("Z")); selectBrushStyle->addAction(tr("Extremely Dense")); selectBrushStyle->actions().back()->setToolTip(tr("Extremely dense brush pattern")); selectBrushStyle->actions().back()->setStatusTip(tr("Extremely dense brush pattern")); selectBrushStyle->actions().back()->setShortcut(tr("E")); selectBrushStyle->addAction(tr("Very Dense")); selectBrushStyle->actions().back()->setToolTip(tr("Very dense brush pattern")); selectBrushStyle->actions().back()->setStatusTip(tr("Very dense brush pattern")); selectBrushStyle->actions().back()->setShortcut(tr("R")); selectBrushStyle->addAction(tr("Somewhat Dense")); selectBrushStyle->actions().back()->setToolTip(tr("Somewhat dense brush pattern")); selectBrushStyle->actions().back()->setStatusTip(tr("Somewhat dense brush pattern")); selectBrushStyle->actions().back()->setShortcut(tr("T")); selectBrushStyle->addAction(tr("Half Dense")); selectBrushStyle->actions().back()->setToolTip(tr("Half dense brush pattern")); selectBrushStyle->actions().back()->setStatusTip(tr("Half dense brush pattern")); selectBrushStyle->actions().back()->setShortcut(tr("Y")); selectBrushStyle->addAction(tr("Somewhat Sparse")); selectBrushStyle->actions().back()->setToolTip(tr("Somewhat sparse brush pattern")); selectBrushStyle->actions().back()->setStatusTip(tr("Somewhat sparse brush pattern")); selectBrushStyle->actions().back()->setShortcut(tr("U")); selectBrushStyle->addAction(tr("Very Sparse")); selectBrushStyle->actions().back()->setToolTip(tr("Very sparse brush pattern")); selectBrushStyle->actions().back()->setStatusTip(tr("Very sparse brush pattern")); selectBrushStyle->actions().back()->setShortcut(tr("I")); selectBrushStyle->addAction(tr("Extremely Sparse")); selectBrushStyle->actions().back()->setToolTip(tr("Extremely sparse brush pattern")); selectBrushStyle->actions().back()->setStatusTip(tr("Extremely sparse brush pattern")); selectBrushStyle->actions().back()->setShortcut(tr("O")); selectBrushStyle->addAction(tr("Horizontal lines")); selectBrushStyle->actions().back()->setToolTip(tr("Horizontal lines pattern")); selectBrushStyle->actions().back()->setStatusTip(tr("Horizontal lines pattern")); selectBrushStyle->actions().back()->setShortcut(tr("P")); selectBrushStyle->addAction(tr("Vertical lines")); selectBrushStyle->actions().back()->setToolTip(tr("Vertical lines pattern")); selectBrushStyle->actions().back()->setStatusTip(tr("Vertical lines pattern")); selectBrushStyle->actions().back()->setShortcut(tr("D")); selectBrushStyle->addAction(tr("Crossing horizontal and vertical lines")); selectBrushStyle->actions().back()->setToolTip(tr("Crossing horizontal and vertical lines pattern")); selectBrushStyle->actions().back()->setStatusTip(tr("Crossing horizontal and vertical lines pattern")); selectBrushStyle->actions().back()->setShortcut(tr("F")); selectBrushStyle->addAction(tr("Backward diagonal lines")); selectBrushStyle->actions().back()->setToolTip(tr("Backward diagonal lines pattern")); selectBrushStyle->actions().back()->setStatusTip(tr("Backward diagonal lines pattern")); selectBrushStyle->actions().back()->setShortcut(tr("G")); selectBrushStyle->addAction(tr("Forward diagonal lines")); selectBrushStyle->actions().back()->setToolTip(tr("Forward diagonal lines pattern")); selectBrushStyle->actions().back()->setStatusTip(tr("Forward diagonal lines pattern")); selectBrushStyle->actions().back()->setShortcut(tr("H")); selectBrushStyle->addAction(tr("Crossing diagonal lines")); selectBrushStyle->actions().back()->setToolTip(tr("Crossing diagonal lines pattern")); selectBrushStyle->actions().back()->setStatusTip(tr("Crossing diagonal lines pattern")); selectBrushStyle->actions().back()->setShortcut(tr("J")); const QStringList brushStylesIdentifiers = (QStringList()<<"No Brush"<<"Solid"<<"+++Dense" <<"++Dense"<<"+Dense"<<"Dense" <<"Sparse"<<"+Sparse"<<"++Sparse" <<"- Lines"<<"| Lines"<<"X Lines" <<"/ Backward"<<"/ Forward"<<"X / Lines"); this->ui->brushBox->addItems(brushStylesIdentifiers); QObject::connect(this->ui->brushBox, SIGNAL(currentIndexChanged(int)), this, SLOT(brushBox_currentIndexChanged(int))); QMenu * brushStyles = Tools->addMenu(tr("Brush Pattern")); brushStyles->addActions(selectBrushStyle->actions()); this->brushActions = selectBrushStyle->actions(); for(int i = 0; i < brushActions.count(); i++ ) QObject::connect(brushActions.at(i), SIGNAL(triggered()), this, SLOT(updateBrushPattern())); this->selectCapStyle = new QActionGroup(this); selectCapStyle->addAction(tr("Square")); selectCapStyle->actions().back()->setToolTip(tr("Square border curves")); selectCapStyle->actions().back()->setStatusTip(tr("Square border curves")); selectCapStyle->actions().back()->setShortcut(tr("K")); selectCapStyle->addAction(tr("Round")); selectCapStyle->actions().back()->setToolTip(tr("Round border curves")); selectCapStyle->actions().back()->setStatusTip(tr("Round border curves")); selectCapStyle->actions().back()->setShortcut(tr("L")); selectCapStyle->addAction(tr("Flat")); selectCapStyle->actions().back()->setToolTip(tr("Flat border curves")); selectCapStyle->actions().back()->setStatusTip(tr("Flat border curves")); selectCapStyle->actions().back()->setShortcut(tr("M")); this->selectMode = new QActionGroup(this); selectMode->addAction(QIcon("://icons/images/cut.png"), tr("Edit")); selectMode->actions().back()->setToolTip(tr("Select and Edit")); selectMode->actions().back()->setStatusTip(tr("Select and Edit")); selectMode->actions().back()->setShortcut(tr("W")); selectMode->addAction(QIcon("://icons/images/paintbrush-symbol_318-9145.jpg"), tr("Draw")); selectMode->actions().back()->setToolTip(tr("Draw")); selectMode->actions().back()->setStatusTip(tr("Draw")); selectMode->actions().back()->setShortcut(tr("X")); QMenu * Mode = menuB->addMenu(tr("Mode")); Mode->addActions(selectMode->actions()); for(int i = 0; i < selectMode->actions().count(); i++ ) QObject::connect(selectMode->actions().at(i), SIGNAL(triggered()), this, SLOT(updateMode())); QAction * translate = new QAction(QIcon("://icons/images/move_arrow_cursor_direction_shift_pan_arrows-512.png"), tr("&Translate"), this); translate->setToolTip(tr("Translate figure")); translate->setStatusTip(tr("Translate figure")); translate->setShortcut(tr(".")); Mode->addAction(translate); QObject::connect(translate, SIGNAL(triggered()), this, SLOT(updateMode())); QMenu * capStyle = Tools->addMenu(tr("Cap Style")); capStyle->addActions(selectCapStyle->actions()); this->capActions = selectCapStyle->actions(); for(int i = 0; i < capActions.count(); i++ ) QObject::connect(capActions.at(i), SIGNAL(triggered()), this, SLOT(updateCapStyle())); this->selectJoinStyle = new QActionGroup(this); selectJoinStyle->addAction(tr("BevelJoin")); selectJoinStyle->actions().back()->setToolTip(tr("")); selectJoinStyle->actions().back()->setStatusTip(tr("")); selectJoinStyle->actions().back()->setShortcut(tr("V")); selectJoinStyle->addAction(tr("MiterJoin")); selectJoinStyle->actions().back()->setToolTip(tr("")); selectJoinStyle->actions().back()->setStatusTip(tr("")); selectJoinStyle->actions().back()->setShortcut(tr("B")); selectJoinStyle->addAction(tr("RoundJoin")); selectJoinStyle->actions().back()->setToolTip(tr("")); selectJoinStyle->actions().back()->setStatusTip(tr("")); selectJoinStyle->actions().back()->setShortcut(tr("N")); QMenu * joinStyle = Tools->addMenu(tr("Join Style")); joinStyle->addActions(selectJoinStyle->actions()); this->joinActions = selectJoinStyle->actions(); for(int i = 0; i < joinActions.count(); i++ ) QObject::connect(joinActions.at(i), SIGNAL(triggered()), this, SLOT(updateJoinStyle())); //this->mainTextView = new QTextEdit(this); this->mainDrawView = this->ui->mainDraw;//new ZoneDeDessin(this); this->mainDrawView->setSlider(this->ui->WidthSlider); //setCentralWidget(this->mainDrawView); //setCentralWidget(mainTextView); this->shapeActions = selectShape->actions(); this->colorActions = selectColor->actions(); for(int i = 0; i < this->shapeActions.count(); i++ ) QObject::connect(this->shapeActions.at(i), SIGNAL(triggered()), this, SLOT(updateShape())); for(int i = 0; i < this->colorActions.count(); i++ ) QObject::connect(this->colorActions.at(i), SIGNAL(triggered()), this, SLOT(updateColor())); this->eraseAll = new QAction(tr("&Erase All"), this); this->eraseAll->setToolTip(tr("Reset canvas")); this->eraseAll->setStatusTip(tr("Reset Canvas")); this->eraseAll->setShortcut(tr("DEL")); Tools->addAction(eraseAll); QObject::connect(eraseAll, SIGNAL(triggered()), this, SLOT(eraseAllCallback())); QToolBar * toolBar = this->ui->mainToolBar;//addToolBar(tr("File")); toolBar->addAction(open); toolBar->addAction(save); toolBar->addAction(this->selectMode->actions().back()); toolBar->addAction(this->selectMode->actions().front()); toolBar->addAction(translate); toolBar->addAction(exit); QObject::connect(open, SIGNAL(triggered()), this, SLOT(openFile())); QObject::connect(save, SIGNAL(triggered()), this, SLOT(saveFile())); QObject::connect(exit, SIGNAL(triggered()), this, SLOT(quitApp())); }
/* Main Menu that sticks everything together */ void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show ) { /* Delete old popup if there is one */ if( p_intf->p_sys->p_popup_menu ) delete p_intf->p_sys->p_popup_menu; if( !show ) { p_intf->p_sys->p_popup_menu = NULL; return; } /* */ QMenu *menu = new QMenu(); QAction *action; bool b_isFullscreen = false; MainInterface *mi = p_intf->p_sys->p_mi; POPUP_BOILERPLATE; PopupPlayEntries( menu, p_intf, p_input ); PopupMenuPlaylistControlEntries( menu, p_intf ); menu->addSeparator(); if( p_input ) { QMenu *submenu; vout_thread_t *p_vout = THEMIM->getVout(); /* Add a fullscreen switch button, since it is the most used function */ if( p_vout ) { vlc_value_t val; var_Get( p_vout, "fullscreen", &val ); b_isFullscreen = !( !val.b_bool ); if( b_isFullscreen ) CreateAndConnect( menu, "fullscreen", qtr( "Leave Fullscreen" ),"" , ITEM_NORMAL, VLC_OBJECT(p_vout), val, VLC_VAR_BOOL, b_isFullscreen ); vlc_object_release( p_vout ); menu->addSeparator(); } /* Input menu */ InputAutoMenuBuilder( p_input, objects, varnames ); /* Audio menu */ submenu = new QMenu( menu ); action = menu->addMenu( AudioMenu( p_intf, submenu ) ); action->setText( qtr( "&Audio" ) ); if( action->menu()->isEmpty() ) action->setEnabled( false ); /* Video menu */ submenu = new QMenu( menu ); action = menu->addMenu( VideoMenu( p_intf, submenu ) ); action->setText( qtr( "&Video" ) ); if( action->menu()->isEmpty() ) action->setEnabled( false ); /* Playback menu for chapters */ submenu = new QMenu( menu ); action = menu->addMenu( NavigMenu( p_intf, submenu ) ); action->setText( qtr( "&Playback" ) ); if( action->menu()->isEmpty() ) action->setEnabled( false ); } menu->addSeparator(); /* Add some special entries for windowed mode: Interface Menu */ if( !b_isFullscreen ) { QMenu *submenu = new QMenu( qtr( "Interface" ), menu ); QMenu *tools = ToolsMenu( submenu ); submenu->addSeparator(); /* In skins interface, append some items */ if( !mi ) { vlc_object_t *p_object = ( vlc_object_t* ) vlc_object_find_name( p_intf, "skins2", FIND_PARENT ); if( p_object ) { objects.clear(); varnames.clear(); objects.push_back( p_object ); varnames.push_back( "intf-skins" ); Populate( p_intf, submenu, varnames, objects ); objects.clear(); varnames.clear(); objects.push_back( p_object ); varnames.push_back( "intf-skins-interactive" ); Populate( p_intf, submenu, varnames, objects ); vlc_object_release( p_object ); } else msg_Warn( p_intf, "could not find parent interface" ); } else menu->addMenu( ViewMenu( p_intf, mi, false )); menu->addMenu( submenu ); } /* Static entries for ending, like open */ PopupMenuStaticEntries( menu ); p_intf->p_sys->p_popup_menu = menu; p_intf->p_sys->p_popup_menu->popup( QCursor::pos() ); }
void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate() { // very bad hack... berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); QMainWindow* mainWindow = qobject_cast<QMainWindow*> (window->GetShell()->GetControl()); if (!windowIcon.isEmpty()) { mainWindow->setWindowIcon(QIcon(windowIcon)); } mainWindow->setContextMenuPolicy(Qt::PreventContextMenu); /*mainWindow->setStyleSheet("color: white;" "background-color: #808080;" "selection-color: #659EC7;" "selection-background-color: #808080;" " QMenuBar {" "background-color: #808080; }");*/ // Load selected icon theme QStringList searchPaths = QIcon::themeSearchPaths(); searchPaths.push_front( QString(":/org_mitk_icons/icons/") ); QIcon::setThemeSearchPaths( searchPaths ); berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer stylePref = prefService->GetSystemPreferences()->Node(berry::QtPreferences::QT_STYLES_NODE); QString iconTheme = stylePref->Get(berry::QtPreferences::QT_ICON_THEME, "<<default>>"); if( iconTheme == QString( "<<default>>" ) ) { iconTheme = QString( "tango" ); } QIcon::setThemeName( iconTheme ); // ==== Application menu ============================ QMenuBar* menuBar = mainWindow->menuBar(); menuBar->setContextMenuPolicy(Qt::PreventContextMenu); #ifdef __APPLE__ menuBar->setNativeMenuBar(true); #else menuBar->setNativeMenuBar(false); #endif QAction* fileOpenAction = new QmitkFileOpenAction(QIcon::fromTheme("document-open",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-open.svg")), window); fileOpenAction->setShortcut(QKeySequence::Open); QAction* fileSaveAction = new QmitkFileSaveAction(QIcon(":/org.mitk.gui.qt.ext/Save_48.png"), window); fileSaveAction->setShortcut(QKeySequence::Save); fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window); fileSaveProjectAction->setIcon(QIcon::fromTheme("document-save",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-save.svg"))); closeProjectAction = new QmitkCloseProjectAction(window); closeProjectAction->setIcon(QIcon::fromTheme("edit-delete",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-delete.svg"))); auto perspGroup = new QActionGroup(menuBar); std::map<QString, berry::IViewDescriptor::Pointer> VDMap; // sort elements (converting vector to map...) QList<berry::IViewDescriptor::Pointer>::const_iterator iter; berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); const QList<berry::IViewDescriptor::Pointer> viewDescriptors = viewRegistry->GetViews(); bool skip = false; for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) { // if viewExcludeList is set, it contains the id-strings of view, which // should not appear as an menu-entry in the menu if (viewExcludeList.size() > 0) { for (int i=0; i<viewExcludeList.size(); i++) { if (viewExcludeList.at(i) == (*iter)->GetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") continue; if ((*iter)->GetId() == "org.mitk.views.imagenavigator") continue; if ((*iter)->GetId() == "org.mitk.views.viewnavigatorview") continue; std::pair<QString, berry::IViewDescriptor::Pointer> p( (*iter)->GetLabel(), (*iter)); VDMap.insert(p); } std::map<QString, berry::IViewDescriptor::Pointer>::const_iterator MapIter; for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) { berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, (*MapIter).second); viewActions.push_back(viewAction); } if (!USE_EXPERIMENTAL_COMMAND_CONTRIBUTIONS) { QMenu* fileMenu = menuBar->addMenu("&File"); fileMenu->setObjectName("FileMenu"); fileMenu->addAction(fileOpenAction); fileMenu->addAction(fileSaveAction); fileMenu->addAction(fileSaveProjectAction); fileMenu->addAction(closeProjectAction); fileMenu->addSeparator(); QAction* fileExitAction = new QmitkFileExitAction(window); fileExitAction->setIcon(QIcon::fromTheme("system-log-out",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/system-log-out.svg"))); fileExitAction->setShortcut(QKeySequence::Quit); fileExitAction->setObjectName("QmitkFileExitAction"); fileMenu->addAction(fileExitAction); // another bad hack to get an edit/undo menu... QMenu* editMenu = menuBar->addMenu("&Edit"); undoAction = editMenu->addAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")), "&Undo", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()), QKeySequence("CTRL+Z")); undoAction->setToolTip("Undo the last action (not supported by all modules)"); redoAction = editMenu->addAction(QIcon::fromTheme("edit-redo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-redo.svg")) , "&Redo", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()), QKeySequence("CTRL+Y")); redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)"); // ==== Window Menu ========================== QMenu* windowMenu = menuBar->addMenu("Window"); if (showNewWindowMenuItem) { windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow())); windowMenu->addSeparator(); } QMenu* perspMenu = windowMenu->addMenu("&Open Perspective"); QMenu* viewMenu; if (showViewMenuItem) { viewMenu = windowMenu->addMenu("Show &View"); viewMenu->setObjectName("Show View"); } windowMenu->addSeparator(); resetPerspAction = windowMenu->addAction("&Reset Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective())); if(showClosePerspectiveMenuItem) closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective())); windowMenu->addSeparator(); windowMenu->addAction("&Preferences...", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()), QKeySequence("CTRL+P")); // fill perspective menu berry::IPerspectiveRegistry* perspRegistry = window->GetWorkbench()->GetPerspectiveRegistry(); QList<berry::IPerspectiveDescriptor::Pointer> perspectives( perspRegistry->GetPerspectives()); skip = false; for (QList<berry::IPerspectiveDescriptor::Pointer>::iterator perspIt = perspectives.begin(); perspIt != perspectives.end(); ++perspIt) { // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which // should not appear as an menu-entry in the perspective menu if (perspectiveExcludeList.size() > 0) { for (int i=0; i<perspectiveExcludeList.size(); i++) { if (perspectiveExcludeList.at(i) == (*perspIt)->GetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } QAction* perspAction = new berry::QtOpenPerspectiveAction(window, *perspIt, perspGroup); mapPerspIdToAction.insert((*perspIt)->GetId(), perspAction); } perspMenu->addActions(perspGroup->actions()); if (showViewMenuItem) { for (auto viewAction : viewActions) { viewMenu->addAction(viewAction); } } // ===== Help menu ==================================== QMenu* helpMenu = menuBar->addMenu("&Help"); helpMenu->addAction("&Welcome",this, SLOT(onIntro())); helpMenu->addAction("&Open Help Perspective", this, SLOT(onHelpOpenHelpPerspective())); helpMenu->addAction("&Context Help",this, SLOT(onHelp()), QKeySequence("F1")); helpMenu->addAction("&About",this, SLOT(onAbout())); // ===================================================== } else { //undoAction = new QAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")), // "&Undo", nullptr); undoAction = new QmitkUndoAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")), nullptr); undoAction->setShortcut(QKeySequence::Undo); redoAction = new QmitkRedoAction(QIcon::fromTheme("edit-redo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-redo.svg")), nullptr); redoAction->setShortcut(QKeySequence::Redo); } // toolbar for showing file open, undo, redo and other main actions auto mainActionsToolBar = new QToolBar; mainActionsToolBar->setObjectName("mainActionsToolBar"); mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu); #ifdef __APPLE__ mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon ); #else mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon ); #endif imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", nullptr); bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator"); if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) { openDicomEditorAction = new QmitkOpenDicomEditorAction(QIcon(":/org.mitk.gui.qt.ext/dcm-icon.png"),window); } if (imageNavigatorViewFound) { QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator())); imageNavigatorAction->setCheckable(true); // add part listener for image navigator imageNavigatorPartListener.reset(new PartListenerForImageNavigator(imageNavigatorAction)); window->GetPartService()->AddPartListener(imageNavigatorPartListener.data()); berry::IViewPart::Pointer imageNavigatorView = window->GetActivePage()->FindView("org.mitk.views.imagenavigator"); imageNavigatorAction->setChecked(false); if (imageNavigatorView) { bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView); if (isImageNavigatorVisible) imageNavigatorAction->setChecked(true); } imageNavigatorAction->setToolTip("Toggle image navigator for navigating through image"); } viewNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/view-manager_48.png"),"&View Navigator", nullptr); viewNavigatorFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.viewnavigatorview"); if (viewNavigatorFound) { QObject::connect(viewNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onViewNavigator())); viewNavigatorAction->setCheckable(true); // add part listener for view navigator viewNavigatorPartListener.reset(new PartListenerForViewNavigator(viewNavigatorAction)); window->GetPartService()->AddPartListener(viewNavigatorPartListener.data()); berry::IViewPart::Pointer viewnavigatorview = window->GetActivePage()->FindView("org.mitk.views.viewnavigatorview"); viewNavigatorAction->setChecked(false); if (viewnavigatorview) { bool isViewNavigatorVisible = window->GetActivePage()->IsPartVisible(viewnavigatorview); if (isViewNavigatorVisible) viewNavigatorAction->setChecked(true); } viewNavigatorAction->setToolTip("Toggle View Navigator"); } mainActionsToolBar->addAction(fileOpenAction); mainActionsToolBar->addAction(fileSaveProjectAction); mainActionsToolBar->addAction(closeProjectAction); mainActionsToolBar->addAction(undoAction); mainActionsToolBar->addAction(redoAction); if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) { mainActionsToolBar->addAction(openDicomEditorAction); } if (imageNavigatorViewFound) { mainActionsToolBar->addAction(imageNavigatorAction); } if (viewNavigatorFound) { mainActionsToolBar->addAction(viewNavigatorAction); } mainWindow->addToolBar(mainActionsToolBar); // ==== Perspective Toolbar ================================== auto qPerspectiveToolbar = new QToolBar; qPerspectiveToolbar->setObjectName("perspectiveToolBar"); if (showPerspectiveToolbar) { qPerspectiveToolbar->addActions(perspGroup->actions()); mainWindow->addToolBar(qPerspectiveToolbar); } else delete qPerspectiveToolbar; // ==== View Toolbar ================================== auto qToolbar = new QToolBar; qToolbar->setObjectName("viewToolBar"); if (showViewToolbar) { mainWindow->addToolBar(qToolbar); for (auto viewAction : viewActions) { qToolbar->addAction(viewAction); } } else delete qToolbar; QSettings settings(GetQSettingsFile(), QSettings::IniFormat); mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray()); auto qStatusBar = new QStatusBar(); //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar auto statusBar = new QmitkStatusBar(qStatusBar); //disabling the SizeGrip in the lower right corner statusBar->SetSizeGripEnabled(false); auto progBar = new QmitkProgressBar(); qStatusBar->addPermanentWidget(progBar, 0); progBar->hide(); // progBar->AddStepsToDo(2); // progBar->Progress(1); mainWindow->setStatusBar(qStatusBar); if (showMemoryIndicator) { auto memoryIndicator = new QmitkMemoryUsageIndicatorView(); qStatusBar->addPermanentWidget(memoryIndicator, 0); } }
QgsComposer::QgsComposer( QgisApp *qgis, const QString& title ) : QMainWindow() , mTitle( title ) , mUndoView( 0 ) { setupUi( this ); setWindowTitle( mTitle ); setupTheme(); connect( mButtonBox, SIGNAL( rejected() ), this, SLOT( close() ) ); QSettings settings; int size = settings.value( "/IconSize", QGIS_ICON_SIZE ).toInt(); setIconSize( QSize( size, size ) ); #ifndef Q_WS_MAC setFontSize( settings.value( "/fontPointSize", QGIS_DEFAULT_FONTSIZE ).toInt() ); #endif QToolButton* orderingToolButton = new QToolButton( this ); orderingToolButton->setPopupMode( QToolButton::InstantPopup ); orderingToolButton->setAutoRaise( true ); orderingToolButton->setToolButtonStyle( Qt::ToolButtonIconOnly ); orderingToolButton->addAction( mActionRaiseItems ); orderingToolButton->addAction( mActionLowerItems ); orderingToolButton->addAction( mActionMoveItemsToTop ); orderingToolButton->addAction( mActionMoveItemsToBottom ); orderingToolButton->setDefaultAction( mActionRaiseItems ); toolBar->addWidget( orderingToolButton ); QToolButton* alignToolButton = new QToolButton( this ); alignToolButton->setPopupMode( QToolButton::InstantPopup ); alignToolButton->setAutoRaise( true ); alignToolButton->setToolButtonStyle( Qt::ToolButtonIconOnly ); alignToolButton->addAction( mActionAlignLeft ); alignToolButton->addAction( mActionAlignHCenter ); alignToolButton->addAction( mActionAlignRight ); alignToolButton->addAction( mActionAlignTop ); alignToolButton->addAction( mActionAlignVCenter ); alignToolButton->addAction( mActionAlignBottom ); alignToolButton->setDefaultAction( mActionAlignLeft ); toolBar->addWidget( alignToolButton ); QToolButton* shapeToolButton = new QToolButton( toolBar ); shapeToolButton->setCheckable( true ); shapeToolButton->setPopupMode( QToolButton::InstantPopup ); shapeToolButton->setAutoRaise( true ); shapeToolButton->setToolButtonStyle( Qt::ToolButtonIconOnly ); shapeToolButton->addAction( mActionAddRectangle ); shapeToolButton->addAction( mActionAddTriangle ); shapeToolButton->addAction( mActionAddEllipse ); shapeToolButton->setDefaultAction( mActionAddEllipse ); toolBar->insertWidget( mActionAddArrow, shapeToolButton ); QActionGroup* toggleActionGroup = new QActionGroup( this ); toggleActionGroup->addAction( mActionMoveItemContent ); toggleActionGroup->addAction( mActionAddNewMap ); toggleActionGroup->addAction( mActionAddNewLabel ); toggleActionGroup->addAction( mActionAddNewLegend ); toggleActionGroup->addAction( mActionAddNewScalebar ); toggleActionGroup->addAction( mActionAddImage ); toggleActionGroup->addAction( mActionSelectMoveItem ); toggleActionGroup->addAction( mActionAddRectangle ); toggleActionGroup->addAction( mActionAddTriangle ); toggleActionGroup->addAction( mActionAddEllipse ); toggleActionGroup->addAction( mActionAddArrow ); toggleActionGroup->addAction( mActionAddTable ); toggleActionGroup->addAction( mActionAddHtml ); toggleActionGroup->setExclusive( true ); mActionAddNewMap->setCheckable( true ); mActionAddNewLabel->setCheckable( true ); mActionAddNewLegend->setCheckable( true ); mActionSelectMoveItem->setCheckable( true ); mActionAddNewScalebar->setCheckable( true ); mActionAddImage->setCheckable( true ); mActionMoveItemContent->setCheckable( true ); mActionAddArrow->setCheckable( true ); #ifdef Q_WS_MAC QMenu *appMenu = menuBar()->addMenu( tr( "QGIS" ) ); appMenu->addAction( QgisApp::instance()->actionAbout() ); appMenu->addAction( QgisApp::instance()->actionOptions() ); #endif QMenu *fileMenu = menuBar()->addMenu( tr( "File" ) ); fileMenu->addAction( mActionLoadFromTemplate ); fileMenu->addAction( mActionSaveAsTemplate ); fileMenu->addSeparator(); fileMenu->addAction( mActionExportAsImage ); fileMenu->addAction( mActionExportAsPDF ); fileMenu->addAction( mActionExportAsSVG ); fileMenu->addSeparator(); fileMenu->addAction( mActionPageSetup ); fileMenu->addAction( mActionPrint ); fileMenu->addSeparator(); fileMenu->addAction( mActionQuit ); QObject::connect( mActionQuit, SIGNAL( triggered() ), this, SLOT( close() ) ); QMenu *viewMenu = menuBar()->addMenu( tr( "View" ) ); viewMenu->addAction( mActionZoomIn ); viewMenu->addAction( mActionZoomOut ); viewMenu->addAction( mActionZoomAll ); viewMenu->addSeparator(); viewMenu->addAction( mActionRefreshView ); // Panel and toolbar submenus mPanelMenu = new QMenu( tr( "Panels" ), this ); mPanelMenu->setObjectName( "mPanelMenu" ); mToolbarMenu = new QMenu( tr( "Toolbars" ), this ); mToolbarMenu->setObjectName( "mToolbarMenu" ); viewMenu->addSeparator(); viewMenu->addMenu( mPanelMenu ); viewMenu->addMenu( mToolbarMenu ); // toolBar already exists, add other widgets as they are created mToolbarMenu->addAction( toolBar->toggleViewAction() ); QMenu *layoutMenu = menuBar()->addMenu( tr( "Layout" ) ); layoutMenu->addAction( mActionUndo ); layoutMenu->addAction( mActionRedo ); layoutMenu->addSeparator(); layoutMenu->addAction( mActionAddNewMap ); layoutMenu->addAction( mActionAddNewLabel ); layoutMenu->addAction( mActionAddNewScalebar ); layoutMenu->addAction( mActionAddNewLegend ); layoutMenu->addAction( mActionAddImage ); layoutMenu->addAction( mActionSelectMoveItem ); layoutMenu->addAction( mActionMoveItemContent ); layoutMenu->addAction( mActionAddArrow ); layoutMenu->addAction( mActionAddTable ); layoutMenu->addSeparator(); layoutMenu->addAction( mActionGroupItems ); layoutMenu->addAction( mActionUngroupItems ); layoutMenu->addAction( mActionRaiseItems ); layoutMenu->addAction( mActionLowerItems ); layoutMenu->addAction( mActionMoveItemsToTop ); layoutMenu->addAction( mActionMoveItemsToBottom ); #ifdef Q_WS_MAC #ifndef Q_WS_MAC64 /* assertion failure in NSMenuItem setSubmenu (Qt 4.5.0-snapshot-20080830) */ menuBar()->addMenu( QgisApp::instance()->windowMenu() ); menuBar()->addMenu( QgisApp::instance()->helpMenu() ); #endif #endif mQgis = qgis; mFirstTime = true; // Create action to select this window mWindowAction = new QAction( windowTitle(), this ); connect( mWindowAction, SIGNAL( triggered() ), this, SLOT( activate() ) ); QgsDebugMsg( "entered." ); setMouseTracking( true ); mViewFrame->setMouseTracking( true ); //create composer view mView = new QgsComposerView( mViewFrame ); //init undo/redo buttons mComposition = new QgsComposition( mQgis->mapCanvas()->mapRenderer() ); mActionUndo->setEnabled( false ); mActionRedo->setEnabled( false ); if ( mComposition->undoStack() ) { connect( mComposition->undoStack(), SIGNAL( canUndoChanged( bool ) ), mActionUndo, SLOT( setEnabled( bool ) ) ); connect( mComposition->undoStack(), SIGNAL( canRedoChanged( bool ) ), mActionRedo, SLOT( setEnabled( bool ) ) ); }
void ScenarioContextMenuManager::createSlotContextMenu( const iscore::DocumentContext& ctx, QMenu& menu, const SlotPresenter& slotp) { using namespace Scenario::Command; // TODO see http://stackoverflow.com/questions/21443023/capturing-a-reference-by-reference-in-a-c11-lambda auto& slotm = slotp.model(); // First changing the process in the current slot auto processes_submenu = menu.addMenu(tr("Focus process in this slot")); for(const Process::LayerModel& proc : slotm.layers) { QAction* procAct = new QAction{ proc.processModel().prettyName(), processes_submenu}; QObject::connect(procAct, &QAction::triggered, [&] () { PutLayerModelToFront cmd{slotm, proc.id()}; cmd.redo(); } ); processes_submenu->addAction(procAct); } // Then creation of a new slot with existing processes auto new_processes_submenu = menu.addMenu(tr("Show process in new slot")); for(const Process::LayerModel& proc : slotm.layers) { QAction* procAct = new QAction{ proc.processModel().prettyName(), new_processes_submenu}; QObject::connect(procAct, &QAction::triggered, [&] () { auto cmd = new Scenario::Command::AddLayerInNewSlot{ slotm.parentConstraint(), proc.processModel().id()}; CommandDispatcher<>{ctx.commandStack}.submitCommand(cmd); } ); new_processes_submenu->addAction(procAct); } // Then removal of slot auto removeSlotAct = new QAction{tr("Remove this slot"), nullptr}; QObject::connect(removeSlotAct, &QAction::triggered, [&] () { auto cmd = new Scenario::Command::RemoveSlotFromRack{slotm}; CommandDispatcher<>{ctx.commandStack}.submitCommand(cmd); }); menu.addAction(removeSlotAct); menu.addSeparator(); // Then Add process in this slot auto existing_processes_submenu = menu.addMenu(tr("Add existing process in this slot")); for(const Process::ProcessModel& proc : slotm.parentConstraint().processes) { // OPTIMIZEME by filtering before. if(std::none_of(slotm.layers.begin(), slotm.layers.end(), [&] (const Process::LayerModel& layer) { return &layer.processModel() == &proc; })) { QAction* procAct = new QAction{proc.prettyName(), existing_processes_submenu}; QObject::connect(procAct, &QAction::triggered, [&] () { auto cmd2 = new Scenario::Command::AddLayerModelToSlot{ slotm, proc}; CommandDispatcher<>{ctx.commandStack}.submitCommand(cmd2); } ); existing_processes_submenu->addAction(procAct); } } auto addNewProcessInExistingSlot = new QAction{tr("Add new process in this slot"), &menu}; QObject::connect(addNewProcessInExistingSlot, &QAction::triggered, [&] () { auto& fact = ctx.app.components.factory<Process::ProcessList>(); AddProcessDialog dialog{fact, qApp->activeWindow()}; QObject::connect(&dialog, &AddProcessDialog::okPressed, [&] (const auto& proc) { auto& constraint = slotm.parentConstraint(); QuietMacroCommandDispatcher disp{ new CreateProcessInExistingSlot, ctx.commandStack}; auto cmd1 = new AddOnlyProcessToConstraint{constraint, proc}; cmd1->redo(); disp.submitCommand(cmd1); auto cmd2 = new Scenario::Command::AddLayerModelToSlot{ slotm, constraint.processes.at(cmd1->processId())}; cmd2->redo(); disp.submitCommand(cmd2); disp.commit(); }); dialog.launchWindow(); }); menu.addAction(addNewProcessInExistingSlot); // Then Add process in a new slot auto addNewProcessInNewSlot = new QAction{tr("Add process in a new slot"), &menu}; QObject::connect(addNewProcessInNewSlot, &QAction::triggered, [&] () { auto& fact = ctx.app.components.factory<Process::ProcessList>(); AddProcessDialog dialog{fact, qApp->activeWindow()}; QObject::connect(&dialog, &AddProcessDialog::okPressed, [&] (const auto& proc) { auto& constraint = slotm.parentConstraint(); QuietMacroCommandDispatcher disp{ new CreateProcessInNewSlot, ctx.commandStack}; auto cmd1 = new AddOnlyProcessToConstraint{constraint, proc}; cmd1->redo(); disp.submitCommand(cmd1); auto& rack = slotm.rack(); auto cmd2 = new Scenario::Command::AddSlotToRack{rack}; cmd2->redo(); disp.submitCommand(cmd2); auto cmd3 = new Scenario::Command::AddLayerModelToSlot{ rack.slotmodels.at(cmd2->createdSlot()), constraint.processes.at(cmd1->processId())}; cmd3->redo(); disp.submitCommand(cmd3); disp.commit(); }); dialog.launchWindow(); }); menu.addAction(addNewProcessInNewSlot); }
virtual void customSetup(void) { QMenu *edit = toMainWidget()->getEditMenu(); edit->addSeparator(); IncMenu = edit->addMenu( qApp->translate("toEditExtensionTool", "Incremental Search")); IncrementalSearch = IncMenu->addAction(qApp->translate("toEditExtensionTool", "Forward"), &toEditExtensionsSingle::Instance(), SLOT(searchForward())); IncrementalSearch->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_S); ReverseSearch = IncMenu->addAction(qApp->translate("toEditExtensionTool", "Backward"), &toEditExtensionsSingle::Instance(), SLOT(searchBackward())); ReverseSearch->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_R); // ------------------------------ indentation menu IndentMenu = edit->addMenu( qApp->translate("toEditExtensionTool", "Auto Indent")); IndentBlock = IndentMenu->addAction(qApp->translate( "toEditExtensionTool", "Selection"), &toEditExtensionsSingle::Instance(), SLOT(autoIndentBlock())); IndentBlock->setShortcut(Qt::CTRL + + Qt::ALT + Qt::Key_I); IndentBuffer = IndentMenu->addAction(qApp->translate( "toEditExtensionTool", "Editor"), &toEditExtensionsSingle::Instance(), SLOT(autoIndentBuffer())); IndentBuffer->setShortcut(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_I); IndentMenu->addSeparator(); ObsBlock = IndentMenu->addAction(qApp->translate( "toEditExtensionTool", "Obfuscate Selection"), &toEditExtensionsSingle::Instance(), SLOT(obfuscateBlock())); ObsBuffer = IndentMenu->addAction(qApp->translate("toEditExtensionTool", "Obfuscate Editor"), &toEditExtensionsSingle::Instance(), SLOT(obfuscateBuffer())); // ------------------------------ case menu CaseMenu = edit->addMenu( qApp->translate("toEditExtensionTool", "Modify Case")); UpperCase = CaseMenu->addAction(qApp->translate("toEditExtensionTool", "Upper"), &toEditExtensionsSingle::Instance(), SLOT(upperCase())); UpperCase->setShortcut(Qt::CTRL + Qt::Key_U); LowerCase = CaseMenu->addAction(qApp->translate("toEditExtensionTool", "Lower"), &toEditExtensionsSingle::Instance(), SLOT(lowerCase())); LowerCase->setShortcut(Qt::CTRL + Qt::Key_L); // bookmark menu BookmarkMenu = edit->addMenu(qApp->translate("toEditExtensionTool", "Bookmarks")); BookmarkSwitchAct = BookmarkMenu->addAction("Add/Remove Bookmark", &toEditExtensionsSingle::Instance(), SLOT(bookmarkSwitch())); BookmarkSwitchAct->setShortcut(Qt::CTRL + Qt::Key_B); BookmarkPrevAct = BookmarkMenu->addAction("Go to previous Bookmark", &toEditExtensionsSingle::Instance(), SLOT(bookmarkPrev())); BookmarkPrevAct->setShortcut(Qt::ALT + Qt::Key_PageUp); BookmarkNextAct = BookmarkMenu->addAction("Go to next Bookmark", &toEditExtensionsSingle::Instance(), SLOT(bookmarkNext())); BookmarkNextAct->setShortcut(Qt::ALT + Qt::Key_PageDown); // EOL menu EolMenu = edit->addMenu(qApp->translate("toEditExtensionTool", "Convert End of Lines to")); EolUnixAct = EolMenu->addAction("UNIX", &toEditExtensionsSingle::Instance(), SLOT(convertEol())); EolMacAct = EolMenu->addAction("Mac OS X", &toEditExtensionsSingle::Instance(), SLOT(convertEol())); EolWindowsAct = EolMenu->addAction("MS Windows", &toEditExtensionsSingle::Instance(), SLOT(convertEol())); // ------------------------------ etc Indent = edit->addAction( QIcon(QPixmap(const_cast<const char**>(indent_xpm))), qApp->translate("toEditExtensionTool", "Indent Block"), &toEditExtensionsSingle::Instance(), SLOT(indentBlock())); #ifndef Q_WS_MAC Indent->setShortcut(Qt::ALT + Qt::Key_Right); #endif Deindent = edit->addAction( QIcon(QPixmap(const_cast<const char**>(deindent_xpm))), qApp->translate("toEditExtensionTool", "De-indent Block"), &toEditExtensionsSingle::Instance(), SLOT(deindentBlock())); #ifndef Q_WS_MAC Deindent->setShortcut(Qt::ALT + Qt::Key_Left); #endif Quote = edit->addAction(qApp->translate("toEditExtensionTool", "Quote Selection"), &toEditExtensionsSingle::Instance(), SLOT(quoteBlock())); UnQuote = edit->addAction(qApp->translate("toEditExtensionTool", "UnQuote Selection"), &toEditExtensionsSingle::Instance(), SLOT(unquoteBlock())); Comment = edit->addAction(qApp->translate("toEditExtensionTool", "Comment or Uncomment"), &toEditExtensionsSingle::Instance(), SLOT(handleComment()), Qt::CTRL + Qt::Key_D); GotoLine = edit->addAction(qApp->translate("toEditExtensionTool", "Goto Line"), &toEditExtensionsSingle::Instance(), SLOT(gotoLine())); GotoLine->setShortcut(Qt::CTRL + Qt::Key_G); AutoComplete = edit->addAction( qApp->translate("toEditExtensionTool", "Complete"), &toEditExtensionsSingle::Instance(), SLOT(autoComplete())); AutoComplete->setShortcut(Qt::CTRL + Qt::Key_Space); // add buttons to main window // disabled due the problems in the state of toolbars // toMainWidget()->addButtonApplication(Deindent); // toMainWidget()->addButtonApplication(Indent); toEditExtensionsSingle::Instance().receivedFocus(NULL); connect(toMainWidget(), SIGNAL(editEnabled(bool)), &toEditExtensionsSingle::Instance(), SLOT(editEnabled(bool))); }
int init ( ) { BL_FUNC_DEBUG /// Inicializa el sistema de traducciones 'gettext'. setlocale ( LC_ALL, "" ); blBindTextDomain ( "pluginbl_report2ods", g_confpr->value( CONF_DIR_TRADUCCION ).toLatin1().constData() ); PluginBl_Report2ODS *mcont = new PluginBl_Report2ODS; QMenu *pPluginMenu = NULL; /// Buscamos ficheros que tengan el nombre de la tabla QDir dir ( g_confpr->value( CONF_DIR_OPENREPORTS ) ); dir.setFilter ( QDir::Files | QDir::NoSymLinks ); dir.setSorting ( QDir::Size | QDir::Reversed ); /// Hacemos un filtrado de busqueda QStringList filters; filters << "inf_*.pys"; dir.setNameFilters ( filters ); QFileInfoList list = dir.entryInfoList(); for ( int i = 0; i < list.size(); ++i ) { QFileInfo fileInfo = list.at ( i ); QFile file; file.setFileName ( g_confpr->value( CONF_DIR_OPENREPORTS ) + fileInfo.fileName() ); file.open ( QIODevice::ReadOnly ); QTextStream stream ( &file ); QString buff = stream.readAll(); file.close(); /// Buscamos el titulo QString titulo = fileInfo.fileName(); QRegExp rx3 ( "title\\s*=\\s*\"(.*)\"" ); rx3.setMinimal ( true ); if ( rx3.indexIn ( buff, 0 ) != -1 ) { titulo = rx3.cap ( 1 ); } // end if QString pathtitulo = fileInfo.fileName(); QRegExp rx1 ( "pathtitle\\s*=\\s*\"(.*)\"" ); rx1.setMinimal ( true ); if ( rx1.indexIn ( buff, 0 ) != -1 ) { pathtitulo = rx1.cap ( 1 ); } else { pathtitulo = titulo; } // end if /// Buscamos el icono QString icon = ":/Images/template2ods.png"; QRegExp rx4 ( " icon\\s*=\\s*\"(.*)\"" ); rx4.setMinimal ( true ); if ( rx4.indexIn ( buff, 0 ) != -1 ) { icon = rx4.cap ( 1 ); } // end if QMenuBar *menubar =g_pluginbl_report2ods->menuBar(); QMenu *menu = NULL; QStringList path = pathtitulo.split("\\"); if (path.size() > 1) { QList<QMenu *> allPButtons = menubar->findChildren<QMenu *>(); bool encontrado = false; for (int j = 0; j < allPButtons.size(); ++j) { if (allPButtons.at(j)->title() == path[0]) { encontrado = true; menu = allPButtons.at(j); } // end if } // end for if (!encontrado) { //QMenu *pPluginMenu1 = new QMenu ( path[0] , menubar ); //menubar->insertMenu ( pPluginVer->menuAction(), pPluginMenu1 ); /// Miramos si existe un menu Herramientas menu = g_pluginbl_report2ods->newMenu ( path[0], "", "menuHerramientas" ); } // end if } else { if (!pPluginMenu) { pPluginMenu = g_pluginbl_report2ods->newMenu ( _("Informes &ODS"), "menuInfODS", "menuHerramientas" ); } // end if menu = pPluginMenu; } // end if for (int i = 1; i < path.size()-1; ++i) { QList<QMenu *> allPButtons = menu->findChildren<QMenu *>(); bool encontrado = false; for (int j = 0; j < allPButtons.size(); ++j) { if (allPButtons.at(j)->title() == path[i]) { encontrado = true; menu = allPButtons.at(j); } // end if } // end for if (!encontrado) { QMenu *pPluginMenu1 = new QMenu ( path[i] , menu ); menu->addMenu ( pPluginMenu1 ); menu = pPluginMenu1; } // end if } // end for /// Creamos el menú. QAction *accion = new QAction ( path[path.size()-1], 0 ); accion->setIcon(QIcon(icon)); accion->setObjectName ( fileInfo.fileName() ); accion->setStatusTip ( titulo); accion->setWhatsThis ( titulo ); mcont->connect ( accion, SIGNAL ( activated() ), mcont, SLOT ( elslot1() ) ); menu->addAction ( accion ); } // end for return 0; }
QWidget* WidgetStyle::createWidget(const QString& name) { if(name == "CheckBox") { QCheckBox* box = new QCheckBox("CheckBox"); box->setObjectName("CheckBox"); return setLayoutWidget({ box }, { 100, 30 }); } else if(name == "ComboBox") { QComboBox* box = new QComboBox; box->addItem("Item1"); box->addItem("Item3"); box->addItem("Item3"); box->setObjectName("ComboBox"); return setLayoutWidget({ box }, { 70, 30 }); } else if(name == "DateEdit") { QDateEdit* date = new QDateEdit; date->setObjectName("DateEdit"); return setLayoutWidget({ date }, { 110, 40 }); } else if(name == "DateTimeEdit") { QDateTimeEdit* date = new QDateTimeEdit; date->setObjectName("DateTimeEdit"); return setLayoutWidget({ date }, { 160, 30 }); } else if(name == "Dialog") { QDialog* dialog = new QDialog; dialog->setObjectName("Dialog"); return setLayoutWidget({ dialog }, { 160, 110 }); } else if(name == "DockWidget") //? { QDockWidget* widget = new QDockWidget; widget->setObjectName("DockWidget"); widget->resize(61, 22); return widget; } else if(name == "DoubleSpinBox") { QDoubleSpinBox* box = new QDoubleSpinBox; box->setObjectName("DoubleSpinBox"); return setLayoutWidget({ box }, { 90, 40 }); } else if(name == "Frame") //?? { QFrame* frame = new QFrame; frame->setObjectName("Frame"); frame->resize(150, 100); return frame; } else if(name == "GroupBox") { QGroupBox* box = new QGroupBox("GroupBox"); box->setObjectName("GroupBox"); return setLayoutWidget({ box }, { 160, 110 }); } else if(name == "Label") { QLabel* label = new QLabel("Label"); label->setObjectName("Label"); return setLayoutWidget({ label }, { 40, 20}); } else if(name == "LineEdit") { QLineEdit* line = new QLineEdit; line->setObjectName("LineEdit"); return setLayoutWidget({ line }, { 30, 30 }); } else if(name == "ListView") //?? { QListView* view = new QListView; view->setObjectName("ListView"); view->resize(71, 71); return view; } else if(name == "ListWidget") { QListWidget* list = new QListWidget; list->setObjectName("ListWidget"); for(int i = 0; i < 20; i++) list->addItem(QString("Item %1").arg(i)); return setLayoutWidget({ list }, { 80, 80 }); } else if(name == "MainWindow") { QMainWindow* window = new QMainWindow; window->setObjectName("MainWindow"); return setLayoutWidget({ window }, { 160, 110 }); } else if(name == "Menu") { QMenu* parentMenu = new QMenu; parentMenu->setObjectName("Menu"); parentMenu->addMenu("Menu1"); QMenu* menu1 = parentMenu->addMenu("Menu2"); menu1->addMenu("Menu1"); menu1->addMenu("Menu2"); parentMenu->addSeparator(); parentMenu->addMenu("Menu3"); return setLayoutWidget({ parentMenu }, { 160, 110 }); } else if(name == "MenuBar") { QMenuBar* bar = new QMenuBar; bar->setObjectName("QMenuBar"); QMenu* menu1 = bar->addMenu("MenuBar1"); menu1->addMenu("Menu1"); menu1->addSeparator(); menu1->addMenu("Menu2"); QMenu* menu2 = bar->addMenu("MenuBar2"); menu2->addMenu("Menu1"); menu2->addSeparator(); menu2->addMenu("Menu2"); QMenu* menu3 = bar->addMenu("MenuBar3"); menu3->addMenu("Menu1"); menu3->addSeparator(); menu3->addMenu("Menu2"); return setLayoutWidget({ bar }, { 280, 60 }); } else if(name == "ProgressBar") { QProgressBar* bar = new QProgressBar; bar->setObjectName("ProgressBar"); bar->setRange(0, 100); bar->setValue(0); QTimer* timer = new QTimer(bar); this->connect(timer, &QTimer::timeout, this, [bar]() { if(bar->value() == 100) bar->setValue(0); else bar->setValue(bar->value() + 1); }); timer->start(100); return setLayoutWidget({ bar }, { 110, 30 }); } else if(name == "PushButton") { QPushButton* button = new QPushButton("PushButton"); button->setObjectName("PushButton"); return setLayoutWidget({ button }, { 125, 30 }); } else if(name == "RadioButton") { QRadioButton* button = new QRadioButton("RadioButton"); button->setObjectName("RadioButton"); return setLayoutWidget({ button }, { 125, 30 }); } else if(name == "ScrollBar") { QScrollBar* barH = new QScrollBar(Qt::Horizontal); QScrollBar* barV = new QScrollBar(Qt::Vertical); barH->setObjectName("ScrollBarH"); barV->setObjectName("ScrollBarV"); return setLayoutWidget({ barH, barV }, { 200, 100 }); } else if(name == "Slider") { QSlider* sliderH = new QSlider(Qt::Horizontal); QSlider* sliderV = new QSlider(Qt::Vertical); sliderH->setObjectName("SliderH"); sliderV->setObjectName("SliderV"); return setLayoutWidget({ sliderH, sliderV }, { 200, 100 }); } else if(name == "SpinBox") { QSpinBox* spinBox = new QSpinBox; spinBox->setObjectName("SpinBox"); return setLayoutWidget({ spinBox }, { 60, 35 }); } else if(name == "Splitter") { QSplitter* splitterV = new QSplitter(Qt::Vertical); QSplitter* splitterH = new QSplitter(Qt::Horizontal); splitterV->setObjectName("SplitterV"); splitterH->setObjectName("SplitterH"); splitterV->addWidget(new QPushButton("PushButton1")); splitterV->addWidget(new QPushButton("PushButton2")); splitterH->addWidget(splitterV); splitterH->addWidget(new QPushButton("PushButton3")); return setLayoutWidget({ splitterH }, { 250, 110 }); } else if(name == "TabWidget") { QTabWidget* tab = new QTabWidget; tab->addTab(new QWidget, "Widget1"); tab->addTab(new QWidget, "Widget2"); tab->addTab(new QWidget, "Widget3"); tab->setObjectName("TabWidget"); return setLayoutWidget({ tab }, { 210, 110 }); } else if(name == "TableView") //? { QTableView* view = new QTableView; view->setObjectName("TableView"); view->resize(200, 100); return view; } else if(name == "TableWidget") { const int n = 100; QStringList list = { "one", "two", "three" }; QTableWidget* table = new QTableWidget(n, n); table->setObjectName("TableWidget"); table->setHorizontalHeaderLabels(list); table->setVerticalHeaderLabels(list); for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) table->setItem(i, j, new QTableWidgetItem(QString("%1, %2").arg(i).arg(j))); return setLayoutWidget({ table }, { 210, 110 }); } else if(name == "TextEdit") { QTextEdit* text = new QTextEdit; text->setObjectName("TextEdit"); return setLayoutWidget({ text }, { 80, 80 }); } else if(name == "TimeEdit") { QTimeEdit* time = new QTimeEdit; time->setObjectName("TimeEdit"); return setLayoutWidget({ time }, { 80, 80 }); } else if(name == "ToolButton") { QToolButton* button = new QToolButton; button->setText("ToolButton"); button->setObjectName("ToolButton"); return setLayoutWidget({ button }, { 95, 25 }); } else if(name == "ToolBox") { QToolBox* box = new QToolBox; box->addItem(new QWidget, "Widget1"); box->addItem(new QWidget, "Widget2"); box->addItem(new QWidget, "Widget3"); box->setObjectName("ToolBox"); return setLayoutWidget({ box }, { 110, 180 }); } else if(name == "TreeView") //? { QTreeView* tree = new QTreeView; tree->setObjectName("TreeView"); tree->resize(200, 100); return tree; } else if(name == "TreeWidget") { QTreeWidget* tree = new QTreeWidget; tree->setObjectName("TreeWidget"); tree->setHeaderLabels({ "Folders", "Used Space" }); QTreeWidgetItem* item = new QTreeWidgetItem(tree); item->setText(0, "Local Disk"); for(int i = 1; i < 20; i++) { QTreeWidgetItem* dir = new QTreeWidgetItem(item); dir->setText(0, "Directory" + QString::number(i)); dir->setText(1, QString::number(i) + "MB"); } tree->setItemExpanded(item, true); return setLayoutWidget({ tree }, { 210, 110 }); } else if(name == "Widget") { QWidget* widget = new QWidget; widget->setObjectName("Widget"); return setLayoutWidget({ widget }, { 210, 110 }); } return nullptr; }
Escena::Escena(QWidget *parent) : QGLWidget(parent) , m_camara(0) , m_camara2(0) , m_esCamaraLibre(true) , m_manipularMuebles(new QAction("Muebles", this)) , m_manipularLampara(new QAction("Lampara", this)) , m_camaraLibre(new QAction("Libre", this)) , m_camaraEsquina1(new QAction("Esquina", this)) , m_camaraFrontal1(new QAction("Frontal", this)) , m_camaraLateral1(new QAction("Lateral", this)) , m_camaraCenital1(new QAction("Cenital", this)) , m_camaraEsquina2(new QAction("Esquina", this)) , m_camaraFrontal2(new QAction("Frontal", this)) , m_camaraLateral2(new QAction("Lateral", this)) , m_camaraCenital2(new QAction("Cenital", this)) , m_ambiente(new QAction("Ambiente", this)) , m_lampara(new QAction("Lampara", this)) , m_remota(new QAction("Remota", this)) , m_niebla(new QAction("Niebla", this)) , m_proyeccion(Camara::Perspectiva) { s_self = this; QAction *proyeccionOrtogonal = new QAction("Ortogonal", this); proyeccionOrtogonal->setCheckable(true); QAction *proyeccionPerspectiva = new QAction("Perspectiva", this); proyeccionPerspectiva->setCheckable(true); proyeccionPerspectiva->setChecked(true); QAction *proyeccionOblicua = new QAction("Oblicua", this); proyeccionOblicua->setCheckable(true); QActionGroup *proyeccionGroup = new QActionGroup(this); proyeccionGroup->addAction(proyeccionOrtogonal); proyeccionGroup->addAction(proyeccionPerspectiva); proyeccionGroup->addAction(proyeccionOblicua); m_ambiente->setCheckable(true); m_ambiente->setChecked(true); m_lampara->setCheckable(true); m_remota->setCheckable(true); m_niebla->setCheckable(true); connect(proyeccionOrtogonal, SIGNAL(triggered()), this, SLOT(proyeccionOrtogonal())); connect(proyeccionPerspectiva, SIGNAL(triggered()), this, SLOT(proyeccionPerspectiva())); connect(proyeccionOblicua, SIGNAL(triggered()), this, SLOT(proyeccionOblicua())); connect(m_camaraLibre, SIGNAL(triggered()), this, SLOT(camaraLibre())); connect(m_camaraEsquina1, SIGNAL(triggered()), this, SLOT(camaraEsquina1())); connect(m_camaraFrontal1, SIGNAL(triggered()), this, SLOT(camaraFrontal1())); connect(m_camaraLateral1, SIGNAL(triggered()), this, SLOT(camaraLateral1())); connect(m_camaraCenital1, SIGNAL(triggered()), this, SLOT(camaraCenital1())); connect(m_camaraEsquina2, SIGNAL(triggered()), this, SLOT(camaraEsquina2())); connect(m_camaraFrontal2, SIGNAL(triggered()), this, SLOT(camaraFrontal2())); connect(m_camaraLateral2, SIGNAL(triggered()), this, SLOT(camaraLateral2())); connect(m_camaraCenital2, SIGNAL(triggered()), this, SLOT(camaraCenital2())); connect(m_ambiente, SIGNAL(triggered()), this, SLOT(recargaLuces())); connect(m_lampara, SIGNAL(triggered()), this, SLOT(recargaLuces())); connect(m_remota, SIGNAL(triggered()), this, SLOT(recargaLuces())); connect(m_niebla, SIGNAL(triggered()), this, SLOT(recargaLuces())); setFocusPolicy(Qt::StrongFocus); setMouseTracking(true); QMenuBar *menuBar = new QMenuBar(parent); m_manipularMuebles->setCheckable(true); m_manipularMuebles->setChecked(true); m_manipularLampara->setCheckable(true); QActionGroup *actionGroup = new QActionGroup(this); actionGroup->addAction(m_manipularMuebles); actionGroup->addAction(m_manipularLampara); QMenu *controlEscena = new QMenu("Control Escena", this); controlEscena->addActions(actionGroup->actions()); menuBar->addMenu(controlEscena); QMenu *habitacion1 = new QMenu("Habitacion 1", this); habitacion1->addAction(m_camaraEsquina1); habitacion1->addAction(m_camaraFrontal1); habitacion1->addAction(m_camaraLateral1); habitacion1->addAction(m_camaraCenital1); QMenu *habitacion2 = new QMenu("Habitacion 2", this); habitacion2->addAction(m_camaraEsquina2); habitacion2->addAction(m_camaraFrontal2); habitacion2->addAction(m_camaraLateral2); habitacion2->addAction(m_camaraCenital2); QMenu *posicionCamara = new QMenu("Camara", this); posicionCamara->addAction(m_camaraLibre); posicionCamara->addMenu(habitacion1); posicionCamara->addMenu(habitacion2); menuBar->addMenu(posicionCamara); QMenu *proyeccion = new QMenu("Proyeccion", this); proyeccion->addActions(proyeccionGroup->actions()); menuBar->addMenu(proyeccion); QMenu *iluminacion = new QMenu("Iluminacion", this); iluminacion->addAction(m_ambiente); iluminacion->addAction(m_lampara); iluminacion->addAction(m_remota); iluminacion->addAction(m_niebla); menuBar->addMenu(iluminacion); static_cast<QMainWindow*>(parent)->setMenuBar(menuBar); }
/////////////US_Win US_Win::US_Win( QWidget* parent, Qt::WindowFlags flags ) : QMainWindow( parent, flags ) { // We need to handle US_Global::g here becuse US_Widgets is not a parent if ( ! g.isValid() ) { // Do something for invalid global memory qDebug( "US_Win: invalid global memory" ); } g.set_global_position( QPoint( 50, 50 ) ); // Ensure initialization QPoint p = g.global_position(); setGeometry( QRect( p, p + QPoint( 710, 532 ) ) ); g.set_global_position( p + QPoint( 30, 30 ) ); setWindowTitle( "UltraScan III" ); QIcon us3_icon = US_Images::getIcon( US_Images::US3_ICON ); setWindowIcon( us3_icon ); procs = QList<procData*>(); // Initialize to an empty list //////////// QMenu* file = new QMenu( tr( "&File" ), this ); //addMenu( P_CONFIG, tr( "&Configuration" ), file ); //addMenu( P_ADMIN , tr( "&Administrator" ), file ); //file->addSeparator(); addMenu( P_EXIT, tr( "E&xit" ), file ); //QMenu* type1 = new QMenu( tr( "&Velocity Data" ), file ); //addMenu( 21, tr( "&Absorbance Data" ), type1 ); //addMenu( 22, tr( "&Interference Data" ), type1 ); //addMenu( 23, tr( "&Fluorescense Data" ), type1 ); //addMenu( 24, tr( "&Edit Cell ID's Data" ), type1 ); /////////////// QMenu* edit = new QMenu( tr( "&Edit" ), this ); //addMenu( 12, tr( "&Equilibrium Data" ) , edit ); //addMenu( 13, tr( "Edit &Wavelength Data" ), edit ); //addMenu( 14, tr( "View/Edit &Multiwavelength Data" ), edit ); addMenu( P_EDIT, tr( "&Edit Data" ) , edit ); edit->addSeparator(); addMenu( P_CONFIG, tr( "&Preferences" ) , edit ); ///////////// QMenu* velocity = new QMenu( tr( "&Velocity" ), this ); addMenu( P_VHWE , tr( "&Enhanced van Holde - Weischet" ), velocity ); addMenu( P_GRIDEDIT , tr( "C&ustom 2-D Grid Editor" ), velocity ); addMenu( P_2DSA , tr( "&2-D Spectrum Analysis" ), velocity ); addMenu( P_PCSA , tr( "&Parametrically Constrained Spectrum Analysis" ), velocity ); addMenu( P_GAINIT , tr( "&Initialize Genetic Algorithm" ), velocity ); addMenu( P_DMGAINIT , tr( "Initialize Discrete Model &Genetic Algorithm" ), velocity ); addMenu( P_SECOND , tr( "Second &Moment" ), velocity ); addMenu( P_DCDT , tr( "&Time Derivative" ), velocity ); addMenu( P_FEMA , tr( "&FE Model Viewer" ), velocity ); addMenu( P_FEMSTAT , tr( "FE Model &Statistics" ), velocity ); addMenu( P_PSEUDO3D , tr( "&Combine Pseudo-3D Distributions" ), velocity ); addMenu( P_RAMP , tr( "Speed &Ramp Analysis" ), velocity ); #ifdef EQUI_MENU QMenu* equilibrium = new QMenu( tr( "E&quilibrium" ), this ); addMenu( P_EQGLOBFIT, tr( "&Global Fit" ), equilibrium ); //addMenu( P_EQTIMEEST, tr( "Estimate Equilibrium &Times", equilibrium ); #endif // QMenu* fit = new QMenu( tr( "&Global Fit" ), this ); // addMenu( P_GLOBFITEQ, tr( "Global &Equilibrium Fit" ), fit ); //addMenu( P_GLOBFITEX, tr( "Global E&xtinction Fit" ), fit ); //addMenu( P_GLOBFITSP, tr( "Global &Spectrum Fit" ), fit ); QMenu* utilities = new QMenu( tr( "&Utilities" ), this ); QMenu* multiwave = new QMenu( tr( "&Multiwavelength" ), this ); QMenu* spectrum = new QMenu( tr( "Spectral &Analysis" ), this ); addMenu( P_SPECFIT , tr( "&Spectrum Fitter" ), spectrum); addMenu( P_SPECDEC , tr( "Spectrum &Decomposition" ), spectrum); addMenu( P_CONVERT , tr( "&Import Experimental Data" ), utilities ); addMenu( P_EXPORT , tr( "&Export OpenAUC Data" ), utilities ); #if 0 // temporarily disable Create Experiment until truly ready addMenu( P_CEXPERI , tr( "Create E&xperiment" ), utilities ); #endif addMenu( P_FDSMAN , tr( "FDS File &Manager" ), utilities ); addMenu( P_FITMEN , tr( "&Fit Meniscus" ), utilities ); utilities->addMenu(spectrum); addMenu( P_COLORGRAD, tr( "Color &Gradient Generator" ), utilities ); addMenu( P_RPTGEN , tr( "&Report Generator" ), utilities ); addMenu( P_ROTORCAL , tr( "Rotor &Calibration" ), utilities ); addMenu( P_LICENSE , tr( "&License Manager" ), utilities ); addMenu( P_VHWCOMB , tr( "Combine Distribution &Plots (vHW)" ), utilities ); addMenu( P_DDCOMB , tr( "Combine &Discrete Distributions" ), utilities ); addMenu( P_GLOMODL , tr( "Create Global &Model" ), utilities ); addMenu( P_VIEWCFA , tr( "View Raw C&FA Data" ), utilities ); addMenu( P_VIEWXPN , tr( "View Raw &Optima Data" ), utilities ); addMenu( P_VIEWTMST, tr( "View &TimeState" ), utilities ); addMenu( P_VIEWMWL , tr( "&View Multiwavelength Data" ), multiwave ); addMenu( P_VIEWMSS , tr( "View MWL &S-Spectra" ), multiwave ); addMenu( P_MWSPECF , tr( "MWL Species Fit" ), multiwave ); addMenu( P_MWFSIMU , tr( "Optima MWL Fit Simulation" ), multiwave ); QMenu* simulation = new QMenu( tr( "S&imulation" ), this ); addMenu( P_ASTFEM, tr( "&Finite Element Simulation (ASTFEM)" ), simulation ); addMenu( P_EQUILTIMESIM, tr( "Estimate Equilibrium &Times" ), simulation ); addMenu( P_SASSOC, tr( "&Self-Association Equilibrium" ), simulation ); addMenu( P_MODEL1, tr( "&Model s, D and f from MW for 4 basic shapes" ), simulation ); addMenu( P_MODEL2, tr( "&Predict f and axial ratios for 4 basic shapes" ), simulation ); addMenu( P_SOMO, tr( "S&OMO Bead Modeling" ), simulation ); addMenu( P_SOMOCONFIG, tr( "S&OMO Configuration" ), simulation ); QMenu* database = new QMenu( tr( "&Database" ), this ); addMenu( P_INVESTIGATOR , tr( "Manage &Investigator Data" ), database ); addMenu( P_BUFFER , tr( "Manage &Buffer Data" ), database ); addMenu( P_VBAR , tr( "Manage &Analytes" ), database ); addMenu( P_MODEL , tr( "Manage &Models" ), database ); addMenu( P_MANAGEDATA , tr( "Manage &Data" ), database ); addMenu( P_MANAGESOLN , tr( "Manage &Solutions" ), database ); addMenu( P_MANAGEPROJ , tr( "Manage &Projects" ), database ); addMenu( P_MANAGEROTOR , tr( "Manage &Rotors" ), database ); /////////////// QMenu* help = new QMenu( tr( "&Help" ), this ); addMenu( HELP_HOME , tr("UltraScan &Home" ), help ); addMenu( HELP , tr("UltraScan &Manual" ), help ); addMenu( HELP_REG , tr("&Register Software" ), help ); addMenu( HELP_UPGRADE, tr("&Upgrade UltraScan" ), help ); addMenu( HELP_LICENSE, tr("UltraScan &License" ), help ); addMenu( HELP_ABOUT , tr("&About" ), help ); addMenu( HELP_CREDITS, tr("&Credits" ), help ); addMenu( HELP_NOTICES, tr("Show &Notices" ), help ); #ifndef Q_OS_MAC QFont bfont = QFont( US_GuiSettings::fontFamily(), US_GuiSettings::fontSize() - 1, QFont::Bold ); menuBar()->setFont( bfont ); #endif menuBar()->addMenu( file ); menuBar()->addMenu( edit ); menuBar()->addMenu( velocity ); #ifdef EQUI_MENU menuBar()->addMenu( equilibrium ); // menuBar()->addMenu( fit ); #endif menuBar()->addMenu( utilities ); menuBar()->addMenu( multiwave ); menuBar()->addMenu( simulation ); menuBar()->addMenu( database ); menuBar()->addMenu( help ); #ifndef Q_OS_MAC QFont mfont = QFont( US_GuiSettings::fontFamily(), US_GuiSettings::fontSize() - 1, QFont::Normal ); file ->setFont( mfont ); edit ->setFont( mfont ); velocity ->setFont( mfont ); #ifdef EQUI_MENU equilibrium->setFont( mfont ); // fit ->setFont( mfont ); #endif utilities ->setFont( mfont ); multiwave ->setFont( mfont ); simulation ->setFont( mfont ); database ->setFont( mfont ); help ->setFont( mfont ); #endif splash(); statusBar()->showMessage( tr( "Ready" ) ); notice_check(); // Check for any notices pending }
MessageListWidget::MessageListWidget(QWidget *parent) : QWidget(parent), m_supportsFuzzySearch(false) { tree = new MsgListView(this); m_quickSearchText = new LineEdit(this); #if QT_VERSION >= 0x040700 m_quickSearchText->setPlaceholderText(tr("Quick Search / Leading \":=\" for direct IMAP search")); #endif m_queryPlaceholder = tr("<query>"); connect(m_quickSearchText, SIGNAL(returnPressed()), this, SLOT(slotApplySearch())); connect(m_quickSearchText, SIGNAL(textChanged(QString)), this, SLOT(slotConditionalSearchReset())); connect(m_quickSearchText, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(slotUpdateSearchCursor())); m_searchOptions = new QToolButton(this); m_searchOptions->setAutoRaise(true); m_searchOptions->setPopupMode(QToolButton::InstantPopup); m_searchOptions->setText("*"); m_searchOptions->setIcon(loadIcon(QLatin1String("imap-search-details"))); QMenu *optionsMenu = new QMenu(m_searchOptions); m_searchFuzzy = optionsMenu->addAction(tr("Fuzzy Search")); m_searchFuzzy->setCheckable(true); optionsMenu->addSeparator(); m_searchInSubject = optionsMenu->addAction(tr("Subject")); m_searchInSubject->setCheckable(true); m_searchInSubject->setChecked(true); m_searchInBody = optionsMenu->addAction(tr("Body")); m_searchInBody->setCheckable(true); m_searchInSenders = optionsMenu->addAction(tr("Senders")); m_searchInSenders->setCheckable(true); m_searchInSenders->setChecked(true); m_searchInRecipients = optionsMenu->addAction(tr("Recipients")); m_searchInRecipients->setCheckable(true); optionsMenu->addSeparator(); QMenu *complexMenu = new QMenu(tr("Complex IMAP query"), optionsMenu); connect(complexMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotComplexSearchInput(QAction*))); complexMenu->addAction(tr("Not ..."))->setData("NOT " + m_queryPlaceholder); complexMenu->addAction(tr("Either... or..."))->setData("OR " + m_queryPlaceholder + " " + m_queryPlaceholder); complexMenu->addSeparator(); complexMenu->addAction(tr("From sender"))->setData("FROM " + m_queryPlaceholder); complexMenu->addAction(tr("To receiver"))->setData("TO " + m_queryPlaceholder); complexMenu->addSeparator(); complexMenu->addAction(tr("About subject"))->setData("SUBJECT " + m_queryPlaceholder); complexMenu->addAction(tr("Message contains ..."))->setData("BODY " + m_queryPlaceholder); complexMenu->addSeparator(); complexMenu->addAction(tr("Before date"))->setData("BEFORE <d-mmm-yyyy>"); complexMenu->addAction(tr("Since date"))->setData("SINCE <d-mmm-yyyy>"); complexMenu->addSeparator(); complexMenu->addAction(tr("Has been seen"))->setData("SEEN"); optionsMenu->addMenu(complexMenu); m_searchOptions->setMenu(optionsMenu); connect (optionsMenu, SIGNAL(aboutToShow()), SLOT(slotDeActivateSimpleSearch())); delete m_quickSearchText->layout(); QHBoxLayout *hlayout = new QHBoxLayout(m_quickSearchText); hlayout->setContentsMargins(0, 0, 0, 0); hlayout->addWidget(m_searchOptions); hlayout->addStretch(); hlayout->addWidget(m_quickSearchText->clearButton()); hlayout->activate(); // this processes the layout and ensures the toolbutton has it's final dimensions #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if (QGuiApplication::isLeftToRight()) #else if (qApp->keyboardInputDirection() == Qt::LeftToRight) #endif m_quickSearchText->setTextMargins(m_searchOptions->width(), 0, 0, 0); else // ppl. in N Africa and the middle east write the wrong direction... m_quickSearchText->setTextMargins(0, 0, m_searchOptions->width(), 0); m_searchOptions->setCursor(Qt::ArrowCursor); // inherits I-Beam from lineedit otherwise QVBoxLayout *layout = new QVBoxLayout(this); layout->setSpacing(0); layout->addWidget(m_quickSearchText); layout->addWidget(tree); m_searchResetTimer = new QTimer(this); m_searchResetTimer->setSingleShot(true); connect(m_searchResetTimer, SIGNAL(timeout()), SLOT(slotApplySearch())); slotAutoEnableDisableSearch(); }