From 89bf07f5c757c9794aff31aa4767b3e6d7b75624 Mon Sep 17 00:00:00 2001 From: Laurent Trinques Date: Sun, 18 Oct 2026 17:01:17 +0200 Subject: [PATCH] Terminal block manager: say that it is opening Opening the terminal block manager reads every terminal of the project, and builds the folios not built yet (lazy folios): on a big project it can take a while, and the user could think that nothing happens. TerminalStripEditorWindow::instance(), used by the menu action and by a double click on a terminal strip of a folio, now shows a busy message ("Opening the terminal block manager...") and a wait cursor while the window is built or switched to another project. Moved from the header to the .cpp file. --- .../ui/terminalstripeditorwindow.cpp | 40 +++++++++++++++++++ .../ui/terminalstripeditorwindow.h | 13 +----- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/sources/TerminalStrip/ui/terminalstripeditorwindow.cpp b/sources/TerminalStrip/ui/terminalstripeditorwindow.cpp index c47660bd9..aee833db9 100644 --- a/sources/TerminalStrip/ui/terminalstripeditorwindow.cpp +++ b/sources/TerminalStrip/ui/terminalstripeditorwindow.cpp @@ -29,8 +29,48 @@ #include "terminalstripeditorwindow.h" #include "terminalstriptreedockwidget.h" +#include +#include + QPointer TerminalStripEditorWindow::window_; +/** + * @brief TerminalStripEditorWindow::instance + * @param project : the project to edit + * @param parent : parent widget of the window, when it is created + * @return the terminal block manager window, created the first time, + * showing the terminal strips of @a project. + * Opening it reads every terminal of the project (and builds the folios + * not built yet) : it can take a while on a big project. A message and a + * busy cursor say that it is opening, so that the user does not think + * that nothing happens. + */ +TerminalStripEditorWindow *TerminalStripEditorWindow::instance(QETProject *project, QWidget *parent) +{ + QProgressDialog busy_(tr("Opening the terminal block manager..."), QString(), 0, 0, parent); + busy_.setWindowTitle(tr("Terminal block manager")); + busy_.setWindowModality(Qt::ApplicationModal); + busy_.setCancelButton(nullptr); + busy_.setMinimumDuration(0); + busy_.show(); + //Paint the message before the long work starts + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + QApplication::setOverrideCursor(Qt::WaitCursor); + + static QMutex mutex_; + if (!window_) { + mutex_.lock(); + if (!window_) + window_ = new TerminalStripEditorWindow{project, parent}; + mutex_.unlock(); + } else { + window_->setProject(project); + } + + QApplication::restoreOverrideCursor(); + return window_; +} + static const int EMPTY_PAGE = 0; static const int FREE_TERMINAL_PAGE = 1; static const int TERMINAL_STRIP_PAGE = 2; diff --git a/sources/TerminalStrip/ui/terminalstripeditorwindow.h b/sources/TerminalStrip/ui/terminalstripeditorwindow.h index 10c41f468..8786104dc 100644 --- a/sources/TerminalStrip/ui/terminalstripeditorwindow.h +++ b/sources/TerminalStrip/ui/terminalstripeditorwindow.h @@ -44,18 +44,7 @@ class TerminalStripEditorWindow : public QMainWindow static QPointer window_; public: - static TerminalStripEditorWindow* instance(QETProject *project, QWidget *parent = nullptr) { - static QMutex mutex_; - if (!window_) { - mutex_.lock(); - if (!window_) - window_ = new TerminalStripEditorWindow{project, parent}; - mutex_.unlock(); - } else { - window_->setProject(project); - } - return window_; - } + static TerminalStripEditorWindow* instance(QETProject *project, QWidget *parent = nullptr); static void dropInstance () { static QMutex mutex;