┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/statusbar/dolphinstatusbar.cpp
diff options
context:
space:
mode:
authorFelix Ernst <[email protected]>2023-11-18 12:31:00 +0100
committerFelix Ernst <[email protected]>2023-11-24 11:52:54 +0000
commitd3637f380ccca26a281331a02ce76ed60e84cfe3 (patch)
tree82f998010a89bb37bd6fbb88695c284666f85484 /src/statusbar/dolphinstatusbar.cpp
parente8fcef32b25b847e997df3a8232eb20980989794 (diff)
Turn free space label into a flat button
The usage of a label to show this space information is problematic because there are features/actions hidden behind clicking the label. A button makes this clear. It also fixes the accessibility of this control because previously this info would never be read out by screen readers as it couldn't get keyboard focus. A side-effect of this change is that the free disk space bar looks more normal with non-Breeze styles. This had been a long-standing issue.
Diffstat (limited to 'src/statusbar/dolphinstatusbar.cpp')
-rw-r--r--src/statusbar/dolphinstatusbar.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/statusbar/dolphinstatusbar.cpp b/src/statusbar/dolphinstatusbar.cpp
index 9451566fd..9bc6210dc 100644
--- a/src/statusbar/dolphinstatusbar.cpp
+++ b/src/statusbar/dolphinstatusbar.cpp
@@ -46,8 +46,6 @@ DolphinStatusBar::DolphinStatusBar(QWidget *parent)
, m_delayUpdateTimer(nullptr)
, m_textTimestamp()
{
- setContentsMargins(4, 0, 4, 0);
-
// Initialize text label
m_label = new KSqueezedTextLabel(m_text, this);
m_label->setWordWrap(true);
@@ -117,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);
@@ -284,6 +282,7 @@ void DolphinStatusBar::contextMenuEvent(QContextMenuEvent *event)
GeneralSettings::setShowSpaceInfo(visible);
m_spaceInfo->setVisible(visible);
}
+ updateContentsMargins();
}
void DolphinStatusBar::showZoomSliderToolTip(int zoomLevel)
@@ -338,10 +337,22 @@ 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);