Skip to content

Commit

Permalink
Add resizable message box as result dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszptak committed Feb 9, 2024
1 parent cd0cbcc commit 57ffdb6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/deepness/deepness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
20 changes: 20 additions & 0 deletions src/deepness/dialogs/resizable_message_box.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 57ffdb6

Please sign in to comment.