on 1832ace help sign in
117 lines 2.9 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 <QStringList>
24Indicator::Indicator(QObject *parent)
25 : QObject(parent),
26 m_position(0),
27 m_visible(false)
31Indicator::~Indicator()
35void Indicator::init(const QString& busName, const QSettings& settings)
37 setId(settings.value("Indicator Service/Name").toString());
38 setPosition(settings.value("Indicator Service/Position", QVariant::fromValue(0)).toInt());
40 QString actionObjectPath = settings.value("Indicator Service/ObjectPath").toString();
42 QVariantMap mapMenuObjectPaths;
43 Q_FOREACH(const QString& childGroup, settings.childGroups())
44 {
45 if (childGroup == "Indicator Service")
46 continue;
48 QString menuPath = childGroup+"/ObjectPath";
49 if (settings.contains(menuPath))
50 {
51 mapMenuObjectPaths[childGroup] = settings.value(menuPath).toString();
52 }
53 }
55 QVariantMap properties;
56 properties.clear();
57 properties.insert("busType", 1);
58 properties.insert("busName", busName);
59 properties.insert("actionsObjectPath", actionObjectPath);
60 properties.insert("menuObjectPaths", mapMenuObjectPaths);
61 setIndicatorProperties(properties);
64QString Indicator::identifier() const
66 return m_identifier;
69void Indicator::setId(const QString &identifier)
71 if (identifier != m_identifier) {
72 m_identifier = identifier;
73 Q_EMIT identifierChanged(m_identifier);
74 }
77int Indicator::position() const
79 return m_position;
82void Indicator::setPosition(int position)
84 if (position != m_position) {
85 m_position = position;
86 Q_EMIT positionChanged(m_position);
87 }
90bool Indicator::isVisible() const
92 return m_visible;
95bool Indicator::setVisible(bool visible)
97 if (visible != m_visible) {
98 m_visible = visible;
99 Q_EMIT visibleChanged(m_visible);
100 return true;
101 }
102 return false;
105QVariant Indicator::indicatorProperties() const
107 return m_properties;
110void Indicator::setIndicatorProperties(const QVariant &properties)
112 if (m_properties != properties)
113 {
114 m_properties = properties;
115 Q_EMIT indicatorPropertiesChanged(m_properties);
116 }