From 3b7c05b385dc56fbc0b9ffdd332f8d30e7624d0c Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Sun, 12 Sep 2021 15:33:39 +0200 Subject: Add Selection Mode The selection mode action is a checkable toggle action named "Select Files and Folders" which has "Space" as the default shortcut. In selection mode a bottom bar with contextual actions is shown. These should mostly mirror the actions which are available through the right-click context menu aka DolphinContextMenu. Resizing of the window might make a overflow button appear in the bottom selection mode bar. This commit makes press and hold in the view activate selection mode. This behaviour is not triggered if the press and hold is used to either start a rubberband selection or a drag operation within a short time. The length of the short timeframe is defined by a QStyleHint. This is currently not implemented in touch because I can't test it. Mix the selection mode bars' background colors using a nice combination of colors from the current color scheme BUG: 427202 --- src/selectionmode/selectionmodetopbar.h | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/selectionmode/selectionmodetopbar.h (limited to 'src/selectionmode/selectionmodetopbar.h') diff --git a/src/selectionmode/selectionmodetopbar.h b/src/selectionmode/selectionmodetopbar.h new file mode 100644 index 000000000..fa829aef5 --- /dev/null +++ b/src/selectionmode/selectionmodetopbar.h @@ -0,0 +1,66 @@ +/* + This file is part of the KDE project + SPDX-FileCopyrightText: 2022 Felix Ernst + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#ifndef SELECTIONMODETOPBAR_H +#define SELECTIONMODETOPBAR_H + +#include "global.h" + +#include +#include +#include +#include + +class QHideEvent; +class QLabel; +class QPushButton; +class QResizeEvent; +class QShowEvent; + +/** + * @todo write docs + */ +class SelectionModeTopBar : public QWidget +{ + Q_OBJECT + +public: + SelectionModeTopBar(QWidget *parent); + + /** + * Plays a show or hide animation while changing visibility. + * Therefore, if this method is used to hide this widget, the actual hiding will be postponed until the animation finished. + * @see QWidget::setVisible() + */ + void setVisible(bool visible, Animated animated); + using QWidget::setVisible; // Makes sure that the setVisible() declaration above doesn't hide the one from QWidget. + +Q_SIGNALS: + void leaveSelectionModeRequested(); + +protected: + void resizeEvent(QResizeEvent */* resizeEvent */) override; + +private: + /** Decides whether the m_fullLabelString or m_shortLabelString should be used based on available width. */ + void updateLabelString(); + +private: + QLabel *m_label; + QPushButton *m_closeButton; + + /** @see updateLabelString() */ + QString m_fullLabelString; + /** @see updateLabelString() */ + QString m_shortLabelString; + + int m_preferredHeight; + + QPointer m_heightAnimation; +}; + +#endif // SELECTIONMODETOPBAR_H -- cgit v1.3