#include "dolphin_generalsettings.h"
-#include <KIconLoader>
#include <QIcon>
-#include <KLocale>
+#include <KLocalizedString>
+#include <KSqueezedTextLabel>
#include <QMenu>
-#include <KVBox>
#include "statusbarspaceinfo.h"
#include <QApplication>
#include <QHBoxLayout>
-#include <QLabel>
#include <QProgressBar>
-#include <QTextDocument>
#include <QToolButton>
-#include <QTime>
#include <QTimer>
+#include <QSlider>
+#include <QTextDocument>
+#include <QHelpEvent>
#include <views/dolphinview.h>
#include <views/zoomlevelinfo.h>
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);
// Initialize progress information
m_stopButton = new QToolButton(this);
- m_stopButton->setIcon(QIcon::fromTheme("process-stop"));
+ m_stopButton->setIcon(QIcon::fromTheme(QStringLiteral("process-stop")));
m_stopButton->setAccessibleName(i18n("Stop"));
m_stopButton->setAutoRaise(true);
m_stopButton->setToolTip(i18nc("@tooltip", "Stop loading"));
// Initialize top layout and size policies
const int fontHeight = QFontMetrics(m_label->font()).height();
const int zoomSliderHeight = m_zoomSlider->minimumSizeHint().height();
- const int contentHeight = qMax(fontHeight, zoomSliderHeight);
+ const int buttonHeight = m_stopButton->height();
+ const int contentHeight = qMax(qMax(fontHeight, zoomSliderHeight), buttonHeight);
QFontMetrics fontMetrics(m_label->font());
m_zoomSlider->setMaximumWidth(fontMetrics.averageCharWidth() * 25);
- m_spaceInfo->setFixedHeight(contentHeight);
+ m_spaceInfo->setFixedHeight(zoomSliderHeight);
m_spaceInfo->setMaximumWidth(fontMetrics.averageCharWidth() * 25);
m_spaceInfo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- m_progressBar->setFixedHeight(contentHeight);
+ m_progressBar->setFixedHeight(zoomSliderHeight);
m_progressBar->setMaximumWidth(fontMetrics.averageCharWidth() * 25);
QHBoxLayout* topLayout = new QHBoxLayout(this);
- topLayout->setMargin(0);
+ 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);
return m_defaultText;
}
-void DolphinStatusBar::setUrl(const KUrl& url)
+void DolphinStatusBar::setUrl(const QUrl& url)
{
m_spaceInfo->setUrl(url);
}
-KUrl DolphinStatusBar::url() const
+QUrl DolphinStatusBar::url() const
{
return m_spaceInfo->url();
}
}
}
-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);
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()