1/*
2 * SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef ENUMS_H
8#define ENUMS_H
9
10#include <QObject>
11#include <QQmlEngine>
12
13namespace ApplicationHeaderStyle
14{
15Q_NAMESPACE
16QML_ELEMENT
17
18enum Status {
19 Auto = 0,
20 Breadcrumb,
21 Titles,
22 ToolBar, ///@since 5.48
23 None, ///@since 5.48
24};
25Q_ENUM_NS(Status)
26
27enum NavigationButton {
28 NoNavigationButtons = 0,
29 ShowBackButton = 0x1,
30 ShowForwardButton = 0x2,
31};
32Q_ENUM_NS(NavigationButton)
33Q_DECLARE_FLAGS(NavigationButtons, NavigationButton)
34}
35
36namespace MessageType
37{
38Q_NAMESPACE
39QML_ELEMENT
40
41enum Type {
42 Information = 0,
43 Positive,
44 Warning,
45 Error,
46};
47Q_ENUM_NS(Type)
48};
49
50class DisplayHint : public QObject
51{
52 Q_OBJECT
53 QML_ELEMENT
54 QML_SINGLETON
55
56public:
57 /**
58 * Hints for implementations using Actions indicating preferences about how to display the action.
59 */
60 enum Hint : uint {
61 /**
62 * Indicates there is no specific preference.
63 */
64 NoPreference = 0,
65 /**
66 * Only display an icon for this Action.
67 */
68 IconOnly = 1,
69 /**
70 * Try to keep the action visible even when space constrained.
71 * Mutually exclusive with AlwaysHide, KeepVisible has priority.
72 */
73 KeepVisible = 2,
74 /**
75 * If possible, hide the action in an overflow menu or similar location.
76 * Mutually exclusive with KeepVisible, KeepVisible has priority.
77 */
78 AlwaysHide = 4,
79 /**
80 * When this action has children, do not display any indicator (like a
81 * menu arrow) for this action.
82 */
83 HideChildIndicator = 8,
84 };
85 Q_DECLARE_FLAGS(DisplayHints, Hint)
86 Q_ENUM(Hint)
87 Q_FLAG(DisplayHints)
88
89 // Note: These functions are instance methods because they need to be
90 // exposed to QML. Unfortunately static methods are not supported.
91
92 /**
93 * Helper function to check if a certain display hint has been set.
94 *
95 * This function is mostly convenience to enforce certain behaviour of the
96 * various display hints, primarily the mutual exclusivity of KeepVisible
97 * and AlwaysHide.
98 *
99 * @param values The display hints to check.
100 * @param hint The display hint to check if it is set.
101 *
102 * @return true if the hint was set for this action, false if not.
103 *
104 * @since 2.14
105 */
106 Q_INVOKABLE bool displayHintSet(DisplayHints values, Hint hint);
107
108 /**
109 * Check if a certain display hint has been set on an object.
110 *
111 * This overloads @f displayHintSet(DisplayHints, Hint) to accept a QObject
112 * instance. This object is checked to see if it has a displayHint property
113 * and if so, if that property has @p hint set.
114 *
115 * @param object The object to check.
116 * @param hint The hint to check for.
117 *
118 * @return false if object is null, object has no displayHint property or
119 * the hint was not set. true if it has the property and the hint is
120 * set.
121 */
122 Q_INVOKABLE bool displayHintSet(QObject *object, Hint hint);
123
124 /**
125 * Static version of \f displayHintSet(DisplayHints, Hint) that can be
126 * called from C++ code.
127 */
128 static bool isDisplayHintSet(DisplayHints values, Hint hint);
129};
130
131Q_DECLARE_OPERATORS_FOR_FLAGS(DisplayHint::DisplayHints)
132
133#endif // ENUMS_H
134

source code of kirigami/src/enums.h