From af902e0b2268085ff2ff4c21a4430ec4a94164bd Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 20 Aug 2026 17:21:54 +0200 Subject: refactor(ui): extract the busy indicator into a widget, item 134 The status bar's sync bar was a bare QProgressBar configured inline in MainWindow, and item 123's send popup needs the same thing again. It also needs the half MainWindow does not use: the popup drains a determinate bar through its cancellable countdown and switches THE SAME widget to indeterminate when send_command starts and the duration stops being knowable. Building that inline a second time is what this removes. BusyIndicator carries both modes. setBusy() resets the range as well as the visibility, so the switch out of the countdown cannot leave the bar drawing its last fraction, and setProgress() treats a total of zero as busy rather than passing it through: setRange(0, 0) IS the indeterminate range, so a zero total would otherwise hand the caller an animating bar while it believed it had drawn an empty one. Only the bar is extracted, not the status label the backlog row mentions beside it. m_statusLabel has 34 uses across MainWindow for transient messages, selection counts and sync phases; it belongs to the window rather than to the indicator, and the send popup owns its own phase text. The hidden-on-construction test needs a shown parent, which cost a mutation to find. Measured against a standalone Qt program: a parentless widget reports isVisible() false and isHidden() true whether or not hide() was ever called, so both obvious assertions passed against a constructor with the hide() deleted. What differs is WA_WState_ExplicitShowHide, and the behaviour it produces appears only once a parent is shown, which is how the status bar holds this widget. All five mutations checked and killed: the zero-total guard, the range reset in setBusy(), the value clamp, the show() in setProgress() and the hide() in the constructor. --- src/mainwindow.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mainwindow.h') diff --git a/src/mainwindow.h b/src/mainwindow.h index 5b1621f..8e483d2 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -52,11 +52,11 @@ class QPushButton; class QComboBox; class QPlainTextEdit; class QSplitter; -class QProgressBar; class QTimer; class QToolButton; class QVBoxLayout; +class BusyIndicator; class ThreadListModel; class MessageView; class MailSync; @@ -1074,7 +1074,7 @@ private: QLabel *m_pendingLabel = nullptr; /// Indeterminate, shown only while a sync runs. See setSyncBusy(). - QProgressBar *m_syncProgress = nullptr; + BusyIndicator *m_syncProgress = nullptr; /// The last counts the worker answered, one per placeholderLines() entry. /// Empty until the first reply, which renders the pane without its helper -- cgit v1.2.3