Overte C++ Documentation
MenuItemProperties.h
1 //
2 // MenuItemProperties.h
3 // libraries/script-engine/src
4 //
5 // Created by Brad Hefta-Gaub on 1/28/14.
6 // Copyright 2014 High Fidelity, Inc.
7 // Copyright 2023 Overte e.V.
8 //
9 // Distributed under the Apache License, Version 2.0.
10 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
11 // SPDX-License-Identifier: Apache-2.0
12 //
13 
16 
17 #ifndef hifi_MenuItemProperties_h
18 #define hifi_MenuItemProperties_h
19 
20 #include "KeyEvent.h"
21 
22 #include "ScriptValue.h"
23 
24 class ScriptEngine;
25 
28 public:
30  MenuItemProperties(const QString& menuName, const QString& menuItemName,
31  const QString& shortcutKey = QString(""), bool checkable = false, bool checked = false, bool separator = false);
32  MenuItemProperties(const QString& menuName, const QString& menuItemName,
33  const KeyEvent& shortcutKeyEvent, bool checkable = false, bool checked = false, bool separator = false);
34 
35  QString menuName;
36  QString menuItemName;
37 
38  // Shortcut key items: in order of priority
39  QString shortcutKey;
40  KeyEvent shortcutKeyEvent;
41  QKeySequence shortcutKeySequence; // this is what we actually use, it's set from one of the above
42 
43  // location related items: in order of priority
44  int position { UNSPECIFIED_POSITION };
45  QString beforeItem;
46  QString afterItem;
47 
48  // other properties
49  bool isCheckable { false };
50  bool isChecked { false };
51  bool isSeparator { false };
52 
53  QString grouping;
54 
55 private:
56  static const int UNSPECIFIED_POSITION = -1;
57 };
58 Q_DECLARE_METATYPE(MenuItemProperties)
59 ScriptValue menuItemPropertiesToScriptValue(ScriptEngine* engine, const MenuItemProperties& props);
60 bool menuItemPropertiesFromScriptValue(const ScriptValue& object, MenuItemProperties& props);
61 
62 
63 
64 #endif // hifi_MenuItemProperties_h
65 
Represents a keyboard event to the scripting engine. Exposed as KeyEvent
Definition: KeyEvent.h:27
Represents a menu item a script may declare and bind events to. Exposed as MenuItemProperties
Definition: MenuItemProperties.h:27
Provides an engine-independent interface for a scripting engine.
Definition: ScriptEngine.h:93
[ScriptInterface] Provides an engine-independent interface for QScriptValue
Definition: ScriptValue.h:40