X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/1826f905d706925456763394de17294bcb6d1c35..041a3a4a346309b0aec50df41abe7b332804b81a:/src/statusbar/dolphinstatusbar.cpp diff --git a/src/statusbar/dolphinstatusbar.cpp b/src/statusbar/dolphinstatusbar.cpp index 9830960dc..22e80b39e 100644 --- a/src/statusbar/dolphinstatusbar.cpp +++ b/src/statusbar/dolphinstatusbar.cpp @@ -19,8 +19,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -50,7 +52,7 @@ DolphinStatusBar::DolphinStatusBar(QWidget *parent) m_label->setTextFormat(Qt::PlainText); // Initialize zoom slider's explanatory label - m_zoomLabel = new QLabel(i18nc("Used as a noun, i.e. 'Here is the zoom level:'", "Zoom:"), this); + m_zoomLabel = new KSqueezedTextLabel(i18nc("Used as a noun, i.e. 'Here is the zoom level:'", "Zoom:"), this); // Initialize zoom widget m_zoomSlider = new QSlider(Qt::Horizontal, this); @@ -113,7 +115,7 @@ DolphinStatusBar::DolphinStatusBar(QWidget *parent) m_progressBar->setMaximumWidth(fontMetrics.averageCharWidth() * 20); QHBoxLayout *topLayout = new QHBoxLayout(this); - topLayout->setContentsMargins(2, 0, 2, 0); + updateContentsMargins(); topLayout->setSpacing(4); topLayout->addWidget(m_label, 1); topLayout->addWidget(m_zoomLabel); @@ -280,6 +282,7 @@ void DolphinStatusBar::contextMenuEvent(QContextMenuEvent *event) GeneralSettings::setShowSpaceInfo(visible); m_spaceInfo->setVisible(visible); } + updateContentsMargins(); } void DolphinStatusBar::showZoomSliderToolTip(int zoomLevel) @@ -334,6 +337,26 @@ void DolphinStatusBar::setExtensionsVisible(bool visible) m_spaceInfo->setVisible(showSpaceInfo); m_zoomSlider->setVisible(showZoomSlider); m_zoomLabel->setVisible(showZoomSlider); + updateContentsMargins(); +} + +void DolphinStatusBar::updateContentsMargins() +{ + if (GeneralSettings::showSpaceInfo()) { + // We reduce the outside margin for the flat button so it visually has the same margin as the status bar text label on the other end of the bar. + layout()->setContentsMargins(6, 0, 2, 0); + } else { + layout()->setContentsMargins(6, 0, 6, 0); + } +} + +void DolphinStatusBar::paintEvent(QPaintEvent *paintEvent) +{ + Q_UNUSED(paintEvent) + QPainter p(this); + QStyleOption opt; + opt.initFrom(this); + style()->drawPrimitive(QStyle::PE_PanelStatusBar, &opt, &p, this); } #include "moc_dolphinstatusbar.cpp"