|
42 | 42 | QHBoxLayout,
|
43 | 43 | QComboBox)
|
44 | 44 | from qgis.PyQt.QtGui import (QIcon,
|
| 45 | + QPushButton, |
45 | 46 | QStandardItemModel,
|
46 | 47 | QStandardItem)
|
47 | 48 |
|
|
55 | 56 | Setting)
|
56 | 57 | from processing.core.Processing import Processing
|
57 | 58 | from processing.gui.DirectorySelectorDialog import DirectorySelectorDialog
|
58 |
| -from processing.gui.menus import updateMenus |
| 59 | +from processing.gui.menus import defaultMenuEntries, updateMenus |
59 | 60 | from processing.gui.menus import menusSettingsGroup
|
60 | 61 |
|
61 | 62 |
|
@@ -198,6 +199,16 @@ def fillTreeUsingProviders(self):
|
198 | 199 |
|
199 | 200 | rootItem.insertRow(0, [menusItem, emptyItem])
|
200 | 201 |
|
| 202 | + button = QPushButton(self.tr('Reset to defaults')) |
| 203 | + button.clicked.connect(self.resetMenusToDefaults) |
| 204 | + layout = QHBoxLayout() |
| 205 | + layout.setContentsMargins(0, 0, 0, 0) |
| 206 | + layout.addWidget(button) |
| 207 | + layout.addStretch() |
| 208 | + widget = QWidget() |
| 209 | + widget.setLayout(layout) |
| 210 | + self.tree.setIndexWidget(emptyItem.index(), widget) |
| 211 | + |
201 | 212 | providers = Processing.providers
|
202 | 213 | for provider in providers:
|
203 | 214 | providerDescription = provider.getDescription()
|
@@ -240,6 +251,15 @@ def fillTreeUsingProviders(self):
|
240 | 251 | self.tree.sortByColumn(0, Qt.AscendingOrder)
|
241 | 252 | self.adjustColumns()
|
242 | 253 |
|
| 254 | + def resetMenusToDefaults(self): |
| 255 | + providers = Processing.providers |
| 256 | + for provider in providers: |
| 257 | + for alg in provider.algs: |
| 258 | + d = defaultMenuEntries.get(alg.commandLineName(), "") |
| 259 | + setting = ProcessingConfig.settings["MENU_" + alg.commandLineName()] |
| 260 | + item = self.items[setting] |
| 261 | + item.setData(d, Qt.EditRole) |
| 262 | + |
243 | 263 | def accept(self):
|
244 | 264 | for setting in self.items.keys():
|
245 | 265 | if isinstance(setting.value, bool):
|
|
0 commit comments