]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Minor statusbar fixes
authorPeter Penz <peter.penz19@gmail.com>
Sun, 15 Apr 2012 09:44:56 +0000 (11:44 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 15 Apr 2012 09:46:07 +0000 (11:46 +0200)
- Don't show information messages as KMessageWidget
- Assure that a set text in a statusbar will be shown for at least
  one second

src/dolphinviewcontainer.cpp
src/dolphinviewcontainer.h
src/statusbar/dolphinstatusbar.cpp
src/statusbar/dolphinstatusbar.h

index 9d75ad816018ca870e0e07b34b125f32e1851d16..ce602be99599da1ba57c640fdf73ccd8a1c252d0 100644 (file)
@@ -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(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)));
 
     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());
     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);
 
     m_statusBarTimer = new QTimer(this);
     m_statusBarTimer->setSingleShot(true);
@@ -617,11 +617,6 @@ void DolphinViewContainer::showErrorMessage(const QString& msg)
     showMessage(msg, Error);
 }
 
     showMessage(msg, Error);
 }
 
-void DolphinViewContainer::showInfoMessage(const QString& msg)
-{
-    showMessage(msg, Information);
-}
-
 bool DolphinViewContainer::isSearchUrl(const KUrl& url) const
 {
     const QString protocol = url.protocol();
 bool DolphinViewContainer::isSearchUrl(const KUrl& url) const
 {
     const QString protocol = url.protocol();
index 5e98f5e945fbeccdaf3a6724d3c59d8060fa0fcf..db9b5be336ca3c99656c8127073ce31661459dc2 100644 (file)
@@ -273,11 +273,6 @@ private slots:
      */
     void showErrorMessage(const QString& msg);
 
      */
     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://).
 private:
     /**
      * @return True if the URL protocol is a search URL (e. g. nepomuksearch:// or filenamesearch://).
index 61ca84e44d83d4e023ed3fca5853e82ad9466e5a..3ab49974342d87e4f99a8b773578d4bf8f34a8e4 100644 (file)
 #include <views/dolphinview.h>
 #include <views/zoomlevelinfo.h>
 
 #include <views/dolphinview.h>
 #include <views/zoomlevelinfo.h>
 
+namespace {
+    const int ResetToDefaultTimeout = 1000;
+}
+
 DolphinStatusBar::DolphinStatusBar(QWidget* parent) :
     QWidget(parent),
     m_text(),
 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_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);
 {
     // 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_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();
     // 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)
 {
 
 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;
         m_text = text;
+
+        if (m_resetToDefaultTextTimer->isActive()) {
+            m_resetToDefaultTextTimer->start();
+        }
+
         updateLabelText();
     }
 }
         updateLabelText();
     }
 }
@@ -174,8 +200,13 @@ int DolphinStatusBar::progress() const
 
 void DolphinStatusBar::resetToDefaultText()
 {
 
 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)
 }
 
 void DolphinStatusBar::setDefaultText(const QString& text)
@@ -290,6 +321,12 @@ void DolphinStatusBar::updateLabelText()
     m_label->setToolTip(text == elidedText ? QString() : text);
 }
 
     m_label->setToolTip(text == elidedText ? QString() : text);
 }
 
+void DolphinStatusBar::slotResetToDefaultText()
+{
+    m_text.clear();
+    updateLabelText();
+}
+
 void DolphinStatusBar::setExtensionsVisible(bool visible)
 {
     bool showSpaceInfo = visible;
 void DolphinStatusBar::setExtensionsVisible(bool visible)
 {
     bool showSpaceInfo = visible;
index 1a81968a136162650c0d0819f54b08727428b404..d7e37f584c2204513895a5d018edc07318f83b62 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef DOLPHINSTATUSBAR_H
 #define DOLPHINSTATUSBAR_H
 
 #ifndef DOLPHINSTATUSBAR_H
 #define DOLPHINSTATUSBAR_H
 
+#include <QTime>
 #include <QWidget>
 
 class KUrl;
 #include <QWidget>
 
 class KUrl;
@@ -56,8 +57,8 @@ public:
 
     /**
      * Sets the progress in percent (0 - 100). The
 
     /**
      * 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);
      * 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
 
     /**
      * 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();
 
      */
     void resetToDefaultText();
 
@@ -112,6 +114,14 @@ private slots:
      */
     void updateLabelText();
 
      */
     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
 private:
     /**
      * Makes the space information widget and zoom slider widget
@@ -142,6 +152,9 @@ private:
     QToolButton* m_stopButton;
     int m_progress;
     QTimer* m_showProgressBarTimer;
     QToolButton* m_stopButton;
     int m_progress;
     QTimer* m_showProgressBarTimer;
+
+    QTimer* m_resetToDefaultTextTimer;
+    QTime m_textTimestamp;
 };
 
 #endif
 };
 
 #endif