mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
[NEEDS-DOCS][processing] Move configuration to qgis options dialog
This commit is contained in:
parent
2d807f5405
commit
9f23dd2414
@ -32,6 +32,7 @@ import os
|
||||
import sys
|
||||
|
||||
from qgis.core import QgsApplication
|
||||
from qgis.gui import QgsOptionsWidgetFactory
|
||||
from qgis.PyQt.QtCore import Qt, QCoreApplication, QDir
|
||||
from qgis.PyQt.QtWidgets import QMenu, QAction
|
||||
from qgis.PyQt.QtGui import QIcon
|
||||
@ -39,7 +40,7 @@ from qgis.PyQt.QtGui import QIcon
|
||||
from processing.core.Processing import Processing
|
||||
from processing.gui.ProcessingToolbox import ProcessingToolbox
|
||||
from processing.gui.HistoryDialog import HistoryDialog
|
||||
from processing.gui.ConfigDialog import ConfigDialog
|
||||
from processing.gui.ConfigDialog import ConfigOptionsPage, ConfigDialog
|
||||
from processing.gui.ResultsDock import ResultsDock
|
||||
from processing.gui.CommanderWindow import CommanderWindow
|
||||
from processing.modeler.ModelerDialog import ModelerDialog
|
||||
@ -53,10 +54,25 @@ if cmd_folder not in sys.path:
|
||||
sys.path.insert(0, cmd_folder)
|
||||
|
||||
|
||||
class ProcessingOptionsFactory(QgsOptionsWidgetFactory):
|
||||
|
||||
def __init__(self):
|
||||
super(QgsOptionsWidgetFactory, self).__init__()
|
||||
|
||||
def icon(self):
|
||||
return QgsApplication.getThemeIcon('/processingAlgorithm.svg')
|
||||
|
||||
def createWidget(self, parent):
|
||||
return ConfigOptionsPage(parent)
|
||||
|
||||
|
||||
class ProcessingPlugin(object):
|
||||
|
||||
def __init__(self, iface):
|
||||
self.iface = iface
|
||||
self.options_factory = ProcessingOptionsFactory()
|
||||
self.options_factory.setTitle(self.tr('Processing'))
|
||||
iface.registerOptionsWidgetFactory(self.options_factory)
|
||||
Processing.initialize()
|
||||
|
||||
def initGui(self):
|
||||
@ -122,16 +138,6 @@ class ProcessingPlugin(object):
|
||||
|
||||
self.menu.addSeparator()
|
||||
|
||||
self.configAction = QAction(
|
||||
QIcon(QgsApplication.getThemeIcon('mActionOptions.svg')),
|
||||
self.tr('&Options...'), self.iface.mainWindow())
|
||||
self.configAction.setObjectName('configAction')
|
||||
self.configAction.setMenuRole(QAction.NoRole)
|
||||
|
||||
self.configAction.triggered.connect(self.openConfig)
|
||||
self.iface.registerMainWindowAction(self.configAction, 'Ctrl+Alt+C')
|
||||
self.menu.addAction(self.configAction)
|
||||
|
||||
initializeMenus()
|
||||
createMenus()
|
||||
|
||||
@ -152,10 +158,11 @@ class ProcessingPlugin(object):
|
||||
self.iface.unregisterMainWindowAction(self.toolboxAction)
|
||||
self.iface.unregisterMainWindowAction(self.modelerAction)
|
||||
self.iface.unregisterMainWindowAction(self.historyAction)
|
||||
self.iface.unregisterMainWindowAction(self.configAction)
|
||||
self.iface.unregisterMainWindowAction(self.resultsAction)
|
||||
self.iface.unregisterMainWindowAction(self.commanderAction)
|
||||
|
||||
self.iface.unregisterOptionsWidgetFactory(self.options_factory)
|
||||
|
||||
removeMenus()
|
||||
|
||||
def openCommander(self):
|
||||
@ -190,9 +197,5 @@ class ProcessingPlugin(object):
|
||||
dlg = HistoryDialog()
|
||||
dlg.exec_()
|
||||
|
||||
def openConfig(self):
|
||||
dlg = ConfigDialog(self.toolbox)
|
||||
dlg.exec_()
|
||||
|
||||
def tr(self, message):
|
||||
return QCoreApplication.translate('ProcessingPlugin', message)
|
||||
|
@ -48,7 +48,9 @@ from qgis.PyQt.QtGui import (QIcon,
|
||||
QStandardItem,
|
||||
QCursor)
|
||||
|
||||
from qgis.gui import QgsDoubleSpinBox, QgsSpinBox
|
||||
from qgis.gui import (QgsDoubleSpinBox,
|
||||
QgsSpinBox,
|
||||
QgsOptionsPageWidget)
|
||||
from qgis.core import NULL, QgsApplication, QgsSettings
|
||||
|
||||
from processing.core.ProcessingConfig import (ProcessingConfig,
|
||||
@ -64,13 +66,27 @@ WIDGET, BASE = uic.loadUiType(
|
||||
os.path.join(pluginPath, 'ui', 'DlgConfig.ui'))
|
||||
|
||||
|
||||
class ConfigOptionsPage(QgsOptionsPageWidget):
|
||||
|
||||
def __init__(self, parent):
|
||||
super(ConfigOptionsPage, self).__init__(parent)
|
||||
self.config_widget = ConfigDialog()
|
||||
layout = QHBoxLayout()
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.setMargin(0)
|
||||
self.setLayout(layout)
|
||||
layout.addWidget(self.config_widget)
|
||||
|
||||
def apply(self):
|
||||
self.config_widget.accept()
|
||||
|
||||
|
||||
class ConfigDialog(BASE, WIDGET):
|
||||
|
||||
def __init__(self, toolbox):
|
||||
def __init__(self):
|
||||
super(ConfigDialog, self).__init__(None)
|
||||
self.setupUi(self)
|
||||
|
||||
self.toolbox = toolbox
|
||||
self.groupIcon = QIcon()
|
||||
self.groupIcon.addPixmap(self.style().standardPixmap(
|
||||
QStyle.SP_DirClosedIcon), QIcon.Normal, QIcon.Off)
|
||||
@ -262,7 +278,6 @@ class ConfigDialog(BASE, WIDGET):
|
||||
self.saveMenus = True
|
||||
|
||||
def accept(self):
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
qsettings = QgsSettings()
|
||||
for setting in list(self.items.keys()):
|
||||
if setting.group != menusSettingsGroup or self.saveMenus:
|
||||
@ -278,8 +293,6 @@ class ConfigDialog(BASE, WIDGET):
|
||||
setting.save(qsettings)
|
||||
Processing.updateAlgsList()
|
||||
settingsWatcher.settingsChanged.emit()
|
||||
QApplication.restoreOverrideCursor()
|
||||
QDialog.accept(self)
|
||||
|
||||
def itemExpanded(self, idx):
|
||||
if idx == self.menusItem.index():
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DlgConfig</class>
|
||||
<widget class="QDialog" name="DlgConfig">
|
||||
<widget class="QWidget" name="DlgConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -17,8 +17,17 @@
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QgsFilterLineEdit" name="searchBox">
|
||||
@ -37,16 +46,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
@ -57,38 +56,5 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DlgConfig</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>DlgConfig</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
x
Reference in New Issue
Block a user