diff options
| author | Peter Penz <[email protected]> | 2008-10-05 21:13:50 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2008-10-05 21:13:50 +0000 |
| commit | 2efa5667f6dcde4429ec259c4ac703b9d99fb4bc (patch) | |
| tree | f75ad03895a55b2bcb14214a46cbc023a6ea14f1 /src/statusbarspaceinfo.cpp | |
| parent | f47df895c4c760c16b56579be2af3a14cc39048f (diff) | |
do only a polling of the available space when the widget is visible
svn path=/trunk/KDE/kdebase/apps/; revision=868270
Diffstat (limited to 'src/statusbarspaceinfo.cpp')
| -rw-r--r-- | src/statusbarspaceinfo.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/statusbarspaceinfo.cpp b/src/statusbarspaceinfo.cpp index a311902f7..ba37a82a5 100644 --- a/src/statusbarspaceinfo.cpp +++ b/src/statusbarspaceinfo.cpp @@ -30,16 +30,16 @@ StatusBarSpaceInfo::StatusBarSpaceInfo(QWidget* parent) : KCapacityBar(KCapacityBar::DrawTextInline, parent), - m_kBSize(0) + m_kBSize(0), + m_timer(0) { setMaximumWidth(200); setMinimumWidth(200); // something to fix on kcapacitybar (ereslibre) - // Update the space information each 10 seconds. Polling is useful + // Use a timer to update the space information. Polling is useful // here, as files can be deleted/added outside the scope of Dolphin. - QTimer* timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(refresh())); - timer->start(10000); + m_timer = new QTimer(this); + connect(m_timer, SIGNAL(timeout()), this, SLOT(refresh())); } StatusBarSpaceInfo::~StatusBarSpaceInfo() @@ -52,8 +52,26 @@ void StatusBarSpaceInfo::setUrl(const KUrl& url) refresh(); } +void StatusBarSpaceInfo::showEvent(QShowEvent* event) +{ + KCapacityBar::showEvent(event); + if (!event->spontaneous()) { + m_timer->start(10000); + } +} + +void StatusBarSpaceInfo::hideEvent(QHideEvent* event) +{ + m_timer->stop(); + KCapacityBar::hideEvent(event); +} + void StatusBarSpaceInfo::refresh() { + if (!isVisible()) { + return; + } + // KDiskFreeSpace is for local paths only if (!m_url.isLocalFile()) { setText(i18nc("@info:status", "Unknown size")); |
