Skip to content

Commit

Permalink
[processing] Improve main window Toolbox action
Browse files Browse the repository at this point in the history
Brings the behaviour into line with the styling dock, where
the action is checkable and checked only when the toolbox
is open AND user visible (i.e. not hidden behind another tab). If
the toolbox is open but hidden, then hitting the Toolbox action
brings it to the front tab.

Otherwise it's often necessary to hit to Toolbox shortcut twice -
once to close a hidden toolbox tab, and a second time to open
and raise it.
  • Loading branch information
nyalldawson committed Jan 24, 2018
1 parent e5d00a2 commit 63db1be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 9 additions & 7 deletions python/plugins/processing/ProcessingPlugin.py
Expand Up @@ -177,6 +177,7 @@ def initGui(self):
self.toolbox = ProcessingToolbox()
self.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox)
self.toolbox.hide()
self.toolbox.visibilityChanged.connect(self.toolboxVisibilityChanged)

self.resultsDock = ResultsDock()
self.iface.addDockWidget(Qt.RightDockWidgetArea, self.resultsDock)
Expand All @@ -188,12 +189,13 @@ def initGui(self):
self.menu.setObjectName('processing')
self.menu.setTitle(self.tr('Pro&cessing'))

self.toolboxAction = self.toolbox.toggleViewAction()
self.toolboxAction = QAction(self.tr('&Toolbox'), self.iface.mainWindow())
self.toolboxAction.setCheckable(True)
self.toolboxAction.setObjectName('toolboxAction')
self.toolboxAction.setIcon(
QgsApplication.getThemeIcon("/processingAlgorithm.svg"))
self.toolboxAction.setText(self.tr('&Toolbox'))
self.iface.registerMainWindowAction(self.toolboxAction, 'Ctrl+Alt+T')
self.toolboxAction.toggled.connect(self.openToolbox)
self.menu.addAction(self.toolboxAction)

self.modelerAction = QAction(
Expand Down Expand Up @@ -276,11 +278,11 @@ def unload(self):
removeMenus()
Processing.deinitialize()

def openToolbox(self):
if self.toolbox.isVisible():
self.toolbox.hide()
else:
self.toolbox.show()
def openToolbox(self, show):
self.toolbox.setUserVisible(show)

def toolboxVisibilityChanged(self, visible):
self.toolboxAction.setChecked(visible)

def openModeler(self):
dlg = ModelerDialog()
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/gui/ProcessingToolbox.py
Expand Up @@ -34,6 +34,7 @@
from qgis.utils import iface
from qgis.core import (QgsApplication,
QgsProcessingAlgorithm)
from qgis.gui import QgsDockWidget

from processing.gui.Postprocessing import handleAlgorithmResults
from processing.core.Processing import Processing
Expand All @@ -55,7 +56,7 @@
os.path.join(pluginPath, 'ui', 'ProcessingToolbox.ui'))


class ProcessingToolbox(BASE, WIDGET):
class ProcessingToolbox(QgsDockWidget, WIDGET):
ALG_ITEM = 'ALG_ITEM'
PROVIDER_ITEM = 'PROVIDER_ITEM'
GROUP_ITEM = 'GROUP_ITEM'
Expand Down

0 comments on commit 63db1be

Please sign in to comment.