Example #1
0
    def createAction(self, text="", slot=None, shortcut=None, icon=None,
                     tip=None, checkable=False, signal="triggered()"):
        """Create action out of keyword arguments. Return action.

        Keyword arguments:
        text -- User visible text (default "")
        slot -- function to call (default None)
        shortcut -- Key sequence (default None)
        icon -- Name of icon file (default None)
        tip -- Tooltip (default None)
        checkable -- Should action be checkable (default None)
        signal -- Signal to emit (default "triggered()")

        """
        action = QAction(text, self)
        if icon is not None:
            action.setIcon(QIcon(":/resource/{0}.png".format(icon)))
        if shortcut is not None:
            action.setShortcut(shortcut)
        if tip is not None:
            action.setToolTip(tip)
            action.setStatusTip(tip)
        if slot is not None:
            self.connect(action, SIGNAL(signal), slot)
        if checkable:
            action.setCheckable(True)
        return action
Example #2
0
class Actions(actioncollection.ActionCollection):
    name = "docbrowser"

    def title(self):
        return _("Documentation Browser")

    def createActions(self, parent=None):
        self.help_back = QAction(parent)
        self.help_forward = QAction(parent)
        self.help_home = QAction(parent)
        self.help_print = QAction(parent)
        self.help_lilypond_doc = QAction(parent)
        self.help_lilypond_context = QAction(parent)

        self.help_back.setIcon(icons.get("go-previous"))
        self.help_forward.setIcon(icons.get("go-next"))
        self.help_home.setIcon(icons.get("go-home"))
        self.help_lilypond_doc.setIcon(icons.get("lilypond-run"))
        self.help_print.setIcon(icons.get("document-print"))

        self.help_lilypond_doc.setShortcut(QKeySequence("F9"))
        self.help_lilypond_context.setShortcut(QKeySequence("Shift+F9"))

    def translateUI(self):
        self.help_back.setText(_("Back"))
        self.help_forward.setText(_("Forward"))
        # L10N: Home page of the LilyPond manual
        self.help_home.setText(_("Home"))
        self.help_print.setText(_("Print..."))
        self.help_lilypond_doc.setText(_("&LilyPond Documentation"))
        self.help_lilypond_context.setText(_("&Contextual LilyPond Help"))
Example #3
0
 def __init__(self):
     QObject.__init__(self)
     self._createdActions = []
     self._createdSeparators = []
     self._createdMenus = []
     self._currentDocument = core.workspace().currentDocument()  # probably None
     
     for menu in _MENUS:
         if menu[2]:
             menuObj = core.actionManager().addMenu(menu[0], menu[1], QIcon(':/enkiicons/' + menu[2]))
         else:
             menuObj = core.actionManager().addMenu(menu[0], menu[1])
         menuObj.setEnabled(False)
         self._createdMenus.append(menuObj)
     
     for item in _ACTIONS:
         if isinstance(item, tuple):  # action
             command, path, text, shortcut, icon = item
             actObject = QAction(text, self)
             if shortcut:
                 actObject.setShortcut(shortcut)
             if icon:
                 actObject.setIcon(QIcon(':/enkiicons/' + icon))
             actObject.setData(command)
             actObject.setEnabled(False)
             actObject.triggered.connect(self.onAction)
             core.actionManager().addAction(path, actObject)
             self._createdActions.append(actObject)
         else:  # separator
             menuPath = item
             menu = core.actionManager().menu(menuPath)
             self._createdSeparators.append(menu.addSeparator())
     
     core.workspace().currentDocumentChanged.connect(self.onCurrentDocumentChanged)
Example #4
0
 def __init__(self):
     QObject.__init__(self)
     self._createdActions = []
     self._createdMenus = []
     self._currentDocument = core.workspace().currentDocument()  # probably None
     model = core.actionManager()
     
     for menu in _MENUS:
         if menu[2]:
             menuObj = model.addMenu(menu[0], menu[1], QIcon(':/enkiicons/' + menu[2]))
         else:
             menuObj = model.addMenu(menu[0], menu[1])
         menuObj.setEnabled(False)
         self._createdMenus.append(menuObj)
     
     for command, path, text, shortcut, icon in _ACTIONS:
         actObject = QAction(text, self)
         if shortcut:
             actObject.setShortcut(shortcut)
         if icon:
             actObject.setIcon(QIcon(':/enkiicons/' + icon))
         actObject.setData(command)
         actObject.setEnabled(False)
         actObject.triggered.connect(self.onAction)
         model.addAction(path, actObject)
         self._createdActions.append(actObject)
     
     core.workspace().currentDocumentChanged.connect(self.onCurrentDocumentChanged)
Example #5
0
def createAction(self, text, slot, icon=None, signal='triggered()'):
    action = QAction(text, self)
    action.setFont(defaultFont)
    if icon:
        action.setIcon(icon)
    self.connect(action, SIGNAL(signal), slot)
    return action
Example #6
0
    def createTabButton(self, widget, text, icon=None, toolTip=None):
        """
        Create the tab button for `widget`.
        """
        action = QAction(text, self)
        action.setCheckable(True)

        if icon:
            action.setIcon(icon)

        if toolTip:
            action.setToolTip(toolTip)
        self.__tabActionGroup.addAction(action)
        self.__actionMapper.setMapping(action, action)
        action.toggled.connect(self.__actionMapper.map)

        button = ToolBoxTabButton(self, objectName="toolbox-tab-button")
        button.setDefaultAction(action)
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)

        if self.__tabIconSize.isValid():
            button.setIconSize(self.__tabIconSize)

        if self.__tabButtonHeight > 0:
            button.setFixedHeight(self.__tabButtonHeight)

        return button
Example #7
0
    def loadpages(self, pages):
        def safe_connect(method, to):
            try:
                method.connect(to)
            except AttributeError:
                pass

        for PageClass in pages:
            action = QAction(self.menutoolbar)
            text = PageClass.title.ljust(13)
            action.setIconText(text)
            action.setIcon(QIcon(PageClass.icon))
            action.setCheckable(True)
            if PageClass.projectpage:
                action.setVisible(False)
                self.projectbuttons.append(action)
                self.menutoolbar.insertAction(self.spaceraction, action)
            else:
                self.menutoolbar.insertAction(self.actionProject, action)

            iface = RoamInterface(RoamEvents, GPS, self)
            pagewidget = PageClass(iface, self)

            safe_connect(RoamEvents.selectionchanged, pagewidget.selection_changed)
            safe_connect(RoamEvents.projectloaded, pagewidget.project_loaded)

            pageindex = self.stackedWidget.insertWidget(-1, pagewidget)
            action.setProperty('page', pageindex)
            self.pluginactions.append(action)
            self.menuGroup.addAction(action)
Example #8
0
class Actions(actioncollection.ActionCollection):
    name = "documentactions"
    def createActions(self, parent):
        self.file_open_file_at_cursor = QAction(parent)
        self.edit_cut_assign = QAction(parent)
        self.view_highlighting = QAction(parent)
        self.view_highlighting.setCheckable(True)
        self.tools_indent_auto = QAction(parent)
        self.tools_indent_auto.setCheckable(True)
        self.tools_indent_indent = QAction(parent)
        self.tools_reformat = QAction(parent)
        self.tools_convert_ly = QAction(parent)
        
        self.edit_cut_assign.setIcon(icons.get('edit-cut'))

        self.file_open_file_at_cursor.setShortcut(QKeySequence("Alt+Ctrl+O"))
        self.edit_cut_assign.setShortcut(QKeySequence(Qt.SHIFT + Qt.CTRL + Qt.Key_X))
    
    def translateUI(self):
        self.file_open_file_at_cursor.setText(_("Open File at C&ursor"))
        self.edit_cut_assign.setText(_("Cut and Assign..."))
        self.view_highlighting.setText(_("Syntax &Highlighting"))
        self.tools_indent_auto.setText(_("&Automatic Indent"))
        self.tools_indent_indent.setText(_("Re-&Indent"))
        self.tools_reformat.setText(_("&Format"))
        self.tools_convert_ly.setText(_("&Update with convert-ly...")) 
    def loadpages(self, pages):
        def safe_connect(method, to):
            try:
                method.connect(to)
            except AttributeError:
                pass

        for PageClass in pages:
            action = QAction(self.menutoolbar)
            text = PageClass.title.ljust(13)
            action.setIconText(text)
            action.setIcon(QIcon(PageClass.icon))
            action.setCheckable(True)
            if PageClass.projectpage:
                action.setVisible(False)
                self.projectbuttons.append(action)
                self.menutoolbar.insertAction(self.spaceraction, action)
            else:
                self.menutoolbar.insertAction(self.actionProject, action)

            iface = RoamInterface(RoamEvents, GPS, self)
            pagewidget = PageClass(iface, self)

            safe_connect(RoamEvents.selectionchanged, pagewidget.selection_changed)
            safe_connect(RoamEvents.projectloaded, pagewidget.project_loaded)

            pageindex = self.stackedWidget.insertWidget(-1, pagewidget)
            action.setProperty('page', pageindex)
            self.pluginactions.append(action)
            self.menuGroup.addAction(action)
Example #10
0
def create_action(parent, text, shortcut=None, icon=None, tip=None,
                  toggled=None, triggered=None, data=None,
                  context=Qt.WindowShortcut):
    """Create a QAction"""
    action = QAction(text, parent)
    if triggered is not None:
        parent.connect(action, SIGNAL("triggered()"), triggered)
    if toggled is not None:
        parent.connect(action, SIGNAL("toggled(bool)"), toggled)
        action.setCheckable(True)
    if icon is not None:
        if isinstance(icon, (str, unicode)):
            icon = get_icon(icon)
        action.setIcon( icon )
    if shortcut is not None:
        action.setShortcut(shortcut)
    if tip is not None:
        action.setToolTip(tip)
        action.setStatusTip(tip)
    if data is not None:
        action.setData(QVariant(data))
    #TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut
    # (this will avoid calling shortcuts from another dockwidget
    #  since the context thing doesn't work quite well with these widgets)
    action.setShortcutContext(context)
    return action
Example #11
0
class ViewActions(actioncollection.ActionCollection):
    name = "view"
    def createActions(self, parent=None):
        self.window_split_horizontal = QAction(parent)
        self.window_split_vertical = QAction(parent)
        self.window_close_view = QAction(parent)
        self.window_close_others = QAction(parent)
        self.window_next_view = QAction(parent)
        self.window_previous_view = QAction(parent)
        
        # icons
        self.window_split_horizontal.setIcon(icons.get('view-split-top-bottom'))
        self.window_split_vertical.setIcon(icons.get('view-split-left-right'))
        self.window_close_view.setIcon(icons.get('view-close'))
        self.window_next_view.setIcon(icons.get('go-next-view'))
        self.window_previous_view.setIcon(icons.get('go-previous-view'))
        
        # shortcuts
        self.window_close_view.setShortcut(Qt.CTRL + Qt.SHIFT + Qt.Key_W)
        self.window_next_view.setShortcuts(QKeySequence.NextChild)
        qutil.removeShortcut(self.window_next_view, "Ctrl+,")
        self.window_previous_view.setShortcuts(QKeySequence.PreviousChild)
        qutil.removeShortcut(self.window_previous_view, "Ctrl+.")

    def translateUI(self):
        self.window_split_horizontal.setText(_("Split &Horizontally"))
        self.window_split_vertical.setText(_("Split &Vertically"))
        self.window_close_view.setText(_("&Close Current View"))
        self.window_close_others.setText(_("Close &Other Views"))
        self.window_next_view.setText(_("&Next View"))
        self.window_previous_view.setText(_("&Previous View"))
Example #12
0
 def menuAction(menu, title, res):
     action = QAction(title, self)
     icon = QIcon()
     icon.addPixmap(QPixmap(res))
     action.setIcon(icon)
     menu.addAction(action)
     return action
Example #13
0
class Kipcalc(kdeui.KMainWindow):
    def __init__ (self):
        super(Kipcalc, self).__init__()
        self.resize(640, 480)

        self.create_actions()
        self.create_menus()
        self.setCentralWidget(IPWidget(self))

    def print_(self):
        pass

    def create_actions(self):
        self.action_quit = QAction('&Quit', self)
        self.action_quit.setIcon(kdeui.KIcon('exit'))
        self.action_quit.setShortcut(self.tr('Ctrl+Q'))
        self.connect(self.action_quit, SIGNAL('triggered()'), self.close)

        self.action_print = QAction('&Print', self)
        #self.action_print.setIcon(kdeui.KIcon('print'))
        self.connect(self.action_quit, SIGNAL('triggered()'), self.print_)

    def create_menus(self):
        self.file_menu = self.menuBar().addMenu("&File")
        self.file_menu.addAction(self.action_quit)
        self.file_menu.addAction(self.action_print)
Example #14
0
    def _onTvFilesCustomContextMenuRequested(self, pos ):
        """Connected automatically by uic
        """
        menu = QMenu()
        
        menu.addAction( core.actionManager().action( "mFile/mClose/aCurrent" ) )
        menu.addAction( core.actionManager().action( "mFile/mSave/aCurrent" ) )
        menu.addAction( core.actionManager().action( "mFile/mReload/aCurrent" ) )
        menu.addSeparator()
        
        # sort menu
        sortMenu = QMenu( self )
        group = QActionGroup( sortMenu )

        group.addAction( self.tr( "Opening order" ) )
        group.addAction( self.tr( "File name" ) )
        group.addAction( self.tr( "URL" ) )
        group.addAction( self.tr( "Suffixes" ) )
        group.triggered.connect(self._onSortTriggered)
        sortMenu.addActions( group.actions() )
        
        for i, sortMode in enumerate(["OpeningOrder", "FileName", "URL", "Suffixes"]):
            action = group.actions()[i]
            action.setData( sortMode )
            action.setCheckable( True )
            if sortMode == self.model.sortMode():
                action.setChecked( True )
        
        aSortMenu = QAction( self.tr( "Sorting" ), self )
        aSortMenu.setMenu( sortMenu )
        aSortMenu.setIcon( QIcon( ":/enkiicons/sort.png" ))
        aSortMenu.setToolTip( aSortMenu.text() )
        
        menu.addAction( sortMenu.menuAction() )
        menu.exec_( self.tvFiles.mapToGlobal( pos ) )
Example #15
0
class Actions(actioncollection.ActionCollection):
    name = "docbrowser"
    
    def title(self):
        return _("Documentation Browser")
    
    def createActions(self, parent=None):
        self.help_back = QAction(parent)
        self.help_forward = QAction(parent)
        self.help_home = QAction(parent)
        self.help_print = QAction(parent)
        self.help_lilypond_doc= QAction(parent)
        self.help_lilypond_context = QAction(parent)
        
        self.help_back.setIcon(icons.get("go-previous"))
        self.help_forward.setIcon(icons.get("go-next"))
        self.help_home.setIcon(icons.get("go-home"))
        self.help_lilypond_doc.setIcon(icons.get("lilypond-run"))
        self.help_print.setIcon(icons.get("document-print"))
        
        self.help_lilypond_doc.setShortcut(QKeySequence("F9"))
        self.help_lilypond_context.setShortcut(QKeySequence("Shift+F9"))
        
    def translateUI(self):
        self.help_back.setText(_("Back"))
        self.help_forward.setText(_("Forward"))
        # L10N: Home page of the LilyPond manual
        self.help_home.setText(_("Home"))
        self.help_print.setText(_("Print..."))
        self.help_lilypond_doc.setText(_("&LilyPond Documentation"))
        self.help_lilypond_context.setText(_("&Contextual LilyPond Help"))
Example #16
0
def create_action(parent,
                  text,
                  shortcut=None,
                  icon=None,
                  tip=None,
                  toggled=None,
                  triggered=None,
                  data=None,
                  menurole=None,
                  context=Qt.WindowShortcut):
    """Create a QAction"""
    action = QAction(text, parent)
    if triggered is not None:
        parent.connect(action, SIGNAL("triggered()"), triggered)
    if toggled is not None:
        parent.connect(action, SIGNAL("toggled(bool)"), toggled)
        action.setCheckable(True)
    if icon is not None:
        if is_text_string(icon):
            icon = get_icon(icon)
        action.setIcon(icon)
    if shortcut is not None:
        action.setShortcut(shortcut)
    if tip is not None:
        action.setToolTip(tip)
        action.setStatusTip(tip)
    if data is not None:
        action.setData(data)
    if menurole is not None:
        action.setMenuRole(menurole)
    #TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut
    # (this will avoid calling shortcuts from another dockwidget
    #  since the context thing doesn't work quite well with these widgets)
    action.setShortcutContext(context)
    return action
Example #17
0
    def create_action(self,
                      text,
                      slot=None,
                      shortcut=None,
                      icon=None,
                      tip=None,
                      checkable=False,
                      signal="triggered()"):
        u"""

        :param text:
        :param slot:
        :param shortcut:
        :param icon:
        :param tip:
        :param checkable:
        :param signal:
        :return:
        """
        action = QAction(text, self)
        if slot is not None:
            self.connect(action, SIGNAL(signal), slot)
        if shortcut is not None:
            action.setShortcut(shortcut)
        if icon is not None:
            action.setIcon(icon)
        if tip is not None:
            action.setToolTip(tip)
        if checkable is not None:
            action.setCheckable(checkable)
        return action
Example #18
0
    def createTabButton(self, widget, text, icon=None, toolTip=None):
        """
        Create the tab button for `widget`.
        """
        action = QAction(text, self)
        action.setCheckable(True)

        if icon:
            action.setIcon(icon)

        if toolTip:
            action.setToolTip(toolTip)
        self.__tabActionGroup.addAction(action)
        self.__actionMapper.setMapping(action, action)
        action.toggled.connect(self.__actionMapper.map)

        button = ToolBoxTabButton(self, objectName="toolbox-tab-button")
        button.setDefaultAction(action)
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        button.setSizePolicy(QSizePolicy.Expanding,
                             QSizePolicy.Fixed)

        if self.__tabIconSize.isValid():
            button.setIconSize(self.__tabIconSize)

        if self.__tabButtonHeight > 0:
            button.setFixedHeight(self.__tabButtonHeight)

        return button
Example #19
0
def create_action(parent,
                  text,
                  shortcut=None,
                  icon=None,
                  tip=None,
                  toggled=None,
                  triggered=None,
                  data=None,
                  window_context=True):
    """Create a QAction"""
    action = QAction(text, parent)
    if triggered is not None:
        parent.connect(action, SIGNAL("triggered()"), triggered)
    if toggled is not None:
        parent.connect(action, SIGNAL("toggled(bool)"), toggled)
        action.setCheckable(True)
    if icon is not None:
        if isinstance(icon, (str, unicode)):
            icon = get_icon(icon)
        action.setIcon(icon)
    if shortcut is not None:
        action.setShortcut(shortcut)
    if tip is not None:
        action.setToolTip(tip)
        action.setStatusTip(tip)
    if data is not None:
        action.setData(QVariant(data))
    if window_context:
        action.setShortcutContext(Qt.WindowShortcut)
    else:
        #TODO: Hard-code all shortcuts and choose window_context=False
        # (this will avoid calling shortcuts from another dockwidget
        #  since the context thing doesn't work quite well with these)
        action.setShortcutContext(Qt.WidgetShortcut)
    return action
Example #20
0
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_language.setIcon(icons.get('tools-pitch-language'))
        self.pitch_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."))
Example #21
0
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"))
Example #22
0
 def action(self, parent, slot, icon=None, text='', tooltip=None):
     action = QAction(text, parent)
     if type(icon) == str:
         action.setIcon(PIcon(icon))
     if type(tooltip) == str:
         action.setToolTip(tooltip)
     self.__addAction(action, parent, slot)
     return action
Example #23
0
 def action(self, parent, slot, icon=None, text='', tooltip=None):
     action = QAction(text, parent)
     if type(icon) == str:
         action.setIcon(PIcon(icon))
     if type(tooltip) == str:
         action.setToolTip(tooltip)
     self.__addAction(action, parent, slot)
     return action
Example #24
0
def createAction( parent, label, callback=None, icon = None, tip = None, shortcut = None, data = None, 
                toggled = False, tooltip=None, cb_arg=None, iconText=None, checkable=None):
    """
    Create a QAction

    @param parent: 
    @type parent:

    @param label: 
    @type label:

    @param callback: 
    @type callback:

    @param icon: 
    @type icon:

    @param tip: 
    @type tip:

    @param shortcut: 
    @type shortcut:

    @param data: 
    @type data:

    @param toggled: 
    @type toggled:

    @return:
    @rtype:
    """
    action = QAction(label, parent)
    if toggled:
        if callback is not None:
            action.toggled.connect(callback)
            action.setCheckable(True)
    else:
        if callback is not None:
            if cb_arg is None:
                action.triggered.connect(callback)
            else:
                action.triggered.connect(lambda: callback(cb_arg) )
    if icon:
        action.setIcon(icon)
    if shortcut: 
        action.setShortcut(shortcut)
    if tip: 
        action.setStatusTip(tip)
    if tooltip:
        action.setToolTip(tooltip)
    if data is not None: 
        action.setData( QVariant(data) )
    if iconText is not None:
        action.setIconText(iconText)
    if checkable is not None:
        action.setCheckable(checkable)
    return action
Example #25
0
File: actions.py Project: eteq/glue
def act(name, parent, tip='', icon=None, shortcut=None):
    """ Factory for making a new action """
    a = QAction(name, parent)
    a.setToolTip(tip)
    if icon:
        a.setIcon(QIcon(':icons/%s' % icon))
    if shortcut:
        a.setShortcut(shortcut)
    return a
Example #26
0
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..."))
    def add_menu_item(self, item, project, submenu):

        iface = self.iface

        action = QAction(item, iface.mainWindow())
        action.setIcon(QIcon(":/plugins/ProjectLauncher/icon_project.png"))
        submenu.addAction(action)

        helper = lambda _project: (lambda: self.open_project(_project))
        action.triggered.connect(helper(project))
Example #28
0
 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
Example #29
0
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)
Example #30
0
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)
Example #31
0
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..."))
Example #32
0
class ToolBar(QToolBar):
    def __init__(self, window, qsci):
        QToolBar.__init__(self)
        self.qsci = qsci
        self.actions_dict = {'action_new':("document-new", "New", self._new_file),
                        'action_open':("document-open", "Open", self._open_file),
                        'action_save':("document-save", "Save", self._save_file),
                        'action_save_as':("document-save-as", "Save As", self._saveas_file),
                        'action_cut':("edit-cut", "Cut", SLOT("cut ()")),
                        'action_copy':("edit-copy", "Copy", SLOT("copy ()")),
                        'action_paste':("edit-paste", "Paste", SLOT("paste ()")),
                        'action_undo':("edit-undo", "Undo", SLOT("undo ()")),
                        'action_redo':("edit-redo", "Redo", SLOT("redo ()")),
                        'action_execute':("edit-Execute", "Execute", self._execute)}
        self._action_names = {}
        for action in self.actions_dict:
            self.action = QAction(window)
            self.action.setIcon(QIcon.fromTheme(self.actions_dict[action][0]))
            self._action_names[action] = self.action
            self.action.setIconText(QApplication.translate("MainWindow", self.actions_dict[action][1], None, QApplication.UnicodeUTF8))
            self.addAction(self.action)
            self.addSeparator()
            if action in ('action_new', 'action_open', 'action_save', 'action_save_as', 'action_execute'):
                QObject.connect(self.action, SIGNAL("triggered()"), self.actions_dict[action][2])
            else:
                QObject.connect(self.action, SIGNAL("triggered()"), qsci, self.actions_dict[action][2])
        
        QObject.connect(self.qsci, SIGNAL("textChanged()"), self._enable_save_btn)


    def _enable_save_btn(self):
        self._action_names['action_save'].setEnabled(True)

    def _execute(self):
        pass

    ##when empty document has been created - Save button should be disabled
    def _new_file(self):
        self.qsci.setText(QString(""))
        self._action_names['action_save'].setDisabled(True)

    ##name of document to be saved is given explicitly for simple purpose
    #to be changed
    def _save_file(self):
        self.filename = 'syntax.txt'
        content = open(self.filename, 'w')
        content.write(self.qsci.text())
        content.close()

    def _saveas_file(self):
        pass

    def _open_file(self):
        pass
Example #33
0
    def __insertItem(self, index, item):
        """
        Insert a widget action (from a `QStandardItem`) at index.
        """
        value = item.data(self.__actionRole)
        if value is not None:
            action = value
        else:
            action = QAction(item.text(), self)
            action.setIcon(item.icon())

        self.insertAction(index, action)
Example #34
0
    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
Example #35
0
    def __insertItem(self, index, item):
        """
        Insert a widget action (from a `QStandardItem`) at index.
        """
        value = item.data(self.__actionRole)
        if value is not None:
            action = value
        else:
            action = QAction(item.text(), self)
            action.setIcon(item.icon())

        self.insertAction(index, action)
Example #36
0
    def _init_context_menu(self):
        self.setContextMenu(QMenu(None))

        settings_act = QAction('Settings', self)
        settings_act.setIcon(QIcon.fromTheme("preferences-system"))
        settings_act.triggered.connect(self.main_win.settings_dlg.show)
        self.contextMenu().addAction(settings_act)

        exit_act = QAction('Exit', self)
        exit_act.setIcon(QIcon.fromTheme("application-exit"))
        exit_act.triggered.connect(self.main_win.exit)
        self.contextMenu().addAction(exit_act)
Example #37
0
class Actions(actioncollection.ActionCollection):
    name = "documentactions"

    def createActions(self, parent):
        self.edit_cut_assign = QAction(parent)
        self.view_highlighting = QAction(parent)
        self.view_highlighting.setCheckable(True)
        self.view_goto_file_or_definition = QAction(parent)
        self.tools_indent_auto = QAction(parent)
        self.tools_indent_auto.setCheckable(True)
        self.tools_indent_indent = QAction(parent)
        self.tools_reformat = QAction(parent)
        self.tools_remove_trailing_whitespace = QAction(parent)
        self.tools_convert_ly = QAction(parent)
        self.tools_quick_remove_comments = QAction(parent)
        self.tools_quick_remove_articulations = QAction(parent)
        self.tools_quick_remove_ornaments = QAction(parent)
        self.tools_quick_remove_instrument_scripts = QAction(parent)
        self.tools_quick_remove_slurs = QAction(parent)
        self.tools_quick_remove_dynamics = QAction(parent)
        self.tools_quick_remove_fingerings = QAction(parent)
        self.tools_quick_remove_markup = QAction(parent)

        self.edit_cut_assign.setIcon(icons.get('edit-cut'))

        self.view_goto_file_or_definition.setShortcut(
            QKeySequence(Qt.ALT + Qt.Key_Return))
        self.edit_cut_assign.setShortcut(
            QKeySequence(Qt.SHIFT + Qt.CTRL + Qt.Key_X))

    def translateUI(self):
        self.edit_cut_assign.setText(_("Cut and Assign..."))
        self.view_highlighting.setText(_("Syntax &Highlighting"))
        self.view_goto_file_or_definition.setText(
            _("View File or Definition at &Cursor"))
        self.tools_indent_auto.setText(_("&Automatic Indent"))
        self.tools_indent_indent.setText(_("Re-&Indent"))
        self.tools_reformat.setText(_("&Format"))
        self.tools_remove_trailing_whitespace.setText(
            _("Remove Trailing &Whitespace"))
        self.tools_convert_ly.setText(_("&Update with convert-ly..."))
        self.tools_quick_remove_comments.setText(_("Remove &Comments"))
        self.tools_quick_remove_articulations.setText(
            _("Remove &Articulations"))
        self.tools_quick_remove_ornaments.setText(_("Remove &Ornaments"))
        self.tools_quick_remove_instrument_scripts.setText(
            _("Remove &Instrument Scripts"))
        self.tools_quick_remove_slurs.setText(_("Remove &Slurs"))
        self.tools_quick_remove_dynamics.setText(_("Remove &Dynamics"))
        self.tools_quick_remove_fingerings.setText(_("Remove &Fingerings"))
        self.tools_quick_remove_markup.setText(
            _("Remove Text &Markup (from music)"))
Example #38
0
    def __insertItem(self, index, item):
        """
        Insert a widget action from `item` (`QModelIndex`) at `index`.
        """
        value = item.data(self.__actionRole)
        if value.isValid():
            action = value.toPyObject()
        else:
            action = QAction(item_text(item), self)
            action.setIcon(item_icon(item))
            action.setToolTip(item_tooltip(item))

        self.insertAction(index, action)
Example #39
0
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..."))
Example #40
0
    def __insertItem(self, index, item):
        """
        Insert a widget action from `item` (`QModelIndex`) at `index`.
        """
        value = qtcompat.qunwrap(item.data(self.__actionRole))
        if isinstance(value, QAction):
            action = value
        else:
            action = QAction(item_text(item), self)
            action.setIcon(item_icon(item))
            action.setToolTip(item_tooltip(item))

        self.insertAction(index, action)
Example #41
0
    def __insertItem(self, index, item):
        """
        Insert a widget action from `item` (`QModelIndex`) at `index`.
        """
        value = item.data(self.__actionRole)
        if value.isValid():
            action = value.toPyObject()
        else:
            action = QAction(item_text(item), self)
            action.setIcon(item_icon(item))
            action.setToolTip(item_tooltip(item))

        self.insertAction(index, action)
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()
Example #43
0
def createAction(parent, text, slot=None, shortcut=None, icon=None, tip=None, checkable=False, signal="triggered()"):
    action = QAction(text, parent)
    if icon is not None:
        action.setIcon(QIcon(":/%s.png" % icon))
    if shortcut is not None:
        action.setShortcut(shortcut)
    if tip is not None:
        action.setToolTip(tip)
        action.setStatusTip(tip)
    if slot is not None:
        parent.connect(action, SIGNAL(signal), slot)
    if checkable:
        action.setCheckable(True)
    return action
Example #44
0
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"))
Example #45
0
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"))
Example #46
0
 def createAction(self, text, slot=None, shortcut=None, icon=None, tip=None, checkable=False):
     action = QAction(text, self)
     if slot is not None:
         action.triggered.connect(slot)
     if shortcut is not None:
         action.setShortcut(shortcut)
     if icon is not None:
         action.setIcon(QIcon(":/{}.png".format(icon)))
     if tip is not None:
         action.setToolTip(tip)
         action.setStatusTip(tip)
     if checkable:
         action.setCheckable(True)
     return action
Example #47
0
    def _setup_actions(self):
        ''' Bind actions to callbacks and setup keyboard shortcuts '''

        # Keyboard shortcuts
        self.actOpenProject.setShortcut('Ctrl+O')
        self.actSaveProject.setShortcut('Ctrl+S')
        self.actShowHidden.setShortcut('Ctrl+H')
        self.actSaveProjectAs.setShortcut('Ctrl+Shift+S')
        self.actReloadProject.setShortcut('Ctrl+Shift+R')
        self.actCloseProject.setShortcut('Ctrl+W')
        self.actExit.setShortcut('Ctrl+Q')
        self.actVariableLibrary.setShortcut('Ctrl+V')
        self.actLaunchResultBrowser.setShortcut('Ctrl+R')
        self.actDatabaseSettings.setShortcut('Ctrl+D')
        self.actPreferences.setShortcut('Ctrl+P')

        # Connect trigger slots using a little quickie function
        def connect(action, callback):
            QObject.connect(action, SIGNAL("triggered()"), callback)
        connect(self.actNewProject, self.newProject)
        connect(self.actOpenProject, self.openProject)
        connect(self.actSaveProject, self.saveProject)
        connect(self.actShowHidden, self.showHidden)
        connect(self.actSaveProjectAs, self.saveProjectAs)
        connect(self.actReloadProject, self.reloadProject)
        connect(self.actCloseProject, self.closeProject)
        connect(self.actExit, self.close)
        connect(self.actAbout, self.openAbout)
        connect(self.actPreferences, self.openPreferences)
        connect(self.actDatabaseSettings, self.openDatabaseSettings)
        connect(self.actVariableLibrary, self.editAllVariables)
        connect(self.actLogView, self.openLogTab)
        connect(self.actLaunchResultBrowser, self.openResultBrowser)

        # Create a 'Close tab' widget
        action = QAction(self)
        action.setIcon(QIcon(':/Images/Images/cross.png'))
        connect(action, self.closeCurrentTab)
        widget = QToolButton(self)
        widget.setDefaultAction(action)
        widget.setWhatsThis('Close tab')
        widget.setToolTip('Close tab')
        self.tabWidget.setCornerWidget(widget)

        # GIS -- disabled for time being
        # connect(self.actionMap_View, self.openMapTab)

        # Disable some options by default
        self.actVariableLibrary.setEnabled(False)
        self.actLaunchResultBrowser.setEnabled(False)
Example #48
0
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"))
Example #49
0
    def _addDatasetAction(self, dataset):
        """
        Adds an action for the inputed dataset to the toolbar
        
        :param      dataset | <XChartDataset>
        """
        # create the toolbar action
        action = QAction(dataset.name(), self)
        action.setIcon(XColorIcon(dataset.color()))
        action.setCheckable(True)
        action.setChecked(True)
        action.setData(qt.wrapVariant(dataset))
        action.toggled.connect(self.toggleDataset)

        self.uiDatasetTBAR.addAction(action)
Example #50
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)
Example #51
0
    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)
Example #52
0
        def createAction(text, shortcut, slot, iconFileName=None):
            """Create QAction with given parameters and add to the widget
            """
            action = QAction(text, self)
            if iconFileName is not None:
                action.setIcon(QIcon(getIconPath(iconFileName)))

            keySeq = shortcut if isinstance(
                shortcut, QKeySequence) else QKeySequence(shortcut)
            action.setShortcut(keySeq)
            action.setShortcutContext(Qt.WidgetShortcut)
            action.triggered.connect(slot)

            self.addAction(action)

            return action
 def create_action(self, text, slot=None, shortcut=None,
                   icon=None, tip=None, checkable=False,
                   signal="triggered()"):
     action = QAction(text, self)
     if icon is not None:
         action.setIcon(QIcon(":/%s.png" % icon))
     if shortcut is not None:
         action.setShortcut(shortcut)
     if tip is not None:
         action.setToolTip(tip)
         action.setStatusTip(tip)
     if slot is not None:
         self.connect(action, QtCore.SIGNAL(signal), slot)
     if checkable:
         action.setCheckable(True)
     return action
Example #54
0
    def _setup_actions(self):
        ''' Bind actions to callbacks and setup keyboard shortcuts '''

        # Keyboard shortcuts
        self.actOpenProject.setShortcut('Ctrl+O')
        self.actSaveProject.setShortcut('Ctrl+S')
        self.actSaveProjectAs.setShortcut('Ctrl+Shift+S')
        self.actCloseProject.setShortcut('Ctrl+W')
        self.actVariableLibrary.setShortcut('Ctrl+V')
        self.actLaunchResultBrowser.setShortcut('Ctrl+R')
        self.actDatabaseSettings.setShortcut('Ctrl+D')
        self.actPreferences.setShortcut('Ctrl+P')

        # Connect trigger slots using a little quickie function
        def connect(action, callback):
            QObject.connect(action, SIGNAL("triggered()"), callback)
        connect(self.actNewProject, self.newProject)
        connect(self.actOpenProject, self.openProject)
        connect(self.actSaveProject, self.saveProject)
        connect(self.actSaveProjectAs, self.saveProjectAs)
        connect(self.actCloseProject, self.closeProject)
        connect(self.actExit, self.close)
        connect(self.actAbout, self.openAbout)
        connect(self.actPreferences, self.openPreferences)
        connect(self.actDatabaseSettings, self.openDatabaseSettings)
        connect(self.actVariableLibrary, self.editAllVariables)
        connect(self.actLogView, self.openLogTab)
        connect(self.actLaunchResultBrowser, self.openResultBrowser)

        # Create a 'Close tab' widget
        action = QAction(self)
        action.setIcon(QIcon(':/Images/Images/cross.png'))
        connect(action, self.closeCurrentTab)
        widget = QToolButton(self)
        widget.setDefaultAction(action)
        widget.setWhatsThis('Close tab')
        widget.setToolTip('Close tab')
        self.tabWidget.setCornerWidget(widget)

        # GIS -- disabled for time being
        # connect(self.actionMap_View, self.openMapTab)

        # Disable some options by default
        self.actVariableLibrary.setEnabled(False)
        self.actLaunchResultBrowser.setEnabled(False)
Example #55
0
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"))
Example #56
0
    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)
Example #57
0
def menuTitle(icon, text, parent):
    eventEater = EventEater()
    buttonaction = QAction(parent)
    font = buttonaction.font()
    font.setBold(True)
    buttonaction.setFont(font)
    buttonaction.setText(text)
    buttonaction.setIcon(icon)

    action = QWidgetAction(parent)
    action.setObjectName('trayMenuTitle')
    titleButton = QToolButton(parent)
    titleButton.installEventFilter(eventEater)
    titleButton.setDefaultAction(buttonaction)
    titleButton.setDown(True)
    titleButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
    action.setDefaultWidget(titleButton)

    return action
 def create(self):
     """Creates menu actions."""
     for i in range(self.max_recent):
         action = QAction(self.parent)
         action.setIcon(QIcon(QPixmap(":/icons/action_rom.png")))
         self.recent_actions.append(action)
         self.recent_actions[i].setVisible(False)
         self.parent.connect(self.recent_actions[i], SIGNAL("triggered()"),
                             self.parent.file_open)
         self.parent.menuRecent.addAction(self.recent_actions[i])
     self.parent.menuRecent.addSeparator()
     self.action_clear_history.setText("&Clear history")
     self.action_clear_history.setEnabled(False)
     self.action_clear_history.setVisible(True)
     self.action_clear_history.setIcon(
         QIcon(QPixmap(":/icons/action_clear.png")))
     self.parent.connect(self.action_clear_history, SIGNAL("triggered()"),
                         self.clear)
     self.parent.menuRecent.addAction(self.action_clear_history)
Example #59
0
def action(name, parent=None, collection=None):
    """Returns a QAction with text and icon for the given snippet name.

    Returns None is no such snippet is available.
    If collection is provided, it is used to set shortcuts to the action.
    """
    title = snippets.title(name)
    if not title:
        return
    a = QAction(parent)
    a.setObjectName(name)
    a.setText(title.replace('&', '&&'))
    icon = snippets.icon(name)
    if icon:
        a.setIcon(icon)
    if collection:
        shortcuts = collection.shortcuts(name)
        if shortcuts:
            a.setShortcuts(shortcuts)
    return a