class Actions(actioncollection.ActionCollection): name = "pitch" def createActions(self, parent): self.pitch_language = QAction(parent) self.pitch_rel2abs = QAction(parent) self.pitch_abs2rel = QAction(parent) self.pitch_transpose = QAction(parent) self.pitch_modal_transpose = QAction(parent) self.pitch_language.setIcon(icons.get('tools-pitch-language')) self.pitch_transpose.setIcon(icons.get('tools-transpose')) self.pitch_modal_transpose.setIcon(icons.get('tools-transpose')) def translateUI(self): self.pitch_language.setText(_("Pitch Name &Language")) self.pitch_language.setToolTip(_( "Change the LilyPond language used for pitch names " "in this document or in the selection.")) self.pitch_rel2abs.setText(_("Convert Relative to &Absolute")) self.pitch_rel2abs.setToolTip(_( "Converts the notes in the document or selection from relative to " "absolute pitch.")) self.pitch_abs2rel.setText(_("Convert Absolute to &Relative")) self.pitch_abs2rel.setToolTip(_( "Converts the notes in the document or selection from absolute to " "relative pitch.")) self.pitch_transpose.setText(_("&Transpose...")) self.pitch_transpose.setToolTip(_( "Transposes all notes in the document or selection.")) self.pitch_modal_transpose.setText(_("&Modal Transpose...")) self.pitch_modal_transpose.setToolTip(_( "Transposes all notes in the document or selection within a given mode."))
class Actions(actioncollection.ActionCollection): name = "sidebar" def createActions(self, parent): self.view_linenumbers = QAction(parent, checkable=True) def translateUI(self): self.view_linenumbers.setText(_("&Line Numbers"))
def aAddAction_triggered(self): index = self.tvActions.selectionModel().selectedIndexes()[0] path = '' if index.isValid(): action = mActionsModel.action( index ); if action.menu(): path = mActionsModel.path(action).split('/')[:-2] else: path = mActionsModel.path() if path: path += '/' path = QInputDialog.getText( self, '', self.tr( "Enter the full path where to add " + "the action (/some/path/to/add/the/actionName):" ), QLineEdit.Normal, path ) if not "/" in path or path.replace("/", '').trim().isEmpty(): return action = QAction( self ) action.setText(path.split('/')[-1]) if not self.mActionsModel.addAction( path, action ) : del action QMessageBox.information( self, '', self.tr( "Can't add action to '%s' % path" ))
def create_exampleActs(self): """ Create Actions to open example files """ exdir = None self.menuExamples.menuAction().setVisible(False) bpath = sys.path[0] + os.sep for p in ['../share/openscadpy/examples', '../../share/openscadpy/examples', '../../examples','../examples','examples']: exdir = bpath + p if os.access(exdir, os.R_OK ): break else: exdir = None if not exdir: return for e in sorted(os.listdir(exdir)): if e[-3:] == '.py': fname = exdir + os.sep + e a = QAction(self) QtCore.QObject.connect(a, QtCore.SIGNAL(_fromUtf8("triggered()")), self.on_open_menu_file) a.setText(e) a.setData(fname) self.menuExamples.addAction(a) self.menuExamples.menuAction().setVisible(True)
class Actions(actioncollection.ActionCollection): name = "pitch" def createActions(self, parent): self.pitch_language = QAction(parent) self.pitch_rel2abs = QAction(parent) self.pitch_abs2rel = QAction(parent) self.pitch_transpose = QAction(parent) self.pitch_modal_transpose = QAction(parent) self.pitch_language.setIcon(icons.get('tools-pitch-language')) self.pitch_transpose.setIcon(icons.get('tools-transpose')) self.pitch_modal_transpose.setIcon(icons.get('tools-transpose')) def translateUI(self): self.pitch_language.setText(_("Pitch Name &Language")) self.pitch_language.setToolTip( _("Change the LilyPond language used for pitch names " "in this document or in the selection.")) self.pitch_rel2abs.setText(_("Convert Relative to &Absolute")) self.pitch_rel2abs.setToolTip( _("Converts the notes in the document or selection from relative to " "absolute pitch.")) self.pitch_abs2rel.setText(_("Convert Absolute to &Relative")) self.pitch_abs2rel.setToolTip( _("Converts the notes in the document or selection from absolute to " "relative pitch.")) self.pitch_transpose.setText(_("&Transpose...")) self.pitch_transpose.setToolTip( _("Transposes all notes in the document or selection.")) self.pitch_modal_transpose.setText(_("&Modal Transpose...")) self.pitch_modal_transpose.setToolTip( _("Transposes all notes in the document or selection within a given mode." ))
class Interpreter(MDockWidget): def __init__(self, mainWindow=None): MDockWidget.__init__(self, mainWindow) self.__mainWindow = mainWindow self.icon = QIcon(":interpreter.png") self.addAction(mainWindow) self.g_display() def g_display(self): self.setWidget(InterpreterView(self)) self.setWindowTitle(QApplication.translate("Interpreter", "Interpreter", None, QApplication.UnicodeUTF8)) def addAction(self, mainWindow): self.__action = QAction(self) self.__action.setCheckable(True) self.__action.setChecked(True) self.__action.setObjectName("actionCoreInformations") self.__action.setText(QApplication.translate("MainWindow", "DFF interpreter", None, QApplication.UnicodeUTF8)) mainWindow.menuWindow.addAction(self.__action) self.connect(self.__action, SIGNAL("triggered()"), self.changeVisibleInformations) def changeVisibleInformations(self): if not self.isVisible() : self.setVisible(True) self.__action.setChecked(True) else : self.setVisible(False) self.__action.setChecked(False)
def setupLanguageMenu(self): self.languages = QDir(":/languages").entryList() if self.current_language is None: self.current_language = QLocale.system().name( ) # Retrieve Current Locale from the operating system. log.debug("Detected user's locale as %s" % self.current_language) for language in self.languages: translator = QTranslator( ) # Create a translator to translate Language Display Text. translator.load(":/languages/%s" % language) language_display_text = translator.translate( "Translation", "Language Display Text") languageAction = QAction(self) languageAction.setCheckable(True) languageAction.setText(language_display_text) languageAction.setData(language) self.menuLanguage.addAction(languageAction) self.langActionGroup.addAction(languageAction) if self.current_language == str(language).strip("tr_").rstrip( ".qm"): languageAction.setChecked(True)
def _addToRecents(self, connString): # do nothing if there is no connection string if not connString: return # action to add to the menu action = None # check if the connection string is already in the list for oldAction in self.menuRecent.actions(): if oldAction.text() == connString: # if it is found, remove it from the list and use it as action to add action = oldAction self.menuRecent.removeAction(action) break # if the action was not found in the menu, create a new one if action is None: action = QAction(self) action.setText(connString) QObject.connect(action, SIGNAL("triggered()"), self.openRecentDatabase) # if the menu is not empty if self.menuRecent.actions(): # add the action at the beginning of the list self.menuRecent.insertAction(self.menuRecent.actions()[0], action) # and remove the entries exceeding the maximum while len(self.menuRecent.actions()) > self.maxRecentEntries: self.menuRecent.removeAction(self.menuRecent.actions()[-1]) else: # otherwise just add the action self.menuRecent.addAction(action)
class Actions(actioncollection.ActionCollection): name = "engrave" def createActions(self, parent=None): self.engrave_sticky = QAction(parent) self.engrave_sticky.setCheckable(True) self.engrave_runner = QAction(parent) self.engrave_preview = QAction(parent) self.engrave_publish = QAction(parent) self.engrave_custom = QAction(parent) self.engrave_abort = QAction(parent) self.engrave_preview.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_M)) self.engrave_publish.setShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_P)) self.engrave_custom.setShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_M)) self.engrave_abort.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Pause)) self.engrave_sticky.setIcon(icons.get('pushpin')) self.engrave_preview.setIcon(icons.get('lilypond-run')) self.engrave_publish.setIcon(icons.get('lilypond-run')) self.engrave_custom.setIcon(icons.get('lilypond-run')) self.engrave_abort.setIcon(icons.get('process-stop')) def translateUI(self): self.engrave_runner.setText(_("Engrave")) self.engrave_preview.setText(_("&Engrave (preview)")) self.engrave_publish.setText(_("Engrave (&publish)")) self.engrave_custom.setText(_("Engrave (&custom)...")) self.engrave_abort.setText(_("Abort Engraving &Job"))
class QTrayIcon(QSystemTrayIcon, auxilia.Actions): def __init__(self, icon, parent): QSystemTrayIcon.__init__(self, icon, parent) self.parent = parent self.pauseIcon = auxilia.PIcon("media-playback-pause") self.startIcon = auxilia.PIcon("media-playback-start") self.actionList = [] self.menu = QMenu('Pythagora MPD client', parent) self.menu.addAction(menuTitle(icon, 'Pythagora', parent)) self.setContextMenu(self.menu) self.hideResoreAction = QAction('Minimize', self.menu) self.connect(self.hideResoreAction, SIGNAL('triggered()'), self.__activated) self.connect( self, SIGNAL('activated(QSystemTrayIcon::ActivationReason)'), self.__activated) self.connect(self.menu, SIGNAL('aboutToShow()'), self.__buildMenu) self.show() def addMenuItem(self, action): self.actionList.append(action) def setState(self, state): if state == 'play': self.setIcon(self.startIcon) else: self.setIcon(self.pauseIcon) def setToolTip(self, iconPath, text): super(QTrayIcon, self).setToolTip( 'Pythagora, Now Playing:<br>%s' % text) def __activated(self, reason=None): if reason == QSystemTrayIcon.MiddleClick: self.emit(SIGNAL('secondaryActivateRequested(QPoint)'), QPoint()) if reason == None or reason == QSystemTrayIcon.Trigger: self.emit(SIGNAL('activate()')) def __buildMenu(self): if self.parent.isVisible(): self.hideResoreAction.setText('Minimize') else: self.hideResoreAction.setText('Restore') for action in self.actionList: self.menu.addAction(action) self.menu.addSeparator() self.menu.addAction(self.hideResoreAction) self.menu.addAction(self.parent.actionExit) def event(self, event): if event.type() == 31: # enum: QEvent.wheel event.accept() self.emit(SIGNAL('scrollRequested(int, Qt::Orientation)'), event.delta(), Qt.Horizontal) return True else: super(QTrayIcon, self).event(event) return False
class Actions(actioncollection.ActionCollection): name = "file_export" def createActions(self, parent): self.export_musicxml = QAction(parent) def translateUI(self): self.export_musicxml.setText(_("Export Music&XML...")) self.export_musicxml.setToolTip(_("Export current document as MusicXML."))
class Actions(actioncollection.ActionCollection): name = "file_import" def createActions(self, parent): self.import_musicxml = QAction(parent) def translateUI(self): self.import_musicxml.setText(_("Import MusicXML...")) self.import_musicxml.setToolTip(_("Import a MusicXML file using musicxml2ly."))
def createAction(self, model): """ @type model: ButtonModelMixin""" action = QAction(self.button) action.setText(model.getButtonName()) action.setEnabled(model.buttonIsEnabled()) action.triggered.connect(model.buttonTriggered) model.observable().attach(ButtonModelMixin.BUTTON_STATE_CHANGED_EVENT, self.modelChanged) self.models[model] = action return action
class Actions(actioncollection.ActionCollection): name = "matchingpair" def createActions(self, parent): self.view_matching_pair = QAction(parent) self.view_matching_pair_select = QAction(parent) def translateUI(self): self.view_matching_pair.setText(_("Matching Pai&r")) self.view_matching_pair_select.setText(_("&Select Matching Pair"))
class Actions(actioncollection.ActionCollection): name = 'scorewiz' def createActions(self, parent=None): self.scorewiz = QAction(parent) self.scorewiz.setIcon(icons.get("tools-score-wizard")) self.scorewiz.setShortcut(QKeySequence("Ctrl+Shift+N")) def translateUI(self): self.scorewiz.setText(_("Setup New Score..."))
class Actions(actioncollection.ActionCollection): name = "file_import" def createActions(self, parent): self.import_musicxml = QAction(parent) def translateUI(self): self.import_musicxml.setText(_("Import MusicXML...")) self.import_musicxml.setToolTip( _("Import a MusicXML file using musicxml2ly."))
def action(filename): url = QUrl.fromLocalFile(filename) a = QAction(menu) a.setText(_("Open \"{url}\"").format(url=util.homify(filename))) a.setIcon(icons.get('document-open')) @a.triggered.connect def open_doc(): d = mainwindow.openUrl(url) mainwindow.setCurrentDocument(d) return a
class Actions(actioncollection.ActionCollection): name = 'autocomplete' def createActions(self, parent): self.autocomplete = QAction(parent, checkable=True) self.popup_completions = QAction(parent) self.popup_completions.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Space)) def translateUI(self): self.autocomplete.setText(_("Automatic &Completion")) self.popup_completions.setText(_("Show C&ompletions Popup"))
class Actions(actioncollection.ActionCollection): name = 'scorewiz' def createActions(self, parent=None): self.scorewiz = QAction(parent) self.scorewiz.setIcon(icons.get("tools-score-wizard")) self.scorewiz.setShortcut(QKeySequence("Ctrl+Shift+N")) self.scorewiz.setMenuRole(QAction.NoRole) def translateUI(self): self.scorewiz.setText(_("Score &Wizard..."))
class QTrayIcon(QSystemTrayIcon, auxilia.Actions): def __init__(self, icon, parent): QSystemTrayIcon.__init__(self, QIcon(icon), parent) self.parent = parent self.pauseIcon = auxilia.PIcon("media-playback-pause") self.startIcon = auxilia.PIcon("media-playback-start") self.actionList = [] self.menu = QMenu('Pythagora MPD client', parent) self.menu.addAction(menuTitle(QIcon(icon), 'Pythagora', parent)) self.setContextMenu(self.menu) self.hideResoreAction = QAction('Minimize', self.menu) self.connect(self.hideResoreAction, SIGNAL('triggered()'), self.__activated) self.connect(self, SIGNAL('activated(QSystemTrayIcon::ActivationReason)'), self.__activated) self.connect(self.menu, SIGNAL('aboutToShow()'), self.__buildMenu) self.show() def addMenuItem(self, action): self.actionList.append(action) def setState(self, state): if state == 'play': self.setIcon(self.startIcon) else: self.setIcon(self.pauseIcon) def setToolTip(self, iconPath, text): super(QTrayIcon, self).setToolTip('Pythagora, Now Playing:<br>%s' % text) def __activated(self, reason=None): if reason == QSystemTrayIcon.MiddleClick: self.emit(SIGNAL('secondaryActivateRequested(QPoint)'), QPoint()) if reason == None or reason == QSystemTrayIcon.Trigger: self.emit(SIGNAL('activate()')) def __buildMenu(self): if self.parent.isVisible(): self.hideResoreAction.setText('Minimize') else: self.hideResoreAction.setText('Restore') for action in self.actionList: self.menu.addAction(action) self.menu.addSeparator() self.menu.addAction(self.hideResoreAction) self.menu.addAction(self.parent.actionExit) def event(self, event): if event.type() == 31: # enum: QEvent.wheel event.accept() self.emit(SIGNAL('scrollRequested(int, Qt::Orientation)'), event.delta(), Qt.Horizontal) return True else: super(QTrayIcon, self).event(event) return False
def createActions(actions, target): # actions = [(name, shortcut, icon, desc, func)] for name, shortcut, icon, desc, func in actions: action = QAction(target) if icon: action.setIcon(QIcon(QPixmap(':/' + icon))) if shortcut: action.setShortcut(shortcut) action.setText(desc) action.triggered.connect(func) setattr(target, name, action)
class Actions(actioncollection.ActionCollection): name = "file_export" def createActions(self, parent): self.export_musicxml = QAction(parent) self.export_audio = QAction(parent) def translateUI(self): self.export_musicxml.setText(_("Export Music&XML...")) self.export_musicxml.setToolTip(_("Export current document as MusicXML.")) self.export_audio.setText(_("Export Audio...")) self.export_audio.setToolTip(_("Export to different audio formats."))
def action(filename): url = QUrl.fromLocalFile(filename) a = QAction(menu) a.setText(_("Open \"{url}\"").format(url=util.homify(filename))) a.setIcon(icons.get('document-open')) @a.triggered.connect def open_doc(): d = mainwindow.openUrl(url) browseriface.get(mainwindow).setCurrentDocument(d) return a
class Actions(actioncollection.ActionCollection): name = "logtool" def createActions(self, parent=None): self.log_next_error = QAction(parent) self.log_previous_error = QAction(parent) self.log_next_error.setShortcut(QKeySequence("Ctrl+E")) self.log_previous_error.setShortcut(QKeySequence("Ctrl+Shift+E")) def translateUI(self): self.log_next_error.setText(_("Next Error Message")) self.log_previous_error.setText(_("Previous Error Message"))
def readSettings(self): settings = QSettings() settings.beginGroup("MainWindow") self.resize(settings.value("Size", QVariant(QSize(965, 655))).toSize()) self.move(settings.value("Pos", QVariant(QPoint(0, 0))).toPoint()) settings.endGroup() settings.beginGroup("BrowsePanel") self.browsePanel.setVisible(settings.value("Visible", QVariant(True)).toBool()) self.browsePanel.setFloating(settings.value("Floating", QVariant(False)).toBool()) self.browsePanel.resize(settings.value("Size", QVariant(QSize(250, 655))).toSize()) self.browsePanel.move(settings.value("Pos", QVariant(QPoint(0, 0))).toPoint()) settings.endGroup() settings.beginGroup("FilterPanel") self.filterPanel.setVisible(settings.value("Visible", QVariant(True)).toBool()) self.filterPanel.setFloating(settings.value("Floating", QVariant(False)).toBool()) self.filterPanel.resize(settings.value("Size", QVariant(QSize(270, 655))).toSize()) self.filterPanel.move(settings.value("Pos", QVariant(QPoint(0, 0))).toPoint()) settings.endGroup() settings.beginGroup("DataView") self.dataView.setFixedWidthFont(settings.value("FixedWidthFont", QVariant(False)).toBool()) settings.endGroup() settings.beginGroup("FindDialog") d = self.dataView.findDialog d.setVisible(settings.value("Visible", QVariant(False)).toBool()) d.move(settings.value("Pos", QVariant(QPoint(0, 0))).toPoint()) # Note: QVariant.toInt returns a tuple with the result of the conversion # and a boolean for the successful conversion d.setFindFlags(settings.value("Flags", QVariant(0)).toInt()[0]) d.setWrappedSearch(settings.value("WrappedSearch", QVariant(True)).toBool()) settings.endGroup() self.iovUTCCheckBox.setChecked(settings.value("IOVs/UTC", QVariant(True)).toBool()) size = settings.beginReadArray("Recent") for i in range(size): settings.setArrayIndex(i) conn = settings.value("ConnString").toString() action = QAction(self) action.setText(conn) QObject.connect(action, SIGNAL("triggered()"), self.openRecentDatabase) self.menuRecent.addAction(action) settings.endArray() settings.beginGroup("Misc") self._showWelcome = settings.value("ShowWelcome", QVariant(True)).toBool() self._externalEditor = str(settings.value("ExternalEditor", QVariant("emacs")).toString()) settings.endGroup()
class Actions(actioncollection.ActionCollection): name = 'scorewiz' def createActions(self, parent=None): self.scorewiz = QAction(parent) self.scorewiz.setIcon(icons.get("tools-score-wizard")) self.scorewiz.setShortcut(QKeySequence("Ctrl+Shift+N")) self.newwithwiz = QAction(parent) self.newwithwiz.setIcon(icons.get("tools-score-wizard")) self.scorewiz.setMenuRole(QAction.NoRole) def translateUI(self): self.scorewiz.setText(_("Setup New Score (in current document)...")) self.newwithwiz.setText(_("New Score with &Wizard..."))
class puPlugin(object): """The main class of the PU Plugin.""" def __init__(self, iface): """Constructor. Args: iface (QgisInterface): A reference to the QgisInterface. """ self.iface = iface self.name = u'PU Plugin' self.pluginDir = QDir(os.path.dirname(__file__)) def initGui(self): """Initializes GUI.""" self.puAction = QAction(self.iface.mainWindow()) self.puAction.setText(self.name) puIcon = QIcon(self.pluginDir.filePath(u'puplugin.svg')) self.puAction.setIcon(puIcon) self.puAction.triggered.connect(self.run) self.iface.addToolBarIcon(self.puAction) self.iface.addPluginToMenu(self.name, self.puAction) self.dockWidget = dockwidget.DockWidget( self.iface, self.pluginDir, self.name) self.iface.addDockWidget(Qt.TopDockWidgetArea, self.dockWidget) def unload(self): """Removes the plugin menu and icon.""" self.dockWidget.disconnect_from_iface() self.iface.removePluginMenu(self.name, self.puAction) self.iface.removeToolBarIcon(self.puAction) self.iface.removeDockWidget(self.dockWidget) def run(self): """Shows the dockWidget if not visible, otherwise hides it.""" if not self.dockWidget.isVisible(): self.dockWidget.show() else: self.dockWidget.hide()
class Actions(actioncollection.ActionCollection): name = "midiinputtool" def createActions(self, parent=None): self.capture_start = QAction(parent) self.capture_stop = QAction(parent) self.capture_start.setIcon(icons.get('media-record')) self.capture_stop.setIcon(icons.get('process-stop')) def translateUI(self): self.capture_start.setText(_("midi input", "Start MIDI capturing")) self.capture_start.setToolTip(_("midi input", "Start MIDI capturing")) self.capture_stop.setText(_("midi input", "Stop MIDI capturing")) self.capture_stop.setToolTip(_("midi input", "Stop MIDI capturing"))
class Actions(actioncollection.ActionCollection): name = "midiinputtool" def createActions(self, parent=None): self.capture_start = QAction(parent) self.capture_stop = QAction(parent) self.capture_start.setIcon(icons.get('media-record')) self.capture_stop.setIcon(icons.get('process-stop')) def translateUI(self): self.capture_start.setText(_("midi input", "Start capturing")) self.capture_start.setToolTip(_("midi input", "Start MIDI capturing")) self.capture_stop.setText(_("midi input", "Stop capturing")) self.capture_stop.setToolTip(_("midi input", "Stop MIDI capturing"))
def _on_header_menu(self, point): menu = QMenu() for index, title in enumerate(self.model().header): action = QAction(self) action.setData(index) action.setText(title) action.setCheckable(True) action.setChecked(False if self.isColumnHidden(index) else True) action.triggered.connect(self._on_header_menu_action) menu.addAction(action) menu.popup(self.mapToGlobal(point)) menu.exec_()
def updateRecentFiles(self): for a in self._recent_projects_act: self._projects_mapper.removeMappings(a) del self._recent_projects_act[:] menu = self._recent_projects_menu menu.clear() recent_projects = parameters.instance.recent_projects for i, p in enumerate(recent_projects): act = QAction(self) act.setText("&{0:d} {1}".format(i + 1, p)) self._recent_projects_act.append(act) act.triggered.connect(self._projects_mapper.map) self._projects_mapper.setMapping(act, i) menu.addAction(act)
def updateMenu(self, menu, index): tree = self.uiRecordTREE first_action = menu.actions()[1] column = tree.columnOf(index) enable_action = QAction(menu) enable_action.setText('Enable Grouping') disable_action = QAction(menu) disable_action.setText('Disable Grouping') quick_action = QAction(menu) quick_action.setText('Group by "%s"' % column) adv_action = QAction(menu) adv_action.setText('More Grouping Options...') menu.insertSeparator(first_action) menu.insertAction(first_action, enable_action) menu.insertAction(first_action, disable_action) menu.insertSeparator(first_action) menu.insertAction(first_action, quick_action) menu.insertAction(first_action, adv_action) quick_action.triggered.connect(self.groupByHeaderIndex) adv_action.triggered.connect(self.showAdvancedGroupingOptions) enable_action.triggered.connect(self.enableGrouping) disable_action.triggered.connect(self.disableGrouping)
class Actions(actioncollection.ActionCollection): name = "miditool" def createActions(self, parent=None): self.midi_pause = QAction(parent) self.midi_play = QAction(parent) self.midi_stop = QAction(parent) self.midi_restart = QAction(parent) try: self.midi_pause.setShortcut(QKeySequence(Qt.Key_MediaPause)) except AttributeError: pass # No Qt.Key_MediaPause in some PyQt4 versions self.midi_play.setShortcut(QKeySequence(Qt.Key_MediaPlay)) self.midi_stop.setShortcut(QKeySequence(Qt.Key_MediaStop)) self.midi_restart.setShortcut(QKeySequence(Qt.Key_MediaPrevious)) self.midi_pause.setIcon(icons.get('media-playback-pause')) self.midi_play.setIcon(icons.get('media-playback-start')) self.midi_stop.setIcon(icons.get('media-playback-stop')) self.midi_restart.setIcon(icons.get('media-skip-backward')) def translateUI(self): self.midi_pause.setText(_("midi player", "Pause")) self.midi_play.setText(_("midi player", "Play")) self.midi_stop.setText(_("midi player", "Stop")) self.midi_restart.setText(_("midi player", "Restart"))
class NewLayersToTheTop: def __init__(self, iface): self.iface = iface self.settings = QSettings() def initGui(self): icon = QIcon() icon.addFile(":/plugins/NewLayersToTheTop/default.png", state=QIcon.Off) icon.addFile(":/plugins/NewLayersToTheTop/toTheTop.png", state=QIcon.On) self.action = QAction(icon, u"", self.iface.mainWindow()) self.action.toggled.connect(self.run) self.action.setCheckable(True) checked = self.settings.value("/NewLayersToTheTop/checked", True, type=bool) self.action.setChecked(checked) self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu(u"New layers to the &top", self.action) def unload(self): self.iface.removePluginMenu(u"New layers to the &top", self.action) self.iface.removeToolBarIcon(self.action) if self.action.isChecked(): QgsMapLayerRegistry.instance().layersAdded.disconnect( self.changeLayerAdditionMode) def run(self): checked = self.action.isChecked() if checked: self.action.setText( u"Click to make new layers to be added to the selected group") QgsMapLayerRegistry.instance().layersAdded.connect( self.changeLayerAdditionMode) self.settings.setValue("/NewLayersToTheTop/checked", True) #self.iface.messageBar().pushMessage( "'New layers to the top' (plugin)", u'From now on, new layers will be added to the top of the tree,', 0, 5 ) else: self.action.setText( u"Click to make new layers to be added to the top of the tree") QgsMapLayerRegistry.instance().layersAdded.disconnect( self.changeLayerAdditionMode) self.settings.setValue("/NewLayersToTheTop/checked", False) #self.iface.messageBar().pushMessage( "'New layers to the top' (plugin)", u'From now on, new layers will be added to the selected group.', 0, 5 ) def changeLayerAdditionMode(self, layers): QgsProject.instance().layerTreeRegistryBridge().setLayerInsertionPoint( QgsProject.instance().layerTreeRoot(), 0)
def load_application_sync(self): print "Load application sync" providers = list(roam.syncing.syncprovders()) if not providers: return actionwidget = ActionPickerWidget() actionwidget.setTile("Roam Syncing") for provider in providers: action = QAction(None) action.setText(provider.name) action.setIcon(QIcon(":/icons/sync")) action.triggered.connect(partial(self.run, action, provider)) actionwidget.addAction(action) self.syncwidgets.layout().addWidget(actionwidget)
def setDefaultDatabases(self, connStrings): self.menuStandard.clear() self.defaultDatabases = {} names = connStrings.keys() names.sort() for name in names: conn = connStrings[name] action = QAction(self) action.setText(name) action.setData(QVariant(conn)) action.setStatusTip(conn) QObject.connect(action, SIGNAL("triggered()"), self.openStandardDatabase) self.menuStandard.addAction(action) self.defaultDatabases[name] = action self.menuStandard.setEnabled(not self.menuStandard.isEmpty())
class KTrayIcon(KStatusNotifierItem): actionList = [] def __init__(self, icon, parent): KStatusNotifierItem.__init__(self, parent) self.setStandardActionsEnabled(False) self.connect(self.contextMenu(), SIGNAL('aboutToShow()'), self.__buildMenu) self.actionQuit = KStandardAction.quit(parent.app, SLOT("quit()"), self) self.hideResoreAction = QAction('Minimize', self.contextMenu()) self.connect(self.hideResoreAction, SIGNAL('triggered()'), SIGNAL("activate()")) self.icon = icon self.parent = parent self.setIconByPixmap(icon) self.setCategory(1) self.setStatus(2) def addMenuItem(self, action): self.actionList.append(action) def setState(self, state): if state == 'play': self.setIconByName("media-playback-start") else: self.setIconByName("media-playback-pause") def setToolTip(self, iconPath, text): if not iconPath: iconPath = self.icon super(KTrayIcon, self).setToolTip(iconPath, 'Pythagora, Now Playing:', text) def activate(self, pos): self.emit(SIGNAL('activate()')) def __buildMenu(self): if self.parent.isVisible(): self.hideResoreAction.setText('Minimize') else: self.hideResoreAction.setText('Restore') for action in self.actionList: self.contextMenu().addAction(action) self.contextMenu().addSeparator() self.contextMenu().addAction(self.hideResoreAction) self.contextMenu().addAction(self.actionQuit)
def loadprojects(self, projects): #root = self.synctree.invisibleRootItem() for project in projects: providers = list(project.syncprovders()) if not providers: continue actionwidget = ActionPickerWidget() actionwidget.setTile(project.name) for provider in providers: action = QAction(None) action.setText(provider.name) action.setIcon(QIcon(":/icons/sync")) action.triggered.connect(partial(self.run, action, provider)) actionwidget.addAction(action) self.syncwidgets.layout().addWidget(actionwidget)
def __createMenu(self): menu = self.menuBar() ## About Menu ---------------------------------------- aboutMenu = menu.addMenu(MainWindow.ABOUT_MENU) versionAction = QAction(menu) versionAction.setText(MainWindow.VERSION_MENU) versionAction.triggered.connect(self.__showAbout) aboutMenu.addAction(versionAction) ## Shutdown Menu ----------------------------------------- #shutdownMenu = menu.addMenu(MainWindow.SHUTDOWN_MENU) if ADD_PATTERN_ENABLED: newPatternAction = QAction(menu) newPatternAction.setText(MainWindow.ADD_MENU) newPatternAction.triggered.connect(self.__addPattern) deletePatternAction = QAction(menu) deletePatternAction.setText(MainWindow.DELETE_MENU) deletePatternAction.triggered.connect(self.__deletePattern) #shutdownMenu.addAction(newPatternAction) #shutdownMenu.addAction(deletePatternAction) #shutdownAction = QAction(menu) #shutdownAction.setText(MainWindow.SHUTDOWN_MENU) #shutdownAction.triggered.connect(self.__shutdown) #shutdownMenu.addAction(shutdownAction) ## Soft Exit Menu ------------------------------------ helpMenu = menu.addMenu(MainWindow.HELP_MENU) softExitAction = QAction(menu) softExitAction.setText(MainWindow.SOFT_EXIT) softExitAction.triggered.connect(self.__exit) helpMenu.addAction(softExitAction) if PHONE_HOME_ENABLED: phoneHomeAction = QAction(menu) phoneHomeAction.setText(MainWindow.PHONE_HOME) softExitAction.triggered.connect(self.__phoneHome) helpMenu.addAction(phoneHomeAction)
class Actions(actioncollection.ActionCollection): name = "browseriface" def createActions(self, parent): self.go_back = QAction(parent) self.go_forward = QAction(parent) self.go_back.setIcon(icons.get('go-previous')) self.go_forward.setIcon(icons.get('go-next')) self.go_back.setShortcut(QKeySequence(Qt.ALT + Qt.Key_Backspace)) self.go_forward.setShortcut(QKeySequence(Qt.ALT + Qt.Key_End)) def translateUI(self): self.go_back.setText(_("Go to previous position")) self.go_back.setIconText(_("Back")) self.go_forward.setText(_("Go to next position")) self.go_forward.setIconText(_("Forward"))
def __createLanguageOptions(self): """Creates the language selection in the menubar. """ self.langGroup = QActionGroup(self) self.langGroup.setExclusive(True) self.langGroup.triggered['QAction*'].connect(self.languageChanged) for key, name in self.languages.iteritems(): action = QAction(self) action.setCheckable(True) action.setData(key) action.setText(name[0]) action.setStatusTip(name[1]) action.setActionGroup(self.langGroup) self.menuLanguage.addAction(action) if key == self.currentLanguage: action.setChecked(True)
def __createMenu(self): menu = self.menuBar() # File Menu ------------------------------------------ fileMenu = menu.addMenu(WorkoutTracker.FILE_MENU) addWorkoutAction = QAction(menu) addWorkoutAction.setText(WorkoutTracker.ADD_WORKOUT_MENU) addWorkoutAction.triggered.connect(self.__addWorkout) fileMenu.addAction(addWorkoutAction) ## About Menu ---------------------------------------- aboutMenu = menu.addMenu(WorkoutTracker.ABOUT_MENU) versionAction = QAction(menu) versionAction.setText(WorkoutTracker.VERSION_MENU) versionAction.triggered.connect(self.__showAbout) aboutMenu.addAction(versionAction)
def onclick(self, event): if event.inaxes and event.button == 3: # populate menu menu = QMenu(self) ac = QAction(menu) ac.setText(self.app.aw.popupadd) ac.key = ("add", event.xdata, event.ydata) menu.addAction(ac) if (self.lastMotionX and self.lastMotionY): ac = QAction(menu) ac.setText(self.app.aw.popupdelete) ac.key = ("delete", event.xdata, event.ydata) menu.addAction(ac) self.mousepress = False self.indexpoint = None # show menu menu.triggered.connect(self.event_popup_action) menu.popup(QCursor.pos())
def onclick(self,event): if event.inaxes and event.button==3: # populate menu menu = QMenu(self) ac = QAction(menu) ac.setText(self.app.aw.popupadd) ac.key = ("add",event.xdata,event.ydata) menu.addAction(ac) if (self.lastMotionX and self.lastMotionY): ac = QAction(menu) ac.setText(self.app.aw.popupdelete) ac.key = ("delete",event.xdata,event.ydata) menu.addAction(ac) self.mousepress = False self.indexpoint = None # show menu menu.triggered.connect(self.event_popup_action) menu.popup(QCursor.pos())
def setupLanguageMenu(self): self.languages = QDir(":/languages").entryList() if self.current_language is None: self.current_language = QLocale.system().name() # Retrieve Current Locale from the operating system. log.debug("Detected user's locale as %s" % self.current_language) for language in self.languages: translator = QTranslator() # Create a translator to translate Language Display Text. translator.load(":/languages/%s" % language) language_display_text = translator.translate("Translation", "Language Display Text") languageAction = QAction(self) languageAction.setCheckable(True) languageAction.setText(language_display_text) languageAction.setData(language) self.menuLanguage.addAction(languageAction) self.langActionGroup.addAction(languageAction)
def loadprojects(self, projects): #root = self.synctree.invisibleRootItem() self.load_application_sync() for project in projects: providers = list(project.syncprovders()) if not providers: continue actionwidget = ActionPickerWidget() actionwidget.setTile(project.name) for provider in providers: action = QAction(None) action.setText(provider.name) action.setIcon(QIcon(":/icons/sync")) action.triggered.connect(partial(self.run, action, provider)) actionwidget.addAction(action) self.syncwidgets.layout().addWidget(actionwidget) spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Expanding) self.syncwidgets.layout().addItem(spacerItem)