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 | |
| 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
| -rw-r--r-- | src/dolphinviewcontainer.cpp | 17 | ||||
| -rw-r--r-- | src/dolphinviewcontainer.h | 5 | ||||
| -rw-r--r-- | src/statusbar/dolphinstatusbar.cpp | 45 | ||||
| -rw-r--r-- | src/statusbar/dolphinstatusbar.h | 21 |
4 files changed, 64 insertions, 24 deletions
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 9d75ad816..ce602be99 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -111,8 +111,6 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) : connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(delayedStatusBarUpdate())); connect(m_view, SIGNAL(urlAboutToBeChanged(KUrl)), this, SLOT(slotViewUrlAboutToBeChanged(KUrl))); connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString))); - connect(m_view, SIGNAL(infoMessage(QString)), this, SLOT(showInfoMessage(QString))); - connect(m_view, SIGNAL(operationCompletedMessage(QString)), m_statusBar, SLOT(setText(QString))); connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(KUrl)), this, SLOT(slotUrlNavigatorLocationAboutToBeChanged(KUrl))); @@ -125,10 +123,12 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) : m_statusBar = new DolphinStatusBar(this); m_statusBar->setUrl(m_view->url()); m_statusBar->setZoomLevel(m_view->zoomLevel()); - connect(m_view, SIGNAL(urlChanged(KUrl)), m_statusBar, SLOT(setUrl(KUrl))); - connect(m_view, SIGNAL(zoomLevelChanged(int,int)), m_statusBar, SLOT(setZoomLevel(int))); - connect(m_statusBar, SIGNAL(stopPressed()), this, SLOT(stopDirectoryLoading())); - connect(m_statusBar, SIGNAL(zoomLevelChanged(int)), this, SLOT(slotStatusBarZoomLevelChanged(int))); + connect(m_view, SIGNAL(urlChanged(KUrl)), m_statusBar, SLOT(setUrl(KUrl))); + connect(m_view, SIGNAL(zoomLevelChanged(int,int)), m_statusBar, SLOT(setZoomLevel(int))); + connect(m_view, SIGNAL(infoMessage(QString)), m_statusBar, SLOT(setText(QString))); + connect(m_view, SIGNAL(operationCompletedMessage(QString)), m_statusBar, SLOT(setText(QString))); + connect(m_statusBar, SIGNAL(stopPressed()), this, SLOT(stopDirectoryLoading())); + connect(m_statusBar, SIGNAL(zoomLevelChanged(int)), this, SLOT(slotStatusBarZoomLevelChanged(int))); m_statusBarTimer = new QTimer(this); m_statusBarTimer->setSingleShot(true); @@ -617,11 +617,6 @@ void DolphinViewContainer::showErrorMessage(const QString& msg) showMessage(msg, Error); } -void DolphinViewContainer::showInfoMessage(const QString& msg) -{ - showMessage(msg, Information); -} - bool DolphinViewContainer::isSearchUrl(const KUrl& url) const { const QString protocol = url.protocol(); diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index 5e98f5e94..db9b5be33 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -273,11 +273,6 @@ private slots: */ void showErrorMessage(const QString& msg); - /** - * Slot that calls showMessage(msg, Information). - */ - void showInfoMessage(const QString& msg); - private: /** * @return True if the URL protocol is a search URL (e. g. nepomuksearch:// or filenamesearch://). 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; diff --git a/src/statusbar/dolphinstatusbar.h b/src/statusbar/dolphinstatusbar.h index 1a81968a1..d7e37f584 100644 --- a/src/statusbar/dolphinstatusbar.h +++ b/src/statusbar/dolphinstatusbar.h @@ -20,6 +20,7 @@ #ifndef DOLPHINSTATUSBAR_H #define DOLPHINSTATUSBAR_H +#include <QTime> #include <QWidget> class KUrl; @@ -56,8 +57,8 @@ public: /** * Sets the progress in percent (0 - 100). The - * progress is shown delayed by 1 second: - * If the progress does reach 100 % within 1 second, + * progress is shown delayed by 500 milliseconds: + * If the progress does reach 100 % within 500 milliseconds, * the progress is not shown at all. */ void setProgress(int percent); @@ -65,8 +66,9 @@ public: /** * Replaces the text set by setText() by the text that - * has been set by setDefaultText(). DolphinStatusBar::text() - * will return an empty string afterwards. + * has been set by setDefaultText(). It is assured that the previous + * text will be shown for at least 1 second. DolphinStatusBar::text() + * will return an empty string after the reset has been done. */ void resetToDefaultText(); @@ -112,6 +114,14 @@ private slots: */ void updateLabelText(); + /** + * Is invoked by m_resetToDefaultTextTimer and clears + * m_text so that the default text will be shown. This + * prevents that information-messages will be cleared + * too fast. + */ + void slotResetToDefaultText(); + private: /** * Makes the space information widget and zoom slider widget @@ -142,6 +152,9 @@ private: QToolButton* m_stopButton; int m_progress; QTimer* m_showProgressBarTimer; + + QTimer* m_resetToDefaultTextTimer; + QTime m_textTimestamp; }; #endif |
