Open-Typer
Open source typewriting tutor program
Loading...
Searching...
No Matches
AppMenuItem.h
1/*
2 * AppMenuItem.h
3 * This file is part of Open-Typer
4 *
5 * Copyright (C) 2023 - adazem009
6 *
7 * Open-Typer is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * Open-Typer is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Open-Typer. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef APPMENUITEM_H
22#define APPMENUITEM_H
23
24#include <QObject>
25#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
26Q_MOC_INCLUDE("framework/ui/menubar/AppMenuModel.h")
27#endif
28
29class Q_DECL_EXPORT AppMenuModel;
30
32class Q_DECL_EXPORT AppMenuItem : public QObject
33{
34 Q_OBJECT
35 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
36 Q_PROPERTY(AppMenuModel *submenu READ submenu WRITE setSubmenu NOTIFY submenuChanged)
37 Q_PROPERTY(bool isSeparator READ isSeparator WRITE setIsSeparator NOTIFY isSeparatorChanged)
38 Q_PROPERTY(bool checkable READ checkable WRITE setCheckable NOTIFY checkableChanged)
39 Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY checkedChanged)
40 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
41 public:
42 explicit AppMenuItem(QObject *parent = nullptr);
43
44 QString text(void);
45 void setText(QString newText);
46
47 AppMenuModel *submenu(void);
48 void setSubmenu(AppMenuModel *newSubmenu);
49
50 bool isSeparator(void);
51 void setIsSeparator(bool newIsSeparator);
52
53 bool checkable(void);
54 void setCheckable(bool newCheckable);
55
56 bool checked(void);
57 void setChecked(bool newChecked);
58
59 bool enabled() const;
60 void setEnabled(bool newEnabled);
61
62 private:
63 QString m_text;
64 AppMenuModel *m_submenu = nullptr;
65 bool m_isSeparator = false;
66 bool m_checkable = false;
67 bool m_checked = false;
68 bool m_enabled = true;
69
70 signals:
71 void textChanged(QString text);
72 void submenuChanged(AppMenuModel *menu);
73 void isSeparatorChanged(bool value);
74 void checkableChanged(bool checkable);
75 void checkedChanged(bool checked);
76 void clicked();
77 void enabledChanged();
78};
79
80#endif // APPMENUITEM_H
The AppMenuItem class provides a model for a menu item.
Definition AppMenuItem.h:33
The AppMenuModel class provides a menu model for the application menu bar.
Definition AppMenuModel.h:30