Libplasma

qmenuitem.h
1/*
2 SPDX-FileCopyrightText: 2011 Viranch Mehta <viranch.mehta@gmail.com>
3 SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8#ifndef QMENUITEM_H
9#define QMENUITEM_H
10
11#include <QAction>
12#include <QObject>
13
14#include <qqmlregistration.h>
15
16class QMenuItem : public QObject
17{
19 QML_ELEMENT
20 QML_NAMED_ELEMENT(MenuItem)
21
22 /**
23 * The parent object
24 */
25 Q_PROPERTY(QObject *parent READ parent WRITE setParent)
26
27 /**
28 * If true, the menu item will behave like a separator
29 */
30 Q_PROPERTY(bool separator READ separator WRITE setSeparator NOTIFY separatorChanged)
31 /**
32 * If true, the menu item will behave like a section
33 */
34 Q_PROPERTY(bool section READ section WRITE setSection NOTIFY sectionChanged)
35 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
36 Q_PROPERTY(QVariant icon READ icon WRITE setIcon NOTIFY iconChanged)
37 Q_PROPERTY(QAction *action READ action WRITE setAction NOTIFY actionChanged)
38 Q_PROPERTY(bool checkable READ checkable WRITE setCheckable NOTIFY checkableChanged)
39 Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY toggled)
40 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
41 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
42
43public:
44 explicit QMenuItem(QObject *parent = nullptr);
45
46 QAction *action() const;
47 void setAction(QAction *a);
48 QVariant icon() const;
49 void setIcon(const QVariant &i);
50 bool separator() const;
51 void setSeparator(bool s);
52 bool section() const;
53 void setSection(bool s);
54 QString text() const;
55 void setText(const QString &t);
56
57 bool checkable() const;
58 void setCheckable(bool checkable);
59
60 bool checked() const;
61 void setChecked(bool checked);
62
63 bool isEnabled() const;
64 void setEnabled(bool enabled);
65
66 bool isVisible() const;
67 void setVisible(bool visible);
68
70 void clicked();
71
72 void actionChanged();
73 void iconChanged();
74 void separatorChanged();
75 void sectionChanged();
76 void textChanged();
77 void toggled(bool checked);
78 void checkableChanged();
79 void enabledChanged();
80 void visibleChanged();
81
82private:
83 QAction *m_action;
84 QVariant m_icon;
85 bool m_section;
86};
87
88#endif // QMENUITEM_H
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
void setParent(QObject *parent)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.