diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py
index 946eb54e..7d2d963b 100644
--- a/src/View/MainWindow.py
+++ b/src/View/MainWindow.py
@@ -49,6 +49,7 @@ from View.Tools.ListedSubWindow import ListedSubWindow
from View.DummyWindow import DummyWindow
from View.Translate import MainTranslate
+from View.WaitingDialog import WaitingDialog
from View.MainWindowTabInfo import WidgetInfo
from View.MainWindowTabChecker import WidgetChecker
@@ -931,7 +932,19 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
if dialog.exec_():
file_name = dialog.selectedFiles()
- self.open_study(file_name[0])
+
+ def fn():
+ self._tmp_study = Study.open(file_name[0])
+
+ dlg = WaitingDialog(
+ payload_fn=fn,
+ title="waiting_load",
+ parent=self
+ )
+ dlg.exec_()
+
+ self.set_model(self._tmp_study)
+ self.set_title()
def open_new_study(self):
"""Open dialog to set new study
@@ -1260,7 +1273,11 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
name=name
)
- dlg = ReadingResultsDialog(reading_fn=reading_fn, parent=self)
+ dlg = WaitingDialog(
+ payload_fn=reading_fn,
+ title="waiting_result",
+ parent=self
+ )
dlg.exec_()
results = self._tmp_results
diff --git a/src/View/Translate.py b/src/View/Translate.py
index 16b198b5..e728cb25 100644
--- a/src/View/Translate.py
+++ b/src/View/Translate.py
@@ -92,3 +92,10 @@ class MainTranslate(UnitTranslate):
self._dict["active_window"] = _translate(
"MainWindow", "Enable this window"
)
+
+ self._dict["waiting_load"] = _translate(
+ "MainWindow", "Loading file ..."
+ )
+ self._dict["waiting_result"] = _translate(
+ "MainWindow", "Reading results ..."
+ )
diff --git a/src/View/WaitingDialog.py b/src/View/WaitingDialog.py
new file mode 100644
index 00000000..8520c74d
--- /dev/null
+++ b/src/View/WaitingDialog.py
@@ -0,0 +1,132 @@
+# WaitingDialog.py -- Pamhyr
+# Copyright (C) 2023-2024 INRAE
+#
+# 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 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+# -*- coding: utf-8 -*-
+
+import logging
+import random
+
+from tools import logger_exception
+
+from View.Tools.PamhyrWindow import PamhyrDialog
+from View.Translate import MainTranslate
+
+from PyQt5.QtGui import (
+ QKeySequence,
+)
+
+from PyQt5.QtCore import (
+ Qt, QVariant, QAbstractTableModel, QTimer,
+ QObject, pyqtSlot, pyqtSignal, QThread,
+)
+
+from PyQt5.QtWidgets import (
+ QLabel,
+)
+
+logger = logging.getLogger()
+
+
+class Worker(QObject):
+ signalStatus = pyqtSignal(str)
+
+ def __init__(self, payload_fn, parent=None):
+ super(self.__class__, self).__init__(parent)
+
+ self._payload_fn = payload_fn
+
+ def process(self):
+ self._payload_fn()
+ self.signalStatus.emit('end')
+
+
+class WaitingDialog(PamhyrDialog):
+ _pamhyr_ui = "WaitingDialog"
+ _pamhyr_name = "Waiting"
+
+ _spin_set = [
+ "-\\|/",
+ ["", "", ".", ".", "..", "..", "...", "..."],
+ "▖▘▝▗",
+ "◢◣◤◥",
+ "◐◓◑◒",
+ "◰◳◲◱",
+ "◴◷◶◵",
+ "┤┘┴└├┌┬┐",
+ "⣷⣯⣟⡿⢿⣻⣽⣾",
+ "⡀⡁⡂⡃⡄⡅⡆⡇⡈⡉⡊⡋⡌⡍⡎⡏⡐⡑⡒⡓⡔⡕⡖⡗⡘⡙⡚⡛⡜⡝⡞⡟⡠⡡⡢⡣⡤⡥⡦⡧⡨⡩⡪⡫⡬⡭⡮⡯⡰⡱⡲⡳⡴⡵⡶⡷⡸⡹⡺⡻⡼⡽⡾⡿⢀⢁⢂⢃⢄⢅⢆⢇⢈⢉⢊⢋⢌⢍⢎⢏⢐⢑⢒⢓⢔⢕⢖⢗⢘⢙⢚⢛⢜⢝⢞⢟⢠⢡⢢⢣⢤⢥⢦⢧⢨⢩⢪⢫⢬⢭⢮⢯⢰⢱⢲⢳⢴⢵⢶⢷⢸⢹⢺⢻⢼⢽⢾⢿⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿",
+ ]
+
+ def __init__(self, payload_fn, title, parent=None):
+ trad = MainTranslate()
+ super(WaitingDialog, self).__init__(
+ title=trad[title],
+ trad=trad,
+ options=[],
+ parent=parent
+ )
+
+ self._payload_fn = payload_fn
+
+ self._init_default_values()
+
+ self.setup_timer()
+ self.setup_worker()
+
+ self._timer.start(300)
+ self._worker_thread.start()
+
+ def _init_default_values(self):
+ self._spinner_step = 0
+ self._spin = self._spin_set[
+ random.randrange(0, len(self._spin_set))
+ ]
+
+ self.set_label_text("label_spinner", self._spin[0])
+
+ def setup_worker(self):
+ self._worker = Worker(self._payload_fn)
+ self._worker_thread = QThread(parent=self)
+ self._worker.moveToThread(self._worker_thread)
+
+ self._worker.signalStatus.connect(self.close)
+ self._worker_thread.started.connect(self._worker.process)
+
+ def setup_timer(self):
+ self._timer = QTimer(self)
+ self._timer.timeout.connect(self.update_spinner)
+
+ def update_spinner(self):
+ self._spinner_step += 1
+ self._spinner_step %= len(self._spin)
+
+ self.set_label_text(
+ "label_spinner",
+ self._spin[self._spinner_step]
+ )
+
+ def end_worker(self):
+ self._worker_thread.terminate()
+ self._worker_thread.wait()
+
+ def close(self):
+ try:
+ self._timer.stop()
+ self.end_worker()
+ except Exception as e:
+ logger_exception(e)
+
+ super().close()
diff --git a/src/View/ui/WaitingDialog.ui b/src/View/ui/WaitingDialog.ui
new file mode 100644
index 00000000..4e61c2ae
--- /dev/null
+++ b/src/View/ui/WaitingDialog.ui
@@ -0,0 +1,70 @@
+
+
+ Dialog
+
+
+
+ 0
+ 0
+ 205
+ 42
+
+
+
+ Dialog
+
+
+ -
+
+
-
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ Monospace
+ 12
+ 50
+ false
+
+
+
+ .
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+
+
+
+
+
+
+