]> cloud.milkyroute.net Git - dolphin.git/blob - src/selectionmode/topbar.h
Better separation of classes
[dolphin.git] / src / selectionmode / topbar.h
1 /*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2022 Felix Ernst <felixernst@zohomail.eu>
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 <QStyle>
16 #include <QWidget>
17
18 class QHideEvent;
19 class QLabel;
20 class QPushButton;
21 class QResizeEvent;
22 class QShowEvent;
23
24 namespace SelectionMode
25 {
26
27 /**
28 * @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.
29 */
30 class TopBar : public QWidget
31 {
32 Q_OBJECT
33
34 public:
35 TopBar(QWidget *parent);
36
37 /**
38 * Plays a show or hide animation while changing visibility.
39 * Therefore, if this method is used to hide this widget, the actual hiding will be postponed until the animation finished.
40 * @see QWidget::setVisible()
41 */
42 void setVisible(bool visible, Animated animated);
43 using QWidget::setVisible; // Makes sure that the setVisible() declaration above doesn't hide the one from QWidget.
44
45 Q_SIGNALS:
46 void leaveSelectionModeRequested();
47
48 protected:
49 void resizeEvent(QResizeEvent */* resizeEvent */) override;
50
51 private:
52 /** Decides whether the m_fullLabelString or m_shortLabelString should be used based on available width. */
53 void updateLabelString();
54
55 private:
56 QLabel *m_label;
57 QPushButton *m_closeButton;
58
59 /** @see updateLabelString() */
60 QString m_fullLabelString;
61 /** @see updateLabelString() */
62 QString m_shortLabelString;
63
64 int m_preferredHeight;
65
66 QPointer<QPropertyAnimation> m_heightAnimation;
67 };
68
69 }
70
71 #endif // SELECTIONMODETOPBAR_H