]> cloud.milkyroute.net Git - dolphin.git/blob - src/admin/bar.h
5399fa66973b15dd93673d2dcda61c016c21027a
[dolphin.git] / src / admin / bar.h
1 /*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2024 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 ADMINBAR_H
9 #define ADMINBAR_H
10
11 #include "animatedheightwidget.h"
12
13 class QLabel;
14 class QPushButton;
15 class QResizeEvent;
16 class QToolButton;
17
18 namespace Admin
19 {
20
21 /**
22 * @brief A bar appearing above the view while the user is acting with administrative privileges.
23 *
24 * It contains a warning and allows revoking this administrative mode by closing this bar.
25 */
26 class Bar : public AnimatedHeightWidget
27 {
28 Q_OBJECT
29
30 public:
31 explicit Bar(QWidget *parent);
32
33 /** Used to recolor this bar when this application's color scheme changes. */
34 bool event(QEvent *event) override;
35
36 Q_SIGNALS:
37 void activated();
38
39 protected:
40 /** Calls updateLabelString() */
41 void resizeEvent(QResizeEvent *resizeEvent) override;
42
43 private:
44 /** Recolors this bar based on the current color scheme. */
45 void updateColors();
46
47 /** Decides whether the m_fullLabelString or m_shortLabelString should be used based on available width. */
48 void updateLabelString();
49
50 /** @see AnimatedHeightWidget::preferredHeight() */
51 inline int preferredHeight() const override
52 {
53 return m_preferredHeight;
54 };
55
56 private:
57 /** The text on this bar */
58 QLabel *m_label = nullptr;
59 /** Shows a warning about the dangers of acting with administrative privileges. */
60 QToolButton *m_warningButton = nullptr;
61 /** Closes this bar and exits the administrative mode. */
62 QPushButton *m_closeButton = nullptr;
63
64 /** @see updateLabelString() */
65 QString m_fullLabelString;
66 /** @see updateLabelString() */
67 QString m_shortLabelString;
68
69 /** @see preferredHeight() */
70 int m_preferredHeight;
71 };
72
73 }
74
75 #endif // ADMINBAR_H