on dc0c118 help sign in
100 lines 2.6 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 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
20#include "indicator.h"
22#include <QUrl>
23#include <QtPlugin>
24#include <QResource>
25#include <QDebug>
26#include <QFileInfo>
27#include <QDir>
28#include <QQmlEngine>
29#include <QQmlContext>
30#include <QJsonObject>
32#include <qdbusmenumodel.h>
33#include <qdbusactiongroup.h>
34#include <qstateaction.h>
36Indicator::Indicator(QObject *parent)
37 : QObject(parent)
41Indicator::~Indicator()
45void Indicator::init(const QString& busName, const QSettings& settings)
47 setId(settings.value("Indicator Service/Name").toString());
49 QString actionObjectPath = settings.value("Indicator Service/ObjectPath").toString();
51 QVariantMap mapMenuObjectPaths;
52 Q_FOREACH(const QString& childGroup, settings.childGroups())
53 {
54 if (childGroup == "Indicator Service")
55 continue;
57 QString menuPath = childGroup+"/ObjectPath";
58 if (settings.contains(menuPath))
59 {
60 mapMenuObjectPaths[childGroup] = settings.value(menuPath).toString();
61 }
62 }
65 QVariantMap properties;
66 properties.clear();
67 properties.insert("busType", 1);
68 properties.insert("busName", busName);
69 properties.insert("actionsObjectPath", actionObjectPath);
70 properties.insert("menuObjectPaths", mapMenuObjectPaths);
71 setIndicatorProperties(properties);
74QString Indicator::identifier() const
76 return m_identifier;
79void Indicator::setId(const QString &identifier)
81 if (identifier != m_identifier) {
82 m_identifier = identifier;
83 Q_EMIT identifierChanged(m_identifier);
84 }
88QVariant Indicator::indicatorProperties() const
90 return m_properties;
93void Indicator::setIndicatorProperties(const QVariant &properties)
95 if (m_properties != properties)
96 {
97 m_properties = properties;
98 Q_EMIT indicatorPropertiesChanged(m_properties);
99 }