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.
This commit is contained in:
Laurent Trinques
2026-10-18 17:01:17 +02:00
parent ff18467117
commit 89bf07f5c7
2 changed files with 41 additions and 12 deletions
@@ -29,8 +29,48 @@
#include "terminalstripeditorwindow.h"
#include "terminalstriptreedockwidget.h"
#include <QApplication>
#include <QProgressDialog>
QPointer<TerminalStripEditorWindow> 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;
@@ -44,18 +44,7 @@ class TerminalStripEditorWindow : public QMainWindow
static QPointer<TerminalStripEditorWindow> 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;