From 57ffdb6a4663c323e1b7894cfa685655d0e6ace6 Mon Sep 17 00:00:00 2001 From: Bartosz Date: Fri, 9 Feb 2024 10:43:13 +0100 Subject: [PATCH] Add resizable message box as result dialog --- src/deepness/deepness.py | 26 +++++++++++-------- src/deepness/dialogs/resizable_message_box.py | 20 ++++++++++++++ 2 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 src/deepness/dialogs/resizable_message_box.py diff --git a/src/deepness/deepness.py b/src/deepness/deepness.py index 4c3b46f..c8867ca 100644 --- a/src/deepness/deepness.py +++ b/src/deepness/deepness.py @@ -8,24 +8,22 @@ import logging import traceback +from qgis.core import Qgis, QgsApplication, QgsProject, QgsVectorLayer +from qgis.gui import QgisInterface from qgis.PyQt.QtCore import QCoreApplication, Qt from qgis.PyQt.QtGui import QIcon -from qgis.PyQt.QtWidgets import QAction -from qgis.PyQt.QtWidgets import QMessageBox -from qgis.core import Qgis -from qgis.core import QgsApplication -from qgis.core import QgsProject -from qgis.core import QgsVectorLayer -from qgis.gui import QgisInterface +from qgis.PyQt.QtWidgets import QAction, QMessageBox -from deepness.common.defines import PLUGIN_NAME, IS_DEBUG +from deepness.common.defines import IS_DEBUG, PLUGIN_NAME from deepness.common.lazy_package_loader import LazyPackageLoader from deepness.common.processing_parameters.map_processing_parameters import MapProcessingParameters, ProcessedAreaType from deepness.common.processing_parameters.training_data_export_parameters import TrainingDataExportParameters from deepness.deepness_dockwidget import DeepnessDockWidget +from deepness.dialogs.resizable_message_box import ResizableMessageBox from deepness.images.get_image_path import get_icon_path -from deepness.processing.map_processor.map_processing_result import MapProcessingResult, MapProcessingResultFailed, \ - MapProcessingResultCanceled, MapProcessingResultSuccess +from deepness.processing.map_processor.map_processing_result import (MapProcessingResult, MapProcessingResultCanceled, + MapProcessingResultFailed, + MapProcessingResultSuccess) from deepness.processing.map_processor.map_processor_training_data_export import MapProcessorTrainingDataExport from deepness.processing.models.model_types import ModelDefinition @@ -308,5 +306,11 @@ def _map_processor_finished(self, result: MapProcessingResult): msg = 'Processing finished!' self.iface.messageBar().pushMessage(PLUGIN_NAME, msg, level=Qgis.Success, duration=3) message_to_show = result.message - QMessageBox.information(self.dockwidget, "Processing Result", message_to_show) + + msgBox = ResizableMessageBox(self.dockwidget) + msgBox.setWindowTitle("Processing Result") + msgBox.setText(message_to_show) + msgBox.setStyleSheet("QLabel{min-width:800 px; font-size: 24px;} QPushButton{ width:250px; font-size: 18px; }") + msgBox.exec() + self._map_processor = None diff --git a/src/deepness/dialogs/resizable_message_box.py b/src/deepness/dialogs/resizable_message_box.py new file mode 100644 index 0000000..b2a6794 --- /dev/null +++ b/src/deepness/dialogs/resizable_message_box.py @@ -0,0 +1,20 @@ +from qgis.PyQt.QtWidgets import QMessageBox, QTextEdit + + +class ResizableMessageBox(QMessageBox): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.setSizeGripEnabled(True) + + def event(self, event): + if event.type() in (event.LayoutRequest, event.Resize): + if event.type() == event.Resize: + res = super().event(event) + else: + res = False + details = self.findChild(QTextEdit) + if details: + details.setMaximumSize(16777215, 16777215) + self.setMaximumSize(16777215, 16777215) + return res + return super().event(event)