]> cloud.milkyroute.net Git - dolphin.git/blob - src/selectionmode/topbar.h
Always focus the view after place activation
[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 "animatedheightwidget.h"
12
13 class QLabel;
14 class QPushButton;
15 class QResizeEvent;
16
17 namespace SelectionMode
18 {
19
20 /**
21 * @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.
22 */
23 class TopBar : public AnimatedHeightWidget
24 {
25 Q_OBJECT
26
27 public:
28 TopBar(QWidget *parent);
29
30 Q_SIGNALS:
31 void selectionModeLeavingRequested();
32
33 protected:
34 /** Calls updateLabelString() */
35 void resizeEvent(QResizeEvent *resizeEvent) override;
36
37 private:
38 /** Decides whether the m_fullLabelString or m_shortLabelString should be used based on available width. */
39 void updateLabelString();
40
41 /** @see AnimatedHeightWidget::preferredHeight() */
42 inline int preferredHeight() const override
43 {
44 return m_preferredHeight;
45 };
46
47 private:
48 QLabel *m_label;
49 QPushButton *m_closeButton;
50
51 /** @see updateLabelString() */
52 QString m_fullLabelString;
53 /** @see updateLabelString() */
54 QString m_shortLabelString;
55
56 int m_preferredHeight;
57 };
58
59 }
60
61 #endif // SELECTIONMODETOPBAR_H