X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/261b741d5feb356c1fa8a8ac42397f53eb13ca75..f510339f033658eae27f8400bf042b78b36f82f2:/src/selectionmode/topbar.cpp diff --git a/src/selectionmode/topbar.cpp b/src/selectionmode/topbar.cpp index 5d218dd99..abe9f74a5 100644 --- a/src/selectionmode/topbar.cpp +++ b/src/selectionmode/topbar.cpp @@ -1,6 +1,6 @@ /* This file is part of the KDE project - SPDX-FileCopyrightText: 2022 Felix Ernst + SPDX-FileCopyrightText: 2022 Felix Ernst SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ @@ -15,28 +15,26 @@ #include #include -#include -#include #include #include #include -#include using namespace SelectionMode; -TopBar::TopBar(QWidget *parent) : - QWidget{parent} +TopBar::TopBar(QWidget *parent) + : QWidget{parent} { // Showing of this widget is normally animated. We hide it for now and make it small. hide(); setMaximumHeight(0); setToolTip(KToolTipHelper::whatsThisHintOnly()); - setWhatsThis(xi18nc("@info:whatsthis", "Selection ModeSelect files or folders to manage or manipulate them." - "Press on a file or folder to select it.Press on an already selected file or folder to deselect it." - "Pressing an empty area does not clear the selection." - "Selection rectangles (created by dragging from an empty area) invert the selection status of items within." - "The available action buttons at the bottom change depending on the current selection.")); + setWhatsThis(xi18nc("@info:whatsthis", + "Selection ModeSelect files or folders to manage or manipulate them." + "Press on a file or folder to select it.Press on an already selected file or folder to deselect it." + "Pressing an empty area does not clear the selection." + "Selection rectangles (created by dragging from an empty area) invert the selection status of items within." + "The available action buttons at the bottom change depending on the current selection.")); auto fillParentLayout = new QGridLayout(this); fillParentLayout->setContentsMargins(0, 0, 0, 0); @@ -57,10 +55,8 @@ TopBar::TopBar(QWidget *parent) : setMinimumWidth(0); - m_fullLabelString = i18nc("@info label above the view explaining the state", - "Selection Mode: Click on files or folders to select or deselect them."); - m_shortLabelString = i18nc("@info label above the view explaining the state", - "Selection Mode"); + m_fullLabelString = i18nc("@info label above the view explaining the state", "Selection Mode: Click on files or folders to select or deselect them."); + m_shortLabelString = i18nc("@info label above the view explaining the state", "Selection Mode"); m_label = new QLabel(contentsContainer); m_label->setMinimumWidth(0); BackgroundColorHelper::instance()->controlBackgroundColor(m_label); @@ -68,8 +64,7 @@ TopBar::TopBar(QWidget *parent) : m_closeButton = new QPushButton(QIcon::fromTheme(QStringLiteral("window-close-symbolic")), "", contentsContainer); m_closeButton->setText(i18nc("@action:button", "Exit Selection Mode")); m_closeButton->setFlat(true); - connect(m_closeButton, &QAbstractButton::pressed, - this, &TopBar::selectionModeLeavingRequested); + connect(m_closeButton, &QAbstractButton::clicked, this, &TopBar::selectionModeLeavingRequested); QHBoxLayout *layout = new QHBoxLayout(contentsContainer); auto contentsMargins = layout->contentsMargins(); @@ -92,9 +87,7 @@ void TopBar::setVisible(bool visible, Animated animated) m_heightAnimation->stop(); // deletes because of QAbstractAnimation::DeleteWhenStopped. } m_heightAnimation = new QPropertyAnimation(this, "maximumHeight"); - m_heightAnimation->setDuration(2 * - style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this) * - GlobalConfig::animationDurationFactor()); + m_heightAnimation->setDuration(2 * style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this) * GlobalConfig::animationDurationFactor()); m_heightAnimation->setStartValue(height()); m_heightAnimation->setEasingCurve(QEasingCurve::OutCubic); @@ -103,8 +96,7 @@ void TopBar::setVisible(bool visible, Animated animated) m_heightAnimation->setEndValue(m_preferredHeight); } else { m_heightAnimation->setEndValue(0); - connect(m_heightAnimation, &QAbstractAnimation::finished, - this, &QWidget::hide); + connect(m_heightAnimation, &QAbstractAnimation::finished, this, &QWidget::hide); } m_heightAnimation->start(QAbstractAnimation::DeleteWhenStopped); @@ -119,9 +111,13 @@ void TopBar::resizeEvent(QResizeEvent *resizeEvent) void TopBar::updateLabelString() { QFontMetrics fontMetrics = m_label->fontMetrics(); - if (fontMetrics.horizontalAdvance(m_fullLabelString) + m_closeButton->sizeHint().width() + style()->pixelMetric(QStyle::PM_LayoutLeftMargin) * 2 + style()->pixelMetric(QStyle::PM_LayoutRightMargin) * 2 < width()) { + if (fontMetrics.horizontalAdvance(m_fullLabelString) + m_closeButton->sizeHint().width() + style()->pixelMetric(QStyle::PM_LayoutLeftMargin) * 2 + + style()->pixelMetric(QStyle::PM_LayoutRightMargin) * 2 + < width()) { m_label->setText(m_fullLabelString); } else { m_label->setText(m_shortLabelString); } } + +#include "moc_topbar.cpp"