From 72cd124bc6a71d7be3bf9e6602c9de55156508ee Mon Sep 17 00:00:00 2001 From: Nick Dedekind Date: Wed, 21 Aug 2013 21:39:47 +0100 Subject: Added UnityMenuAction for out-of-line actions. Action muxer copied to submenus. --- libqmenumodel/src/unitymenuaction.h | 73 +++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 libqmenumodel/src/unitymenuaction.h (limited to 'libqmenumodel/src/unitymenuaction.h') diff --git a/libqmenumodel/src/unitymenuaction.h b/libqmenumodel/src/unitymenuaction.h new file mode 100644 index 0000000..e6cc4d9 --- /dev/null +++ b/libqmenumodel/src/unitymenuaction.h @@ -0,0 +1,73 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authors: Nick Dedekind + */ + +#ifndef UNITYMENUACTION_H +#define UNITYMENUACTION_H + +#include +#include +class UnityMenuModel; + +class UnityMenuAction: public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QVariant state READ state NOTIFY stateChanged) + Q_PROPERTY(bool enabled READ isEnabled NOTIFY enabledChanged) + Q_PROPERTY(bool valid READ isValid NOTIFY validChanged) + Q_PROPERTY(UnityMenuModel* model READ model WRITE setModel NOTIFY modelChanged) +public: + UnityMenuAction(QObject* parent = 0); + ~UnityMenuAction(); + + QString name() const; + void setName(const QString& str); + + UnityMenuModel* model() const; + void setModel(UnityMenuModel* model); + + QVariant state() const; + bool isEnabled() const; + bool isValid() const; + +public Q_SLOTS: + void onAdded(bool enabled, const QVariant &state); + void onRemoved(); + void onEnabledChanged(bool enabled); + void onStateChanged(const QVariant &state); + +Q_SIGNALS: + void nameChanged(const QString& name); + void modelChanged(UnityMenuModel* model); + void stateChanged(const QVariant& name); + void enabledChanged(bool enabled); + void validChanged(bool valid); + +private: + void unregisterAction(); + void registerAction(); + + QString m_name; + QVariant m_state; + bool m_valid; + bool m_enabled; + UnityMenuModel* m_model; +}; + +#endif // UNITYMENUACTIONGROUP_H -- cgit v1.2.3 From d912a0aed3c62b8f615c37fd9406583b9f0a6a36 Mon Sep 17 00:00:00 2001 From: Nick Dedekind Date: Thu, 22 Aug 2013 12:03:08 +0100 Subject: Added activate/changeState to UnityMenuModel --- libqmenumodel/src/unitymenuaction.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libqmenumodel/src/unitymenuaction.h') diff --git a/libqmenumodel/src/unitymenuaction.h b/libqmenumodel/src/unitymenuaction.h index e6cc4d9..7c19fc5 100644 --- a/libqmenumodel/src/unitymenuaction.h +++ b/libqmenumodel/src/unitymenuaction.h @@ -53,6 +53,9 @@ public Q_SLOTS: void onStateChanged(const QVariant &state); Q_SIGNALS: + Q_INVOKABLE void activate(const QVariant& parameter = QVariant()); + Q_INVOKABLE void changeState(const QVariant& parameter); + void nameChanged(const QString& name); void modelChanged(UnityMenuModel* model); void stateChanged(const QVariant& name); -- cgit v1.2.3 From c2746565786204a732ff5531434bf636f8df605c Mon Sep 17 00:00:00 2001 From: Nick Dedekind Date: Thu, 22 Aug 2013 12:56:43 +0100 Subject: Using qt event loop to pass UnityMenuAction events --- libqmenumodel/src/unitymenuaction.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'libqmenumodel/src/unitymenuaction.h') diff --git a/libqmenumodel/src/unitymenuaction.h b/libqmenumodel/src/unitymenuaction.h index 7c19fc5..b8391fe 100644 --- a/libqmenumodel/src/unitymenuaction.h +++ b/libqmenumodel/src/unitymenuaction.h @@ -46,12 +46,6 @@ public: bool isEnabled() const; bool isValid() const; -public Q_SLOTS: - void onAdded(bool enabled, const QVariant &state); - void onRemoved(); - void onEnabledChanged(bool enabled); - void onStateChanged(const QVariant &state); - Q_SIGNALS: Q_INVOKABLE void activate(const QVariant& parameter = QVariant()); Q_INVOKABLE void changeState(const QVariant& parameter); @@ -62,6 +56,13 @@ Q_SIGNALS: void enabledChanged(bool enabled); void validChanged(bool valid); +protected: + virtual bool event(QEvent* e); + + void setState(const QVariant& state); + void setEnabled(bool enabled); + void setValid(bool valid); + private: void unregisterAction(); void registerAction(); -- cgit v1.2.3