Skip to content
Permalink
Browse files

Merge pull request #3415 from arnaud-morvan/processing_reset_menus

[processing] Add a reset menus button
  • Loading branch information
volaya committed Sep 2, 2016
2 parents 8c3537b + e716bae commit 6054bb9518786c094cfbafe4f1d1fa77a4dbfd78
Showing with 24 additions and 2 deletions.
  1. +22 −2 python/plugins/processing/gui/ConfigDialog.py
  2. +2 −0 python/plugins/processing/gui/menus.py
@@ -42,6 +42,7 @@
QHBoxLayout,
QComboBox)
from qgis.PyQt.QtGui import (QIcon,
QPushButton,

This comment has been minimized.

Copy link
@nirvn

nirvn Sep 4, 2016

Contributor

This is causing an error:

File "/home/webmaster/dev/cpp/QGIS/bm-qt5/output/python/plugins/processing/gui/ConfigDialog.py", line 46, in
from qgis.PyQt.QtGui import (QIcon,
ImportError: cannot import name 'QPushButton'

QStandardItemModel,
QStandardItem)

@@ -55,7 +56,7 @@
Setting)
from processing.core.Processing import Processing
from processing.gui.DirectorySelectorDialog import DirectorySelectorDialog
from processing.gui.menus import updateMenus
from processing.gui.menus import defaultMenuEntries, updateMenus
from processing.gui.menus import menusSettingsGroup


@@ -189,7 +190,7 @@ def fillTreeUsingProviders(self):
"""
Filter 'Menus' items
"""
menusItem = QStandardItem(self.tr('Menus (requires restart)'))
menusItem = QStandardItem(self.tr('Menus'))
icon = QIcon(os.path.join(pluginPath, 'images', 'menu.png'))
menusItem.setIcon(icon)
menusItem.setEditable(False)
@@ -198,6 +199,16 @@ def fillTreeUsingProviders(self):

rootItem.insertRow(0, [menusItem, emptyItem])

button = QPushButton(self.tr('Reset to defaults'))
button.clicked.connect(self.resetMenusToDefaults)
layout = QHBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.addWidget(button)
layout.addStretch()
widget = QWidget()
widget.setLayout(layout)
self.tree.setIndexWidget(emptyItem.index(), widget)

providers = Processing.providers
for provider in providers:
providerDescription = provider.getDescription()
@@ -240,6 +251,15 @@ def fillTreeUsingProviders(self):
self.tree.sortByColumn(0, Qt.AscendingOrder)
self.adjustColumns()

def resetMenusToDefaults(self):
providers = Processing.providers
for provider in providers:
for alg in provider.algs:
d = defaultMenuEntries.get(alg.commandLineName(), "")
setting = ProcessingConfig.settings["MENU_" + alg.commandLineName()]
item = self.items[setting]
item.setData(d, Qt.EditRole)

def accept(self):
for setting in self.items.keys():
if isinstance(setting.value, bool):
@@ -1,4 +1,5 @@
import os
from qgis.PyQt.QtCore import QCoreApplication
from qgis.PyQt.QtWidgets import QAction, QMenu
from PyQt4.QtGui import QIcon
from processing.core.alglist import algList
@@ -127,6 +128,7 @@ def initializeMenus():

def updateMenus():
removeMenus()
QCoreApplication.processEvents()
createMenus()


0 comments on commit 6054bb9

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