def __init__(self, results, only_symbology, geodata_server, metadata_server, parent): super(PublishReportDialog, self).__init__(parent) self.results = results self.setupUi(self) txt_on = self.tr('on').upper() txt_off = self.tr('off').upper() self.setWindowIcon(QIcon(files.getIconPath('geocat'))) self.tableWidget.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) if isinstance(geodata_server, bases.DataCatalogServerBase): url = geodata_server.baseUrl self.labelUrlMapServer.setText(f'<a href="{url}">{url}</a>') else: self.labelUrlMapServer.setText("----") if isinstance(metadata_server, bases.MetaCatalogServerBase): url = metadata_server.baseUrl self.labelUrlMetadataServer.setText(f'<a href="{url}">{url}</a>') else: self.labelUrlMetadataServer.setText("----") publish_data = geodata_server is not None self.labelPublishMapData.setText( txt_on if publish_data and not only_symbology else txt_off) self.labelPublishSymbology.setText( txt_on if publish_data or only_symbology else txt_off) self.labelPublishMetadata.setText( txt_on if metadata_server is not None else txt_off) self.tableWidget.setRowCount(len(results)) # Populate report table for i, name in enumerate(results.keys()): # Add layer name item self.tableWidget.setItem(i, 0, QTableWidgetItem(name)) # Just show "success" in the last column if there are no errors and warnings warnings, errors = results[name] if not (warnings or errors): self.tableWidget.setItem(i, 1, QTableWidgetItem('OK')) continue # Show error and warning count and dialog button (for details) in the last column if there are issues status_widget = QWidget() layout = QHBoxLayout(status_widget) button = QToolButton() button.setIcon(QIcon(files.getIconPath("attention"))) button.clicked.connect(partial(self.openDetails, name)) layout.addWidget(button) status_lbl = QLabel() status_lbl.setText( self.tr(f"{len(warnings)} warnings, {len(errors)} errors")) if errors: # Also render text in red if there are any errors status_lbl.setStyleSheet("QLabel { color: red; }") layout.addWidget(status_lbl) layout.setAlignment(Qt.AlignLeft) layout.setContentsMargins(0, 0, 0, 0) status_widget.setLayout(layout) self.tableWidget.setCellWidget(i, 1, status_widget)
def __init__(self, layer_ids, parent=None): super(ProgressDialog, self).__init__(parent) self.setupUi(self) self.setWindowIcon(QIcon(files.getIconPath('geocat'))) self.layer_ids = layer_ids self.populateTree()
def __init__(self, html_error, md_error): super(ErrorDialog, self).__init__() self.setupUi(self) self.setWindowTitle(f"{getAppName()} Error Report") self.setWindowIcon(QIcon(getIconPath('geocat'))) pixmap = QPixmap(getIconPath("bridge_logo")) self.labelIcon.setPixmap(pixmap) self.label.setText( f"The {getAppName()} plugin has caused the following exception:") self.txtError.setHtml(html_error) tracker_url = getTrackerUrl() if not tracker_url: self.btnSendReport.setEnabled(False) else: self.btnSendReport.clicked.connect( lambda: self.sendReport(md_error, tracker_url)) self.btnClose.clicked.connect(self.close)
def addPanels(self): """ Populate stackWidget and listWidget and return a list of available panel widgets and a keymap. """ keymap = {} panels = [] for i, panel in enumerate(Panels): widget = panel.value(self) panels.append(widget) self.stackedWidget.addWidget(widget) name = panel.name.lower().title() list_item = QListWidgetItem(QIcon(files.getIconPath(name.lower())), name) self.listWidget.insertItem(panel, list_item) keymap[name.lower()[0]] = i return panels, keymap
def initGui(self): self.initProcessing() # Publish / main dialog menu item + toolbar button self.action_publish = QAction( QIcon(files.getIconPath("publish_button")), QCoreApplication.translate(self.name, "Publish"), self._win) self.action_publish.setObjectName("startPublish") self.action_publish.triggered.connect(self.bridgeButtonClicked) self.iface.addPluginToWebMenu(self.name, self.action_publish) self.iface.addWebToolBarIcon(self.action_publish) # Register dockable StyleViewer widget (also registers to View > Panels) but keep hidden self.iface.addDockWidget(Qt.RightDockWidgetArea, self.widget_styleviewer) self.widget_styleviewer.hide() # StyleViewer menu item self.action_styleviewer = QAction( QIcon(files.getIconPath("symbology")), QCoreApplication.translate(self.name, "StyleViewer"), self._win) self.action_styleviewer.setObjectName("StyleViewer") self.action_styleviewer.triggered.connect(self.widget_styleviewer.show) self.iface.addPluginToWebMenu(self.name, self.action_styleviewer) # Help menu item self.action_help = QAction( QgsApplication.getThemeIcon('/mActionHelpContents.svg'), "Plugin Help...", self._win) self.action_help.setObjectName(f"{self.name} Help") self.action_help.triggered.connect(self.openDocUrl) self.iface.addPluginToWebMenu(self.name, self.action_help) # Add layer event handlers QgsProject().instance().layersAdded.connect(self.layersAdded) QgsProject().instance().layersWillBeRemoved.connect( self.layersWillBeRemoved)
def __init__(self, html_error, md_error): super(ErrorDialog, self).__init__() self.setupUi(self) pixmap = QPixmap(getIconPath("geocatlogo")) self.labelIcon.setPixmap(pixmap) self.txtError.setHtml(html_error) tracker_url = getTrackerUrl() if not tracker_url: self.btnSendReport.setEnabled(False) else: self.btnSendReport.clicked.connect(lambda: self.sendReport(md_error, tracker_url)) self.btnClose.clicked.connect(self.close)
def initGui(self): self.action_publish = QAction( QIcon(files.getIconPath("publish_button")), QCoreApplication.translate(self.name, "Publish"), self._win) self.action_publish.setObjectName("startPublish") self.action_publish.triggered.connect(self.publishClicked) self.iface.addPluginToWebMenu(self.name, self.action_publish) self.iface.addWebToolBarIcon(self.action_publish) self.action_help = QAction( QgsApplication.getThemeIcon('/mActionHelpContents.svg'), "Plugin help...", self._win) self.action_help.setObjectName(f"{self.name} Help") self.action_help.triggered.connect( lambda: webbrowser.open_new(files.getHtmlDocsPath("index"))) self.iface.addPluginToWebMenu(self.name, self.action_help) self.widget_multistyler = MultistylerWidget() self.iface.addDockWidget(Qt.RightDockWidgetArea, self.widget_multistyler) self.widget_multistyler.hide() self.action_multistyler = QAction( QIcon(files.getIconPath("symbology")), QCoreApplication.translate(self.name, "Multistyler"), self._win) self.action_multistyler.setObjectName("Multistyler") self.action_multistyler.triggered.connect(self.widget_multistyler.show) self.iface.addPluginToWebMenu(self.name, self.action_multistyler) self.iface.currentLayerChanged.connect( self.widget_multistyler.updateForCurrentLayer) QgsProject().instance().layerWasAdded.connect(self.layerWasAdded) QgsProject().instance().layerWillBeRemoved.connect( self.layerWillBeRemoved)
def getPngIcon(cls) -> QPixmap: """ Returns the Qt icon for the server list widget. Icons should be PNG files with the same path and name as the server widget controller. If a matching icon is not found, a default icon is returned. :return: A QPixmap object. """ module_name = getattr(cls, '__module__', None) if module_name: # Retrieve the icon path from the module path module = import_module(module_name) icon = Path(module.__file__).with_suffix('.png') if icon.exists(): return QPixmap(str(icon)) # Return the default unknown.png if no matching icon was found return QPixmap(files.getIconPath('unknown'))
def __init__(self, parent=None): super().__init__(parent) self.setupUi(self) self.setWindowTitle(meta.getLongAppName()) self.setWindowIcon(QIcon(files.getIconPath('geocat'))) self.panel_widgets, self.keymap = self.addPanels() self.panel_widgets[Panels.PUBLISH].restoreConfig() # Connect event handlers for panel activation self.listWidget.itemClicked.connect(partial(self.listItemClicked)) self.listWidget.keyPressEvent = partial(self.listKeyPressed) if self.showAbout(): # Show About panel first on fresh install or update self.listWidget.setCurrentRow(Panels.ABOUT) else: self.listWidget.setCurrentRow(Panels.PUBLISH)
def __init__(self, metadata, tab, parent=None): super(MetadataDialog, self).__init__(parent) self.setModal(True) self.setWindowIcon(QIcon(getIconPath('geocat'))) self.metadata = metadata self.setWindowTitle(self.tr('Metadata')) layout = QVBoxLayout() self.metadataWidget = QgsMetadataWidget() self.metadataWidget.setMetadata(metadata) layout.addWidget(self.metadataWidget) self.metadataWidget.layout().itemAt(0).widget().setCurrentIndex(tab) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) layout.addWidget(self.buttonBox) self.setLayout(layout) self.buttonBox.accepted.connect(self.okPressed) self.buttonBox.rejected.connect(self.cancelPressed)
def __init__(self, parent=None): super(BridgeDialog, self).__init__(parent) self.setupUi(self) self.publishWidget = PublishWidget(self) self.serversWidget = ServerConnectionsWidget() self.geocatWidget = GeoCatWidget() self.stackedWidget.addWidget(self.publishWidget) self.stackedWidget.addWidget(self.serversWidget) self.stackedWidget.addWidget(self.geocatWidget) self.listWidget.setMinimumSize(QSize(100, 200)) self.listWidget.setMaximumSize(QSize(153, 16777215)) self.listWidget.setStyleSheet( "QListWidget{\n" " background-color: rgb(69, 69, 69, 220);\n" " outline: 0;\n" "}\n" "QListWidget::item {\n" " color: white;\n" " padding: 3px;\n" "}\n" "QListWidget::item::selected {\n" " color: black;\n" " background-color:palette(Window);\n" " padding-right: 0px;\n" "}") self.listWidget.setFrameShape(QFrame.Box) self.listWidget.setLineWidth(0) self.listWidget.setIconSize(QSize(32, 32)) self.listWidget.setUniformItemSizes(True) self.item = [] for i in range(3): item = self.listWidget.item(i) item.setIcon(QIcon(files.getIconPath("preview"))) self.listWidget.currentRowChanged.connect(self.sectionChanged) if self.isFirstTime(): self.currentIdx = 2 self.listWidget.setCurrentRow(2) else: self.currentIdx = 0 self.listWidget.setCurrentRow(0)
def __init__(self, parent=None): super().__init__(parent) self._server_widgets = {} self.setupUi(self) self.addMenuToButtonNew() self.buttonRemove.clicked.connect(self.removeButtonClicked) self.populateServerList() self.showServerWidget() self.buttonSave.clicked.connect(self.saveServer) self.buttonImport.clicked.connect(self.importServers) self.buttonExport.clicked.connect(self.exportServers) self.buttonDuplicate.clicked.connect(self.duplicateServer) self.buttonClose.clicked.connect(parent.close) self.buttonTest.clicked.connect(self.testConnection) self.buttonTest.setVisible(False) self.buttonTest.setIcon(QIcon(files.getIconPath("connect"))) # Connect event handlers for server widget activation self.listServers.itemClicked.connect(partial(self.listItemClicked)) self.listServers.keyPressEvent = partial(self.listKeyPressed) self.stackedWidget.currentChanged.connect( partial(self.toggleTestButton))
def icon(self): return QIcon(getIconPath("geocat"))
) from qgis.utils import iface from geocatbridge.publish.metadata import uuidForLayer, loadMetadataFromXml from geocatbridge.publish.tasks import PublishTask, ExportTask from geocatbridge.servers import manager from geocatbridge.ui.metadatadialog import MetadataDialog from geocatbridge.ui.progressdialog import ProgressDialog from geocatbridge.utils import files, gui, meta, l10n from geocatbridge.utils.feedback import FeedbackMixin from geocatbridge.utils.layers import getPublishableLayers, getLayerById, getLayerTitleAndName # QGIS setting that stores the online/offline publish settings PUBLISH_SETTING = f"{meta.PLUGIN_NAMESPACE}/BridgePublish" PUBLISHED_ICON = QIcon(files.getIconPath("published")) ERROR_ICON = f'<img src="{files.getIconPath("error-red")}">' REMOVE_ICON = QIcon(files.getIconPath("remove")) VALIDATE_ICON = QIcon(files.getIconPath("validation")) PREVIEW_ICON = QIcon(files.getIconPath("preview")) IMPORT_ICON = QIcon(files.getIconPath("save")) IDENTIFICATION, CATEGORIES, KEYWORDS, ACCESS, EXTENT, CONTACT = range(6) WIDGET, BASE = gui.loadUiType(__file__) class PublishWidget(FeedbackMixin, BASE, WIDGET): def __init__(self, parent): super().__init__(parent)
def setIcon(label, server): pixmap = QPixmap( files.getIconPath(server.__class__.__name__.lower()[:-6])) label.setPixmap(pixmap)
from qgis.PyQt.QtCore import Qt, QCoreApplication from qgis.PyQt.QtGui import QBrush, QIcon, QColor from qgis.PyQt.QtWidgets import QTreeWidgetItem from geocatbridge.utils import files, gui from geocatbridge.utils import layers as lyr_utils WIDGET, BASE = gui.loadUiType(__file__) SYMBOLOGY, DATA, METADATA, GROUPS = range(4) DATA_ICON = QIcon(files.getIconPath("layer")) METADATA_ICON = QIcon(files.getIconPath("metadata")) SYMBOLOGY_ICON = QIcon(files.getIconPath("symbology")) GROUPS_ICON = QIcon(files.getIconPath("group")) CHECK_ICON = QIcon(files.getIconPath("checkmark")) class ProgressDialog(BASE, WIDGET): def __init__(self, layer_ids, parent=None): super(ProgressDialog, self).__init__(parent) self.setupUi(self) self.setWindowIcon(QIcon(files.getIconPath('geocat'))) self.layer_ids = layer_ids self.populateTree() def populateTree(self): for lyr_name in (lyr_utils.getLayerById(id_).name() for id_ in self.layer_ids):