2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2024 Felix Ernst <felixernst@kde.org>
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
11 #include "animatedheightwidget.h"
13 class DolphinViewContainer
;
23 * @brief A bar appearing above the view while the user is acting with administrative privileges.
25 * It contains a warning and allows revoking this administrative mode by closing this bar.
27 class Bar
: public AnimatedHeightWidget
32 explicit Bar(DolphinViewContainer
*parentViewContainer
);
34 /** Used to recolor this bar when this application's color scheme changes. */
35 bool event(QEvent
*event
) override
;
38 /** Calls updateLabelString() */
39 void resizeEvent(QResizeEvent
*resizeEvent
) override
;
43 * Makes sure this admin bar hides itself when the elevated privileges expire so the user doesn't mistakenly assume that they are still acting with
44 * administrative rights. The view container is also changed to a non-admin url, so no password prompts will pop up unexpectedly.
45 * Then this method shows a message to the user to explain this.
46 * The mechanism of this method only fires once and will need to be called again the next time the user regains administrative rights for this view.
48 void hideTheNextTimeAuthorizationExpires();
50 /** Recolors this bar based on the current color scheme. */
53 /** Decides whether the m_fullLabelString or m_shortLabelString should be used based on available width. */
54 void updateLabelString();
56 /** @see AnimatedHeightWidget::preferredHeight() */
57 inline int preferredHeight() const override
59 return m_preferredHeight
;
63 /** The text on this bar */
64 QLabel
*m_label
= nullptr;
65 /** Shows a warning about the dangers of acting with administrative privileges. */
66 QToolButton
*m_warningButton
= nullptr;
67 /** Closes this bar and exits the administrative mode. */
68 QPushButton
*m_closeButton
= nullptr;
70 /** @see updateLabelString() */
71 QString m_fullLabelString
;
72 /** @see updateLabelString() */
73 QString m_shortLabelString
;
75 /** @see preferredHeight() */
76 int m_preferredHeight
;
79 * A proxy action for the real actAsAdminAction.
80 * This proxy action can be used to reenable admin mode for the view belonging to this bar object specifically.
82 QAction
*m_reenableActAsAdminAction
= nullptr;
85 * The parent of this bar. The bar acts on the DolphinViewContainer to exit the admin mode. This can happen in two ways:
86 * 1. The user closes the bar which implies exiting of the admin mode.
87 * 2. The admin authorization expires so all views can factually no longer be in admin mode.
89 DolphinViewContainer
*m_parentViewContainer
;