Skip to content
Permalink
Browse files

[console] Make console action checkable, and bring behaviour into

line with style dock/processing toolbox

Where the action is checked only if the dock is open and user visible,
and checking the action brings hidden tabs to the foreground instead
of closing them.
  • Loading branch information
nyalldawson committed Jan 30, 2018
1 parent 3c63e0b commit 77e54d35026e6f60d6c2c343db6b20f70e8f691f
Showing with 13 additions and 7 deletions.
  1. +10 −7 python/console/console.py
  2. +3 −0 src/ui/qgisapp.ui
@@ -23,7 +23,7 @@
import os

from qgis.PyQt.QtCore import Qt, QTimer, QCoreApplication, QSize, QByteArray, QFileInfo, QUrl, QDir
from qgis.PyQt.QtWidgets import QDockWidget, QToolBar, QToolButton, QWidget, QSplitter, QTreeWidget, QAction, QFileDialog, QCheckBox, QSizePolicy, QMenu, QGridLayout, QApplication, QShortcut
from qgis.PyQt.QtWidgets import QToolBar, QToolButton, QWidget, QSplitter, QTreeWidget, QAction, QFileDialog, QCheckBox, QSizePolicy, QMenu, QGridLayout, QApplication, QShortcut
from qgis.PyQt.QtGui import QDesktopServices, QKeySequence
from qgis.PyQt.QtWidgets import QVBoxLayout
from qgis.utils import iface
@@ -32,7 +32,7 @@
from .console_editor import EditorTabWidget
from .console_settings import optionsDialog
from qgis.core import QgsApplication, QgsSettings
from qgis.gui import QgsFilterLineEdit, QgsHelp
from qgis.gui import QgsFilterLineEdit, QgsHelp, QgsDockWidget
from functools import partial

import sys
@@ -46,14 +46,17 @@ def show_console():
if _console is None:
parent = iface.mainWindow() if iface else None
_console = PythonConsole(parent)
if iface:
_console.visibilityChanged.connect(iface.actionShowPythonDialog().setChecked)

_console.show() # force show even if it was restored as hidden
# set focus to the console so the user can start typing
# defer the set focus event so it works also whether the console not visible yet
QTimer.singleShot(0, _console.activate)
else:
_console.setVisible(not _console.isVisible())
_console.setUserVisible(not _console.isUserVisible())
# set focus to the console so the user can start typing
if _console.isVisible():
if _console.isUserVisible():
_console.activate()

return _console
@@ -70,10 +73,10 @@ def console_displayhook(obj):
_console_output = obj


class PythonConsole(QDockWidget):
class PythonConsole(QgsDockWidget):

def __init__(self, parent=None):
QDockWidget.__init__(self, parent)
super().__init__(parent)
self.setObjectName("PythonConsole")
self.setWindowTitle(QCoreApplication.translate("PythonConsole", "Python Console"))
# self.setAllowedAreas(Qt.BottomDockWidgetArea)
@@ -89,7 +92,7 @@ def __init__(self, parent=None):
def activate(self):
self.activateWindow()
self.raise_()
QDockWidget.setFocus(self)
QgsDockWidget.setFocus(self)

def closeEvent(self, event):
self.console.saveSettingsConsole()
@@ -1815,6 +1815,9 @@ Ctrl (Cmd) increments by 15 deg.</string>
</property>
</action>
<action name="mActionShowPythonDialog">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/console/mIconRunConsole.svg</normaloff>:/images/themes/default/console/mIconRunConsole.svg</iconset>

0 comments on commit 77e54d3

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