]> cloud.milkyroute.net Git - dolphin.git/blob - src/selectionmode/topbar.h
Merge branch 'master' into kf6
[dolphin.git] / src / selectionmode / topbar.h
1 /*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2022 Felix Ernst <felixernst@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7
8 #ifndef SELECTIONMODETOPBAR_H
9 #define SELECTIONMODETOPBAR_H
10
11 #include "global.h"
12
13 #include <QPointer>
14 #include <QPropertyAnimation>
15 #include <QWidget>
16
17 class QHideEvent;
18 class QLabel;
19 class QPushButton;
20 class QResizeEvent;
21 class QShowEvent;
22
23 namespace SelectionMode
24 {
25
26 /**
27 * @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.
28 */
29 class TopBar : public QWidget
30 {
31 Q_OBJECT
32
33 public:
34 TopBar(QWidget *parent);
35
36 /**
37 * Plays a show or hide animation while changing visibility.
38 * Therefore, if this method is used to hide this widget, the actual hiding will be postponed until the animation finished.
39 * @see QWidget::setVisible()
40 */
41 void setVisible(bool visible, Animated animated);
42
43 Q_SIGNALS:
44 void selectionModeLeavingRequested();
45
46 protected:
47 /** Calls updateLabelString() */
48 void resizeEvent(QResizeEvent *resizeEvent) override;
49
50 private:
51 using QWidget::setVisible; // Makes sure that the setVisible() declaration above doesn't hide the one from QWidget so we can still use it privately.
52
53 /** Decides whether the m_fullLabelString or m_shortLabelString should be used based on available width. */
54 void updateLabelString();
55
56 private:
57 QLabel *m_label;
58 QPushButton *m_closeButton;
59
60 /** @see updateLabelString() */
61 QString m_fullLabelString;
62 /** @see updateLabelString() */
63 QString m_shortLabelString;
64
65 int m_preferredHeight;
66
67 QPointer<QPropertyAnimation> m_heightAnimation;
68 };
69
70 }
71
72 #endif // SELECTIONMODETOPBAR_H