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