def __createProjectPopupMenu( self ):
        " Creates the recent project popup menu "
        self.__projectMenu = QMenu( self.projectsView )
        self.__prjLoadMenuItem = self.__projectMenu.addAction(
                                getIcon( 'load.png' ), 'Load',
                                self.__loadProject )
        self.__projectMenu.addSeparator()
        self.__propsMenuItem = self.__projectMenu.addAction(
                                getIcon( 'smalli.png' ), 'Properties',
                                self.__viewProperties )
        self.__prjCopyPathMenuItem = self.__projectMenu.addAction(
                                getIcon( 'copytoclipboard.png' ),
                                'Copy path to clipboard',
                                self.__prjPathToClipboard )
        self.__projectMenu.addSeparator()
        self.__delPrjMenuItem = self.__projectMenu.addAction(
                                getIcon( 'trash.png' ), 'Delete from recent',
                                self.__deleteProject )
        self.projectsView.setContextMenuPolicy( Qt.CustomContextMenu )
        self.connect( self.projectsView,
                      SIGNAL( "customContextMenuRequested(const QPoint &)" ),
                      self.__handleShowPrjContextMenu )

        Settings().recentListChanged.connect( self.__populateProjects )
        GlobalData().project.projectChanged.connect( self.__projectChanged )
        return
    def __init__(self):
        self.menu = None
        self.individualMenus = {}

        # Scene menu preparation
        self.sceneMenu = QMenu()
        self.sceneMenu.addAction(getIcon("filesvg.png"), "Save as SVG...", self.parent().onSaveAsSVG)
        self.sceneMenu.addAction(getIcon("filepdf.png"), "Save as PDF...", self.parent().onSaveAsPDF)
        self.sceneMenu.addAction(getIcon("filepixmap.png"), "Save as PNG...", self.parent().onSaveAsPNG)
        self.sceneMenu.addSeparator()
        self.sceneMenu.addAction(getIcon("copymenu.png"), "Copy to clipboard", self.parent().copyToClipboard)

        # Common menu for all the individually selected items
        self.commonMenu = QMenu()
        # self.commonMenu.addAction(
        #    getIcon( "cutmenu.png" ), "Cut (Ctrl+X)", self.onCut )
        # self.commonMenu.addAction(
        #    getIcon( "copymenu.png" ), "Copy (Ctrl+C)", self.onCopy )
        # self.commonMenu.addSeparator()
        # self.commonMenu.addAction(
        #    getIcon( "trash.png" ), "Delete (Del)", self.onDelete )

        # Non-comment common menu for the individually selected items
        self.nonCommentCommonMenu = QMenu()
        # self.nonCommentCommonMenu.addAction(
        #    getIcon( "customcolors.png" ), "Custom colors...",
        #    self.onCustomColors )
        # self.nonCommentCommonMenu.addAction(
        #    getIcon( "replacetitle.png" ), "Replace text...",
        #    self.onReplaceText )

        # Individual items specific menu: begin
        ifContextMenu = QMenu()
        ifContextMenu.addAction(getIcon("switchbranches.png"), "Switch branch layout", self.onSwitchIfBranch)

        self.individualMenus[IfCell] = ifContextMenu
        # Individual items specific menu: end

        # Menu for a group of selected items
        self.groupMenu = QMenu()
        # self.groupMenu.addAction(
        #    getIcon( "cfgroup.png" ), "Group...",
        #    self.onGroup )
        # self.groupMenu.addAction(
        #    getIcon( "customcolors.png" ), "Custom colors...",
        #    self.onCustomColors )
        # self.groupMenu.addSeparator()
        # self.groupMenu.addAction(
        #    getIcon( "trash.png" ), "Delete (Del)", self.onDelete )

        return
Exemple #3
0
 def __initDocContextMenu(self):
     """Create the Documentation submenu"""
     self.__docSubmenu = QMenu('Documentation')
     self.__docSubmenu.setIcon(getIcon('markdown.png'))
     self.__editDocAction = self.__docSubmenu.addAction(
         getIcon('replacetitle.png'), 'Add/edit doc link/anchor...',
         self.onEditDoc)
     self.__autoDocActon = self.__docSubmenu.addAction(
         getIcon('createdoc.png'),
         'Create doc file, add link and open for editing',
         self.onAutoAddDoc)
     self.__docSubmenu.addSeparator()
     self.__removeDocAction = self.__docSubmenu.addAction(
         getIcon('trash.png'), 'Remove doc link/anchor',
         self.onRemoveDoc)
     return self.__docSubmenu
    def __init__(self, parent=None):
        FilesBrowser.__init__(self, FileSystemBrowserModel(), False, parent)

        self.setWindowTitle('Filesystem browser')
        self.setWindowIcon(getIcon('icon.png'))

        GlobalData().project.sigFSChanged.connect(self._onFSChanged)
Exemple #5
0
 def __markBroken(self):
     """Mark the file as broken"""
     self.__isValid = False
     self.setToolTip(0, 'File does not exist')
     self.setToolTip(1, 'File does not exist')
     self.setToolTip(2, self.getFilename())
     self.setIcon(0, getIcon('brokenproject.png'))
Exemple #6
0
 def _showVCSLabelContextMenu(self, pos):
     """Triggered when a context menu is requested for a VCS label"""
     contextMenu = QMenu(self)
     contextMenu.addAction(getIcon("vcsintervalmenu.png"),
                           "Configure monitor interval",
                           self.__onVCSMonitorInterval)
     contextMenu.popup(self.sbVCSStatus.mapToGlobal(pos))
Exemple #7
0
    def __init__(self, parent):
        TreeViewItem.__init__(self, parent, "Static attributes")

        self.itemType = StaticAttributesItemType
        self.icon = getIcon('attributes.png')
        self.populated = False
        self.lazyPopulation = True
Exemple #8
0
    def __showPyflakesContextMenu(self, pos):
        """Triggered when the icon context menu is requested"""
        if self.__currentUUID is None:
            return
        if self.__currentUUID not in self.__flakesResults:
            return

        messages = self.__flakesResults[self.__currentUUID].messages
        if not messages:
            return

        # Check that there is at least one non -1 lineno message
        lineNumbers = list(messages.keys())
        for lineno in lineNumbers:
            if lineno > 0:
                break
        else:
            return

        # OK, we have something to show
        lineNumbers.sort()
        contextMenu = QMenu(self.__uiLabel)
        for lineno in lineNumbers:
            if lineno > 0:
                for item in messages[lineno]:
                    act = contextMenu.addAction(
                        getIcon('pyflakesmsgmarker.png'),
                        "Line " + str(lineno) + ": " + item)
                    act.setData(lineno)
        contextMenu.triggered.connect(self.__onContextMenu)
        contextMenu.popup(self.__uiLabel.mapToGlobal(pos))
Exemple #9
0
 def __init__(self, items, tooltip):
     items.insert(1, '')
     QTreeWidgetItem.__init__(self, items)
     self.__intColumn = 0
     self.__tooltip = tooltip
     self.__fileModified = False
     self.setIcon(1, getIcon('findtooltip.png'))
Exemple #10
0
    def __showCCContextMenu(self, pos):
        """Triggered when the cc icon context menu is requested"""
        if self.__currentUUID is None:
            return
        if self.__currentUUID not in self.__flakesResults:
            return

        count = 0
        contextMenu = QMenu(self.__ccLabel)
        for item in self.__flakesResults[self.__currentUUID].ccMessages:
            complexity = cc_rank(item.complexity)

            if complexity != 'A':
                count += 1
                title = complexity + '(' + str(item.complexity) + ') ' + \
                        item.fullname
                if item.letter in ('F', 'M'):
                    title += '()'
                act = contextMenu.addAction(getIcon('ccmarker.png'), title)
                act.setData(item.lineno)
        if count > 0:
            contextMenu.triggered.connect(self.__onContextMenu)
            contextMenu.popup(self.__ccLabel.mapToGlobal(pos))
        else:
            del contextMenu
    def __createFilePopupMenu(self):
        """create the recent files popup menu"""
        self.__fileMenu = QMenu(self.recentFilesView)
        self.__openMenuItem = self.__fileMenu.addAction(
            getIcon('openitem.png'), 'Open', self.__openFile)
        self.__copyPathFileMenuItem = self.__fileMenu.addAction(
            getIcon('copymenu.png'),
            'Copy path to clipboard', self.__filePathToClipboard)
        self.__fileMenu.addSeparator()
        self.__delFileMenuItem = self.__fileMenu.addAction(
            getIcon('trash.png'), 'Delete from recent', self.__deleteFile)
        self.recentFilesView.setContextMenuPolicy(Qt.CustomContextMenu)
        self.recentFilesView.customContextMenuRequested.connect(
            self.__handleShowFileContextMenu)

        GlobalData().project.sigRecentFilesChanged.connect(self.__populateFiles)
Exemple #12
0
    def __init__(self):
        QPushButton.__init__(self, getIcon('pluginsettings.png'), "")
        self.setFixedSize(24, 24)
        self.setFocusPolicy(Qt.NoFocus)

        self.index = -1
        self.clicked.connect(self.onClick)
Exemple #13
0
    def __init__(self, editorsManager, parent=None):
        QWidget.__init__(self, parent)

        self.__editorsManager = editorsManager
        self.__mainWindow = parent
        self.__editorsManager.currentChanged.connect(self.__onTabChanged)
        self.__editorsManager.sigTabClosed.connect(self.__onTabClosed)
        self.__editorsManager.sigBufferSavedAs.connect(self.__onSavedBufferAs)
        self.__editorsManager.sigFileTypeChanged.connect(
            self.__onFileTypeChanged)

        self.__outlineBrowsers = {}  # UUID -> OutlineAttributes
        self.__currentUUID = None
        self.__updateTimer = QTimer(self)
        self.__updateTimer.setSingleShot(True)
        self.__updateTimer.timeout.connect(self.__updateView)

        self.findButton = None
        self.outlineViewer = None
        self.toolbar = None
        self.__createLayout()

        self.__modifiedFormat = Settings()['modifiedFormat']

        # create the context menu
        self.__menu = QMenu(self)
        self.__findMenuItem = self.__menu.addAction(
            getIcon('findusage.png'), 'Find where used', self.__findWhereUsed)
Exemple #14
0
    def __createLayout(self):
        """Helper to create the viewer layout"""
        self.globalsViewer = GlobalsBrowser()

        # Toolbar part - buttons
        self.definitionButton = QAction(getIcon('definition.png'),
                                        'Jump to highlighted item definition',
                                        self)
        self.definitionButton.triggered.connect(self.__goToDefinition)
        self.findButton = QAction(getIcon('findusage.png'),
                                  'Find highlighted item occurences', self)
        self.findButton.triggered.connect(self.__findWhereUsed)
        self.copyPathButton = QAction(getIcon('copymenu.png'),
                                      'Copy path to clipboard', self)
        self.copyPathButton.triggered.connect(
            self.globalsViewer.copyToClipboard)

        self.toolbar = QToolBar(self)
        self.toolbar.setMovable(False)
        self.toolbar.setAllowedAreas(Qt.TopToolBarArea)
        self.toolbar.setIconSize(QSize(16, 16))
        self.toolbar.setContentsMargins(0, 0, 0, 0)
        self.toolbar.addAction(self.definitionButton)
        self.toolbar.addAction(self.findButton)
        self.toolbar.addAction(self.copyPathButton)

        filterLabel = QLabel("  Filter ")
        filterLabel.setStyleSheet('background: transparent')
        self.toolbar.addWidget(filterLabel)
        self.filterEdit = CDMComboBox(True, self.toolbar)
        self.filterEdit.setSizePolicy(QSizePolicy.Expanding,
                                      QSizePolicy.Expanding)
        self.filterEdit.lineEdit().setToolTip(
            "Space separated regular expressions")
        self.toolbar.addWidget(self.filterEdit)
        self.filterEdit.editTextChanged.connect(self.__filterChanged)
        self.filterEdit.itemAdded.connect(self.__filterItemAdded)
        self.filterEdit.enterClicked.connect(self.__enterInFilter)

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.addWidget(self.toolbar)
        layout.addWidget(self.globalsViewer)

        self.setLayout(layout)
 def __markBroken( self ):
     " Mark the file as broken "
     self.__isValid = False
     self.setToolTip( 0, 'File does not exist' )
     self.setToolTip( 1, 'File does not exist' )
     self.setToolTip( 2, self.getFilename() )
     self.setIcon( 0, getIcon( 'brokenproject.png' ) )
     return
Exemple #16
0
    def __init__(self, parent, functionObj):
        TreeViewItem.__init__(self, parent, functionObj.getDisplayName())

        self.sourceObj = functionObj
        self.itemType = FunctionItemType

        self.__updateTooltip()

        if functionObj.isPrivate():
            self.icon = getIcon('method_private.png')
        elif functionObj.isProtected():
            self.icon = getIcon('method_protected.png')
        else:
            self.icon = getIcon('method.png')

        self.populated = False
        self.lazyPopulation = True
Exemple #17
0
    def __init__(self, parent, infoObj):
        TreeViewItem.__init__(self, parent, "Classes")

        self.sourceObj = infoObj
        self.itemType = ClassesItemType
        self.icon = getIcon('class.png')
        self.populated = False
        self.lazyPopulation = True
Exemple #18
0
    def __init__(self, parent, infoObj):
        TreeViewItem.__init__(self, parent, "Functions")

        self.sourceObj = infoObj
        self.itemType = FunctionsItemType
        self.icon = getIcon('method.png')
        self.populated = False
        self.lazyPopulation = True
Exemple #19
0
    def __init__(self, parent, infoObj):
        TreeViewItem.__init__(self, parent, "Globals")

        self.sourceObj = infoObj
        self.itemType = GlobalsItemType
        self.icon = getIcon('globalvar.png')
        self.populated = False
        self.lazyPopulation = True
Exemple #20
0
 def __buildDiagramsMenu(self):
     """Builds the diagram menu"""
     diagramsMenu = QMenu("&Diagrams", self)
     diagramsMenu.aboutToShow.connect(self.__diagramsAboutToShow)
     self._prjImportDgmAct = diagramsMenu.addAction(
         getIcon('importsdiagram.png'), '&Project imports diagram',
         self._onImportDgm)
     self._prjImportsDgmDlgAct = diagramsMenu.addAction(
         getIcon('detailsdlg.png'), 'P&roject imports diagram...',
         self._onImportDgmTuned)
     self.__tabImportDgmAct = diagramsMenu.addAction(
         getIcon('importsdiagram.png'), '&Tab imports diagram',
         self._onTabImportDgm)
     self.__tabImportDgmDlgAct = diagramsMenu.addAction(
         getIcon('detailsdlg.png'), 'T&ab imports diagram...',
         self._onTabImportDgmTuned)
     return diagramsMenu
Exemple #21
0
    def __createLayout(self):
        """Creates the widget layout"""
        verticalLayout = QVBoxLayout(self)
        verticalLayout.setContentsMargins(0, 0, 0, 0)
        verticalLayout.setSpacing(0)

        self.headerFrame = QFrame()
        self.headerFrame.setObjectName('stackheader')
        self.headerFrame.setStyleSheet('QFrame#stackheader {' +
                                       getLabelStyle(self) + '}')
        self.headerFrame.setFixedHeight(HEADER_HEIGHT)

        self.__stackLabel = QLabel("Stack")

        expandingSpacer = QSpacerItem(10, 10, QSizePolicy.Expanding)

        self.__showHideButton = QToolButton()
        self.__showHideButton.setAutoRaise(True)
        self.__showHideButton.setIcon(getIcon('less.png'))
        self.__showHideButton.setFixedSize(HEADER_BUTTON, HEADER_BUTTON)
        self.__showHideButton.setToolTip("Hide frames list")
        self.__showHideButton.setFocusPolicy(Qt.NoFocus)
        self.__showHideButton.clicked.connect(self.__onShowHide)

        headerLayout = QHBoxLayout()
        headerLayout.setContentsMargins(0, 0, 0, 0)
        headerLayout.addSpacing(3)
        headerLayout.addWidget(self.__stackLabel)
        headerLayout.addSpacerItem(expandingSpacer)
        headerLayout.addWidget(self.__showHideButton)
        self.headerFrame.setLayout(headerLayout)

        self.__framesList = QTreeWidget(self)
        self.__framesList.setSortingEnabled(False)
        # I might not need that because of two reasons:
        # - the window has no focus
        # - the window has custom current indicator
        # self.__framesList.setAlternatingRowColors(True)
        self.__framesList.setRootIsDecorated(False)
        self.__framesList.setItemsExpandable(False)
        self.__framesList.setUniformRowHeights(True)
        self.__framesList.setSelectionMode(QAbstractItemView.NoSelection)
        self.__framesList.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.__framesList.setItemDelegate(NoOutlineHeightDelegate(4))
        self.__framesList.setFocusPolicy(Qt.NoFocus)
        self.__framesList.setContextMenuPolicy(Qt.CustomContextMenu)

        self.__framesList.itemClicked.connect(self.__onFrameClicked)
        self.__framesList.itemDoubleClicked.connect(
            self.__onFrameDoubleClicked)
        self.__framesList.customContextMenuRequested.connect(
            self.__showContextMenu)

        self.__framesList.setHeaderLabels(
            ["", "File:line", "Function", "Arguments", "Full path"])

        verticalLayout.addWidget(self.headerFrame)
        verticalLayout.addWidget(self.__framesList)
Exemple #22
0
    def __createLayout(self, parent):
        """Helper to create the viewer layout"""
        # Messages list area
        self.messages = QPlainTextEdit(parent)
        self.messages.setLineWrapMode(QPlainTextEdit.NoWrap)
        self.messages.setReadOnly(True)
        self.messages.setMaximumBlockCount(MAX_LINES)

        # Default font size is good enough for most of the systems.
        # 12.0 might be good only in case of the XServer on PC (Xming).
        # self.messages.setFontPointSize( 12.0 )

        # Buttons
        self.selectAllButton = QAction(getIcon('selectall.png'), 'Select all',
                                       self)
        self.selectAllButton.triggered.connect(self.messages.selectAll)
        self.copyButton = QAction(getIcon('copymenu.png'), 'Copy to clipboard',
                                  self)
        self.copyButton.triggered.connect(self.messages.copy)
        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.clearButton = QAction(getIcon('trash.png'), 'Clear all', self)
        self.clearButton.triggered.connect(self.__clear)

        # Toolbar
        self.toolbar = QToolBar()
        self.toolbar.setOrientation(Qt.Vertical)
        self.toolbar.setMovable(False)
        self.toolbar.setAllowedAreas(Qt.LeftToolBarArea)
        self.toolbar.setIconSize(QSize(16, 16))
        self.toolbar.setFixedWidth(28)
        self.toolbar.setContentsMargins(0, 0, 0, 0)
        self.toolbar.addAction(self.selectAllButton)
        self.toolbar.addAction(self.copyButton)
        self.toolbar.addWidget(spacer)
        self.toolbar.addAction(self.clearButton)

        # layout
        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.addWidget(self.toolbar)
        layout.addWidget(self.messages)

        self.setLayout(layout)
Exemple #23
0
    def __init__(self, parent):

        TreeViewItem.__init__(self, parent, "sys.path")

        self.itemType = SysPathItemType
        self.icon = getIcon('filepython.png')
        self.populated = False
        self.lazyPopulation = True
        self.isLink = False
Exemple #24
0
    def __init__(self, parent, importObj):
        TreeViewItem.__init__(self, parent, importObj.getDisplayName())

        self.sourceObj = importObj
        self.itemType = ImportItemType
        self.icon = getIcon('imports.png')

        self.populated = False
        self.lazyPopulation = True
Exemple #25
0
 def _recomposePluginMenu(self):
     """Recomposes the plugin menu"""
     self.__pluginsMenu.clear()
     self.__pluginsMenu.addAction(getIcon('pluginmanagermenu.png'),
                                  'Plugin &manager', self._onPluginManager)
     if self._pluginMenus:
         self.__pluginsMenu.addSeparator()
     for path in self._pluginMenus:
         self.__pluginsMenu.addMenu(self._pluginMenus[path])
Exemple #26
0
    def __init__(self):
        QPushButton.__init__(self, getIcon(pluginHomeDir + 'svnmenudiff.png'),
                             "")
        self.setFixedSize(24, 24)
        self.setFocusPolicy(Qt.NoFocus)

        self.path = ""
        self.status = None
        self.clicked.connect(self.onClick)
Exemple #27
0
    def __createLayout(self):
        """Helper to create the viewer layout"""
        # Toolbar part - buttons
        self.findButton = QAction(
            getIcon('findusage.png'), 'Find where highlighted item is used',
            self)
        self.findButton.setVisible(False)
        self.findButton.triggered.connect(self.__findWhereUsed)
        self.showParsingErrorsButton = QAction(
            getIcon('showparsingerrors.png'), 'Show lexer/parser errors', self)
        self.showParsingErrorsButton.triggered.connect(self.__showParserError)
        self.showParsingErrorsButton.setEnabled(False)

        self.toolbar = QToolBar(self)
        self.toolbar.setMovable(False)
        self.toolbar.setAllowedAreas(Qt.TopToolBarArea)
        self.toolbar.setIconSize(QSize(16, 16))
        self.toolbar.setFixedHeight(28)
        self.toolbar.setContentsMargins(0, 0, 0, 0)
        self.toolbar.addAction(self.findButton)
        self.toolbar.addAction(self.showParsingErrorsButton)

        # Prepare members for reuse
        self.__noneLabel = QLabel("\nNot a python file")
        self.__noneLabel.setFrameShape(QFrame.StyledPanel)
        self.__noneLabel.setAlignment(Qt.AlignHCenter)
        headerFont = self.__noneLabel.font()
        headerFont.setPointSize(headerFont.pointSize() + 2)
        self.__noneLabel.setFont(headerFont)
        self.__noneLabel.setAutoFillBackground(True)
        noneLabelPalette = self.__noneLabel.palette()
        noneLabelPalette.setColor(QPalette.Background,
                                  GlobalData().skin['nolexerPaper'])
        self.__noneLabel.setPalette(noneLabelPalette)

        self.__layout = QVBoxLayout()
        self.__layout.setContentsMargins(0, 0, 0, 0)
        self.__layout.setSpacing(0)
        self.__layout.addWidget(self.toolbar)
        self.__layout.addWidget(self.__noneLabel)

        self.setLayout(self.__layout)
 def __togglePath(self, state):
     """Triggered when full path/file name is switched"""
     self.__profTable.togglePath(state)
     if state:
         fName = 'shortpath.png'
         tip = 'Show file names only for item location'
     else:
         fName = 'longpath.png'
         tip = 'Show full paths for item location'
     self.__togglePathButton.setIcon(getIcon(fName))
     self.__togglePathButton.setToolTip(tip)
Exemple #29
0
    def updateStatus(self):
        """Updates internal fields"""
        if os.path.exists(self._dirName):
            self.icon = getIcon('dirclosed.png')
            self.populated = False
            self.lazyPopulation = True

            if os.path.islink(self._dirName):
                self.isLink = True
                linkTo = os.readlink(self._dirName)
                realpath = os.path.realpath(self._dirName)
                self.toolTip = "-> " + linkTo + "  (" + realpath + ")"
                self.icon = getIcon('dirlink.png')
        else:
            self.icon = getIcon('dirbroken.png')
            self.populated = True
            self.lazyPopulation = False

            self.childItems = []
            self.childItemsSize = 0
    def __init__(self, files, action, parent=None):
        QDialog.__init__(self, parent)

        count = len(files)
        if count >= 2:
            title = str(count) + " project files are modified and not saved"
        else:
            title = "1 project file modified and not saved"
        self.setWindowTitle(title)
        self.setWindowIcon(getIcon('warning.png'))
        self.__createLayout(action, title, files)
Exemple #31
0
    def __createProjectPopupMenu(self):
        """Creates the recent project popup menu"""
        self.__projectMenu = QMenu(self.projectsView)
        self.__prjLoadMenuItem = self.__projectMenu.addAction(
            getIcon('load.png'), 'Load', self.__loadProject)
        self.__projectMenu.addSeparator()
        self.__propsMenuItem = self.__projectMenu.addAction(
            getIcon('smalli.png'), 'Properties', self.__viewProperties)
        self.__prjCopyPathMenuItem = self.__projectMenu.addAction(
            getIcon('copymenu.png'),
            'Copy path to clipboard', self.__prjPathToClipboard)
        self.__projectMenu.addSeparator()
        self.__delPrjMenuItem = self.__projectMenu.addAction(
            getIcon('trash.png'), 'Delete from recent', self.__deleteProject)
        self.projectsView.setContextMenuPolicy(Qt.CustomContextMenu)
        self.projectsView.customContextMenuRequested.connect(
            self.__handleShowPrjContextMenu)

        Settings().sigRecentListChanged.connect(self.__populateProjects)
        GlobalData().project.sigProjectChanged.connect(self.__projectChanged)
Exemple #32
0
    def __createLayout(self):
        """Creates the widget layout"""
        verticalLayout = QVBoxLayout(self)
        verticalLayout.setContentsMargins(0, 0, 0, 0)
        verticalLayout.setSpacing(0)

        self.__stackLabel = HeaderFitLabel(self)
        self.__stackLabel.setText('Stack')
        self.__stackLabel.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Fixed)
        self.__stackLabel.setMinimumWidth(10)

        self.__showHideButton = QToolButton()
        self.__showHideButton.setAutoRaise(True)
        self.__showHideButton.setIcon(getIcon('less.png'))
        self.__showHideButton.setFixedSize(self.__stackLabel.height(),
                                           self.__stackLabel.height())
        self.__showHideButton.setToolTip('Hide frames list')
        self.__showHideButton.setFocusPolicy(Qt.NoFocus)
        self.__showHideButton.clicked.connect(self.__onShowHide)

        self.headerToolbar = QToolBar(self)
        self.headerToolbar.setIconSize(QSize(16, 16))
        self.headerToolbar.setContentsMargins(1, 1, 1, 1)
        self.headerToolbar.addWidget(self.__stackLabel)
        self.headerToolbar.addWidget(self.__showHideButton)

        self.__framesList = QTreeWidget(self)
        self.__framesList.setSortingEnabled(False)
        # I might not need that because of two reasons:
        # - the window has no focus
        # - the window has custom current indicator
        # self.__framesList.setAlternatingRowColors(True)
        self.__framesList.setRootIsDecorated(False)
        self.__framesList.setItemsExpandable(False)
        self.__framesList.setUniformRowHeights(True)
        self.__framesList.setSelectionMode(QAbstractItemView.NoSelection)
        self.__framesList.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.__framesList.setItemDelegate(NoOutlineHeightDelegate(4))
        self.__framesList.setFocusPolicy(Qt.NoFocus)
        self.__framesList.setContextMenuPolicy(Qt.CustomContextMenu)

        self.__framesList.itemClicked.connect(self.__onFrameClicked)
        self.__framesList.itemDoubleClicked.connect(
            self.__onFrameDoubleClicked)
        self.__framesList.customContextMenuRequested.connect(
            self.__showContextMenu)

        self.__framesList.setHeaderLabels(
            ['', 'File:line', 'Function', 'Arguments', 'Full path'])

        verticalLayout.addWidget(self.headerToolbar)
        verticalLayout.addWidget(self.__framesList)
Exemple #33
0
    def __onShowHide(self):
        """Triggered when show/hide button is clicked"""
        if self.projectsView.isVisible():
            self.projectsView.setVisible(False)
            self.lowerToolbar.setVisible(False)
            self.__showHideButton.setIcon(getIcon('more.png'))
            self.__showHideButton.setToolTip("Show recent projects list")

            self.__minH = self.lower.minimumHeight()
            self.__maxH = self.lower.maximumHeight()

            self.lower.setMinimumHeight(self.headerFrame.height())
            self.lower.setMaximumHeight(self.headerFrame.height())
        else:
            self.projectsView.setVisible(True)
            self.lowerToolbar.setVisible(True)
            self.__showHideButton.setIcon(getIcon('less.png'))
            self.__showHideButton.setToolTip("Hide recent projects list")

            self.lower.setMinimumHeight(self.__minH)
            self.lower.setMaximumHeight(self.__maxH)
    def __markOK( self ):
        " Mark the file as OK "
        self.__isValid = True
        fileName = self.getFilename()
        fileType = detectFileType( fileName )
        if fileType in [ PythonFileType, Python3FileType ]:
            # The tooltip could be the file docstring
            info = GlobalData().briefModinfoCache.get( fileName )
            if info.docstring is not None and Settings().recentTooltips:
                self.setToolTip( 1, info.docstring.text )
            else:
                self.setToolTip( 1, "" )
            if info.isOK:
                self.setIcon( 0, getIcon( 'filepython.png' ) )
            else:
                self.setIcon( 0, getIcon( 'filepythonbroken.png' ) )
            self.setToolTip( 0, "" )

        elif fileType == CodimensionProjectFileType:
            # Get the project properties
            try:
                self.setToolTip( 0, "" )
                tooltip = getProjectFileTooltip( fileName )
                if Settings().recentTooltips:
                    self.setToolTip( 1, tooltip )
                else:
                    self.setToolTip( 1, "" )
                self.setText( 0, "" )
            except:
                # cannot get project properties. Mark broken.
                self.__isValid = False
                self.setToolTip( 0, 'Broken project file' )
                self.setToolTip( 1, 'Broken project file' )
            self.setIcon( 0, getFileIcon( fileType ) )
        else:
            # Get the other file type icon
            self.setIcon( 0, getFileIcon( fileType ) )

        self.setToolTip( 2, self.getFilename() )
        return
    def __createFilePopupMenu( self ):
        " create the recent files popup menu "
        self.__fileMenu = QMenu( self.recentFilesView )
        self.__openMenuItem = self.__fileMenu.addAction(
                                getIcon( 'openitem.png' ),
                                'Open', self.__openFile )
        self.__copyPathFileMenuItem = self.__fileMenu.addAction(
                        getIcon( 'copytoclipboard.png' ),
                        'Copy path to clipboard', self.__filePathToClipboard )
        self.__fileMenu.addSeparator()
        self.__delFileMenuItem = self.__fileMenu.addAction(
                                getIcon( 'trash.png' ),
                                'Delete from recent',
                                self.__deleteFile )
        self.recentFilesView.setContextMenuPolicy( Qt.CustomContextMenu )
        self.connect( self.recentFilesView,
                      SIGNAL( "customContextMenuRequested(const QPoint &)" ),
                      self.__handleShowFileContextMenu )

        self.connect( GlobalData().project, SIGNAL( 'recentFilesChanged' ),
                      self.__populateFiles )
        return
    def __onShowHide( self ):
        " Triggered when show/hide button is clicked "
        if self.projectsView.isVisible():
            self.projectsView.setVisible( False )
            self.lowerToolbar.setVisible( False )
            self.__showHideButton.setIcon( getIcon( 'more.png' ) )
            self.__showHideButton.setToolTip( "Show recent projects list" )

            self.__minH = self.lower.minimumHeight()
            self.__maxH = self.lower.maximumHeight()

            self.lower.setMinimumHeight( self.headerFrame.height() )
            self.lower.setMaximumHeight( self.headerFrame.height() )
        else:
            self.projectsView.setVisible( True )
            self.lowerToolbar.setVisible( True )
            self.__showHideButton.setIcon( getIcon( 'less.png' ) )
            self.__showHideButton.setToolTip( "Hide recent projects list" )

            self.lower.setMinimumHeight( self.__minH )
            self.lower.setMaximumHeight( self.__maxH )
        return
Exemple #37
0
    def __createToolbar( self ):
        " Creates the toolbar "
        self.__toolbar = QToolBar( self )
        self.__toolbar.setOrientation( Qt.Vertical )
        self.__toolbar.setMovable( False )
        self.__toolbar.setAllowedAreas( Qt.RightToolBarArea )
        self.__toolbar.setIconSize( QSize( 16, 16 ) )
        self.__toolbar.setFixedWidth( 28 )
        self.__toolbar.setContentsMargins( 0, 0, 0, 0 )

        # Buttons
        saveAsMenu = QMenu( self )
        saveAsSVGAct = saveAsMenu.addAction( getIcon( 'filesvg.png' ),
                                             'Save as SVG...' )
        saveAsSVGAct.triggered.connect( self.onSaveAsSVG )

        saveAsPDFAct = saveAsMenu.addAction( getIcon( 'filepdf.png' ),
                                             'Save as PDF...' )
        saveAsPDFAct.triggered.connect( self.onSaveAsPDF )
        saveAsPNGAct = saveAsMenu.addAction( getIcon( 'filepixmap.png' ),
                                             'Save as PNG...' )
        saveAsPNGAct.triggered.connect( self.onSaveAsPNG )
        saveAsMenu.addSeparator()
        saveAsCopyToClipboardAct = saveAsMenu.addAction( getIcon( 'copymenu.png' ),
                                                         'Copy to clipboard' )
        saveAsCopyToClipboardAct.triggered.connect( self.copyToClipboard )


        self.__saveAsButton = QToolButton( self )
        self.__saveAsButton.setIcon( getIcon( 'saveasmenu.png' ) )
        self.__saveAsButton.setToolTip( 'Save as' )
        self.__saveAsButton.setPopupMode( QToolButton.InstantPopup )
        self.__saveAsButton.setMenu( saveAsMenu )
        self.__saveAsButton.setFocusPolicy( Qt.NoFocus )

        self.__toolbar.addWidget( self.__saveAsButton )
        return self.__toolbar
    def __createRecentProjectsLayout( self ):
        " Creates the bottom layout "
        self.headerFrame = QFrame()
        self.headerFrame.setFrameStyle( QFrame.StyledPanel )
        self.headerFrame.setAutoFillBackground( True )
        headerPalette = self.headerFrame.palette()
        headerBackground = headerPalette.color( QPalette.Background )
        headerBackground.setRgb( min( headerBackground.red() + 30, 255 ),
                                 min( headerBackground.green() + 30, 255 ),
                                 min( headerBackground.blue() + 30, 255 ) )
        headerPalette.setColor( QPalette.Background, headerBackground )
        self.headerFrame.setPalette( headerPalette )
        self.headerFrame.setFixedHeight( 24 )

        recentProjectsLabel = QLabel()
        recentProjectsLabel.setText( "Recent projects" )

        expandingSpacer = QSpacerItem( 10, 10, QSizePolicy.Expanding )

        self.__showHideButton = QToolButton()
        self.__showHideButton.setAutoRaise( True )
        self.__showHideButton.setIcon( getIcon( 'less.png' ) )
        self.__showHideButton.setFixedSize( 20, 20 )
        self.__showHideButton.setToolTip( "Hide recent projects list" )
        self.__showHideButton.setFocusPolicy( Qt.NoFocus )
        self.connect( self.__showHideButton, SIGNAL( 'clicked()' ),
                      self.__onShowHide )

        headerLayout = QHBoxLayout()
        headerLayout.setContentsMargins( 3, 0, 0, 0 )
        headerLayout.addWidget( recentProjectsLabel )
        headerLayout.addSpacerItem( expandingSpacer )
        headerLayout.addWidget( self.__showHideButton )
        self.headerFrame.setLayout( headerLayout )

        # Toolbar part - buttons
        self.loadButton = QAction( getIcon( 'load.png' ),
                                   'Load the highlighted project', self )
        self.connect( self.loadButton, SIGNAL( "triggered()" ),
                      self.__loadProject )
        self.propertiesButton = QAction( getIcon( 'smalli.png' ),
                                         'Show the highlighted project '
                                         'properties', self )
        self.connect( self.propertiesButton, SIGNAL( "triggered()" ),
                      self.__viewProperties )
        self.copyPrjPathButton = QAction( getIcon( 'copytoclipboard.png' ),
                                                   'Copy path to clipboard',
                                                   self )
        self.connect( self.copyPrjPathButton, SIGNAL( "triggered()" ),
                      self.__prjPathToClipboard )
        spacer = QWidget()
        spacer.setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Expanding )
        self.trashButton = QAction( getIcon( 'delitem.png' ),
                                    'Remove selected (not from the disk)',
                                    self )
        self.connect( self.trashButton, SIGNAL( "triggered()" ),
                      self.__deleteProject )

        self.lowerToolbar = QToolBar()
        self.lowerToolbar.setMovable( False )
        self.lowerToolbar.setAllowedAreas( Qt.TopToolBarArea )
        self.lowerToolbar.setIconSize( QSize( 16, 16 ) )
        self.lowerToolbar.setFixedHeight( 28 )
        self.lowerToolbar.setContentsMargins( 0, 0, 0, 0 )
        self.lowerToolbar.addAction( self.loadButton )
        self.lowerToolbar.addAction( self.propertiesButton )
        self.lowerToolbar.addAction( self.copyPrjPathButton )
        self.lowerToolbar.addWidget( spacer )
        self.lowerToolbar.addAction( self.trashButton )

        self.projectsView = QTreeWidget()
        self.projectsView.setAlternatingRowColors( True )
        self.projectsView.setRootIsDecorated( False )
        self.projectsView.setItemsExpandable( False )
        self.projectsView.setSortingEnabled( True )
        self.projectsView.setItemDelegate( NoOutlineHeightDelegate( 4 ) )
        self.projectsView.setUniformRowHeights( True )

        self.__projectsHeaderItem = QTreeWidgetItem( [ "", "Project",
                                                       "Absolute path" ] )
        self.projectsView.setHeaderItem( self.__projectsHeaderItem )

        self.projectsView.header().setSortIndicator( 1, Qt.AscendingOrder )
        self.connect( self.projectsView,
                      SIGNAL( "itemActivated(QTreeWidgetItem *, int)" ),
                      self.__projectActivated )
        self.connect( self.projectsView,
                      SIGNAL( "itemSelectionChanged()" ),
                      self.__projectSelectionChanged )

        recentProjectsLayout = QVBoxLayout()
        recentProjectsLayout.setContentsMargins( 0, 0, 0, 0 )
        recentProjectsLayout.setSpacing( 0 )
        recentProjectsLayout.addWidget( self.headerFrame )
        recentProjectsLayout.addWidget( self.lowerToolbar )
        recentProjectsLayout.addWidget( self.projectsView )

        lowerContainer = QWidget()
        lowerContainer.setContentsMargins( 0, 0, 0, 0 )
        lowerContainer.setLayout( recentProjectsLayout )
        return lowerContainer
 def __markBroken( self ):
     """ Mark the broken project with an icon """
     self.setIcon( 0, getIcon( 'brokenproject.png' ) )
     return
 def __markCurrent( self ):
     """ Mark the current project with an icon """
     self.setIcon( 0, getIcon( 'currentproject.png' ) )
     self.__isCurrent = True
     return
    def __createRecentFilesLayout( self ):
        " Creates the upper part - recent files "
        headerFrame = QFrame()
        headerFrame.setFrameStyle( QFrame.StyledPanel )
        headerFrame.setAutoFillBackground( True )
        headerPalette = headerFrame.palette()
        headerBackground = headerPalette.color( QPalette.Background )
        headerBackground.setRgb( min( headerBackground.red() + 30, 255 ),
                                 min( headerBackground.green() + 30, 255 ),
                                 min( headerBackground.blue() + 30, 255 ) )
        headerPalette.setColor( QPalette.Background, headerBackground )
        headerFrame.setPalette( headerPalette )
        headerFrame.setFixedHeight( 24 )

        recentFilesLabel = QLabel()
        recentFilesLabel.setText( "Recent files" )

        headerLayout = QHBoxLayout()
        headerLayout.setContentsMargins( 3, 0, 0, 0 )
        headerLayout.addWidget( recentFilesLabel )
        headerFrame.setLayout( headerLayout )

        self.recentFilesView = QTreeWidget()
        self.recentFilesView.setAlternatingRowColors( True )
        self.recentFilesView.setRootIsDecorated( False )
        self.recentFilesView.setItemsExpandable( False )
        self.recentFilesView.setSortingEnabled( True )
        self.recentFilesView.setItemDelegate( NoOutlineHeightDelegate( 4 ) )
        self.recentFilesView.setUniformRowHeights( True )

        self.__filesHeaderItem = QTreeWidgetItem( [ "", "File",
                                                    "Absolute path" ] )
        self.recentFilesView.setHeaderItem( self.__filesHeaderItem )
        self.recentFilesView.header().setSortIndicator( 1, Qt.AscendingOrder )

        self.connect( self.recentFilesView,
                      SIGNAL( "itemSelectionChanged()" ),
                      self.__fileSelectionChanged )
        self.connect( self.recentFilesView,
                      SIGNAL( "itemActivated(QTreeWidgetItem *, int)" ),
                      self.__fileActivated )

        # Toolbar part - buttons
        self.openFileButton = QAction( getIcon( 'openitem.png' ),
                                       'Open the highlighted file', self )
        self.connect( self.openFileButton, SIGNAL( "triggered()" ),
                      self.__openFile )
        self.copyFilePathButton = QAction(
                        getIcon( 'copytoclipboard.png' ),
                        'Copy path to clipboard', self )
        self.connect( self.copyFilePathButton, SIGNAL( "triggered()" ),
                      self.__filePathToClipboard )
        spacer = QWidget()
        spacer.setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Expanding )
        self.trashFileButton = QAction( getIcon( 'delitem.png' ),
                                        'Remove selected (not from the disk)',
                                        self )
        self.connect( self.trashFileButton, SIGNAL( "triggered()" ),
                      self.__deleteFile )

        self.upperToolbar = QToolBar()
        self.upperToolbar.setMovable( False )
        self.upperToolbar.setAllowedAreas( Qt.TopToolBarArea )
        self.upperToolbar.setIconSize( QSize( 16, 16 ) )
        self.upperToolbar.setFixedHeight( 28 )
        self.upperToolbar.setContentsMargins( 0, 0, 0, 0 )
        self.upperToolbar.addAction( self.openFileButton )
        self.upperToolbar.addAction( self.copyFilePathButton )
        self.upperToolbar.addWidget( spacer )
        self.upperToolbar.addAction( self.trashFileButton )

        recentFilesLayout = QVBoxLayout()
        recentFilesLayout.setContentsMargins( 0, 0, 0, 0 )
        recentFilesLayout.setSpacing( 0 )
        recentFilesLayout.addWidget( headerFrame )
        recentFilesLayout.addWidget( self.upperToolbar )
        recentFilesLayout.addWidget( self.recentFilesView )

        upperContainer = QWidget()
        upperContainer.setContentsMargins( 0, 0, 0, 0 )
        upperContainer.setLayout( recentFilesLayout )
        return upperContainer