diff options
Diffstat (limited to 'src/selectionmode')
| -rw-r--r-- | src/selectionmode/actiontexthelper.cpp | 7 | ||||
| -rw-r--r-- | src/selectionmode/actiontexthelper.h | 16 | ||||
| -rw-r--r-- | src/selectionmode/actionwithwidget.cpp | 13 | ||||
| -rw-r--r-- | src/selectionmode/actionwithwidget.h | 9 | ||||
| -rw-r--r-- | src/selectionmode/backgroundcolorhelper.cpp | 14 | ||||
| -rw-r--r-- | src/selectionmode/bottombar.cpp | 20 | ||||
| -rw-r--r-- | src/selectionmode/bottombar.h | 2 | ||||
| -rw-r--r-- | src/selectionmode/bottombarcontentscontainer.cpp | 67 | ||||
| -rw-r--r-- | src/selectionmode/bottombarcontentscontainer.h | 3 | ||||
| -rw-r--r-- | src/selectionmode/singleclickselectionproxystyle.h | 4 | ||||
| -rw-r--r-- | src/selectionmode/topbar.cpp | 35 |
11 files changed, 110 insertions, 80 deletions
diff --git a/src/selectionmode/actiontexthelper.cpp b/src/selectionmode/actiontexthelper.cpp index 103604236..28a247185 100644 --- a/src/selectionmode/actiontexthelper.cpp +++ b/src/selectionmode/actiontexthelper.cpp @@ -9,9 +9,10 @@ using namespace SelectionMode; -ActionTextHelper::ActionTextHelper(QObject *parent) : - QObject(parent) -{ } +ActionTextHelper::ActionTextHelper(QObject *parent) + : QObject(parent) +{ +} void ActionTextHelper::registerTextWhenNothingIsSelected(QAction *action, QString registeredText) { diff --git a/src/selectionmode/actiontexthelper.h b/src/selectionmode/actiontexthelper.h index 1b8840375..6ca99990f 100644 --- a/src/selectionmode/actiontexthelper.h +++ b/src/selectionmode/actiontexthelper.h @@ -42,10 +42,7 @@ public: void textsWhenNothingIsSelectedEnabled(bool enabled); private: - enum TextState { - TextWhenNothingIsSelected, - TextWhenSomethingIsSelected - }; + enum TextState { TextWhenNothingIsSelected, TextWhenSomethingIsSelected }; /** * Utility struct to allow switching back and forth between registered actions showing their @@ -53,16 +50,15 @@ private: * An example is "Copy" or "Copy…". The latter one is used when nothing is selected and signifies * that it will trigger SelectionMode so items can be selected and then copied. */ - struct RegisteredActionTextChange { + struct RegisteredActionTextChange { QPointer<QAction> action; QString registeredText; TextState textStateOfRegisteredText; - RegisteredActionTextChange(QAction *action, QString registeredText, TextState state) : - action{action}, - registeredText{registeredText}, - textStateOfRegisteredText{state} - { }; + RegisteredActionTextChange(QAction *action, QString registeredText, TextState state) + : action{action} + , registeredText{registeredText} + , textStateOfRegisteredText{state} {}; }; /** diff --git a/src/selectionmode/actionwithwidget.cpp b/src/selectionmode/actionwithwidget.cpp index 82ce045db..1284912b6 100644 --- a/src/selectionmode/actionwithwidget.cpp +++ b/src/selectionmode/actionwithwidget.cpp @@ -14,13 +14,14 @@ using namespace SelectionMode; -ActionWithWidget::ActionWithWidget(QAction *action) : - m_action{action} -{ } +ActionWithWidget::ActionWithWidget(QAction *action) + : m_action{action} +{ +} -ActionWithWidget::ActionWithWidget(QAction *action, QAbstractButton *button) : - m_action{action}, - m_widget{button} +ActionWithWidget::ActionWithWidget(QAction *action, QAbstractButton *button) + : m_action{action} + , m_widget{button} { copyActionDataToButton(button, action); } diff --git a/src/selectionmode/actionwithwidget.h b/src/selectionmode/actionwithwidget.h index 14db6df22..9b83022de 100644 --- a/src/selectionmode/actionwithwidget.h +++ b/src/selectionmode/actionwithwidget.h @@ -42,13 +42,15 @@ public: ActionWithWidget(QAction *action, QAbstractButton *button); /** @returns the action of this object. */ - inline QAction *action() { + inline QAction *action() + { Q_CHECK_PTR(m_action); return m_action; }; /** @returns the widget of this object. */ - inline QWidget *widget() { + inline QWidget *widget() + { return m_widget; } @@ -61,7 +63,8 @@ public: QWidget *newWidget(QWidget *parent); /** returns true if the widget exists and is visible. false otherwise. */ - inline bool isWidgetVisible() const { + inline bool isWidgetVisible() const + { return m_widget && m_widget->isVisible(); }; diff --git a/src/selectionmode/backgroundcolorhelper.cpp b/src/selectionmode/backgroundcolorhelper.cpp index 799db43d5..1615c36bb 100644 --- a/src/selectionmode/backgroundcolorhelper.cpp +++ b/src/selectionmode/backgroundcolorhelper.cpp @@ -23,11 +23,10 @@ BackgroundColorHelper *BackgroundColorHelper::instance() return s_instance; } - void setBackgroundColorForWidget(QWidget *widget, QColor color) { QPalette palette; - palette.setBrush(QPalette::Active, QPalette::Window, color); + palette.setBrush(QPalette::Active, QPalette::Window, color); palette.setBrush(QPalette::Inactive, QPalette::Window, color); palette.setBrush(QPalette::Disabled, QPalette::Window, color); widget->setAutoFillBackground(true); @@ -38,7 +37,8 @@ void BackgroundColorHelper::controlBackgroundColor(QWidget *widget) { setBackgroundColorForWidget(widget, m_backgroundColor); - Q_ASSERT_X(std::find(m_colorControlledWidgets.begin(), m_colorControlledWidgets.end(), widget) == m_colorControlledWidgets.end(), "controlBackgroundColor", + Q_ASSERT_X(std::find(m_colorControlledWidgets.begin(), m_colorControlledWidgets.end(), widget) == m_colorControlledWidgets.end(), + "controlBackgroundColor", "Duplicate insertion is not necessary because the background color should already automatically update itself on paletteChanged"); m_colorControlledWidgets.emplace_back(widget); } @@ -46,7 +46,9 @@ void BackgroundColorHelper::controlBackgroundColor(QWidget *widget) BackgroundColorHelper::BackgroundColorHelper() { updateBackgroundColor(); - QObject::connect(qApp, &QGuiApplication::paletteChanged, [=](){ slotPaletteChanged(); }); + QObject::connect(qApp, &QGuiApplication::paletteChanged, [=]() { + slotPaletteChanged(); + }); } void BackgroundColorHelper::slotPaletteChanged() @@ -77,9 +79,7 @@ void BackgroundColorHelper::updateBackgroundColor() if (std::abs(hueDifference) > 80) { newHue = (activeBackgroundColor.hue() + positiveBackgroundColor.hue()) / 2; } else { - newHue = hueDifference > 0 ? - activeBackgroundColor.hue() + 40 : - activeBackgroundColor.hue() - 40; + newHue = hueDifference > 0 ? activeBackgroundColor.hue() + 40 : activeBackgroundColor.hue() - 40; newHue %= 360; // hue needs to be between 0 and 359 per Qt documentation. } diff --git a/src/selectionmode/bottombar.cpp b/src/selectionmode/bottombar.cpp index c912dd489..f39431076 100644 --- a/src/selectionmode/bottombar.cpp +++ b/src/selectionmode/bottombar.cpp @@ -7,8 +7,8 @@ #include "bottombar.h" -#include "bottombarcontentscontainer.h" #include "backgroundcolorhelper.h" +#include "bottombarcontentscontainer.h" #include <QGridLayout> #include <QResizeEvent> @@ -18,8 +18,8 @@ using namespace SelectionMode; -BottomBar::BottomBar(KActionCollection *actionCollection, QWidget *parent) : - QWidget{parent} +BottomBar::BottomBar(KActionCollection *actionCollection, QWidget *parent) + : QWidget{parent} { // Showing of this widget is normally animated. We hide it for now and make it small. hide(); @@ -44,7 +44,7 @@ BottomBar::BottomBar(KActionCollection *actionCollection, QWidget *parent) : m_scrollArea->setWidget(m_contentsContainer); m_contentsContainer->installEventFilter(this); // Adjusts the height of this bar to the height of the contentsContainer connect(m_contentsContainer, &BottomBarContentsContainer::error, this, &BottomBar::error); - connect(m_contentsContainer, &BottomBarContentsContainer::barVisibilityChangeRequested, this, [this](bool visible){ + connect(m_contentsContainer, &BottomBarContentsContainer::barVisibilityChangeRequested, this, [this](bool visible) { if (!m_allowedToBeVisible && visible) { return; } @@ -77,20 +77,18 @@ void BottomBar::setVisibleInternal(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); if (visible) { show(); m_heightAnimation->setEndValue(sizeHint().height()); - connect(m_heightAnimation, &QAbstractAnimation::finished, - this, [this](){ setMaximumHeight(sizeHint().height()); }); + connect(m_heightAnimation, &QAbstractAnimation::finished, this, [this]() { + setMaximumHeight(sizeHint().height()); + }); } 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); diff --git a/src/selectionmode/bottombar.h b/src/selectionmode/bottombar.h index 2ee05f39c..3ad361ef6 100644 --- a/src/selectionmode/bottombar.h +++ b/src/selectionmode/bottombar.h @@ -24,7 +24,7 @@ class QUrl; namespace SelectionMode { - class BottomBarContentsContainer; +class BottomBarContentsContainer; /** * @brief A bar used in selection mode that serves various purposes depending on what the user is currently trying to do. diff --git a/src/selectionmode/bottombarcontentscontainer.cpp b/src/selectionmode/bottombarcontentscontainer.cpp index 522afcd01..4619bcae0 100644 --- a/src/selectionmode/bottombarcontentscontainer.cpp +++ b/src/selectionmode/bottombarcontentscontainer.cpp @@ -25,9 +25,9 @@ using namespace SelectionMode; -BottomBarContentsContainer::BottomBarContentsContainer(KActionCollection *actionCollection, QWidget *parent) : - QWidget{parent}, - m_actionCollection{actionCollection} +BottomBarContentsContainer::BottomBarContentsContainer(KActionCollection *actionCollection, QWidget *parent) + : QWidget{parent} + , m_actionCollection{actionCollection} { // We will mostly interact with m_layout when changing the contents and not care about the other internal hierarchy. m_layout = new QHBoxLayout(this); @@ -38,7 +38,9 @@ void BottomBarContentsContainer::resetContents(BottomBar::Contents contents) emptyBarContents(); // A label is added in many of the methods below. We only know its size a bit later and if it should be hidden. - QTimer::singleShot(10, this, [this](){ updateExplanatoryLabelVisibility(); }); + QTimer::singleShot(10, this, [this]() { + updateExplanatoryLabelVisibility(); + }); Q_CHECK_PTR(m_actionCollection); m_contents = contents; @@ -155,8 +157,10 @@ void BottomBarContentsContainer::addCopyContents() m_explanatoryLabel->setWordWrap(true); m_layout->addWidget(m_explanatoryLabel); + // clang-format off // i18n: Aborts the current step-by-step process to copy files by leaving the selection mode. auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Copying"), this); + // clang-format on connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); @@ -188,8 +192,10 @@ void BottomBarContentsContainer::addCopyLocationContents() m_explanatoryLabel->setWordWrap(true); m_layout->addWidget(m_explanatoryLabel); + // clang-format off // i18n: Aborts the current step-by-step process to copy the location of files by leaving the selection mode. auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Copying"), this); + // clang-format on connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); @@ -201,14 +207,18 @@ void BottomBarContentsContainer::addCopyLocationContents() void BottomBarContentsContainer::addCopyToOtherViewContents() { + // clang-format off // i18n: "Copy over" refers to copying to the other split view area that is currently visible to the user. m_explanatoryLabel = new QLabel(i18nc("@info explaining the next step in a process", "Select the files and folders that should be copied over."), this); + // clang-format on m_explanatoryLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); m_explanatoryLabel->setWordWrap(true); m_layout->addWidget(m_explanatoryLabel); + // clang-format off // i18n: Aborts the current step-by-step process to copy the location of files by leaving the selection mode. auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Copying"), this); + // clang-format on connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); @@ -225,8 +235,10 @@ void BottomBarContentsContainer::addCutContents() m_explanatoryLabel->setWordWrap(true); m_layout->addWidget(m_explanatoryLabel); + // clang-format off // i18n: Aborts the current step-by-step process to cut files by leaving the selection mode. auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Cutting"), this); + // clang-format on connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); @@ -240,7 +252,7 @@ void BottomBarContentsContainer::addCutContents() // Connect the cut action as a second step. m_mainAction = ActionWithWidget(m_actionCollection->action(KStandardAction::name(KStandardAction::Cut)), cutButton); // Finally connect the lambda that actually changes the contents to the PasteContents. - connect(cutButton, &QAbstractButton::clicked, [this](){ + connect(cutButton, &QAbstractButton::clicked, [this]() { if (GeneralSettings::showPasteBarAfterCopying()) { resetContents(BottomBar::Contents::PasteContents); // resetContents() needs to be connected last because // it instantly deletes the button and then the other slots won't be called. @@ -253,13 +265,16 @@ void BottomBarContentsContainer::addCutContents() void BottomBarContentsContainer::addDeleteContents() { - m_explanatoryLabel = new QLabel(i18nc("@info explaining the next step in a process", "Select the files and folders that should be permanently deleted."), this); + m_explanatoryLabel = + new QLabel(i18nc("@info explaining the next step in a process", "Select the files and folders that should be permanently deleted."), this); m_explanatoryLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); m_explanatoryLabel->setWordWrap(true); m_layout->addWidget(m_explanatoryLabel); + // clang-format off // i18n: Aborts the current step-by-step process to delete files by leaving the selection mode. auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel"), this); + // clang-format on connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); @@ -276,8 +291,10 @@ void BottomBarContentsContainer::addDuplicateContents() m_explanatoryLabel->setWordWrap(true); m_layout->addWidget(m_explanatoryLabel); + // clang-format off // i18n: Aborts the current step-by-step process to duplicate files by leaving the selection mode. auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Duplicating"), this); + // clang-format on connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); @@ -290,9 +307,11 @@ void BottomBarContentsContainer::addDuplicateContents() void BottomBarContentsContainer::addGeneralContents() { if (!m_overflowButton) { + // clang-format off // i18n: This button appears in a bar if there isn't enough horizontal space to fit all the other buttons so please keep it short. // The small button opens a menu that contains the actions that didn't fit on the bar. m_overflowButton = new QPushButton{QIcon::fromTheme(QStringLiteral("view-more-symbolic")), i18nc("@action keep short", "More"), this}; + // clang-format on m_overflowButton->setMenu(new QMenu{m_overflowButton}); m_overflowButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding); // Makes sure it has the same height as the labeled buttons. m_layout->addWidget(m_overflowButton); @@ -335,14 +354,18 @@ void BottomBarContentsContainer::addGeneralContents() void BottomBarContentsContainer::addMoveToOtherViewContents() { + // clang-format off // i18n: "Move over" refers to moving to the other split view area that is currently visible to the user. m_explanatoryLabel = new QLabel(i18nc("@info explaining the next step in a process", "Select the files and folders that should be moved over."), this); + // clang-format on m_explanatoryLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); m_explanatoryLabel->setWordWrap(true); m_layout->addWidget(m_explanatoryLabel); + // clang-format off // i18n: Aborts the current step-by-step process to copy the location of files by leaving the selection mode. auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Moving"), this); + // clang-format on connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); @@ -354,13 +377,16 @@ void BottomBarContentsContainer::addMoveToOtherViewContents() void BottomBarContentsContainer::addMoveToTrashContents() { - m_explanatoryLabel = new QLabel(i18nc("@info explaining the next step in a process", "Select the files and folders that should be moved to the Trash."), this); + m_explanatoryLabel = + new QLabel(i18nc("@info explaining the next step in a process", "Select the files and folders that should be moved to the Trash."), this); m_explanatoryLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); m_explanatoryLabel->setWordWrap(true); m_layout->addWidget(m_explanatoryLabel); + // clang-format off // i18n: Aborts the current step-by-step process of moving files to the trash by leaving the selection mode. auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel"), this); + // clang-format on connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); @@ -373,9 +399,10 @@ void BottomBarContentsContainer::addMoveToTrashContents() void BottomBarContentsContainer::addPasteContents() { m_explanatoryLabel = new QLabel(xi18n("<para>The selected files and folders were added to the Clipboard. " - "Now the <emphasis>Paste</emphasis> action can be used to transfer them from the Clipboard " - "to any other location. They can even be transferred to other applications by using their " - "respective <emphasis>Paste</emphasis> actions.</para>"), this); + "Now the <emphasis>Paste</emphasis> action can be used to transfer them from the Clipboard " + "to any other location. They can even be transferred to other applications by using their " + "respective <emphasis>Paste</emphasis> actions.</para>"), + this); m_explanatoryLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); m_explanatoryLabel->setWordWrap(true); m_layout->addWidget(m_explanatoryLabel); @@ -415,13 +442,17 @@ void BottomBarContentsContainer::addPasteContents() void BottomBarContentsContainer::addRenameContents() { - m_explanatoryLabel = new QLabel(i18nc("@info explains the next step in a process", "Select the file or folder that should be renamed.\nBulk renaming is possible when multiple items are selected."), this); + m_explanatoryLabel = new QLabel(i18nc("@info explains the next step in a process", + "Select the file or folder that should be renamed.\nBulk renaming is possible when multiple items are selected."), + this); m_explanatoryLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); m_explanatoryLabel->setWordWrap(true); m_layout->addWidget(m_explanatoryLabel); + // clang-format off // i18n: Aborts the current step-by-step process to delete files by leaving the selection mode. auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Renaming"), this); + // clang-format on connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); @@ -439,15 +470,15 @@ void BottomBarContentsContainer::emptyBarContents() QLayoutItem *grandChild; while ((grandChild = childLayout->takeAt(0)) != nullptr) { delete grandChild->widget(); // delete the widget - delete grandChild; // delete the layout item + delete grandChild; // delete the layout item } } delete child->widget(); // delete the widget - delete child; // delete the layout item + delete child; // delete the layout item } } -std::vector<QAction *> BottomBarContentsContainer::contextActionsFor(const KFileItemList& selectedItems, const QUrl& baseUrl) +std::vector<QAction *> BottomBarContentsContainer::contextActionsFor(const KFileItemList &selectedItems, const QUrl &baseUrl) { if (selectedItems.isEmpty()) { // There are no contextual actions to show for these items. @@ -483,7 +514,8 @@ std::vector<QAction *> BottomBarContentsContainer::contextActionsFor(const KFile // KHamburgerMenu would only be visible if there is no menu available anywhere on the user interface. This might be useful for recovery from // such a situation in theory but a bar with context dependent actions doesn't really seem like the right place for it. - Q_ASSERT(internalContextMenuActions.first()->icon().name() == m_actionCollection->action(KStandardAction::name(KStandardAction::HamburgerMenu))->icon().name()); + Q_ASSERT(internalContextMenuActions.first()->icon().name() + == m_actionCollection->action(KStandardAction::name(KStandardAction::HamburgerMenu))->icon().name()); internalContextMenuActions.removeFirst(); for (auto it = internalContextMenuActions.constBegin(); it != internalContextMenuActions.constEnd(); ++it) { @@ -529,7 +561,7 @@ int BottomBarContentsContainer::unusedSpace() const sumOfPreferredWidths += m_layout->itemAt(i)->sizeHint().width() + m_layout->spacing(); } return m_barWidth - sumOfPreferredWidths - 20; // We consider all space used when there are only 20 pixels left - // so there is some room to breath and not too much wonkyness while resizing. + // so there is some room to breath and not too much wonkyness while resizing. } void BottomBarContentsContainer::updateExplanatoryLabelVisibility() @@ -544,7 +576,7 @@ void BottomBarContentsContainer::updateExplanatoryLabelVisibility() m_explanatoryLabel->setVisible(unusedSpace() > m_explanatoryLabel->sizeHint().width() + 20); } } - +// clang-format off void BottomBarContentsContainer::updateMainActionButton(const KFileItemList& selectedItems) { if (!m_mainAction.widget()) { @@ -627,3 +659,4 @@ void BottomBarContentsContainer::updateMainActionButton(const KFileItemList& sel updateExplanatoryLabelVisibility(); } } +// clang-format on diff --git a/src/selectionmode/bottombarcontentscontainer.h b/src/selectionmode/bottombarcontentscontainer.h index 6cb66fcc1..560220258 100644 --- a/src/selectionmode/bottombarcontentscontainer.h +++ b/src/selectionmode/bottombarcontentscontainer.h @@ -52,7 +52,8 @@ public: return m_contents; }; - inline bool hasSomethingToShow() { + inline bool hasSomethingToShow() + { return contents() != BottomBar::GeneralContents || m_internalContextMenu; } diff --git a/src/selectionmode/singleclickselectionproxystyle.h b/src/selectionmode/singleclickselectionproxystyle.h index ece46cce6..a0c1585d5 100644 --- a/src/selectionmode/singleclickselectionproxystyle.h +++ b/src/selectionmode/singleclickselectionproxystyle.h @@ -21,8 +21,8 @@ namespace SelectionMode class SingleClickSelectionProxyStyle : public QProxyStyle { public: - inline int styleHint(StyleHint hint, const QStyleOption *option = nullptr, - const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override + inline int + styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override { if (hint == QStyle::SH_ItemView_ActivateItemOnSingleClick) { return 0; diff --git a/src/selectionmode/topbar.cpp b/src/selectionmode/topbar.cpp index b2934a4d7..1981be411 100644 --- a/src/selectionmode/topbar.cpp +++ b/src/selectionmode/topbar.cpp @@ -21,19 +21,20 @@ 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", "<title>Selection Mode</title><para>Select files or folders to manage or manipulate them." - "<list><item>Press on a file or folder to select it.</item><item>Press on an already selected file or folder to deselect it.</item>" - "<item>Pressing an empty area does <emphasis>not</emphasis> clear the selection.</item>" - "<item>Selection rectangles (created by dragging from an empty area) invert the selection status of items within.</item></list></para>" - "<para>The available action buttons at the bottom change depending on the current selection.</para>")); + setWhatsThis(xi18nc("@info:whatsthis", + "<title>Selection Mode</title><para>Select files or folders to manage or manipulate them." + "<list><item>Press on a file or folder to select it.</item><item>Press on an already selected file or folder to deselect it.</item>" + "<item>Pressing an empty area does <emphasis>not</emphasis> clear the selection.</item>" + "<item>Selection rectangles (created by dragging from an empty area) invert the selection status of items within.</item></list></para>" + "<para>The available action buttons at the bottom change depending on the current selection.</para>")); auto fillParentLayout = new QGridLayout(this); fillParentLayout->setContentsMargins(0, 0, 0, 0); @@ -54,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); @@ -65,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::clicked, - this, &TopBar::selectionModeLeavingRequested); + connect(m_closeButton, &QAbstractButton::clicked, this, &TopBar::selectionModeLeavingRequested); QHBoxLayout *layout = new QHBoxLayout(contentsContainer); auto contentsMargins = layout->contentsMargins(); @@ -89,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); @@ -100,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); @@ -116,7 +111,9 @@ 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); |
