]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/statusbar/dolphinstatusbar.cpp
Fix minor typos
[dolphin.git] / src / statusbar / dolphinstatusbar.cpp
index 31d4ab81a58a396dffe5e6876b7958f52b77d46c..0feaa119bcd5d5a81f1b356b76f2e9a8a4fe1ef2 100644 (file)
 #include "dolphinstatusbar.h"
 
 #include "dolphin_generalsettings.h"
+#include "statusbarspaceinfo.h"
+#include "views/dolphinview.h"
+#include "views/zoomlevelinfo.h"
 
-#include <QIcon>
 #include <KLocalizedString>
-#include <QMenu>
-
-#include "statusbarspaceinfo.h"
+#include <KSqueezedTextLabel>
 
 #include <QApplication>
 #include <QHBoxLayout>
-#include <QLabel>
+#include <QHelpEvent>
+#include <QIcon>
+#include <QMenu>
 #include <QProgressBar>
-#include <QToolButton>
-#include <QTime>
-#include <QTimer>
 #include <QSlider>
 #include <QTextDocument>
-#include <QHelpEvent>
-
-#include <views/dolphinview.h>
-#include <views/zoomlevelinfo.h>
+#include <QTimer>
+#include <QToolButton>
 
 namespace {
     const int ResetToDefaultTimeout = 1000;
@@ -49,21 +46,20 @@ DolphinStatusBar::DolphinStatusBar(QWidget* parent) :
     QWidget(parent),
     m_text(),
     m_defaultText(),
-    m_label(0),
-    m_spaceInfo(0),
-    m_zoomSlider(0),
-    m_progressBar(0),
-    m_stopButton(0),
+    m_label(nullptr),
+    m_spaceInfo(nullptr),
+    m_zoomSlider(nullptr),
+    m_progressBar(nullptr),
+    m_stopButton(nullptr),
     m_progress(100),
-    m_showProgressBarTimer(0),
-    m_resetToDefaultTextTimer(0),
+    m_showProgressBarTimer(nullptr),
+    m_resetToDefaultTextTimer(nullptr),
     m_textTimestamp()
 {
     // Initialize text label
-    m_label = new QLabel(this);
+    m_label = new KSqueezedTextLabel(m_text, this);
     m_label->setWordWrap(true);
     m_label->setTextFormat(Qt::PlainText);
-    m_label->installEventFilter(this);
 
     // Initialize zoom widget
     m_zoomSlider = new QSlider(Qt::Horizontal, this);
@@ -127,9 +123,9 @@ DolphinStatusBar::DolphinStatusBar(QWidget* parent) :
     QHBoxLayout* topLayout = new QHBoxLayout(this);
     topLayout->setContentsMargins(2, 0, 2, 0);
     topLayout->setSpacing(4);
-    topLayout->addWidget(m_label);
-    topLayout->addWidget(m_zoomSlider);
-    topLayout->addWidget(m_spaceInfo);
+    topLayout->addWidget(m_label, 1);
+    topLayout->addWidget(m_zoomSlider, 1);
+    topLayout->addWidget(m_spaceInfo, 1);
     topLayout->addWidget(m_stopButton);
     topLayout->addWidget(m_progressTextLabel);
     topLayout->addWidget(m_progressBar);
@@ -151,7 +147,7 @@ void DolphinStatusBar::setText(const QString& text)
 
     if (text.isEmpty()) {
         // Assure that the previous set text won't get
-        // cleared immediatelly.
+        // cleared immediately.
         m_resetToDefaultTextTimer->start();
     } else {
         m_text = text;
@@ -256,6 +252,11 @@ void DolphinStatusBar::readSettings()
     setExtensionsVisible(true);
 }
 
+void DolphinStatusBar::updateSpaceInfo()
+{
+    m_spaceInfo->update();
+}
+
 void DolphinStatusBar::contextMenuEvent(QContextMenuEvent* event)
 {
     Q_UNUSED(event);
@@ -282,14 +283,6 @@ void DolphinStatusBar::contextMenuEvent(QContextMenuEvent* event)
     }
 }
 
-bool DolphinStatusBar::eventFilter(QObject* obj, QEvent* event)
-{
-    if (obj == m_label && event->type() == QEvent::Resize) {
-        updateLabelText();
-    }
-    return QWidget::eventFilter(obj, event);
-}
-
 void DolphinStatusBar::showZoomSliderToolTip(int zoomLevel)
 {
     updateZoomSliderToolTip(zoomLevel);
@@ -320,18 +313,7 @@ void DolphinStatusBar::updateProgressInfo()
 void DolphinStatusBar::updateLabelText()
 {
     const QString text = m_text.isEmpty() ? m_defaultText : m_text;
-
-    // Set status bar text and elide it if too long
-    QFontMetrics fontMetrics(m_label->font());
-    const QString elidedText = fontMetrics.elidedText(text, Qt::ElideRight, m_label->width());
-    m_label->setText(elidedText);
-
-    // If the text has been elided, set the original text as tooltip
-    if (text != elidedText) {
-        m_label->setToolTip(Qt::convertFromPlainText(text));
-    } else {
-        m_label->setToolTip(QString());
-    }
+    m_label->setText(text);
 }
 
 void DolphinStatusBar::slotResetToDefaultText()