Exemplo n.º 1
0
    def _onShowAnyWhitespaceTriggered(self, checked):
        for document in core.workspace().documents():
            document.qutepart.drawAnyWhitespace = checked
        core.config()["Qutepart"]["WhiteSpaceVisibility"]["Any"] = checked
        core.config().flush()

        core.actionManager().action("mView/aShowIncorrectIndentation").setEnabled(not checked)
Exemplo n.º 2
0
    def __init__(self, fileBrowser):
        QComboBox.__init__(self, fileBrowser)

        self._fileBrowser = fileBrowser

        self.setAttribute(Qt.WA_MacShowFocusRect, False)
        self.setAttribute(Qt.WA_MacSmallSize)
        self.setEditable(True)
        self.setMinimumContentsLength(1)
        self.setSizeAdjustPolicy(
            QComboBox.AdjustToMinimumContentsLengthWithIcon)
        self.lineEdit().setReadOnly(False)
        self._completionModel = QDirModel(self.lineEdit())
        self._completionModel.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot)
        self.lineEdit().setCompleter(
            QCompleter(self._completionModel, self.lineEdit()))
        #TODO QDirModel is deprecated but QCompleter does not yet handle
        #QFileSystemModel - please update when possible.
        self._count = 0

        # Show popup action
        self._showPopupAction = QAction(QIcon(':enkiicons/filtered.png'),
                                        "File browser history", self)
        self._showPopupAction.setShortcut('Ctrl+H')
        core.actionManager().addAction("mNavigation/mFileBrowser/aMenuShow",
                                       self._showPopupAction)
        self._showPopupAction.triggered.connect(self._onShowPopup)

        # reconnected in self.updateComboItems()
        self.currentIndexChanged[int].connect(self._onItemSelected)
Exemplo n.º 3
0
    def __init__(self):
        QObject.__init__(self)
        self._commandClasses = []

        self._action = core.actionManager().addAction("mNavigation/aLocator", "Locator", shortcut='Ctrl+L')
        self._action.triggered.connect(self._onAction)
        self._separator = core.actionManager().menu("mNavigation").addSeparator()
Exemplo n.º 4
0
 def terminate(self):
     """Explicitly called destructor
     """
     self._cleanupActions()
     core.workspace().documentClosed.disconnect(self._onDocumentClosed)
     core.actionManager().removeAction(self._undoClose)
     enki.core.json_wrapper.dump(_FILE_PATH, 'recent file', self._recent)
Exemplo n.º 5
0
    def _install(self):
        """Install the plugin to the core
        """
        if self._installed:
            return

        self._schemeMenu = core.actionManager().addMenu(self._MENU_PATH, self._FULL_NAME)
        self._evalAction = core.actionManager().addAction("%s/aEval" % self._MENU_PATH,
                                                          "Eval. selection/Save and eval.")
        self._evalAction.setStatusTip("Evaluate selection. If nothing is selected - save and evaluate whole file")
        self._evalAction.setShortcut("Ctrl+E")
        self._evalAction.triggered.connect(self._onEvalTriggered)
        self._breakAction = core.actionManager().addAction("%s/aBreak" % self._MENU_PATH, "Stop the interpreter")
        self._breakAction.setStatusTip("Use it as a restart action.")
        self._breakAction.setShortcut("Pause")
        self._breakAction.triggered.connect(self._onBreakTriggered)
        self._breakAction.setEnabled(False)

        self._activeInterpreterPath = self._settingsGroup()["InterpreterPath"]
        
        self._interpreter = self._createInterpreter()
        
        self._interpreter.processIsRunningChanged.connect(lambda isRunning: self._breakAction.setEnabled(isRunning))
        
        from repl import ReplDock
        self._dock = ReplDock(self._interpreter.widget(), self._LANGUAGE, self._DOCK_TITLE, self._icon())

        core.mainWindow().addDockWidget(Qt.BottomDockWidgetArea, self._dock)
        self._dock.hide()

        self._installed = True
Exemplo n.º 6
0
    def __init__(self, parent):
        DockWidget.__init__(self, parent, "&Search Results",
                            QIcon(":/enkiicons/search.png"), "Alt+S")

        # actions
        self._model = searchresultsmodel.SearchResultsModel(self)
        self.onResultsHandledByReplaceThread.connect(
            self._model.onResultsHandledByReplaceThread)

        self._view = QTreeView(self)
        self._view.setHeaderHidden(True)
        self._view.setUniformRowHeights(True)
        self._view.setModel(self._model)
        self._delegate = HTMLDelegate()
        self._view.setItemDelegate(self._delegate)

        self.setWidget(self._view)
        self.setFocusProxy(self._view)

        # connections
        self._model.firstResultsAvailable.connect(self.show)
        self._view.activated.connect(self._onResultActivated)

        core.actionManager().addAction("mView/aSearchResults",
                                       self.showAction())

        self._expandCollapseAll = ExpandCollapseAllButton(
            self.titleBarWidget(), self._view, self._model)
        self._checkUncheckAll = None
Exemplo n.º 7
0
 def _addAction(self):
     """Add action to main menu
     This action uses embedded icons. You can find list of icons in **icons** directory at project root
     """
     self._action = core.actionManager().addAction("mHelp/aSayHello", 'Say Hello...', QIcon(':/enkiicons/logo/32x32/enki.png'))
     core.actionManager().setDefaultShortcut(self._action, "Ctrl+Alt+Shift+H")
     self._action.triggered.connect(self._sayHello)
Exemplo n.º 8
0
 def _onDocumentOpenedOrClosed(self):
     # update view menu
     moreThanOneDocument = len(core.workspace().documents()) > 0
     core.actionManager().action("mNavigation/aForwardSwitch").setEnabled(
         moreThanOneDocument)
     core.actionManager().action("mNavigation/aBackwardSwitch").setEnabled(
         moreThanOneDocument)
Exemplo n.º 9
0
    def terminate(self):
        """Explicitly called destructor
        """
        if self._searchThread is not None:
            self._searchThread.stop()
        if self._replaceThread is not None:
            self._replaceThread.stop()

        for action in self._createdActions:
            core.actionManager().removeAction(action)
        self._menuSeparator.parent().removeAction(self._menuSeparator)

        if self._widget is not None:
            core.workspace().currentDocumentChanged.disconnect(
                self._updateFileActionsState)
            self._widget.visibilityChanged.disconnect(
                self._updateSearchWidgetFoundItemsHighlighting)
            core.workspace().textChanged.disconnect(
                self._updateSearchWidgetFoundItemsHighlighting)
            self._widget = None

        if self._dock is not None:
            self._dock.terminate()
            self._dock = None

        core.workspace().currentDocumentChanged.disconnect(
            self._onCurrentDocumentChanged)
        core.workspace().currentDocumentChanged.disconnect(
            self._resetSearchInFileStartPoint)
        QApplication.instance().focusChanged.disconnect(
            self._resetSearchInFileStartPoint)
Exemplo n.º 10
0
 def _addAction(self):
     """Add action to main menu
     """
     action = core.actionManager().addAction(
         "mTools/aOpenTerm", ACTION_TEXT, QIcon(':enkiicons/console.png'))
     core.actionManager().setDefaultShortcut(action, "Ctrl+T")
     action.triggered.connect(self._openTerm)
Exemplo n.º 11
0
    def __init__(self):
        Plugin.instance = self
        core.workspace().documentOpened.connect(self._onDocumentOpened)
        core.uiSettingsManager().aboutToExecute.connect(
            self._onSettingsDialogAboutToExecute)

        showTrailingAction = core.actionManager().action(
            'mView/aShowIncorrectIndentation')
        showTrailingAction.triggered.connect(self._onShowIncorrectTriggered)
        showTrailingAction.setChecked(self._confShowIncorrect())
        showTrailingAction.setEnabled(not self._confShowAnyWhitespace())

        showAnyIndentAction = core.actionManager().action(
            'mView/aShowAnyWhitespaces')
        showAnyIndentAction.triggered.connect(
            self._onShowAnyWhitespaceTriggered)
        showAnyIndentAction.setChecked(self._confShowAnyWhitespace())
        showAnyIndentAction.setEnabled(True)

        stripTrailingWhitespaceAction = core.actionManager().action(
            'mEdit/aStripTrailingWhitespace')
        stripTrailingWhitespaceAction.triggered.connect(
            self._onStripTrailingTriggered)
        stripTrailingWhitespaceAction.setChecked(self._confStripTrailing())
        stripTrailingWhitespaceAction.setEnabled(True)

        enableVimMode = core.actionManager().action('mEdit/aEnableVimMode')
        enableVimMode.triggered.connect(self._onVimModeEnabledChanged)
        enableVimMode.setChecked(self._confVimModeEnabled())
        enableVimMode.setEnabled(True)
Exemplo n.º 12
0
    def __init__(self, workspace):
        DockWidget.__init__(self, workspace, "&Opened Files", QIcon(":/enkiicons/filtered.png"), "Alt+O")

        self._workspace = workspace

        self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)

        self.tvFiles = QTreeView(self)
        self.tvFiles.setHeaderHidden(True)
        self.tvFiles.setEditTriggers(QAbstractItemView.SelectedClicked)
        self.tvFiles.setContextMenuPolicy(Qt.CustomContextMenu)
        self.tvFiles.setDragEnabled(True)
        self.tvFiles.setDragDropMode(QAbstractItemView.InternalMove)
        self.tvFiles.setRootIsDecorated(False)
        self.tvFiles.setTextElideMode(Qt.ElideMiddle)
        self.tvFiles.setUniformRowHeights(True)

        self.tvFiles.customContextMenuRequested.connect(self._onTvFilesCustomContextMenuRequested)

        self.setWidget(self.tvFiles)
        self.setFocusProxy(self.tvFiles)

        self.model = _OpenedFileModel(self)  # Not protected, because used by Configurator
        self.tvFiles.setModel(self.model)
        self.tvFiles.setAttribute(Qt.WA_MacShowFocusRect, False)
        self.tvFiles.setAttribute(Qt.WA_MacSmallSize)

        self._workspace.currentDocumentChanged.connect(self._onCurrentDocumentChanged)

        # disconnected by startModifyModel()
        self.tvFiles.selectionModel().selectionChanged.connect(self._onSelectionModelSelectionChanged)

        self.tvFiles.activated.connect(self._workspace.focusCurrentDocument)

        core.actionManager().addAction("mView/aOpenedFiles", self.showAction())
Exemplo n.º 13
0
    def _install(self):
        """Install the plugin to the core
        """
        if self._installed:
            return

        self._schemeMenu = core.actionManager().addMenu(self._MENU_PATH, self._FULL_NAME)
        self._evalAction = core.actionManager().addAction("%s/aEval" % self._MENU_PATH,
                                                          "Eval. selection/Save and eval.")
        self._evalAction.setStatusTip("Evaluate selection. If nothing is selected, then save and evaluate whole file.")
        self._evalAction.setShortcut("Ctrl+E")
        self._evalAction.triggered.connect(self._onEvalTriggered)
        self._breakAction = core.actionManager().addAction("%s/aBreak" % self._MENU_PATH, "Stop the interpreter")
        self._breakAction.setStatusTip("Use it as a restart action.")
        self._breakAction.setShortcut("Pause")
        self._breakAction.triggered.connect(self._onBreakTriggered)
        #self._breakAction.setEnabled(False)

        if self._dock is None:
            from .repl import ReplDock
            self._dock = ReplDock(self._DOCK_TITLE, self._icon())

        core.actionManager().addAction("mView/a%s" % self._LANGUAGE, self._dock.showAction())
        core.mainWindow().addDockWidget(Qt.BottomDockWidgetArea, self._dock)

        self._installed = True
Exemplo n.º 14
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)
Exemplo n.º 15
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 ) )
Exemplo n.º 16
0
 def _onDocumentOpenedOrClosed(self):
     # update view menu
     moreThanOneDocument = len(core.workspace().documents()) > 1
     core.actionManager().action("mNavigation/aNext").setEnabled(
         moreThanOneDocument)
     core.actionManager().action("mNavigation/aPrevious").setEnabled(
         moreThanOneDocument)
Exemplo n.º 17
0
    def _install(self):
        """Install the plugin to the core
        """
        if self._installed:
            return

        self._schemeMenu = core.actionManager().addMenu(self._MENU_PATH, self._FULL_NAME)
        self._evalAction = core.actionManager().addAction("%s/aEval" % self._MENU_PATH,
                                                          "Eval. selection/Save and eval.")
        self._evalAction.setStatusTip("Evaluate selection. If nothing is selected - save and evaluate whole file")
        self._evalAction.setShortcut("Ctrl+E")
        self._evalAction.triggered.connect(self._onEvalTriggered)
        self._breakAction = core.actionManager().addAction("%s/aBreak" % self._MENU_PATH, "Stop the interpreter")
        self._breakAction.setStatusTip("Use it as a restart action.")
        self._breakAction.setShortcut("Pause")
        self._breakAction.triggered.connect(self._onBreakTriggered)
        self._breakAction.setEnabled(False)

        self._activeInterpreterPath = self._settingsGroup()["InterpreterPath"]

        self._interpreter = self._createInterpreter()

        self._interpreter.processIsRunningChanged.connect(lambda isRunning: self._breakAction.setEnabled(isRunning))

        if self._dock is None:
            from repl import ReplDock
            self._dock = ReplDock(self._interpreter.widget(),
                                  self._DOCK_TITLE,
                                  self._icon())

        core.actionManager().addAction("mView/a%s" % self._LANGUAGE, self._dock.showAction())
        core.mainWindow().addDockWidget(Qt.BottomDockWidgetArea, self._dock)

        self._installed = True
Exemplo n.º 18
0
 def _removeDock(self):
     """Remove dock from GUI
     """
     core.actionManager().removeAction("mView/aPreview")
     core.actionManager().removeAction("mFile/aSavePreview")
     core.mainWindow().removeDockWidget(self._dock)
     self._dockInstalled = False
Exemplo n.º 19
0
 def _removeDock(self):
     """Remove dock from GUI
     """
     self._wasVisible = self._dock.isVisible()
     core.actionManager().removeAction("mView/aPreview")
     core.mainWindow().removeDockWidget(self._dock)
     self._dockInstalled = False
Exemplo n.º 20
0
    def _createDock(self):
        """Install dock
        """
        # create dock
        if self._dock is None:
            if haveWebEngine:
                from enki.plugins.preview.preview import PreviewDock
                self._dock = PreviewDock()

                self._saveAction = QAction(QIcon(':enkiicons/save.png'),
                                           'Save Preview as HTML', self._dock)
                self._saveAction.setShortcut(QKeySequence("Alt+Shift+P"))
                self._saveAction.triggered.connect(self._dock.onPreviewSave)
            else:
                self._dock = NoWebkitDock()

        if haveWebEngine:
            core.actionManager().addAction("mFile/aSavePreview",
                                           self._saveAction)

        self._dock.closed.connect(self._onDockClosed)
        self._dock.shown.connect(self._onDockShown)
        core.mainWindow().addDockWidget(Qt.RightDockWidgetArea, self._dock)

        core.actionManager().addAction("mView/aPreview",
                                       self._dock.showAction())
        self._dockInstalled = True
        if core.config()['Preview']['Enabled']:
            self._dock.show()
Exemplo n.º 21
0
    def __init__(self, parent):
        DockWidget.__init__( self, parent, "&Search Results", QIcon(":/enkiicons/search.png"), "Alt+S")

        # actions
        widget = QWidget( self )

        self._model = searchresultsmodel.SearchResultsModel(self)
        self.onResultsHandledByReplaceThread.connect(self._model.onResultsHandledByReplaceThread)

        self._view = QTreeView( self )
        self._view.setHeaderHidden( True )
        self._view.setUniformRowHeights( True )
        self._view.setModel( self._model )
        self._delegate = HTMLDelegate()
        self._view.setItemDelegate(self._delegate)

        self._layout = QHBoxLayout( widget )
        self._layout.setMargin( 5 )
        self._layout.setSpacing( 5 )
        self._layout.addWidget( self._view )

        self.setWidget( widget )
        self.setFocusProxy(self._view)

        # connections
        self._model.firstResultsAvailable.connect(self.show)
        self._view.activated.connect(self._onResultActivated)

        core.actionManager().addAction("mView/aSearchResults", self.showAction())

        self._expandCollapseAll = ExpandCollapseAllButton(self.titleBarWidget(), self._view, self._model)
        self._checkUncheckAll = None
Exemplo n.º 22
0
    def __init__(self, fileBrowser):
        QObject.__init__(self)
        self._fileBrowser = fileBrowser
        self._currDir = None
        self._currIsActive = False
        self._history = []
        self._historyIndex = -1

        fileBrowser.titleBarWidget().addSeparator()
        self._aBack = QAction(  QIcon(':enkiicons/previous.png'),
                                self.tr("Back"),
                                self)
        self._aBack.setShortcut('Alt+Left')
        fileBrowser.titleBarWidget().addAction(self._aBack)
        core.actionManager().addAction("mNavigation/mFileBrowser/aBack", self._aBack)
        self._aBack.triggered.connect(self._onTbBackTriggered)

        self._aForward = QAction(   QIcon(':enkiicons/next.png'),
                                    self.tr("Forward"),
                                    self)
        self._aForward.setShortcut('Alt+Right')
        fileBrowser.titleBarWidget().addAction(self._aForward)
        core.actionManager().addAction("mNavigation/mFileBrowser/aForward", self._aForward)
        self._aForward.triggered.connect(self._onTbForwardTriggered)

        fileBrowser.titleBarWidget().addSeparator()

        # incoming connections
        fileBrowser.rootChanged.connect(self._onRootChanged)
        fileBrowser.fileActivated.connect(self._onFileActivated)
Exemplo n.º 23
0
    def terminate(self):
        """Uninstall the plugin
        """
        core.actionManager().removeAction('mTools/aSetSphinxPath')

        if self._dockInstalled:
            self._removeDock()

        if self._dock is not None:
            self._dock.terminate()

        core.workspace().currentDocumentChanged.disconnect(
            self._onDocumentChanged)
        core.workspace().languageChanged.disconnect(self._onDocumentChanged)
        core.uiSettingsManager().aboutToExecute.disconnect(
            self._onSettingsDialogAboutToExecute)
        core.uiSettingsManager().dialogAccepted.disconnect(
            self._onDocumentChanged)
        core.uiSettingsManager().dialogAccepted.disconnect(
            self._setSphinxActionVisibility)
        core.project().changed.disconnect(self.onFileBrowserPathChanged)

        if self._dock:
            self._dock.closed.disconnect(self._onDockClosed)
            self._dock.shown.disconnect(self._onDockShown)
            self._saveAction.triggered.disconnect(self._dock.onPreviewSave)
Exemplo n.º 24
0
 def _removeDock(self):
     """Remove dock from GUI
     """
     core.actionManager().removeAction("mView/aPreview")
     core.actionManager().removeAction("mFile/aSavePreview")
     core.mainWindow().removeDockWidget(self._dock)
     self._dockInstalled = False
Exemplo n.º 25
0
    def _onShowIndentationTriggered(self, checked):
        for document in core.workspace().documents():
            document.qutepart.drawWhiteSpaceAnyIndentation = checked
        core.config()['Qutepart']['WhiteSpaceVisibility']['AnyIndentation'] = checked
        core.config().flush()

        core.actionManager().action('mView/aShowTrailingWhitespaces').setEnabled(not checked)
Exemplo n.º 26
0
 def _addAction(self):
     """Add action to main menu
     """
     action = core.actionManager().addAction("mView/aOpenTerm", "Open Term",
                                             QIcon(':enkiicons/enki.png'))
     core.actionManager().setDefaultShortcut(action, "Ctrl+Alt+Shift+T")
     action.triggered.connect(self._openTerm)
Exemplo n.º 27
0
 def _addAction(self):
     """Add action to main menu
     This action uses embedded icons. You can find list of icons in **icons** directory at project root
     """
     action = core.actionManager().addAction( "mHelp/aSayHello", 'Say Hello...', QIcon(':/enkiicons/logo/32x32/enki.png'))
     core.actionManager().setDefaultShortcut(action, "Ctrl+Alt+Shift+H")
     action.triggered.connect(self._sayHello)
Exemplo n.º 28
0
    def terminate(self):
        """Explicitly called destructor
        """
        if self._searchThread is not None:
            self._searchThread.stop()
        if self._replaceThread is not None:
            self._replaceThread.stop()

        for action in self._createdActions:
            core.actionManager().removeAction(action)
        self._menuSeparator.parent().removeAction(self._menuSeparator)

        if self._widget is not None:
            core.workspace().currentDocumentChanged.disconnect(self._updateFileActionsState)
            self._widget.visibilityChanged.disconnect(self._updateSearchWidgetFoundItemsHighlighting)
            core.workspace().textChanged.disconnect(self._updateSearchWidgetFoundItemsHighlighting)
            self._widget = None

        if self._dock is not None:
            self._dock.terminate()
            self._dock = None

        core.workspace().currentDocumentChanged.disconnect(self._onCurrentDocumentChanged)
        core.workspace().currentDocumentChanged.disconnect(self._resetSearchInFileStartPoint)
        QApplication.instance().focusChanged.disconnect(self._resetSearchInFileStartPoint)
Exemplo n.º 29
0
 def del_(self):
     """Explicitly called destructor
     """
     self._cleanupActions()
     core.workspace().documentClosed.disconnect(self._onDocumentClosed)
     core.actionManager().removeAction(self._undoClose)
     enki.core.json_wrapper.dump(_FILE_PATH, 'recent file', self._recent)
Exemplo n.º 30
0
    def _doTest(self, incorrect, anyIndent):
        incorrectAction = core.actionManager().action(
            'mView/aShowIncorrectIndentation')
        anyIndentAction = core.actionManager().action(
            'mView/aShowAnyWhitespaces')

        if anyIndentAction.isChecked() != anyIndent:
            anyIndentAction.trigger()

        if not anyIndent:
            if incorrectAction.isChecked() != incorrect:
                incorrectAction.trigger()

        self.assertEqual(
            core.config()['Qutepart']['WhiteSpaceVisibility']['Any'],
            anyIndent)
        self.assertEqual(
            core.workspace().currentDocument().qutepart.drawAnyWhitespace,
            anyIndent)

        if not anyIndent:
            self.assertEqual(
                core.config()['Qutepart']['WhiteSpaceVisibility']['Incorrect'],
                incorrect)
            self.assertEqual(
                core.workspace().currentDocument().qutepart.
                drawIncorrectIndentation, incorrect)

        self.assertEqual(incorrectAction.isEnabled(), not anyIndent)
Exemplo n.º 31
0
    def _install(self):
        """Install the plugin to the core
        """
        if self._installed:
            return

        self._schemeMenu = core.actionManager().addMenu("mScheme", "MIT Scheme")
        self._evalAction = core.actionManager().addAction("mScheme/aEval", "Eval. selection/Save and eval.")
        self._evalAction.setStatusTip("Evaluate selection. If nothing is selected - save and evaluate whole file")
        self._evalAction.setShortcut("Ctrl+E")
        self._evalAction.triggered.connect(self._onEvalTriggered)
        self._breakAction = core.actionManager().addAction("mScheme/aBreak", "Stop the interpreter")
        self._breakAction.setStatusTip("Use it as a restart action.")
        self._breakAction.setShortcut("Pause")
        self._breakAction.triggered.connect(self._onBreakTriggered)
        self._breakAction.setEnabled(False)

        self._activeInterpreterPath = core.config()["Modes"]["Scheme"]["InterpreterPath"]
        
        from mitscheme import MitScheme
        self._mitScheme = MitScheme(self._activeInterpreterPath)
        
        self._mitScheme.processIsRunningChanged.connect(lambda isRunning: self._breakAction.setEnabled(isRunning))
        
        from mitscheme import MitSchemeDock
        self._dock = MitSchemeDock(self._mitScheme.widget())

        core.mainWindow().addDockWidget(Qt.BottomDockWidgetArea, self._dock)
        self._dock.hide()

        self._installed = True
Exemplo n.º 32
0
    def __init__(self, fileBrowser):
        QObject.__init__(self)
        self._fileBrowser = fileBrowser
        self._currDir = None
        self._currIsActive = False
        self._history = []
        self._historyIndex = -1

        fileBrowser.titleBarWidget().addSeparator()
        self._aBack = QAction(QIcon(':enkiicons/previous.png'),
                              self.tr("Back"), self)
        self._aBack.setShortcut('Alt+Left')
        fileBrowser.titleBarWidget().addAction(self._aBack)
        core.actionManager().addAction("mNavigation/mFileBrowser/aBack",
                                       self._aBack)
        self._aBack.triggered.connect(self._onTbBackTriggered)

        self._aForward = QAction(QIcon(':enkiicons/next.png'),
                                 self.tr("Forward"), self)
        self._aForward.setShortcut('Alt+Right')
        fileBrowser.titleBarWidget().addAction(self._aForward)
        core.actionManager().addAction("mNavigation/mFileBrowser/aForward",
                                       self._aForward)
        self._aForward.triggered.connect(self._onTbForwardTriggered)

        fileBrowser.titleBarWidget().addSeparator()

        # incoming connections
        fileBrowser.rootChanged.connect(self._onRootChanged)
        fileBrowser.fileActivated.connect(self._onFileActivated)
Exemplo n.º 33
0
    def __init__(self, fileBrowser):
        QComboBox.__init__(self, fileBrowser)

        self._fileBrowser = fileBrowser

        self.setAttribute( Qt.WA_MacShowFocusRect, False )
        self.setAttribute( Qt.WA_MacSmallSize )
        self.setEditable(True)
        self.setMinimumContentsLength(1)
        self.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
        self.lineEdit().setReadOnly( False )
        self._completionModel = QDirModel(self.lineEdit())
        self._completionModel.setFilter( QDir.AllDirs | QDir.NoDotAndDotDot )
        self.lineEdit().setCompleter(QCompleter(self._completionModel,
                                               self.lineEdit()))
        #TODO QDirModel is deprecated but QCompleter does not yet handle
        #QFileSystemModel - please update when possible.
        self._count = 0

        # Show popup action
        self._showPopupAction = QAction(QIcon(':enkiicons/filtered.png'), "File browser history", self)
        self._showPopupAction.setShortcut('Ctrl+H')
        core.actionManager().addAction("mNavigation/mFileBrowser/aMenuShow", self._showPopupAction)
        self._showPopupAction.triggered.connect(self._onShowPopup)

        # reconnected in self.updateComboItems()
        self.currentIndexChanged[int].connect(self._onItemSelected)
Exemplo n.º 34
0
    def _createDock(self):
        """Install dock
        """
        # create dock
        if self._dock is None:
            if haveWebEngine:
                from enki.plugins.preview.preview import PreviewDock
                self._dock = PreviewDock()

                self._saveAction = QAction(QIcon(':enkiicons/save.png'),
                                           'Save Preview as HTML', self._dock)
                self._saveAction.setShortcut(QKeySequence("Alt+Shift+P"))
                self._saveAction.triggered.connect(self._dock.onPreviewSave)
            else:
                self._dock = NoWebkitDock()

        if haveWebEngine:
            core.actionManager().addAction("mFile/aSavePreview", self._saveAction)

        self._dock.closed.connect(self._onDockClosed)
        self._dock.shown.connect(self._onDockShown)
        core.mainWindow().addDockWidget(Qt.RightDockWidgetArea, self._dock)

        core.actionManager().addAction("mView/aPreview",
                                       self._dock.showAction())
        self._dockInstalled = True
        if core.config()['Preview']['Enabled']:
            self._dock.show()
Exemplo n.º 35
0
    def del_(self):
        """Explicitly called destructor
        """
        core.actionManager().removeAction(self._action)
        core.actionManager().menu("mNavigation").removeAction(self._separator)

        if self._completerConstructorThread is not None:
            self._completerConstructorThread.terminate()
Exemplo n.º 36
0
 def del_(self):
     """Explicitly called destructor
     """
     if self._smartHistory is not None:
         self._smartHistory.del_()
     if self._comboBox is not None:
         self._comboBox.del_()
     core.actionManager().removeAction("mView/aFileBrowser")
Exemplo n.º 37
0
 def del_(self):
     """Explicitly called destructor
     """
     if self._smartHistory is not None:
         self._smartHistory.del_()
     if self._comboBox is not None:
         self._comboBox.del_()
     core.actionManager().removeAction("mView/aFileBrowser")
Exemplo n.º 38
0
    def _initActions(self):
        """ Public method for actionManager. """

        self._createMenuStructure()
        core.actionManager().action('mView/aOpenMainMenu').triggered.connect(
            self._openMainMenu)
        core.actionManager().action('mFile/aQuit').triggered.connect(
            self.onQuit)
Exemplo n.º 39
0
 def _addAction(self):
     """Add action to main menu
     """
     action = core.actionManager().addAction( "mView/aOpenTerm",
                                              "Open Term",
                                              QIcon(':enkiicons/enki.png'))
     core.actionManager().setDefaultShortcut(action, "Ctrl+Alt+Shift+T")
     action.triggered.connect(self._openTerm)
Exemplo n.º 40
0
 def del_(self):
     """Uninstall the plugin
     """
     core.workspace().currentDocumentChanged.disconnect(self._updateAction)
     core.workspace().languageChanged.disconnect(self._updateAction)
     if self._action is not None:
         core.actionManager().removeAction(self._action)
         del self._action
Exemplo n.º 41
0
 def terminate(self):
     """Uninstall the plugin
     """
     core.workspace().currentDocumentChanged.disconnect(self._updateAction)
     core.workspace().languageChanged.disconnect(self._updateAction)
     if self._action is not None:
         core.actionManager().removeAction(self._action)
         del self._action
Exemplo n.º 42
0
    def _onShowAnyWhitespaceTriggered(self, checked):
        for document in core.workspace().documents():
            document.qutepart.drawAnyWhitespace = checked
        core.config()['Qutepart']['WhiteSpaceVisibility']['Any'] = checked
        core.config().flush()

        core.actionManager().action(
            'mView/aShowIncorrectIndentation').setEnabled(not checked)
Exemplo n.º 43
0
 def _addAction(self):
     """Add action to main menu
     """
     action = core.actionManager().addAction("mTools/aOpenTerm",
                                             ACTION_TEXT,
                                             QIcon(':enkiicons/console.png'))
     core.actionManager().setDefaultShortcut(action, "Ctrl+T")
     action.triggered.connect(self._openTerm)
Exemplo n.º 44
0
 def del_(self):
     """Explicitly called destructor
     """
     for action in self._createdActions:
         core.actionManager().removeAction(action)
     self._menuSeparator.parent().removeAction(self._menuSeparator)
     
     if self._dock is not None:
         self._dock.del_()
Exemplo n.º 45
0
    def del_(self):
        for actObject in self._createdActions:
            core.actionManager().removeAction(actObject)

        for separatorObject in self._createdSeparators:
            separatorObject.parent().removeAction(separatorObject)

        for menuObj in self._createdMenus[::-1]:
            core.actionManager().removeMenu(menuObj)
Exemplo n.º 46
0
 def action(path, name, icon, shortcut, tooltip, enabled):  # pylint: disable=R0913
     """Subfunction for create an action in the main menu"""
     if icon:  # has icon
         actObject = core.actionManager().addAction(path, name, QIcon(':/enkiicons/' + icon), shortcut)
     else:
         actObject = core.actionManager().addAction(path, name, shortcut=shortcut)
     actObject.setStatusTip(tooltip)
     actObject.setEnabled(enabled)
     self._createdActions.append(actObject)
Exemplo n.º 47
0
 def terminate(self):
     """Explicitly called destructor
     """
     if self._smartHistory is not None:
         self._smartHistory.terminate()
     if self._comboBox is not None:
         self._comboBox.terminate()
     core.actionManager().removeAction("mView/aFileBrowser")
     if self._tree is not None:
         self._tree.term()
Exemplo n.º 48
0
 def openSettings(self, runInDialogFunc):
     """Open Enki settings dialog and run ``runInDialogFunc``.
     Dialog is passed as a parameter to ``runInDialogFunc``
     """
     # Note that the settings dialog calls ``dialog.open()``, not
     # ``dialog.exec_()``. So, open it:
     core.actionManager().action("mSettings/aSettings").trigger()
     # Then run exec_, with runInDialogFunc executing in exec_'s loop.
     dialog = self._findDialog()
     return self.openDialog(dialog.exec_, runInDialogFunc)
Exemplo n.º 49
0
    def __init__(self, widget):
        DockWidget.__init__(self, core.mainWindow(), "&MIT Scheme", QIcon(':/enkiicons/languages/scheme.png'), "Alt+M")

        self.setAllowedAreas( Qt.BottomDockWidgetArea)
        
        core.actionManager().addAction("mView/aMitScheme", self.showAction())

        self.setWidget(widget)
        self.setFocusProxy(widget)
        widget.installEventFilter(self)
Exemplo n.º 50
0
    def __init__(self):
        QObject.__init__(self)
        self._commandClasses = []

        self._action = core.actionManager().addAction("mNavigation/aLocator",
                                                      "Locator",
                                                      shortcut='Ctrl+L')
        self._action.triggered.connect(self._onAction)
        self._separator = core.actionManager().menu(
            "mNavigation").addSeparator()
Exemplo n.º 51
0
 def action(path, name, icon, shortcut, tooltip, enabled, checkable=False):  # pylint: disable=R0913
     """Subfunction for create an action in the main menu"""
     if icon:  # has icon
         actObject = core.actionManager().addAction(path, name, QIcon(':/enkiicons/' + icon), shortcut)
     else:
         actObject = core.actionManager().addAction(path, name, shortcut=shortcut)
     if tooltip:
         actObject.setStatusTip(tooltip)
     actObject.setEnabled(enabled)
     actObject.setCheckable(checkable)
     self._createdActions.append(actObject)
Exemplo n.º 52
0
    def del_(self):
        """Explicitly called destructor
        """
        if self._queuedMessageToolBar:
            self.removeToolBar(self._queuedMessageToolBar)
            del self._queuedMessageToolBar

        for act in self._createdActions:
            core.actionManager().removeAction(act, False)
        for menuPath in self._createdMenuPathes[::-1]:
            core.actionManager().removeMenu(menuPath)
Exemplo n.º 53
0
Arquivo: base.py Projeto: gpa14/enki
 def openSettings(self, runInDialogFunc):
     """Open Enki settings dialog and run ``runInDialogFunc``.
     Dialog is passed as a parameter to ``runInDialogFunc``
     """
     # Note that the settings dialog calls ``dialog.open()``, not
     # ``dialog.exec_()``. So, open it:
     core.actionManager().action("mSettings/aSettings").trigger()
     # Then run exec_, with runInDialogFunc executing in exec_'s loop.
     dialog = self._findDialog()
     return self.openDialog(dialog.exec_,
                            runInDialogFunc)
Exemplo n.º 54
0
 def __init__(self):
     QObject.__init__(self)
     self._recentFileActions = []
     self._recent = enki.core.json_wrapper.load(_FILE_PATH, 'recent file list', [])
     self._undoClose = core.actionManager().addAction("mFile/mUndoClose/aUndoClose",
                                                      "Undo close",
                                                      shortcut = 'Shift+Ctrl+U')
     core.workspace().documentClosed.connect(self._onDocumentClosed)
     self._undoClose.triggered.connect(self._onUndoClose)
     menu = core.actionManager().action("mFile/mUndoClose").menu()
     menu.aboutToShow.connect(self._onMenuAboutToShow)
Exemplo n.º 55
0
    def del_(self):
        """Explicitly called destructor
        """
        if self._queuedMessageToolBar:
            self.removeToolBar(self._queuedMessageToolBar)
            del self._queuedMessageToolBar

        for act in self._createdActions:
            core.actionManager().removeAction(act, False)
        for menuPath in self._createdMenuPathes[::-1]:
            core.actionManager().removeMenu(menuPath)
Exemplo n.º 56
0
 def __init__(self):
     QObject.__init__(self)
     self._recentFileActions = []
     self._recent = enki.core.json_wrapper.load(_FILE_PATH, 'recent file list', [])
     self._undoClose = core.actionManager().addAction("mFile/mUndoClose/aUndoClose",
                                                      "Undo close",
                                                      shortcut='Shift+Ctrl+U')
     core.workspace().documentClosed.connect(self._onDocumentClosed)
     self._undoClose.triggered.connect(self._onUndoClose)
     menu = core.actionManager().action("mFile/mUndoClose").menu()
     menu.aboutToShow.connect(self._onMenuAboutToShow)
Exemplo n.º 57
0
    def terminate(self):
        """Uninstall the plugin
        """
        core.actionManager().removeAction('mTools/aSetSphinxPath')

        if self._dockInstalled:
            self._removeDock()

        if self._dock is not None:
            self._dock.terminate()

        sip.delete(self)
Exemplo n.º 58
0
    def __init__(self):
        """Create and install the plugin
        """
        QObject.__init__(self)

        self._dock = None
        self._saveAction = None
        self._dockInstalled = False
        core.workspace().currentDocumentChanged.connect(
            self._onDocumentChanged)
        core.workspace().languageChanged.connect(self._onDocumentChanged)

        # Install our CodeChat page into the settings dialog.
        core.uiSettingsManager().aboutToExecute.connect(
            self._onSettingsDialogAboutToExecute)
        # Update preview dock when the settings dialog (which contains the
        # CodeChat enable checkbox) is changed.
        core.uiSettingsManager().dialogAccepted.connect(
            self._onDocumentChanged)

        # Provide a "Set Sphinx Path" menu item.
        core.uiSettingsManager().dialogAccepted.connect(
            self._setSphinxActionVisibility)
        self._sphinxAction = QAction('Set Sphinx path', self._dock)
        self._sphinxAction.setShortcut(QKeySequence('Alt+Shift+S'))
        core.actionManager().addAction('mTools/aSetSphinxPath',
                                       self._sphinxAction)
        self._sphinxAction.triggered.connect(self.onSphinxPath)
        # Only enable this command if the File browser has a valid path.
        self.onFileBrowserPathChanged()
        core.project().changed.connect(self.onFileBrowserPathChanged)

        # If user's config .json file lacks it, populate CodeChat's default
        # config key and Sphinx's default config key.
        if not 'CodeChat' in core.config():
            core.config()['CodeChat'] = {}
            core.config()['CodeChat']['Enabled'] = False
            core.config().flush()
        if not 'Sphinx' in core.config():
            core.config()['Sphinx'] = {}
            core.config()['Sphinx']['Enabled'] = False
            core.config()['Sphinx']['Executable'] = 'sphinx-build'
            core.config()['Sphinx']['ProjectPath'] = ''
            core.config()['Sphinx']['BuildOnSave'] = False
            core.config()['Sphinx']['OutputPath'] = os.path.join(
                '_build', 'html')
            core.config()['Sphinx']['AdvancedMode'] = False
            core.config()['Sphinx']['Cmdline'] = (
                'sphinx-build -d ' + os.path.join('_build', 'doctrees') +
                ' . ' + os.path.join('_build', 'html'))
            core.config().flush()

        self._setSphinxActionVisibility()
Exemplo n.º 59
0
    def del_(self):
        """Explicitly called destructor
        """
        if self._searchThread is not None:
            self._searchThread.stop()
        if self._replaceThread is not None:
            self._replaceThread.stop()

        for action in self._createdActions:
            core.actionManager().removeAction(action)
        self._menuSeparator.parent().removeAction(self._menuSeparator)

        if self._dock is not None:
            self._dock.del_()