[processing] improve the modeler dialog UI and icons

- use a proper toolbar to match other parts of QGIS
- show keyboard shortcuts in toolbar action tooltips
- create vector icons to replace PNG ones
This commit is contained in:
nirvn 2016-11-23 12:05:58 +07:00
parent ee80be4317
commit 2652aa50c9
6 changed files with 6400 additions and 277 deletions

View File

@ -114,6 +114,7 @@
<file>themes/default/mActionAddBasicShape.svg</file>
<file>themes/default/mActionAddBasicCircle.svg</file>
<file>themes/default/mActionEditNodesItem.svg</file>
<file>themes/default/mActionEditHelpContent.svg</file>
<file>themes/default/mActionAddNodesItem.svg</file>
<file>themes/default/mActionAddPolygon.svg</file>
<file>themes/default/mActionAddPolyline.svg</file>
@ -278,6 +279,7 @@
<file>themes/default/mActionRotatePointSymbols.svg</file>
<file>themes/default/mActionSaveAllEdits.svg</file>
<file>themes/default/mActionSaveAsPDF.svg</file>
<file>themes/default/mActionSaveAsPython.svg</file>
<file>themes/default/mActionSaveAsSVG.svg</file>
<file>themes/default/mActionSaveEdits.svg</file>
<file>themes/default/mActionSaveMapAsImage.svg</file>
@ -307,6 +309,7 @@
<file>themes/default/mActionSimplify.svg</file>
<file>themes/default/mActionSplitFeatures.svg</file>
<file>themes/default/mActionSplitParts.svg</file>
<file>themes/default/mActionStart.svg</file>
<file>themes/default/mActionSum.svg</file>
<file>themes/default/mActionTextAnnotation.svg</file>
<file>themes/default/mActionToggleEditing.svg</file>

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 60 KiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 165 KiB

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="24"
width="24"
viewBox="0 0 24 24"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="mActionStart.svg">
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1865"
inkscape:window-height="1056"
id="namedview6"
showgrid="true"
units="px"
inkscape:zoom="11.313709"
inkscape:cx="1.0883557"
inkscape:cy="11.36737"
inkscape:window-x="55"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:current-layer="svg2">
<inkscape:grid
type="xygrid"
id="grid3195" />
</sodipodi:namedview>
<metadata
id="metadata4">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<path
id="path2848-7-3-9-4-3-3-6-2"
d="m 19.500042,12.00005 -15.0000421,9.499991 0,-19.0000822 z"
style="display:inline;fill:#5a8c5a;fill-opacity:1;fill-rule:evenodd;stroke:#4c734c;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new"
inkscape:connector-curvature="0" />
<path
style="display:inline;fill:#ffffff;fill-opacity:0.52906979;fill-rule:evenodd;stroke:#415a75;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;enable-background:new"
d="M 6.0051239,19.968373 6.0031304,4.0493471 5.0017545,3.407782 5.0018882,20.57731 Z"
id="path2848-7-3-9-4-3-6"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -31,7 +31,7 @@ import sys
import os
from qgis.PyQt import uic
from qgis.PyQt.QtCore import Qt, QRectF, QMimeData, QPoint, QPointF, QSettings, QByteArray, pyqtSignal
from qgis.PyQt.QtCore import Qt, QRectF, QMimeData, QPoint, QPointF, QSettings, QByteArray, QSize, pyqtSignal
from qgis.PyQt.QtWidgets import QGraphicsView, QTreeWidget, QMessageBox, QFileDialog, QTreeWidgetItem, QSizePolicy
from qgis.PyQt.QtGui import QIcon, QImage, QPainter
from qgis.core import QgsApplication
@ -65,7 +65,7 @@ class ModelerDialog(BASE, WIDGET):
self.bar = QgsMessageBar()
self.bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
self.layout().insertWidget(1, self.bar)
self.centralWidget().layout().insertWidget(1, self.bar)
self.zoom = 1
@ -74,8 +74,9 @@ class ModelerDialog(BASE, WIDGET):
Qt.WindowCloseButtonHint)
settings = QSettings()
self.splitter.restoreState(settings.value("/Processing/splitterModeler", QByteArray()))
self.restoreState(settings.value("/Processing/stateModeler", QByteArray()))
self.restoreGeometry(settings.value("/Processing/geometryModeler", QByteArray()))
self.splitter.restoreState(settings.value("/Processing/stateModelerSplitter", QByteArray()))
self.tabWidget.setCurrentIndex(0)
self.scene = ModelerScene(self)
@ -185,15 +186,6 @@ class ModelerDialog(BASE, WIDGET):
self.algorithmTree.setDragDropMode(QTreeWidget.DragOnly)
self.algorithmTree.setDropIndicatorShown(True)
# Set icons
self.btnOpen.setIcon(QgsApplication.getThemeIcon('/mActionFileOpen.svg'))
self.btnSave.setIcon(QgsApplication.getThemeIcon('/mActionFileSave.svg'))
self.btnSaveAs.setIcon(QgsApplication.getThemeIcon('/mActionFileSaveAs.svg'))
self.btnExportImage.setIcon(QgsApplication.getThemeIcon('/mActionSaveMapAsImage.svg'))
self.btnExportPython.setIcon(QgsApplication.getThemeIcon('/console/iconSaveAsConsole.png'))
self.btnEditHelp.setIcon(QIcon(os.path.join(pluginPath, 'images', 'edithelp.png')))
self.btnRun.setIcon(QIcon(os.path.join(pluginPath, 'images', 'runalgorithm.png')))
if hasattr(self.searchBox, 'setPlaceholderText'):
self.searchBox.setPlaceholderText(self.tr('Search...'))
if hasattr(self.textName, 'setPlaceholderText'):
@ -206,13 +198,15 @@ class ModelerDialog(BASE, WIDGET):
self.searchBox.textChanged.connect(self.fillAlgorithmTree)
self.algorithmTree.doubleClicked.connect(self.addAlgorithm)
self.btnOpen.clicked.connect(self.openModel)
self.btnSave.clicked.connect(self.save)
self.btnSaveAs.clicked.connect(self.saveAs)
self.btnExportImage.clicked.connect(self.exportAsImage)
self.btnExportPython.clicked.connect(self.exportAsPython)
self.btnEditHelp.clicked.connect(self.editHelp)
self.btnRun.clicked.connect(self.runModel)
iconSize = settings.value("iconsize", 24)
self.mToolbar.setIconSize(QSize(iconSize, iconSize))
self.mActionOpen.triggered.connect(self.openModel)
self.mActionSave.triggered.connect(self.save)
self.mActionSaveAs.triggered.connect(self.saveAs)
self.mActionExportImage.triggered.connect(self.exportAsImage)
self.mActionExportPython.triggered.connect(self.exportAsPython)
self.mActionEditHelp.triggered.connect(self.editHelp)
self.mActionRun.triggered.connect(self.runModel)
if alg is not None:
self.alg = alg
@ -235,8 +229,9 @@ class ModelerDialog(BASE, WIDGET):
def closeEvent(self, evt):
settings = QSettings()
settings.setValue("/Processing/splitterModeler", self.splitter.saveState())
settings.setValue("/Processing/stateModeler", self.saveState())
settings.setValue("/Processing/geometryModeler", self.saveGeometry())
settings.setValue("/Processing/stateModelerSplitter", self.splitter.saveState())
if self.hasChanged:
ret = QMessageBox.question(

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgModeler</class>
<widget class="QDialog" name="DlgModeler">
<widget class="QMainWindow" name="DlgModeler">
<property name="geometry">
<rect>
<x>0</x>
@ -13,269 +13,255 @@
<property name="windowTitle">
<string>Processing modeler</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>3</number>
</property>
<item>
<widget class="QToolButton" name="btnOpen">
<property name="toolTip">
<string>Open model</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnSave">
<property name="toolTip">
<string>Save</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnSaveAs">
<property name="toolTip">
<string>Save as...</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+S</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnExportImage">
<property name="toolTip">
<string>Export as image</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnExportPython">
<property name="toolTip">
<string>Export as Python script</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnEditHelp">
<property name="toolTip">
<string>Edit model help</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnRun">
<property name="toolTip">
<string>Run model</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="shortcut">
<string>F5</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_1">
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTabWidget" name="tabWidget">
<property name="minimumSize">
<size>
<width>40</width>
<height>20</height>
<width>300</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTabWidget" name="tabWidget">
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<property name="tabPosition">
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Inputs</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QTreeWidget" name="inputsTree">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Algorithms</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QgsFilterLineEdit" name="searchBox">
<property name="toolTip">
<string>Enter algorithm name to filter list</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="algorithmTree">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout">
<property name="spacing">
<number>2</number>
<property name="tabPosition">
<enum>QTabWidget::South</enum>
</property>
<item row="0" column="0">
<widget class="QLineEdit" name="textName">
<property name="toolTip">
<string>Enter model name here</string>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Inputs</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>4</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="textGroup">
<property name="toolTip">
<string>Enter group name here</string>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QGraphicsView" name="view"/>
</item>
</layout>
<item>
<widget class="QTreeWidget" name="inputsTree">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Algorithms</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>4</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QgsFilterLineEdit" name="searchBox">
<property name="toolTip">
<string>Enter algorithm name to filter list</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="algorithmTree">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout">
<property name="spacing">
<number>4</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_1">
<property name="text">
<string>Model</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="textName">
<property name="toolTip">
<string>Enter model name here</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Group</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="textGroup">
<property name="toolTip">
<string>Enter group name here</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QGraphicsView" name="view"/>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QToolBar" name="mToolbar">
<property name="windowTitle">
<string>Navigation</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>true</bool>
</attribute>
<addaction name="mActionOpen"/>
<addaction name="mActionSave"/>
<addaction name="mActionSaveAs"/>
<addaction name="separator"/>
<addaction name="mActionExportImage"/>
<addaction name="mActionExportPython"/>
<addaction name="separator"/>
<addaction name="mActionEditHelp"/>
<addaction name="separator"/>
<addaction name="mActionRun"/>
</widget>
<action name="mActionOpen">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionFileOpen.svg</normaloff>:/images/themes/default/mActionFileOpen.svg</iconset>
</property>
<property name="text">
<string>Open model...</string>
</property>
<property name="toolTip">
<string>Open model (Ctrl+O)</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
</property>
</action>
<action name="mActionSave">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionFileSave.svg</normaloff>:/images/themes/default/mActionFileSave.svg</iconset>
</property>
<property name="text">
<string>Save model</string>
</property>
<property name="toolTip">
<string>Save model (Ctrl+S)</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</action>
<action name="mActionSaveAs">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionFileSaveAs.svg</normaloff>:/images/themes/default/mActionFileSaveAs.svg</iconset>
</property>
<property name="text">
<string>Save model as...</string>
</property>
<property name="toolTip">
<string>Save model as (Ctrl+S)</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+S</string>
</property>
</action>
<action name="mActionExportImage">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionSaveMapAsImage.svg</normaloff>:/images/themes/default/mActionSaveMapAsImage.svg</iconset>
</property>
<property name="text">
<string>Export as image...</string>
</property>
<property name="toolTip">
<string>Export as image</string>
</property>
</action>
<action name="mActionExportPython">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionSaveAsPython.svg</normaloff>:/images/themes/default/mActionSaveAsPython.svg</iconset>
</property>
<property name="text">
<string>Export as Python script...</string>
</property>
<property name="toolTip">
<string>Export as Python script</string>
</property>
</action>
<action name="mActionEditHelp">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionEditHelpContent.svg</normaloff>:/images/themes/default/mActionEditHelpContent.svg</iconset>
</property>
<property name="text">
<string>Edit model help...</string>
</property>
<property name="toolTip">
<string>Edit model help</string>
</property>
</action>
<action name="mActionRun">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionStart.svg</normaloff>:/images/themes/default/mActionStart.svg</iconset>
</property>
<property name="text">
<string>Run model...</string>
</property>
<property name="toolTip">
<string>Run model (F5)</string>
</property>
<property name="shortcut">
<string>F5</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>