Skip to content
Permalink
Browse files

[needs-docs] Remove python console "import class" action

Since these classes are always imported by default, there's no
need for a toolbar action to manually import them
  • Loading branch information
nyalldawson committed Aug 6, 2017
1 parent 069fadf commit 05a039b1739af0511ccaf0a00cf741c228904d93
Showing with 0 additions and 36 deletions.
  1. +0 −33 python/console/console.py
  2. +0 −3 tests/src/python/test_console.py
@@ -325,16 +325,6 @@ def __init__(self, parent=None):
self.optionsButton.setIconVisibleInMenu(True)
self.optionsButton.setToolTip(optionsBt)
self.optionsButton.setText(optionsBt)
# Action menu for class
actionClassBt = QCoreApplication.translate("PythonConsole", "Import Class")
self.actionClass = QAction(self)
self.actionClass.setCheckable(False)
self.actionClass.setEnabled(True)
self.actionClass.setIcon(QgsApplication.getThemeIcon("console/iconClassConsole.png"))
self.actionClass.setMenuRole(QAction.PreferencesRole)
self.actionClass.setIconVisibleInMenu(True)
self.actionClass.setToolTip(actionClassBt)
self.actionClass.setText(actionClassBt)
# Action for Run script
runBt = QCoreApplication.translate("PythonConsole", "Run Command")
self.runButton = QAction(self)
@@ -365,7 +355,6 @@ def __init__(self, parent=None):
self.toolBar.setMovable(False)
self.toolBar.setFloatable(False)
self.toolBar.addAction(self.clearButton)
self.toolBar.addAction(self.actionClass)
self.toolBar.addAction(self.runButton)
self.toolBar.addSeparator()
self.toolBar.addAction(self.showEditorButton)
@@ -400,28 +389,6 @@ def __init__(self, parent=None):
self.toolBarEditor.addSeparator()
self.toolBarEditor.addAction(self.objectListButton)

# Menu Import Class
default_command = {
(QCoreApplication.translate("PythonConsole", "Import Processing Class"),
QgsApplication.getThemeIcon("console/iconProcessingConsole.png")):
["import processing"],
(QCoreApplication.translate("PythonConsole", "Import PyQt.QtCore Class"),
QgsApplication.getThemeIcon("console/iconQtCoreConsole.png")):
["from qgis.PyQt.QtCore import *"],
(QCoreApplication.translate("PythonConsole", "Import PyQt.QtGui Class"),
QgsApplication.getThemeIcon("console/iconQtGuiConsole.png")):
["from qgis.PyQt.QtGui import *", "from qgis.PyQt.QtWidgets import *"]
}

self.classMenu = QMenu()
for (title, icon), commands in list(default_command.items()):
action = self.classMenu.addAction(icon, title)
action.triggered.connect(partial(self.shell.commandConsole, commands))

cM = self.toolBar.widgetForAction(self.actionClass)
cM.setMenu(self.classMenu)
cM.setPopupMode(QToolButton.InstantPopup)

self.widgetButton = QWidget()
sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
@@ -34,9 +34,6 @@ def test_show_console(self):
my_console = console.show_console()
my_console_widget = my_console.console

for action in my_console_widget.classMenu.actions():
action.trigger()


if __name__ == "__main__":
unittest.main()

0 comments on commit 05a039b

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