示例#1
0
文件: editor.py 项目: D3f0/prymatex
 def icon(self):
     baseIcon = QtGui.QIcon()
     if self._file_path is not None:
         baseIcon = resources.get_icon(self._file_path)
     if self.isModified():
         baseIcon = resources.get_icon("document-save")
     if self._external_action is not None:
         importantIcon = resources.get_icon("emblem-important")
         baseIcon = combine_icons(baseIcon, importantIcon, 0.8)
     return baseIcon
示例#2
0
 def data(self, index, role = QtCore.Qt.DisplayRole):
     if not index.isValid():
         return None
     suggestion = self.suggestions[index.row()]
     if role == QtCore.Qt.DisplayRole:
         if 'display' in suggestion:
             return suggestion['display']
         elif 'title' in suggestion:
             return suggestion['title']
     elif role == QtCore.Qt.EditRole:
         if 'match' in suggestion:
             return suggestion['match']
         elif 'display' in suggestion:
             return suggestion['display']
         elif 'title' in suggestion:
             return suggestion['title']
     elif role == QtCore.Qt.DecorationRole:
         if index.column() == 0 and 'image' in suggestion:
             return resources.get_icon(suggestion['image'])
     elif role == QtCore.Qt.ToolTipRole:
         if 'tooltip' in suggestion:
             if 'tooltip_format' in suggestion:
                 print(suggestion["tooltip_format"])
             return suggestion['tooltip']
     elif role == QtCore.Qt.MatchRole:
         return suggestion['display']
示例#3
0
文件: actions.py 项目: D3f0/prymatex
 def globalEditAction(text):
     objectName = text_to_objectname(text)
     iconName = text_to_iconname(text, prefix = "icon")
     return {
         "text": text,
         "sequence": resources.get_sequence("Global", objectName),
         "icon": resources.get_icon(iconName),
         "triggered": cls.globalCallback,
         "data": objectName
     }
示例#4
0
文件: lists.py 项目: D3f0/prymatex
 def data(self, index, role = QtCore.Qt.DisplayRole):
     if not index.isValid():
         return None
     item = self.__files[index.row()]
     if role == QtCore.Qt.DisplayRole:
         return "<table><tr><td><h4>%(name)s</h4></td></tr><tr><td><small>%(path)s</small></td></tr></table>" % item
     elif role == QtCore.Qt.DecorationRole:
         return resources.get_icon(item["path"])
     elif role == QtCore.Qt.ToolTipRole:
         return None
示例#5
0
文件: editor.py 项目: D3f0/prymatex
 def configSelectTop(self):
     self.comboBoxItemFilter.addItem("Show all")
     self.comboBoxItemFilter.addItem(resources.get_icon("bundle-item-syntax"), "Languages", "syntax")
     self.comboBoxItemFilter.addItem(resources.get_icon("bundle-item-snippet"), "Snippets", "snippet")
     self.comboBoxItemFilter.addItem(resources.get_icon("bundle-item-macro"), "Macros", "macro")
     self.comboBoxItemFilter.addItem(resources.get_icon("bundle-item-command"), "Commands", "command")
     self.comboBoxItemFilter.addItem(resources.get_icon("bundle-item-dragcommand"), "DragCommands", "dragcommand")
     self.comboBoxItemFilter.addItem(resources.get_icon("bundle-item-preference"), "Preferences", "preference")
     self.comboBoxItemFilter.addItem(resources.get_icon("bundle-item-template"), "Templates", "template staticfile")
     self.comboBoxItemFilter.addItem(resources.get_icon("bundle-item-project"), "Projects", "project staticfile")
     self.comboBoxItemFilter.setInsertPolicy(QtGui.QComboBox.NoInsert)
     self.comboBoxItemFilter.lineEdit().returnPressed.connect(self.on_comboBoxItemFilter_returnPressed)
示例#6
0
 def data(self, index, role = QtCore.Qt.DisplayRole):
     if not index.isValid():
         return None
     suggestion = self.suggestions[index.row()]
     if role in (QtCore.Qt.DisplayRole, QtCore.Qt.EditRole):
         return suggestion
     elif role == QtCore.Qt.DecorationRole:
         return resources.get_icon('insert-text')
     elif role == QtCore.Qt.ToolTipRole:
         return suggestion
     elif role == QtCore.Qt.MatchRole:
         #return text.fuzzy_match(self.prefix, suggestion) and self.prefix or suggestion
         return suggestion
示例#7
0
文件: profiles.py 项目: D3f0/prymatex
 def data(self, index, role = QtCore.Qt.DisplayRole):
     if not index.isValid():
         return None
     profile = self.__profiles[index.row()]
     if role == QtCore.Qt.DisplayRole:
         return profile.PMX_PROFILE_NAME
     elif role == QtCore.Qt.CheckStateRole:
         if profile.PMX_PROFILE_DEFAULT:
             return 2
         return 0
     elif role == QtCore.Qt.ToolTipRole:
         return profile.PMX_PROFILE_PATH
     elif role == QtCore.Qt.DecorationRole:
         return resources.get_icon("user-identity")
示例#8
0
文件: window.py 项目: D3f0/prymatex
    def setupUi(self):
        self.setObjectName("MainWindow")
        self.setWindowIcon(resources.get_icon("prymatex"))

        self.setupDockToolBars()
        
        self.setCentralWidget(SplitterWidget(parent = self))
        
        # Splitter signals
        self.centralWidget().currentWidgetChanged.connect(self.on_splitter_currentWidgetChanged)
        self.centralWidget().layoutChanged.connect(self.on_splitter_layoutChanged)
        self.centralWidget().tabCloseRequest.connect(self.closeEditor)
        self.centralWidget().tabCreateRequest.connect(self.addEmptyEditor)

        # Status and menu bars
        self.setStatusBar(PrymatexMainStatusBar(self))
        self.setMenuBar(PrymatexMainMenuBar(self))
        
        self.resize(801, 600)
示例#9
0
文件: group.py 项目: D3f0/prymatex
    def mousePressEvent(self, e):
        """ Reimplemented to handle mouse press events. """
        if e.button() == QtCore.Qt.RightButton:
            widget = self.widgetAtPos(e.pos())
            tabWidget = self.parent()
            tabSplitter = tabWidget._root
            tabMenu = { 
                "text": "Tab Menu",
                "items": [
                    {   "text": "Close",
                        "icon": resources.get_icon("tab-close"),
                        "triggered": partial(tabWidget._close_widget, widget) 
                    },
                    {   "text": "Close all",
                        "triggered": tabSplitter.closeAll
                    },
                    {   "text": "Close other",
                        "icon": resources.get_icon("tab-close-other"),
                        "triggered": partial(tabSplitter.closeAllExceptWidget, widget)
                    }
                ]
            }

            if self.parent().count() > 1:
                tabMenu["items"].extend([
                    "-", {
                        "text": "Split vertically",
                        "icon": resources.get_icon("view-split-left-right"),
                        "triggered": partial(tabSplitter.splitVertically, widget)   
                    }, {
                        "text": "Split horizontally",
                        "icon": resources.get_icon("view-split-top-bottom"),
                        "triggered": partial(tabSplitter.splitHorizontally, widget)
                    }
                ])
            tabMenu["items"].append("-")
            # Create custom menu
            tabMenu["items"].extend(widget.contributeToTabMenu())
            
            menu = create_menu(self, tabMenu)
            
            # Display menu
            menu.exec_(e.globalPos())
        elif e.button() == QtCore.Qt.LeftButton:

            # There is something odd in the focus handling where focus temporarily
            # moves elsewhere (actually to a View) when switching to a different
            # tab page.  We suppress the notification so that the workbench doesn't
            # temporarily make the View active.
            self._root._repeat_focus_changes = False
            QtGui.QTabBar.mousePressEvent(self, e)
            self._root._repeat_focus_changes = True
    
            # Update the current tab.
            self._root._set_current_tab(self.parent(), self.currentIndex())
            self._root._set_focus()
    
            if e.button() != QtCore.Qt.LeftButton:
                return
    
            if self._drag_state is not None:
                return
    
            # Potentially start dragging if the tab under the mouse is the current
            # one (which will eliminate disabled tabs).
            tab = self._tab_at(e.pos())
    
            if tab < 0 or tab != self.currentIndex():
                return
    
            self._drag_state = _DragState(self._root, self, tab, e.pos())
示例#10
0
文件: plugins.py 项目: D3f0/prymatex
 def get_icon(self, index, size = None, default = None):
     if index in self.resources:
         return QtGui.QIcon(self.resources[index])
     return resources.get_icon(index, size, default)
示例#11
0
文件: actions.py 项目: D3f0/prymatex
    def contributeToMainMenu(cls):
        import prymatex
        import collections
        menu = collections.OrderedDict()

        # ------------- File menu
        menu["file"] = {
            "text": "&File",
            "items": [{
                "text": "New",
                "items": [{
                    "text": "Editor",
                    "sequence": resources.get_sequence("Global", "New"),
                    "triggered": cls.addEmptyEditor,
                    "icon": resources.get_icon("tab-new"),
                }, "-", {
                    "text": "From template",
                    "triggered": lambda mw: mw.templateDialog.createFile(),
                    "icon": resources.get_icon("document-new"),
                }, {
                    "text": "Project",
                    "triggered": lambda mw: mw.projectDialog.createProject(),
                    "icon": resources.get_icon("project-development-new-template"),
                }]
            }, {
                "text": "Open",
                'sequence': resources.get_sequence("Global", "Open"),
                "icon": resources.get_icon("document-open"),
                "triggered": cls.on_actionOpen_triggered
            }, {
                "text": "Recent files",
                "aboutToShow": cls.on_menuRecentFiles_aboutToShow,
                "items": ["-", {
                    "text": "Open all recent files",
                    "icon": resources.get_icon("document-open-recent"),
                    "triggered": lambda mw: [ mw.application.openFile(path)
                        for path in mw.application.fileManager.fileHistory ]
                }, {
                    "text": "Remove all recent files",
                    "icon": resources.get_icon("edit-clear"),
                    "triggered": lambda mw: mw.application.fileManager.clearFileHistory()
                }]
            }, {
                "text": "Import project",
                "triggered": cls.on_actionImportProject_triggered,
                "icon": resources.get_icon("project-open"),
            }, "-", {
                "text": "Save",
                'sequence': resources.get_sequence("Global", "Save"),
                "icon": resources.get_icon("document-save"),
                "triggered": lambda mw: mw.saveEditor()
            }, {
                "text": "Save as",
                "icon": resources.get_icon("document-save-as"),
                "triggered": lambda mw: mw.saveEditor(saveAs=True)
            }, {
                "text": "Save all",
                'sequence': resources.get_sequence("Global", "SaveAll", "Ctrl+Shift+S"),
                "icon": resources.get_icon("document-save-all"),
                "triggered": lambda mw: [ mw.saveEditor(editor=editor) for editor in mw.editors() ]
            }, "-", {
                "text": "Close",
                'sequence': resources.get_sequence("Global", "Close"),
                "icon": resources.get_icon("tab-close"),
                "triggered": lambda mw: mw.closeEditor()
            }, {
                "text": "Close all",
                'sequence': resources.get_sequence("Global", "CloseAll", "Ctrl+Shift+W"),
                "triggered": lambda mw: [ mw.closeEditor(editor=editor) for editor in mw.editors() ]
            }, {
                "text": "Close others",
                "icon": resources.get_icon("tab-close-other")
            }, "-", {
                "text": "Switch profile",
                "icon": resources.get_icon("system-switch-user"),
                "triggered": cls.on_actionSwitchProfile_triggered
            }, "-", {
                "text": "Quit",
                'sequence': resources.get_sequence("Global", "Quit"),
                "icon": resources.get_icon("application-exit"),
                "triggered": lambda mw: mw.application.quit()
            }]
        }

        # ------------- Edit menu
        def globalEditAction(text):
            objectName = text_to_objectname(text)
            iconName = text_to_iconname(text, prefix = "icon")
            return {
                "text": text,
                "sequence": resources.get_sequence("Global", objectName),
                "icon": resources.get_icon(iconName),
                "triggered": cls.globalCallback,
                "data": objectName
            }
            
        menu["edit"] = {
            "text": "&Edit",
            "items": [ globalEditAction(name) for name in ("&Undo", "&Redo") ] + ["-"] +
            [ globalEditAction(name) for name in ("Cu&t", "&Copy", "&Paste", "&Delete") ]
        }
        
        # ------------- View menu
        menu["view"] = {
            "text": "&View",
            "items": [{
                "text": "Panels",
                "items": []
            }, "-", {
                "text": "Show main menu",
                "toggled": lambda mw, checked: mw.menuBar().setShown(checked),
                "testChecked": lambda mw: mw.menuBar().isVisible()
            }, {
                "text": "Show status",
                "toggled": lambda mw, checked: mw.statusBar().setShown(checked),
                "testChecked": lambda mw: mw.statusBar().isVisible()
            }, {
                "text": "Show tabs",
                "toggled": lambda mw, checked: mw.centralWidget().setShowTabs(checked),
                "testChecked": lambda mw: mw.centralWidget().showTabs(),
            }, "-", {
                "text": "Layout",
                "items": [{
                    "text": "Split vertically",
                    "icon": resources.get_icon("view-split-left-right"),
                    "triggered": lambda mw: mw.centralWidget().splitVertically()
                }, {
                    "text": "Split horizontally",
                    "icon": resources.get_icon("view-split-top-bottom"),
                    "triggered": lambda mw: mw.centralWidget().splitHorizontally()
                }, "-", {
                    "text": "Single",
                    "sequence": resources.get_sequence("Global", "LayoutSingle", "Shift+Alt+1"),
                    "triggered": lambda mw: mw.centralWidget().setLayout()
                }, {
                    "text": "Columns: 2",
                    "sequence": resources.get_sequence("Global", "Layout2Columns", "Shift+Alt+2"),
                    "triggered": lambda mw: mw.centralWidget().setLayout(columns = 2)
                }, {
                    "text": "Columns: 3",
                    "sequence": resources.get_sequence("Global", "Layout3Columns", "Shift+Alt+3"),
                    "triggered": lambda mw: mw.centralWidget().setLayout(columns = 3)
                }, {
                    "text": "Columns: 4",
                    "sequence": resources.get_sequence("Global", "Layout4Columns", "Shift+Alt+4"),
                    "triggered": lambda mw: mw.centralWidget().setLayout(columns = 4)
                }, {
                    "text": "Rows: 2",
                    "sequence": resources.get_sequence("Global", "Layout2Rows", "Shift+Alt+8"),
                    "triggered": lambda mw: mw.centralWidget().setLayout(rows = 2)
                }, {
                    "text": "Rows: 3",
                    "sequence": resources.get_sequence("Global", "Layout3Rows", "Shift+Alt+9"),
                    "triggered": lambda mw: mw.centralWidget().setLayout(rows = 3)
                }, {
                    "text": "Grid: 4",
                    "sequence": resources.get_sequence("Global", "Layout4Grid", "Shift+Alt+5"),
                    "triggered": lambda mw: mw.centralWidget().setLayout(columns = 2, rows = 2)
                }]
            }, {
                "text": "Groups",
                "items": [{
                    "text": "Move editor to new group",
                    "triggered": cls.moveEditorToNewGroup
                }, {
                    "text": "New group",
                    "triggered": cls.addEmptyGroup
                }, {
                    "text": "Close group",
                    "triggered": cls.closeGroup
                }, "-", {
                    "text": "Max Columns: 1",
                    "testChecked": lambda mw: mw.centralWidget().maxColumns() == 1,
                    "toggled": lambda mw, checked: checked and mw.centralWidget().setMaxColumns(1)
                }, {
                    "text": "Max Columns: 2",
                    "testChecked": lambda mw: mw.centralWidget().maxColumns() == 2,
                    "toggled": lambda mw, checked: checked and mw.centralWidget().setMaxColumns(2)
                }, {
                    "text": "Max Columns: 3",
                    "testChecked": lambda mw: mw.centralWidget().maxColumns() == 3,
                    "toggled": lambda mw, checked: checked and mw.centralWidget().setMaxColumns(3)
                }, {
                    "text": "Max Columns: 4",
                    "testChecked": lambda mw: mw.centralWidget().maxColumns() == 4,
                    "toggled": lambda mw, checked: checked and mw.centralWidget().setMaxColumns(4)
                }, {
                    "text": "Max Columns: 5",
                    "testChecked": lambda mw: mw.centralWidget().maxColumns() == 5,
                    "toggled": lambda mw, checked: checked and mw.centralWidget().setMaxColumns(5)
                }]
            }, {
                "text": "Focus group",
                "items": [{
                    "text": "Next",
                    "triggered": cls.nextGroup
                }, {
                    "text": "Previous",
                    "triggered": cls.previousGroup
                }, "-"]
            }, {
                "text": "Move editor to group",
                "items": [{
                    "text": "Next",
                    "triggered": cls.moveEditorToNextGroup
                }, {
                    "text": "Previous",
                    "triggered": cls.moveEditorToPreviousGroup
                }, "-"]
            }]
        }

        # ------------- Navigation menu
        menu["navigation"] = {
            "text": "&Navigation",
            "items": [{
                "text": "Next tab",
                'sequence': resources.get_sequence("Global", "NextChild"),
                "icon": resources.get_icon("go-next-view"),
                "triggered": lambda mw: mw.centralWidget().focusNextTab()
            }, {
                "text": "Previous tab",
                'sequence': resources.get_sequence("Global", "PreviousChild"),
                "icon": resources.get_icon("go-previous-view"),
                "triggered": lambda mw: mw.centralWidget().focusPreviousTab()
            }, {
                "text": "Select tab",
                "triggered": cls.on_actionSelectTab_triggered
            }, {
                "text": "Jump to tab",
                'sequence': resources.get_sequence("Global", "JumpToTab", "F12"),
                "triggered": cls.on_actionJumpToTab_triggered
            }, "-", {
                "text": "Last edit location",
                "icon": resources.get_icon("go-last"),
                "triggered": cls.on_actionLastEditLocation_triggered
            }, {
                "text": "Go back location",
                'sequence': resources.get_sequence("Global", "GoBackLocation"),
                "icon": resources.get_icon("go-previous"),
                "triggered": cls.on_actionLocationBack_triggered
            }, {
                "text": "Go forward location",
                'sequence': resources.get_sequence("Global", "GoForwardLocation"),
                "icon": resources.get_icon("go-next"),
                "triggered": cls.on_actionLocationForward_triggered
            }]
        }

        # ------------- Bundles menu
        menu["bundles"] = {
            "text": "&Bundles",
            "items": [{
                "text": "Bundle editor",
                "items": [{
                    "text": "Show bundle editor",
                    'sequence': resources.get_sequence("Global", "ShowBundleEditor", "Meta+Ctrl+Alt+B"),
                    "triggered": lambda mw: mw.bundleEditorDialog.execEditor()
                }, "-", {
                    "text": "Edit commands",
                    'sequence': resources.get_sequence("Global", "EditCommands", "Meta+Ctrl+Alt+C"),
                    "triggered": lambda mw: mw.bundleEditorDialog.execCommand()
                }, {
                    "text": "Edit languages",
                    'sequence': resources.get_sequence("Global", "EditLanguages", "Meta+Ctrl+Alt+L"),
                    "triggered": lambda mw: mw.bundleEditorDialog.execLanguage()
                }, {
                    "text": "Edit snippets",
                    'sequence': resources.get_sequence("Global", "EditSnippets", "Meta+Ctrl+Alt+S"),
                    "triggered": lambda mw: mw.bundleEditorDialog.execSnippet()
                }, {
                    "text": "Reload bundles",
                    "triggered": lambda mw: mw.application.supportManager.reloadSupport(mw.showMessage)
                }]
            }, "-"]
        }

        # ------------- Preferences menu
        menu["preferences"] = {
            "text": "&Preferences",
            "items": [ {
                "text": "Full screen",
                "toggled": lambda mw, checked: getattr(mw, checked and "showFullScreen" or "showNormal")(),
                "testChecked": lambda mw: mw.isFullScreen(),
                "icon": resources.get_icon("view-fullscreen"),
                "sequence": resources.get_sequence("Global", "ShowFullScreen", "F11")
            }, {
                "text": "Distraction free mode",
                "toggled": lambda mw, checked: getattr(mw, checked and "showDistractionFreeMode" or "showNormal")(),
                "sequence": resources.get_sequence("Global", "ShowDistractionFreeMode", "Shift+F11")
            }, "-", {
                "text": "Settings",
                "icon": resources.get_icon("configure"),
                "triggered": lambda mw: mw.settingsDialog.exec_()
            }]
        }

        # ------------- Help menu
        menu["help"] = {
            "text": "&Help",
            "items": [ {
                "text": "Read documentation",
                "icon": resources.get_icon("help-contents"),
                "triggered": lambda mw: mw.application.openUrl(prymatex.__source__ + '/wiki')
            }, {
                "text": "Project homepage",
                "triggered": lambda mw: mw.application.openUrl(prymatex.__url__)
            }, "-", {
                "text": "Translate Prymatex",
                "icon": resources.get_icon("applications-development-translation"),
                "triggered": lambda mw: mw.application.openUrl(prymatex.__source__ + '/wiki')
            }, "-", {
                "text": "Report bug",
                "icon": resources.get_icon("tools-report-bug"),
                "triggered": lambda mw: mw.application.openUrl(prymatex.__source__ + '/issues?utf8=%E2%9C%93')
            },  {
                "text": "Take screenshoot",
                "icon": resources.get_icon("ksnapshot"),
                "triggered": cls.on_actionTakeScreenshot_triggered
            }, "-", {
                "text": "About Prymatex",
                "triggered": lambda mw: mw.aboutDialog.exec_()
            }, {
                "text": "About Qt",
                "triggered": lambda mw: mw.application.aboutQt()
            }, ]
        }
        return menu
示例#12
0
文件: search.py 项目: D3f0/prymatex
 def icon(self):
     return resources.get_icon(self.path())
示例#13
0
文件: nodes.py 项目: D3f0/prymatex
 def icon(self):
     if self.manager.isOpen(self):
         return resources.get_icon("project-development")