diff options
| author | Peter Penz <[email protected]> | 2012-04-15 11:44:56 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-04-15 11:46:07 +0200 |
| commit | 1ea09b24e16d98ac2f1033b21462323fb295ae2f (patch) | |
| tree | 7cdeab66f0c729f589cec05d74466b13f7ab9a16 /src/statusbar/dolphinstatusbar.cpp | |
| parent | 60b868108151463a702e8c10933b0ceb99f11bbe (diff) | |
Minor statusbar fixes
- Don't show information messages as KMessageWidget
- Assure that a set text in a statusbar will be shown for at least
one second
Diffstat (limited to 'src/statusbar/dolphinstatusbar.cpp')
| -rw-r--r-- | src/statusbar/dolphinstatusbar.cpp | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/src/statusbar/dolphinstatusbar.cpp b/src/statusbar/dolphinstatusbar.cpp index 61ca84e44..3ab499743 100644 --- a/src/statusbar/dolphinstatusbar.cpp +++ b/src/statusbar/dolphinstatusbar.cpp @@ -41,6 +41,10 @@ #include <views/dolphinview.h> #include <views/zoomlevelinfo.h> +namespace { + const int ResetToDefaultTimeout = 1000; +} + DolphinStatusBar::DolphinStatusBar(QWidget* parent) : QWidget(parent), m_text(), @@ -51,7 +55,9 @@ DolphinStatusBar::DolphinStatusBar(QWidget* parent) : m_progressBar(0), m_stopButton(0), m_progress(100), - m_showProgressBarTimer(0) + m_showProgressBarTimer(0), + m_resetToDefaultTextTimer(0), + m_textTimestamp() { // Initialize text label m_label = new QLabel(this); @@ -90,6 +96,11 @@ DolphinStatusBar::DolphinStatusBar(QWidget* parent) : m_showProgressBarTimer->setSingleShot(true); connect(m_showProgressBarTimer, SIGNAL(timeout()), this, SLOT(updateProgressInfo())); + m_resetToDefaultTextTimer = new QTimer(this); + m_resetToDefaultTextTimer->setInterval(ResetToDefaultTimeout); + m_resetToDefaultTextTimer->setSingleShot(true); + connect(m_resetToDefaultTextTimer, SIGNAL(timeout()), this, SLOT(slotResetToDefaultText())); + // Initialize top layout and size policies const int fontHeight = QFontMetrics(m_label->font()).height(); const int zoomSliderHeight = m_zoomSlider->minimumSizeHint().height(); @@ -123,8 +134,23 @@ DolphinStatusBar::~DolphinStatusBar() void DolphinStatusBar::setText(const QString& text) { - if (m_text != text) { + if (m_text == text) { + return; + } + + m_textTimestamp = QTime::currentTime(); + + if (text.isEmpty()) { + // Assure that the previous set text won't get + // cleared immediatelly. + m_resetToDefaultTextTimer->start(); + } else { m_text = text; + + if (m_resetToDefaultTextTimer->isActive()) { + m_resetToDefaultTextTimer->start(); + } + updateLabelText(); } } @@ -174,8 +200,13 @@ int DolphinStatusBar::progress() const void DolphinStatusBar::resetToDefaultText() { - m_text.clear(); - updateLabelText(); + QTime currentTime; + if (currentTime.msecsTo(m_textTimestamp) < ResetToDefaultTimeout) { + m_resetToDefaultTextTimer->start(); + } else { + m_resetToDefaultTextTimer->stop(); + slotResetToDefaultText(); + } } void DolphinStatusBar::setDefaultText(const QString& text) @@ -290,6 +321,12 @@ void DolphinStatusBar::updateLabelText() m_label->setToolTip(text == elidedText ? QString() : text); } +void DolphinStatusBar::slotResetToDefaultText() +{ + m_text.clear(); + updateLabelText(); +} + void DolphinStatusBar::setExtensionsVisible(bool visible) { bool showSpaceInfo = visible; |
