Action * PythonCommand::createAction(void) { QAction* qtAction = new QAction(0); Action *pcAction; pcAction = new Action(this, qtAction, getMainWindow()); pcAction->setShortcut(QString::fromAscii(getAccel())); applyCommandData(this->getName(), pcAction); if (strcmp(getResource("Pixmap"),"") != 0) pcAction->setIcon(Gui::BitmapFactory().iconFromTheme(getResource("Pixmap"))); try { if (isCheckable()) { pcAction->setCheckable(true); // Here the QAction must be tmp. blocked to avoid to call the 'activated' method qtAction->blockSignals(true); pcAction->setChecked(isChecked()); qtAction->blockSignals(false); } } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); } return pcAction; }
void UIMachineWindowNormal::sltHandleStatusBarConfigurationChange(const QUuid &uMachineID) { /* Skip unrelated machine IDs: */ if (vboxGlobal().managedVMUuid() != uMachineID) return; /* Check whether status-bar is enabled: */ const bool fEnabled = gEDataManager->statusBarEnabled(vboxGlobal().managedVMUuid()); /* Update settings action 'enable' state: */ QAction *pActionStatusBarSettings = actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_S_Settings); pActionStatusBarSettings->setEnabled(fEnabled); /* Update switch action 'checked' state: */ QAction *pActionStatusBarSwitch = actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility); pActionStatusBarSwitch->blockSignals(true); pActionStatusBarSwitch->setChecked(fEnabled); pActionStatusBarSwitch->blockSignals(false); /* Update status-bar visibility: */ statusBar()->setVisible(pActionStatusBarSwitch->isChecked()); /* Update status-bar indicators-pool: */ m_pIndicatorsPool->setAutoUpdateIndicatorStates(statusBar()->isVisible() && uisession()->isRunning()); /* Normalize geometry without moving: */ normalizeGeometry(false /* adjust position */); }
void UIMachineWindowNormal::sltHandleMenuBarConfigurationChange(const QUuid &uMachineID) { /* Skip unrelated machine IDs: */ if (vboxGlobal().managedVMUuid() != uMachineID) return; /* Check whether menu-bar is enabled: */ const bool fEnabled = gEDataManager->menuBarEnabled(vboxGlobal().managedVMUuid()); /* Update settings action 'enable' state: */ QAction *pActionMenuBarSettings = actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings); pActionMenuBarSettings->setEnabled(fEnabled); /* Update switch action 'checked' state: */ QAction *pActionMenuBarSwitch = actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility); pActionMenuBarSwitch->blockSignals(true); pActionMenuBarSwitch->setChecked(fEnabled); pActionMenuBarSwitch->blockSignals(false); /* Update menu-bar visibility: */ menuBar()->setVisible(pActionMenuBarSwitch->isChecked()); /* Update menu-bar: */ updateMenu(); /* Normalize geometry without moving: */ normalizeGeometry(false /* adjust position */); }
void QgsLegendLayerFile::addToPopupMenu( QMenu& theMenu, QAction* toggleEditingAction ) { QgsMapLayer* lyr = layer(); // zoom to layer extent theMenu.addAction( QgisApp::getThemeIcon( "/mActionZoomToLayer.png" ), tr( "&Zoom to layer extent" ), legend(), SLOT( legendLayerZoom() ) ); // show in overview QAction* showInOverviewAction = theMenu.addAction( tr( "&Show in overview" ), this, SLOT( showInOverview() ) ); showInOverviewAction->setCheckable( true ); showInOverviewAction->blockSignals( true ); showInOverviewAction->setChecked( mLyr.isInOverview() ); showInOverviewAction->blockSignals( false ); // remove from canvas theMenu.addAction( QgisApp::getThemeIcon( "/mActionRemove.png" ), tr( "&Remove" ), legend(), SLOT( legendLayerRemove() ) ); theMenu.addSeparator(); if ( lyr->type() == QgsMapLayer::VectorLayer ) { QgsVectorLayer* vlayer = dynamic_cast<QgsVectorLayer*>( lyr ); // attribute table theMenu.addAction( tr( "&Open attribute table" ), this, SLOT( table() ) ); // editing int cap = vlayer->dataProvider()->capabilities(); if ( cap & QgsVectorDataProvider::EditingCapabilities ) { if ( toggleEditingAction ) { theMenu.addAction( toggleEditingAction ); } } // save as shapefile theMenu.addAction( tr( "Save as shapefile..." ), this, SLOT( saveAsShapefile() ) ); QAction* saveSelectionAction = theMenu.addAction( tr( "Save selection as shapefile..." ), this, SLOT( saveSelectionAsShapefile() ) ); if ( vlayer->selectedFeatureCount() == 0 ) { saveSelectionAction->setEnabled( false ); } theMenu.addSeparator(); } else if ( lyr->type() == QgsMapLayer::RasterLayer ) { // TODO: what was this for? //QgsRasterLayer* rlayer = dynamic_cast<QgsRasterLayer*>(lyr); //theMenu.addAction(tr("&Convert to..."), rlayer, SLOT(convertTo())); } // properties goes on bottom of menu for consistency with normal ui standards // e.g. kde stuff theMenu.addAction( tr( "&Properties" ), legend(), SLOT( legendLayerShowProperties() ) ); }
void IdealController::setShowDockStatus(Qt::DockWidgetArea area, bool checked) { QAction* action = actionForArea(area); if (action->isChecked() != checked) { bool blocked = action->blockSignals(true); action->setChecked(checked); action->blockSignals(blocked); } }
void PopupMenu::clearAllChecks() const { QList<QAction*> list = actions(); for(int i = 0; i < list.size(); ++i) { QAction* act = list[i]; if(PopupMenu* menu = qobject_cast<PopupMenu*>(act->menu())) menu->clearAllChecks(); // Recursive. if(act->isCheckable()) { act->blockSignals(true); act->setChecked(false); act->blockSignals(false); } } }
bool eventFilter(QObject *o, QEvent *e) { QPanel *p = qobject_cast<QPanel*>(o); QAction *a = qce->toggleViewAction(p); if ( a ) { bool sig = a->signalsBlocked(); a->blockSignals(true); if ( a->isChecked() && e->type() == QEvent::Hide ) a->setChecked(false); else if ( !a->isChecked() && e->type() == QEvent::Show ) a->setChecked(true); a->blockSignals(sig); } return QObject::eventFilter(o, e); }
void MuseScore::showHelp(const QUrl& url) { qDebug("showHelp <%s>", qPrintable(url.toString())); if (!_helpEngine) return; QAction* a = getAction("local-help"); a->blockSignals(true); a->setChecked(true); a->blockSignals(false); if (!helpBrowser) { helpBrowser = new HelpBrowser; manualDock = new QDockWidget(tr("Manual"), 0); manualDock->setObjectName("Manual"); manualDock->setWidget(helpBrowser); Qt::DockWidgetArea area = Qt::RightDockWidgetArea; addDockWidget(area, manualDock); } manualDock->show(); helpBrowser->setContent(url); }
void QgsLegendLayer::addToPopupMenu( QMenu& theMenu ) { QgsMapLayer *lyr = layer(); QAction *toggleEditingAction = QgisApp::instance()->actionToggleEditing(); QAction *saveLayerEditsAction = QgisApp::instance()->actionSaveActiveLayerEdits(); QAction *allEditsAction = QgisApp::instance()->actionAllEdits(); // zoom to layer extent theMenu.addAction( QgsApplication::getThemeIcon( "/mActionZoomToLayer.svg" ), tr( "&Zoom to Layer Extent" ), legend(), SLOT( legendLayerZoom() ) ); if ( lyr->type() == QgsMapLayer::RasterLayer ) { theMenu.addAction( tr( "&Zoom to Best Scale (100%)" ), legend(), SLOT( legendLayerZoomNative() ) ); QgsRasterLayer *rasterLayer = qobject_cast<QgsRasterLayer *>( lyr ); if ( rasterLayer && rasterLayer->rasterType() != QgsRasterLayer::Palette ) { theMenu.addAction( tr( "&Stretch Using Current Extent" ), legend(), SLOT( legendLayerStretchUsingCurrentExtent() ) ); } } // show in overview QAction* showInOverviewAction = theMenu.addAction( tr( "&Show in Overview" ), this, SLOT( showInOverview() ) ); showInOverviewAction->setCheckable( true ); showInOverviewAction->blockSignals( true ); showInOverviewAction->setChecked( mLyr.isInOverview() ); showInOverviewAction->blockSignals( false ); // remove from canvas theMenu.addAction( QgsApplication::getThemeIcon( "/mActionRemoveLayer.svg" ), tr( "&Remove" ), QgisApp::instance(), SLOT( removeLayer() ) ); // duplicate layer QAction* duplicateLayersAction = theMenu.addAction( QgsApplication::getThemeIcon( "/mActionDuplicateLayer.svg" ), tr( "&Duplicate" ), QgisApp::instance(), SLOT( duplicateLayers() ) ); // set layer crs theMenu.addAction( QgsApplication::getThemeIcon( "/mActionSetCRS.png" ), tr( "&Set Layer CRS" ), QgisApp::instance(), SLOT( setLayerCRS() ) ); // assign layer crs to project theMenu.addAction( QgsApplication::getThemeIcon( "/mActionSetProjectCRS.png" ), tr( "Set &Project CRS from Layer" ), QgisApp::instance(), SLOT( setProjectCRSFromLayer() ) ); theMenu.addSeparator(); if ( lyr->type() == QgsMapLayer::VectorLayer ) { QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( lyr ); // attribute table theMenu.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 ) { theMenu.addAction( toggleEditingAction ); toggleEditingAction->setChecked( vlayer->isEditable() ); } if ( saveLayerEditsAction && vlayer->isModified() ) { theMenu.addAction( saveLayerEditsAction ); } } if ( allEditsAction->isEnabled() ) { theMenu.addAction( allEditsAction ); } // disable duplication of memory layers if ( vlayer->storageType() == "Memory storage" && legend()->selectedLayers().count() == 1 ) { duplicateLayersAction->setEnabled( false ); } // save as vector file theMenu.addAction( tr( "Save As..." ), QgisApp::instance(), SLOT( saveAsFile() ) ); // save selection as vector file QAction* saveSelectionAsAction = theMenu.addAction( tr( "Save Selection As..." ), QgisApp::instance(), SLOT( saveSelectionAsVectorFile() ) ); if ( vlayer->selectedFeatureCount() == 0 ) { saveSelectionAsAction->setEnabled( false ); } if ( !vlayer->isEditable() && vlayer->dataProvider()->supportsSubsetString() && vlayer->vectorJoins().isEmpty() ) theMenu.addAction( tr( "&Filter..." ), QgisApp::instance(), SLOT( layerSubsetString() ) ); //show number of features in legend if requested QAction* showNFeaturesAction = new QAction( tr( "Show Feature Count" ), &theMenu ); showNFeaturesAction->setCheckable( true ); showNFeaturesAction->setChecked( mShowFeatureCount ); QObject::connect( showNFeaturesAction, SIGNAL( toggled( bool ) ), this, SLOT( setShowFeatureCount( bool ) ) ); theMenu.addAction( showNFeaturesAction ); theMenu.addSeparator(); }