diff options
| author | Felix Ernst <[email protected]> | 2024-11-10 16:47:19 +0100 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2024-11-12 10:54:25 +0000 |
| commit | 6c73f7912b6fb0327b9fd0ca7a3fff3b2fb4d5e9 (patch) | |
| tree | 7f3cba330209c4e379d0e688cf46573a2b6c2282 /src/statusbar/statusbarspaceinfo.h | |
| parent | ed870aa7ed971af4e5b34bd653fb96998e8dd4f3 (diff) | |
Avoid flickering of space info on startup
Prior to this commit, when Dolphin was opening in a directory for
which the free space information cannot be retrieved, the free
space info in the status bar would still briefly be visible before
hiding for good.
This commit avoids this flickering by keeping the space info hidden
until space info has been successfully retrieved. There is no use
showing an empty/wrong space info before that anyway.
I assume the error in the previous code was that it assumed that
one could prevent a widget from being shown by overriding
QWidget::showEvent(). This does not work because this method is
only called to notify QWidgets of their state change.
This commit was primarily written because the brief showing of an
empty space info was messing with automatic tests.
Diffstat (limited to 'src/statusbar/statusbarspaceinfo.h')
| -rw-r--r-- | src/statusbar/statusbarspaceinfo.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/statusbar/statusbarspaceinfo.h b/src/statusbar/statusbarspaceinfo.h index 237192c9c..7a1012cf0 100644 --- a/src/statusbar/statusbarspaceinfo.h +++ b/src/statusbar/statusbarspaceinfo.h @@ -35,9 +35,11 @@ public: ~StatusBarSpaceInfo() override; /** - * Use this to set the widget visibility as it can hide itself + * Works similar to QWidget::setVisible() except that this will postpone showing the widget until space info has been retrieved. Hiding happens instantly. + * + * @param shown Whether this widget is supposed to be visible long-term */ - void setShown(bool); + void setShown(bool shown); void setUrl(const QUrl &url); QUrl url() const; @@ -80,6 +82,11 @@ private: */ void initialiseInstallFilelightWidgetAction(); + // The following three methods are only for private use. + using QWidget::hide; // Use StatusBarSpaceInfo::setShown() instead. + using QWidget::setVisible; // Use StatusBarSpaceInfo::setShown() instead. + using QWidget::show; // Use StatusBarSpaceInfo::setShown() instead. + private: QScopedPointer<SpaceInfoObserver> m_observer; KCapacityBar *m_capacityBar; @@ -88,7 +95,9 @@ private: /** An action containing a UI to install Filelight. */ QWidgetAction *m_installFilelightWidgetAction; QUrl m_url; - bool m_ready; + /** Whether m_observer has already retrieved space information for the current url. */ + bool m_hasSpaceInfo; + /** Whether this widget is supposed to be visible long-term. @see StatusBarSpaceInfo::setShown(). */ bool m_shown; }; |
