Skip to content

Commit

Permalink
Add button to reset processing menus in config dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-morvan committed Oct 28, 2016
1 parent 8c7ca62 commit e78fc62
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion python/plugins/processing/gui/ConfigDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
QHBoxLayout,
QComboBox)
from qgis.PyQt.QtGui import (QIcon,
QPushButton,
QStandardItemModel,
QStandardItem)

Expand All @@ -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


Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit e78fc62

Please sign in to comment.