From 175928ec859b9255825252f7109bf9b76a539d3b Mon Sep 17 00:00:00 2001 From: Samweli Date: Wed, 11 Dec 2024 15:03:39 +0300 Subject: [PATCH] include duration when showing report error --- src/qgis_gea_plugin/gui/qgis_gea.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/qgis_gea_plugin/gui/qgis_gea.py b/src/qgis_gea_plugin/gui/qgis_gea.py index cd6e3c6..f73da12 100644 --- a/src/qgis_gea_plugin/gui/qgis_gea.py +++ b/src/qgis_gea_plugin/gui/qgis_gea.py @@ -1095,7 +1095,7 @@ def cancel_drawing(self): ) log(f"Encountered an error when clearing the project drawn area.") - def show_message(self, message, level=Qgis.Warning): + def show_message(self, message, level=Qgis.Warning, duration=None): """Shows message on the main widget message bar. :param message: Text message @@ -1103,9 +1103,21 @@ def show_message(self, message, level=Qgis.Warning): :param level: Message level type :type level: Qgis.MessageLevel + + :param duration: How to display the message + :type duration: int """ self.message_bar.clearWidgets() - self.message_bar.pushMessage(message, level=level) + + if duration: + self.message_bar.pushMessage( + message, + level=level, + duration=duration + ) + else: + self.message_bar.pushMessage(message, level=level) + def prepare_message_bar(self): """Initializes the widget message bar settings""" @@ -1365,7 +1377,8 @@ def on_generate_report(self): if site_layer.dataProvider().dataSourceUri().startswith('memory'): self.show_message( message, - Qgis.Warning + Qgis.Warning, + duration=10 ) return