From: Kai Uwe Broulik Date: Wed, 19 Sep 2018 08:20:14 +0000 (+0200) Subject: Update disk space info on refresh X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/391006130e31b80ecc55343f44bddaf06951c90f Update disk space info on refresh When explicitly refreshing the view (e.g. F5) also refresh disk space info. This would also allow us to raise the refresh interval somewhat. CCBUG: 398612 Differential Revision: https://phabricator.kde.org/D15508 --- diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index b603b8cfa..6576e1b0e 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -590,6 +590,7 @@ void DolphinMainWindow::reloadView() { clearStatusBar(); m_activeViewContainer->reload(); + m_activeViewContainer->statusBar()->updateSpaceInfo(); } void DolphinMainWindow::stopLoading() diff --git a/src/statusbar/dolphinstatusbar.cpp b/src/statusbar/dolphinstatusbar.cpp index 34916830e..b3fddba10 100644 --- a/src/statusbar/dolphinstatusbar.cpp +++ b/src/statusbar/dolphinstatusbar.cpp @@ -252,6 +252,11 @@ void DolphinStatusBar::readSettings() setExtensionsVisible(true); } +void DolphinStatusBar::updateSpaceInfo() +{ + m_spaceInfo->update(); +} + void DolphinStatusBar::contextMenuEvent(QContextMenuEvent* event) { Q_UNUSED(event); diff --git a/src/statusbar/dolphinstatusbar.h b/src/statusbar/dolphinstatusbar.h index 8b872ace5..7461d1d7d 100644 --- a/src/statusbar/dolphinstatusbar.h +++ b/src/statusbar/dolphinstatusbar.h @@ -88,6 +88,11 @@ public: */ void readSettings(); + /** + * Refreshes the disk space information. + */ + void updateSpaceInfo(); + public slots: void setText(const QString& text); void setUrl(const QUrl& url); diff --git a/src/statusbar/spaceinfoobserver.cpp b/src/statusbar/spaceinfoobserver.cpp index 6cf695d55..692eba7e7 100644 --- a/src/statusbar/spaceinfoobserver.cpp +++ b/src/statusbar/spaceinfoobserver.cpp @@ -71,6 +71,13 @@ void SpaceInfoObserver::setUrl(const QUrl& url) } } +void SpaceInfoObserver::update() +{ + if (m_mountPointObserver) { + m_mountPointObserver->update(); + } +} + void SpaceInfoObserver::spaceInfoChanged(quint64 size, quint64 available) { // Make sure that the size has actually changed diff --git a/src/statusbar/spaceinfoobserver.h b/src/statusbar/spaceinfoobserver.h index 1e74caef4..93f4c8c91 100644 --- a/src/statusbar/spaceinfoobserver.h +++ b/src/statusbar/spaceinfoobserver.h @@ -40,6 +40,9 @@ public: void setUrl(const QUrl& url); +public slots: + void update(); + signals: /** * This signal is emitted when the size or available space changes. diff --git a/src/statusbar/statusbarspaceinfo.cpp b/src/statusbar/statusbarspaceinfo.cpp index 65af17490..882249576 100644 --- a/src/statusbar/statusbarspaceinfo.cpp +++ b/src/statusbar/statusbarspaceinfo.cpp @@ -54,6 +54,13 @@ QUrl StatusBarSpaceInfo::url() const return m_url; } +void StatusBarSpaceInfo::update() +{ + if (m_observer) { + m_observer->update(); + } +} + void StatusBarSpaceInfo::showEvent(QShowEvent* event) { KCapacityBar::showEvent(event); diff --git a/src/statusbar/statusbarspaceinfo.h b/src/statusbar/statusbarspaceinfo.h index 4f36517ae..24f8b7f29 100644 --- a/src/statusbar/statusbarspaceinfo.h +++ b/src/statusbar/statusbarspaceinfo.h @@ -45,6 +45,8 @@ public: void setUrl(const QUrl& url); QUrl url() const; + void update(); + protected: void showEvent(QShowEvent* event) override; void hideEvent(QHideEvent* event) override;