File indexing completed on 2024-04-21 03:55:59
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef ENUMS_H 0008 #define ENUMS_H 0009 0010 #include <QObject> 0011 #include <QQmlEngine> 0012 0013 namespace ApplicationHeaderStyle 0014 { 0015 Q_NAMESPACE 0016 QML_ELEMENT 0017 0018 enum Status { 0019 Auto = 0, 0020 Breadcrumb, 0021 Titles, 0022 ToolBar, ///@since 5.48 0023 None, ///@since 5.48 0024 }; 0025 Q_ENUM_NS(Status) 0026 0027 enum NavigationButton { 0028 NoNavigationButtons = 0, 0029 ShowBackButton = 0x1, 0030 ShowForwardButton = 0x2, 0031 }; 0032 Q_ENUM_NS(NavigationButton) 0033 Q_DECLARE_FLAGS(NavigationButtons, NavigationButton) 0034 } 0035 0036 namespace MessageType 0037 { 0038 Q_NAMESPACE 0039 QML_ELEMENT 0040 0041 enum Type { 0042 Information = 0, 0043 Positive, 0044 Warning, 0045 Error, 0046 }; 0047 Q_ENUM_NS(Type) 0048 }; 0049 0050 class DisplayHint : public QObject 0051 { 0052 Q_OBJECT 0053 QML_ELEMENT 0054 QML_SINGLETON 0055 0056 public: 0057 /** 0058 * Hints for implementations using Actions indicating preferences about how to display the action. 0059 */ 0060 enum Hint : uint { 0061 /** 0062 * Indicates there is no specific preference. 0063 */ 0064 NoPreference = 0, 0065 /** 0066 * Only display an icon for this Action. 0067 */ 0068 IconOnly = 1, 0069 /** 0070 * Try to keep the action visible even when space constrained. 0071 * Mutually exclusive with AlwaysHide, KeepVisible has priority. 0072 */ 0073 KeepVisible = 2, 0074 /** 0075 * If possible, hide the action in an overflow menu or similar location. 0076 * Mutually exclusive with KeepVisible, KeepVisible has priority. 0077 */ 0078 AlwaysHide = 4, 0079 /** 0080 * When this action has children, do not display any indicator (like a 0081 * menu arrow) for this action. 0082 */ 0083 HideChildIndicator = 8, 0084 }; 0085 Q_DECLARE_FLAGS(DisplayHints, Hint) 0086 Q_ENUM(Hint) 0087 Q_FLAG(DisplayHints) 0088 0089 // Note: These functions are instance methods because they need to be 0090 // exposed to QML. Unfortunately static methods are not supported. 0091 0092 /** 0093 * Helper function to check if a certain display hint has been set. 0094 * 0095 * This function is mostly convenience to enforce certain behaviour of the 0096 * various display hints, primarily the mutual exclusivity of KeepVisible 0097 * and AlwaysHide. 0098 * 0099 * @param values The display hints to check. 0100 * @param hint The display hint to check if it is set. 0101 * 0102 * @return true if the hint was set for this action, false if not. 0103 * 0104 * @since 2.14 0105 */ 0106 Q_INVOKABLE bool displayHintSet(DisplayHints values, Hint hint); 0107 0108 /** 0109 * Check if a certain display hint has been set on an object. 0110 * 0111 * This overloads @f displayHintSet(DisplayHints, Hint) to accept a QObject 0112 * instance. This object is checked to see if it has a displayHint property 0113 * and if so, if that property has @p hint set. 0114 * 0115 * @param object The object to check. 0116 * @param hint The hint to check for. 0117 * 0118 * @return false if object is null, object has no displayHint property or 0119 * the hint was not set. true if it has the property and the hint is 0120 * set. 0121 */ 0122 Q_INVOKABLE bool displayHintSet(QObject *object, Hint hint); 0123 0124 /** 0125 * Static version of \f displayHintSet(DisplayHints, Hint) that can be 0126 * called from C++ code. 0127 */ 0128 static bool isDisplayHintSet(DisplayHints values, Hint hint); 0129 }; 0130 0131 Q_DECLARE_OPERATORS_FOR_FLAGS(DisplayHint::DisplayHints) 0132 0133 #endif // ENUMS_H