Skip to content

Commit

Permalink
add interface to define layers
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Mar 31, 2020
1 parent 6ed8371 commit 0472eb6
Show file tree
Hide file tree
Showing 3 changed files with 243 additions and 5 deletions.
39 changes: 39 additions & 0 deletions wincan2qgep/gui/settings_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
"""
/***************************************************************************
QGIS Solothurn Locator Plugin
Copyright (C) 2019 Denis Rouzaud
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""

import os
from qgis.PyQt.QtWidgets import QDialog
from qgis.PyQt.uic import loadUiType

from wincan2qgep.core.my_settings import MySettings
from wincan2qgep.qgissettingmanager import SettingDialog, UpdateMode


DialogUi, _ = loadUiType(os.path.join(os.path.dirname(__file__), '../ui/settings.ui'))


class SettingsDialog(QDialog, DialogUi, SettingDialog):
def __init__(self, parent=None):
settings = MySettings()
QDialog.__init__(self, parent)
SettingDialog.__init__(self, setting_manager=settings, mode=UpdateMode.DialogAccept)
self.setupUi(self)
self.settings = settings
self.init_widgets()

190 changes: 190 additions & 0 deletions wincan2qgep/ui/settings.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WincanSettings</class>
<widget class="QDialog" name="WincanSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>728</width>
<height>830</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="8" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>VL damage single class</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Damage</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<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>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Maintenance - WS join</string>
</property>
</widget>
</item>
<item row="11" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>VL damage channel</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QgsMapLayerComboBox" name="channel_layer"/>
</item>
<item row="3" column="1">
<widget class="QgsMapLayerComboBox" name="maintenance_layer"/>
</item>
<item row="6" column="1">
<widget class="QgsMapLayerComboBox" name="join_maintence_wastewaterstructure_layer"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Maintenance</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Channel</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>File</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QgsMapLayerComboBox" name="file_layer"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Cover</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QgsMapLayerComboBox" name="damage_layer"/>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>VL WS structure condition</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QgsMapLayerComboBox" name="cover_layer"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Wastewater structures</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QgsMapLayerComboBox" name="wastewater_structure"/>
</item>
<item row="7" column="1">
<widget class="QgsMapLayerComboBox" name="vl_damage_channel_layer"/>
</item>
<item row="8" column="1">
<widget class="QgsMapLayerComboBox" name="vl_damage_single_class"/>
</item>
<item row="9" column="1">
<widget class="QgsMapLayerComboBox" name="vl_wastewater_structure_structure_condition"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsMapLayerComboBox</class>
<extends>QComboBox</extends>
<header>qgsmaplayercombobox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>WincanSettings</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>WincanSettings</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>
</ui>
19 changes: 14 additions & 5 deletions wincan2qgep/wincan2qgep_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
#---------------------------------------------------------------------

import os.path
from qgis.PyQt.QtCore import Qt, QObject, QSettings, QCoreApplication, QTranslator, pyqtSlot
from qgis.PyQt.QtCore import Qt, QObject, QSettings, QCoreApplication, QTranslator
from qgis.PyQt.QtGui import QIcon, QColor
from qgis.PyQt.QtWidgets import QAction, QFileDialog
from qgis.core import QgsProject
from qgis.gui import QgsRubberBand, QgsMessageBar, QgisInterface
from qgis.gui import QgsRubberBand, QgisInterface

from .core.my_settings import MySettings
from .core.import_data import ImportData
from .gui.databrowserdialog import DataBrowserDialog
from wincan2qgep.core.my_settings import MySettings
from wincan2qgep.core.import_data import ImportData
from wincan2qgep.gui.databrowserdialog import DataBrowserDialog
from wincan2qgep.gui.settings_dialog import SettingsDialog

import wincan2qgep.resources_rc

Expand Down Expand Up @@ -67,6 +68,12 @@ def initGui(self):
self.iface.addPluginToMenu(self.name, self.actions['openInspection'])
self.iface.addToolBarIcon(self.actions['openInspection'])

self.actions['openSettings'] = QAction(
self.tr("Settings"),
self.iface.mainWindow())
self.actions['openSettings'].triggered.connect(self.show_settings)
self.iface.addPluginToMenu(self.name, self.actions['openSettings'])

self.rubber = QgsRubberBand(self.iface.mapCanvas())
self.rubber.setColor(QColor(255, 255, 50, 200))
self.rubber.setIcon(self.rubber.ICON_CIRCLE)
Expand Down Expand Up @@ -103,4 +110,6 @@ def open_inspection(self):
self.dlg = DataBrowserDialog(self.iface, data, parent_path)
self.dlg.show()

def show_settings(self):
SettingsDialog().exec_()

0 comments on commit 0472eb6

Please sign in to comment.