on c1e34fd help sign in
unity8/plugins/Unity/Indicators/rootactionstate.h
82 lines 2.4 kB history raw
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
20#ifndef ROOTACTIONSTATE_H
21#define ROOTACTIONSTATE_H
23#include "unityindicatorsglobal.h"
25#include <actionstateparser.h>
27class UnityMenuModel;
29class UNITYINDICATORS_EXPORT RootActionState : public ActionStateParser
31 Q_OBJECT
32 Q_PROPERTY(UnityMenuModel* menu READ menu WRITE setMenu NOTIFY menuChanged)
34 Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
35 Q_PROPERTY(QString label READ label NOTIFY labelChanged)
36 Q_PROPERTY(QString icon READ icon NOTIFY iconChanged)
37 Q_PROPERTY(QString accessibleName READ accessibleName NOTIFY accessibleNameChanged)
38 Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged)
39public:
40 RootActionState(QObject *parent = 0);
41 virtual ~RootActionState();
43 UnityMenuModel* menu() const;
44 void setMenu(UnityMenuModel* menu);
46 int index() const;
47 void setIndex(int index);
49 bool isValid() const;
50 QString label() const;
51 QString icon() const;
52 QString accessibleName() const;
53 bool isVisible() const;
55 // from ActionStateParser
56 virtual QVariant toQVariant(GVariant* state) const;
58Q_SIGNALS:
59 void updated();
61 void menuChanged();
62 void indexChanged();
64 void validChanged();
65 void labelChanged();
66 void iconChanged();
67 void accessibleNameChanged();
68 void visibleChanged();
70private Q_SLOTS:
71 void onModelRowsAdded(const QModelIndex& parent, int start, int end);
72 void onModelRowsRemoved(const QModelIndex& parent, int start, int end);
73 void onModelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>&);
75private:
76 void updateActionState();
78 UnityMenuModel* m_menu;
79 QVariantMap m_cachedState;
80};
82#endif // ROOTACTIONSTATE_H