┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/selectionmode/topbar.h
diff options
context:
space:
mode:
authorFelix Ernst <[email protected]>2022-04-24 13:18:30 +0200
committerFelix Ernst <[email protected]>2022-08-14 14:42:40 +0000
commit8e55f2c2409fd6ca9ebc66a6568f4d3bcbef7576 (patch)
treeabc2aa68ceb8f79addf0f74615e91efa08a44172 /src/selectionmode/topbar.h
parent402b4a5698f3d12d1848b298c38828d509abfd0d (diff)
Better separation of classes
Make obvious when actions trigger selection mode.
Diffstat (limited to 'src/selectionmode/topbar.h')
-rw-r--r--src/selectionmode/topbar.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/selectionmode/topbar.h b/src/selectionmode/topbar.h
new file mode 100644
index 000000000..e0cd34935
--- /dev/null
+++ b/src/selectionmode/topbar.h
@@ -0,0 +1,71 @@
+/*
+ This file is part of the KDE project
+ SPDX-FileCopyrightText: 2022 Felix Ernst <[email protected]>
+
+ 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 <QPointer>
+#include <QPropertyAnimation>
+#include <QStyle>
+#include <QWidget>
+
+class QHideEvent;
+class QLabel;
+class QPushButton;
+class QResizeEvent;
+class QShowEvent;
+
+namespace SelectionMode
+{
+
+/**
+ * @brief A bar appearing at the top of the view when in selection mode to make users aware of the selection mode state of the application.
+ */
+class TopBar : public QWidget
+{
+ Q_OBJECT
+
+public:
+ TopBar(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<QPropertyAnimation> m_heightAnimation;
+};
+
+}
+
+#endif // SELECTIONMODETOPBAR_H