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)));
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);
showMessage(msg, Error);
}
-void DolphinViewContainer::showInfoMessage(const QString& msg)
-{
- showMessage(msg, Information);
-}
-
bool DolphinViewContainer::isSearchUrl(const KUrl& url) const
{
const QString protocol = url.protocol();
*/
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://).
#include <views/dolphinview.h>
#include <views/zoomlevelinfo.h>
+namespace {
+ const int ResetToDefaultTimeout = 1000;
+}
+
DolphinStatusBar::DolphinStatusBar(QWidget* parent) :
QWidget(parent),
m_text(),
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);
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();
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();
}
}
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)
m_label->setToolTip(text == elidedText ? QString() : text);
}
+void DolphinStatusBar::slotResetToDefaultText()
+{
+ m_text.clear();
+ updateLabelText();
+}
+
void DolphinStatusBar::setExtensionsVisible(bool visible)
{
bool showSpaceInfo = visible;
#ifndef DOLPHINSTATUSBAR_H
#define DOLPHINSTATUSBAR_H
+#include <QTime>
#include <QWidget>
class KUrl;
/**
* 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);
/**
* 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 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
QToolButton* m_stopButton;
int m_progress;
QTimer* m_showProgressBarTimer;
+
+ QTimer* m_resetToDefaultTextTimer;
+ QTime m_textTimestamp;
};
#endif