Skip to content
Permalink
Browse files

[pyqgis-console] fix shortcut keysequence for side editor

- added class menu removed by mistake
- minor fixes
  • Loading branch information
slarosa committed Apr 16, 2013
1 parent 9ab8361 commit 256d28e88219e580e19260ed6ab68f456e8eef06
Showing with 41 additions and 39 deletions.
  1. +9 −0 python/console/console.py
  2. +30 −39 python/console/console_editor.py
  3. +2 −0 python/console/console_sci.py
@@ -352,6 +352,15 @@ def __init__(self, parent=None):
self.toolBarEditor.addAction(self.uncommentEditorButton)
self.toolBarEditor.addSeparator()
self.toolBarEditor.addAction(self.runScriptEditorButton)

## Menu Import Class
self.classMenu = QMenu(self)
self.classMenu.addAction(self.loadSextanteButton)
self.classMenu.addAction(self.loadQtCoreButton)
self.classMenu.addAction(self.loadQtGuiButton)
cM = self.toolBar.widgetForAction(self.actionClass)
cM.setMenu(self.classMenu)
cM.setPopupMode(QToolButton.InstantPopup)

self.widgetButton = QWidget()
sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
@@ -115,7 +115,7 @@ def __init__(self, parent=None):

# Folding
self.setFolding(QsciScintilla.PlainFoldStyle)
self.setFoldMarginColors(QColor("#cccccc"),QColor("#cccccc"))
self.setFoldMarginColors(QColor("#f4f4f4"),QColor("#f4f4f4"))
#self.setWrapMode(QsciScintilla.WrapCharacter)

## Edge Mode
@@ -150,10 +150,21 @@ def __init__(self, parent=None):

## New QShortcut = ctrl+space/ctrl+alt+space for Autocomplete
self.newShortcutCS = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Space), self)
#self.newShortcutCAS = QShortcut(QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_Space), self)
self.newShortcutCS.setContext(Qt.WidgetShortcut)
self.newShortcutCS.activated.connect(self.autoComplete)
self.runScut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_E), self)
self.runScut.activated.connect(self.runScriptCode)
self.runScut.setContext(Qt.WidgetShortcut)
self.runScut.activated.connect(self.runSelectedCode)
self.runScriptScut = QShortcut(QKeySequence(Qt.SHIFT + Qt.CTRL + Qt.Key_E), self)
self.runScriptScut.setContext(Qt.WidgetShortcut)
self.runScriptScut.activated.connect(self.runScriptCode)

self.commentScut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_3), self)
self.commentScut.setContext(Qt.WidgetShortcut)
self.commentScut.activated.connect(self.parent.pc.commentCode)
self.uncommentScut = QShortcut(QKeySequence(Qt.SHIFT + Qt.CTRL + Qt.Key_3), self)
self.uncommentScut.setContext(Qt.WidgetShortcut)
self.uncommentScut.activated.connect(self.parent.pc.uncommentCode)

def autoComplete(self):
self.autoCompleteFromAll()
@@ -222,36 +233,25 @@ def get_end_pos(self):
def contextMenuEvent(self, e):
menu = QMenu(self)
iconRun = QgsApplication.getThemeIcon("console/iconRunConsole.png")
# iconOpen = QgsApplication.getThemeIcon("console/iconOpenConsole.png")
# iconSave = QgsApplication.getThemeIcon("console/iconSaveConsole.png")
iconCodePad = QgsApplication.getThemeIcon("console/iconCodepadConsole.png")
iconNewEditor = QgsApplication.getThemeIcon("console/iconTabEditorConsole.png")
iconCommentEditor = QgsApplication.getThemeIcon("console/iconCommentEditorConsole.png")
iconUncommentEditor = QgsApplication.getThemeIcon("console/iconUncommentEditorConsole.png")
hideEditorAction = menu.addAction("Hide Editor",
self.hideEditor)
menu.addSeparator()
newTabAction = menu.addAction(iconNewEditor,
"New Tab",
self.parent.newTab,
QKeySequence(Qt.CTRL + Qt.Key_T))
self.parent.newTab, 'Ctrl+T')
closeTabAction = menu.addAction("Close Tab",
self.parent.close,
QKeySequence(Qt.CTRL + Qt.Key_W))
self.parent.close, 'Ctrl+W')
menu.addSeparator()
# openAction = menu.addAction(iconOpen,
# "Open",
# self.parent.openFile)
# saveAction = menu.addAction(iconSave,
# "Save",
# self.parent.save,
# QKeySequence(Qt.CTRL + Qt.Key_M))
# menu.addSeparator()
runSelected = menu.addAction(iconRun,
"Enter selected",
self.runSelectedCode,
QKeySequence(Qt.CTRL + Qt.Key_E))
self.runSelectedCode, 'Ctrl+E')
runScript = menu.addAction(iconRun,
"Run Script",
self.runScriptCode)
self.runScriptCode, 'Shift+Ctrl+E')
menu.addSeparator()
undoAction = menu.addAction("Undo", self.undo, QKeySequence.Undo)
redoAction = menu.addAction("Redo", self.redo, QKeySequence.Redo)
@@ -264,6 +264,12 @@ def contextMenuEvent(self, e):
QKeySequence.Copy)
pasteAction = menu.addAction("Paste", self.paste, QKeySequence.Paste)
menu.addSeparator()
commentCodeAction = menu.addAction(iconCommentEditor, "Comment",
self.parent.pc.commentCode, 'Ctrl+3')
uncommentCodeAction = menu.addAction(iconUncommentEditor, "Uncomment",
self.parent.pc.uncommentCode,
'Shift+Ctrl+3')
menu.addSeparator()
codePadAction = menu.addAction(iconCodePad,
"Share on codepad",
self.codepad)
@@ -366,11 +372,7 @@ def commentEditorCode(self, commentCheck):
else:
self.insert(selCmd)
self.setCursorPosition(line, selCmd.length() - 2)


def uncommentEditorCode(self):
pass

def runScriptCode(self):
tabWidget = self.parent.mw.currentWidget()
filename = tabWidget.path
@@ -506,20 +508,7 @@ def modified(self, modified):
self.mw.tabModified(self, modified)

def close(self):
if self.newEditor.isModified():
res = QMessageBox.question( self, 'Save Script',
'The script "%s" has been modified, save changes ?'
% self.mw.tabText(self.mw.indexOf(self)),
QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel )
if res == QMessageBox.Save:
self.save()
elif res == QMessageBox.Cancel:
return
#else:
#isModified = True if self.newEditor.isModified() else False
#self.mw.closeTab(self)
#else:
#self.mw.closeTab(self)
self.mw._removeTab(self, tab2index=True)

def setEventFilter(self, filter):
self.newEditor.installEventFilter(filter)
@@ -654,7 +643,9 @@ def closeTab(self, tab):
def setTabTitle(self, tab, title):
self.setTabText(self.indexOf(tab), title)

def _removeTab(self, tab):
def _removeTab(self, tab, tab2index=False):
if tab2index:
tab = self.indexOf(tab)
if self.widget(tab).newEditor.isModified():
res = QMessageBox.question( self, 'Save Script',
'The script "%s" has been modified, save changes ?'
@@ -101,6 +101,8 @@ def __init__(self, parent=None):
## New QShortcut = ctrl+space/ctrl+alt+space for Autocomplete
self.newShortcutCSS = QShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_Space), self)
self.newShortcutCAS = QShortcut(QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_Space), self)
self.newShortcutCSS.setContext(Qt.WidgetShortcut)
self.newShortcutCAS.setContext(Qt.WidgetShortcut)
self.newShortcutCAS.activated.connect(self.autoComplete)
self.newShortcutCSS.activated.connect(self.showHistory)
self.connect(self, SIGNAL('userListActivated(int, const QString)'),

0 comments on commit 256d28e

Please sign in to comment.
You can’t perform that action at this time.