def testGetIconSvg(self): """ Tests get_icon svg path """ self.assertTrue(GuiUtils.get_icon_svg('icon.svg')) self.assertIn('icon.svg', GuiUtils.get_icon_svg('icon.svg')) self.assertFalse(GuiUtils.get_icon_svg('not_an_icon.svg'))
def __init__(self, parent=None): """Constructor.""" super().__init__(parent) self.setupUi(self) self.button_add_style.setIcon(GuiUtils.get_icon('add.svg')) self.button_remove_style.setIcon(GuiUtils.get_icon('remove.svg')) self.style_label_edit.setEnabled(False) self.style_type_combo.setEnabled(False) self.style_url_edit.setEnabled(False) self.button_remove_style.setEnabled(False) self.style_type_combo.addItem(self.tr('Events'), SERVICE_MANAGER.FDSNEVENT) self.style_type_combo.addItem(self.tr('Macroseismic'), SERVICE_MANAGER.MACROSEISMIC) self.style_type_combo.addItem(self.tr('Stations'), SERVICE_MANAGER.FDSNSTATION) self.button_add_style.clicked.connect(self._add_style) self.button_remove_style.clicked.connect(self._remove_style) self._user_styles = deepcopy(SERVICE_MANAGER._user_styles) self._refresh_styles_list() self.styles_list.currentItemChanged.connect( self._current_style_changed) self.style_label_edit.textEdited.connect(self._style_name_changed) self.style_url_edit.textEdited.connect(self._style_url_changed) self.style_type_combo.currentIndexChanged.connect( self._style_type_changed) self.block_style_updates = False
def testGetUiFilePath(self): """ Tests get_ui_file_path svg path """ self.assertTrue(GuiUtils.get_ui_file_path('fetch_by_url_widget.ui')) self.assertIn('fetch_by_url_widget.ui', GuiUtils.get_ui_file_path('fetch_by_url_widget.ui')) self.assertFalse(GuiUtils.get_ui_file_path('not_a_form.ui'))
def _add_simple_query_item(self, field_name: str, operator: str = '=', value=None): """ Adds a simple query item """ combo = QComboBox() combo.addItem('=') combo.addItem('<') combo.addItem('<=') combo.addItem('>') combo.addItem('>=') combo.addItem('<>') combo.setCurrentIndex(combo.findText(operator)) button = QToolButton() button.setIcon(GuiUtils.get_icon('remove.svg')) button.setAutoRaise(True) filter_item = QTreeWidgetItem() filter_item.setText(0, field_name) filter_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable) filter_item.setText(2, value) self.simple_query_list.addTopLevelItem(filter_item) self.simple_query_list.setItemWidget(filter_item, 1, combo) self.simple_query_list.setItemWidget(filter_item, 3, button) button.clicked.connect(partial(self._remove_simple_item, filter_item))
def initGui(self): """Create the menu entries and toolbar icons inside the QGIS GUI.""" icon_path = GuiUtils.get_icon_svg('icon.svg') self.add_action(icon_path, text=self.tr('QQuake'), callback=self.run, parent=self.iface.mainWindow()) # will be set False in run() self.first_start = True
def initGui(self): """Create the menu entries and toolbar icons inside the QGIS GUI.""" self.menu = QMenu(self.tr('&QQuake')) self.iface.pluginMenu().addMenu(self.menu) show_dialog_action = QAction(self.tr('QQuake')) show_dialog_action.setIcon(GuiUtils.get_icon('icon.svg')) show_dialog_action.triggered.connect(self.show_dialog) self.iface.addToolBarIcon(show_dialog_action) self.menu.addAction(show_dialog_action) self.actions.append(show_dialog_action) show_options_action = QAction(self.tr('Options…')) show_options_action.setIcon(GuiUtils.get_icon('options.svg')) show_options_action.triggered.connect(self.show_options) self.menu.addAction(show_options_action) self.actions.append(show_options_action) # will be set False in run() self.first_start = True self.options_factory = QQuakeOptionsFactory() self.options_factory.setTitle(self.tr('QQuake')) self.iface.registerOptionsWidgetFactory(self.options_factory)
* 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. * * * ***************************************************************************/ """ from qgis.PyQt import uic from qgis.PyQt.QtWidgets import QWidget from qgis.core import QgsUnitTypes from qquake.gui.gui_utils import GuiUtils FORM_CLASS, _ = uic.loadUiType( GuiUtils.get_ui_file_path('output_options_base.ui')) class OutputOptionsWidget(QWidget, FORM_CLASS): def __init__(self, parent=None): """Constructor.""" super().__init__(parent) self.setupUi(self) self.depth_unit_combo_box.addItem(self.tr('Meters'), QgsUnitTypes.DistanceMeters) self.depth_unit_combo_box.addItem(self.tr('Kilometers'), QgsUnitTypes.DistanceKilometers) self.depth_values_combo_box.addItem(
QDialogButtonBox, QListWidgetItem ) from qgis.core import ( QgsCoordinateTransform, QgsProject, QgsCoordinateReferenceSystem, QgsCsException ) from qgis.gui import QgsGui, QgsMapToolExtent from qgis.utils import iface from qquake.gui.gui_utils import GuiUtils from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType(GuiUtils.get_ui_file_path('predefined_areas_widget_base.ui')) class PredefinedAreasWidget(QDialog, FORM_CLASS): """ A widget for configuring predefined areas """ def __init__(self, parent=None): """Constructor.""" super().__init__(parent) self.setupUi(self) self.blocked = False self.previous_map_tool = None self.extent_tool = None
def testGetIcon(self): """ Tests get_icon """ self.assertFalse(GuiUtils.get_icon('icon.svg').isNull()) self.assertTrue(GuiUtils.get_icon('not_an_icon.svg').isNull())
* * * 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. * * * ***************************************************************************/ """ from qgis.PyQt import uic from qgis.PyQt.QtWidgets import QWidget from qgis.core import QgsUnitTypes from qquake.gui.gui_utils import GuiUtils FORM_CLASS, _ = uic.loadUiType(GuiUtils.get_ui_file_path('output_options_base.ui')) class OutputOptionsWidget(QWidget, FORM_CLASS): """ A widget for configuring output layer options """ def __init__(self, parent=None): """Constructor.""" super().__init__(parent) self.setupUi(self) self.depth_unit_combo_box.addItem(self.tr('Meters'), QgsUnitTypes.DistanceMeters) self.depth_unit_combo_box.addItem(self.tr('Kilometers'), QgsUnitTypes.DistanceKilometers)
from qgis.core import (Qgis, QgsProject, QgsSettings, QgsFileUtils) from qgis.gui import (QgsGui, QgsMessageBar, QgsNewNameDialog) from qquake.fetcher import Fetcher from qquake.gui.fetch_by_url_widget import FetchByUrlWidget from qquake.gui.filter_by_id_widget import FilterByIdWidget from qquake.gui.filter_parameter_widget import FilterParameterWidget from qquake.gui.filter_station_by_id_widget import FilterStationByIdWidget from qquake.gui.gui_utils import GuiUtils from qquake.gui.ogc_service_options_widget import OgcServiceWidget from qquake.gui.service_configuration_widget import ServiceConfigurationDialog from qquake.gui.service_information_widget import ServiceInformationWidget from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType( GuiUtils.get_ui_file_path('qquake_dialog_base.ui')) class QQuakeDialog(QDialog, FORM_CLASS): """ The main plugin dialog """ def __init__(self, iface, parent=None): # pylint:disable=too-many-statements """Constructor.""" super().__init__(parent) self.setupUi(self) self.setObjectName('QQuakeDialog') QgsGui.enableAutoGeometryRestore(self)
def icon(self): # pylint: disable=missing-function-docstring return GuiUtils.get_icon('icon.svg')
from typing import Optional, Tuple from qgis.PyQt import uic from qgis.PyQt.QtCore import QDateTime, Qt, pyqtSignal from qgis.PyQt.QtWidgets import (QWidget, QDialog, QVBoxLayout, QDialogButtonBox, QCheckBox, QSpinBox) from qgis.core import ( Qgis, ) from qgis.gui import ( QgsGui, ) from qquake.gui.gui_utils import GuiUtils from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType( GuiUtils.get_ui_file_path('service_configuration_widget_base.ui')) class ServiceConfigurationWidget(QWidget, FORM_CLASS): """ A widget for defining a service configuration """ WIDGET_MAP = { 'queryeventid': 'check_filter_by_eventid', 'queryoriginid': 'check_filter_by_originid', 'querymagnitudeid': 'check_filter_by_magnitudeid', 'queryfocalmechanismid': 'check_filter_by_focalmechanismid', 'queryupdatedafter': 'check_filter_data_updated_after', 'querycatalog': 'check_filter_by_catalog', 'querycontributor': 'check_filter_by_contributor',
import re from typing import List, Optional, Dict from qgis.PyQt import uic from qgis.PyQt.QtCore import (QDir, QUrl, pyqtSignal) from qgis.PyQt.QtNetwork import QNetworkRequest, QNetworkReply from qgis.PyQt.QtWidgets import QWidget, QFileDialog from qgis.PyQt.QtXml import QDomDocument from qgis.core import (QgsSettings, QgsNetworkAccessManager, QgsUnitTypes) from qquake.gui.base_filter_widget import BaseFilterWidget from qquake.gui.gui_utils import GuiUtils from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType( GuiUtils.get_ui_file_path('filter_by_id_widget_base.ui')) class FilterByIdWidget(QWidget, FORM_CLASS, BaseFilterWidget): """ A widget for filtering results by ID """ changed = pyqtSignal() def __init__(self, iface, service_type: str, parent: Optional[QWidget] = None): # pylint: disable=unused-argument """Constructor.""" super().__init__(parent)
QUrl ) from qgis.PyQt.QtGui import QFontMetrics from qgis.PyQt.QtWidgets import ( QWidget, QFileDialog ) from qgis.core import ( QgsUnitTypes ) from qquake.gui.base_filter_widget import BaseFilterWidget from qquake.gui.gui_utils import GuiUtils from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType(GuiUtils.get_ui_file_path('fetch_by_url_widget.ui')) class FetchByUrlWidget(QWidget, FORM_CLASS, BaseFilterWidget): """ Fetch results by URL widget """ changed = pyqtSignal() def __init__(self, iface, # pylint: disable=unused-argument service_type: str, parent=None): """Constructor.""" QWidget.__init__(self, parent) self.setupUi(self)
__author__ = 'Original authors: Mario Locati, Roberto Vallone, Matteo Ghetta, Nyall Dawson' __date__ = '29/01/2020' __copyright__ = 'Istituto Nazionale di Geofisica e Vulcanologia (INGV)' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' from copy import deepcopy from qgis.PyQt import uic from qgis.PyQt.QtCore import Qt from qgis.gui import (QgsOptionsPageWidget) from qquake.gui.gui_utils import GuiUtils from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType(GuiUtils.get_ui_file_path('qquake_options.ui')) class QQuakeOptionsWidget(FORM_CLASS, QgsOptionsPageWidget): """ A widget for configuring general QQuake options """ def __init__(self, parent=None): """Constructor.""" super().__init__(parent) self.setupUi(self) self.button_add_style.setIcon(GuiUtils.get_icon('add.svg')) self.button_remove_style.setIcon(GuiUtils.get_icon('remove.svg'))
from qgis.PyQt import uic from qgis.PyQt.QtCore import QUrl, Qt from qgis.PyQt.QtNetwork import (QNetworkRequest, QNetworkReply) from qgis.PyQt.QtWidgets import (QWidget, QDialog, QVBoxLayout, QDialogButtonBox, QTreeWidgetItem, QComboBox, QToolButton) from qgis.PyQt.QtGui import QDesktopServices from qgis.core import (QgsNetworkAccessManager) from qgis.gui import ( QgsGui, ) from qquake.gui.gui_utils import GuiUtils FORM_CLASS, _ = uic.loadUiType( GuiUtils.get_ui_file_path('cql_filter_builder.ui')) class CqlBuilderWidget(QWidget, FORM_CLASS): """ CQL builder widget """ def __init__(self, parent: QWidget = None): super().__init__(parent) self.setupUi(self) self.field_list.setHeaderLabels([self.tr('Field'), self.tr('Type')]) self.simple_query_list.setHeaderLabels( [self.tr('Field'), self.tr('Operator'),
from qgis.PyQt import uic from qgis.PyQt.QtWidgets import QWidget from qgis.PyQt.QtCore import pyqtSignal from qgis.core import ( QgsSettings, QgsUnitTypes ) from qquake.gui.gui_utils import GuiUtils from qquake.gui.output_table_options_dialog import OutputTableOptionsDialog from qquake.services import SERVICE_MANAGER from qquake.fetcher import Fetcher FORM_CLASS, _ = uic.loadUiType(GuiUtils.get_ui_file_path('filter_station_by_id_widget_base.ui')) class FilterStationByIdWidget(QWidget, FORM_CLASS): changed = pyqtSignal() def __init__(self, iface, service_type, parent=None): """Constructor.""" super().__init__(parent) self.setupUi(self) self.radio_basic_output.toggled.connect(self._enable_widgets) self.radio_extended_output.toggled.connect(self._enable_widgets) self._enable_widgets()
# (at your option) any later version. __author__ = 'Original authors: Mario Locati, Roberto Vallone, Matteo Ghetta, Nyall Dawson' __date__ = '29/01/2020' __copyright__ = 'Istituto Nazionale di Geofisica e Vulcanologia (INGV)' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' from qgis.PyQt import uic from qgis.PyQt.QtWidgets import QWidget from qgis.core import QgsStringUtils from qquake.gui.gui_utils import GuiUtils from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType(GuiUtils.get_ui_file_path('service_information_widget.ui')) class ServiceInformationWidget(QWidget, FORM_CLASS): """ A widget for display of metadata relating to a service """ def __init__(self, iface, parent=None): """Constructor.""" super().__init__(parent) self.iface = iface self.setupUi(self) self.info_browser.viewport().setAutoFillBackground(False) self.layer_model = None
__revision__ = '$Format:%H$' from typing import List from qgis.PyQt import uic from qgis.PyQt.QtCore import (QModelIndex, Qt) from qgis.PyQt.QtWidgets import QDialog from qgis.core import QgsSettings from qgis.gui import QgsGui from qquake.gui.gui_utils import GuiUtils from qquake.gui.simple_node_model import SimpleNodeModel, ModelNode from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType( GuiUtils.get_ui_file_path('output_table_options.ui')) class OutputTableOptionsDialog(QDialog, FORM_CLASS): """ A dialog for configuring output table options """ def __init__( self, # pylint: disable=too-many-locals,too-many-branches,too-many-statements service_type: str, service_id: str, initial_fields: List[str], parent=None): """Constructor.""" super().__init__(parent) self.setupUi(self)
QgsCoordinateTransform, QgsCsException, QgsSettings, QgsUnitTypes, QgsRectangle, QgsPointXY) from qgis.gui import ( QgsMapToolExtent, QgsMapToolEmitPoint, ) from qquake.fetcher import Fetcher from qquake.gui.gui_utils import GuiUtils from qquake.gui.output_table_options_dialog import OutputTableOptionsDialog from qquake.gui.predefined_areas_dialog import PredefinedAreasDialog from qquake.quakeml.common import EVENT_TYPES from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType( GuiUtils.get_ui_file_path('filter_parameter_widget_base.ui')) class FilterParameterWidget(QWidget, FORM_CLASS): # pylint: disable=too-many-public-methods """ Service parameter based filtering widget """ changed = pyqtSignal() def __init__( self, # pylint: disable=too-many-statements iface, service_type: str, parent: Optional[QWidget] = None): """Constructor.""" super().__init__(parent)
""" from copy import deepcopy from qgis.PyQt import uic from qgis.PyQt.QtWidgets import QWidget from qgis.PyQt.QtCore import QModelIndex, Qt from qgis.core import (QgsProject, QgsVectorLayer, QgsRasterLayer) from qquake.services import SERVICE_MANAGER from qquake.style_utils import StyleUtils from qquake.gui.gui_utils import GuiUtils from qquake.gui.simple_node_model import SimpleNodeModel, ModelNode FORM_CLASS, _ = uic.loadUiType( GuiUtils.get_ui_file_path('ogc_service_widget.ui')) class OgcServiceWidget(QWidget, FORM_CLASS): def __init__(self, iface, parent=None): """Constructor.""" super().__init__(parent) self.iface = iface self.setupUi(self) self.layer_model = None self.service_type = None self.service_id = None self.service_config = None self.add_layers_button.clicked.connect(self.add_selected_layers)
from functools import partial from typing import Dict from qgis.PyQt import uic from qgis.PyQt.QtCore import pyqtSignal from qgis.PyQt.QtWidgets import QWidget from qgis.core import QgsSettings from qquake.fetcher import Fetcher from qquake.gui.gui_utils import GuiUtils from qquake.gui.output_table_options_dialog import OutputTableOptionsDialog from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType( GuiUtils.get_ui_file_path('table_options_widget_base.ui')) class OutputTableOptionsWidget(QWidget, FORM_CLASS): """ A widget for configuring output layer options """ changed = pyqtSignal() def __init__(self, parent=None): """Constructor.""" super().__init__(parent) self.setupUi(self)
* * ***************************************************************************/ """ from qgis.PyQt import uic from qgis.PyQt.QtCore import (pyqtSignal, QDir, QUrl) from qgis.PyQt.QtGui import QFontMetrics from qgis.PyQt.QtWidgets import (QWidget, QFileDialog) from qgis.core import (QgsUnitTypes) from qquake.fetcher import Fetcher from qquake.gui.gui_utils import GuiUtils from qquake.gui.output_table_options_dialog import OutputTableOptionsDialog from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType( GuiUtils.get_ui_file_path('fetch_by_url_widget.ui')) class FetchByUrlWidget(QWidget, FORM_CLASS): """ Fetch results by URL widget """ changed = pyqtSignal() def __init__( self, iface, # pylint: disable=unused-argument service_type: str, parent=None): """Constructor.""" super().__init__(parent)
***************************************************************************/ """ from qgis.PyQt import uic from qgis.PyQt.QtCore import Qt from qgis.PyQt.QtWidgets import (QDialog, QVBoxLayout, QDialogButtonBox, QListWidgetItem) from qgis.utils import iface from qgis.core import (QgsCoordinateTransform, QgsProject, QgsCoordinateReferenceSystem, QgsCsException) from qgis.gui import QgsGui, QgsMapToolExtent from qquake.gui.gui_utils import GuiUtils from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType( GuiUtils.get_ui_file_path('predefined_areas_widget_base.ui')) class PredefinedAreasWidget(QDialog, FORM_CLASS): def __init__(self, parent=None): """Constructor.""" super().__init__(parent) self.setupUi(self) self.blocked = False self.previous_map_tool = None self.extent_tool = None for name in SERVICE_MANAGER.available_predefined_bounding_boxes(): extent = SERVICE_MANAGER.predefined_bounding_box(name) item = QListWidgetItem(extent['title'])
* 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. * * * ***************************************************************************/ """ from qgis.PyQt import uic from qgis.PyQt.QtWidgets import QWidget from qgis.core import QgsStringUtils from qquake.gui.gui_utils import GuiUtils from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType( GuiUtils.get_ui_file_path('service_information_widget.ui')) class ServiceInformationWidget(QWidget, FORM_CLASS): """ A widget for display of metadata relating to a service """ def __init__(self, iface, parent=None): """Constructor.""" super().__init__(parent) self.iface = iface self.setupUi(self) self.info_browser.viewport().setAutoFillBackground(False) self.layer_model = None self.service_type = None
QgsMessageBar, QgsNewNameDialog ) from qquake.fetcher import Fetcher from qquake.gui.filter_by_id_widget import FilterByIdWidget from qquake.gui.filter_parameter_widget import FilterParameterWidget from qquake.gui.filter_station_by_id_widget import FilterStationByIdWidget from qquake.gui.fetch_by_url_widget import FetchByUrlWidget from qquake.gui.gui_utils import GuiUtils from qquake.gui.ogc_service_options_widget import OgcServiceWidget from qquake.gui.service_configuration_widget import ServiceConfigurationDialog from qquake.gui.service_information_widget import ServiceInformationWidget from qquake.services import SERVICE_MANAGER FORM_CLASS, _ = uic.loadUiType(GuiUtils.get_ui_file_path('qquake_dialog_base.ui')) class QQuakeDialog(QDialog, FORM_CLASS): def __init__(self, iface, parent=None): """Constructor.""" super().__init__(parent) self.setupUi(self) self.setObjectName('QQuakeDialog') QgsGui.enableAutoGeometryRestore(self) self.fsdn_event_filter = FilterParameterWidget(iface, SERVICE_MANAGER.FDSNEVENT) vl = QVBoxLayout()