2 * Copyright 2013 Canonical Ltd.
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.
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.
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/>.
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Ubo Riboni <ugo.riboni@canonical.com>
21#include "indicatorclient_datetime.h"
23#include <qdbusmenumodel.h>
24#include <qdbusactiongroup.h>
25#include <qstateaction.h>
29IndicatorClientDateTime::IndicatorClientDateTime(QObject *parent)
30 : IndicatorClientCommon(parent),
33 setTitle("Date and Time");
34 setPriority(IndicatorPriority::DATETIME);
36 connect(&m_timer, SIGNAL(timeout()), SLOT(onTimeout()));
39IndicatorClientDateTime::~IndicatorClientDateTime()
46void IndicatorClientDateTime::init(const QSettings& settings)
48 IndicatorClientCommon::init(settings);
49 Q_INIT_RESOURCE(indicatorclient_datetime);
51 m_timer.start(1000 * 10);
54void IndicatorClientDateTime::shutdown()
60QString IndicatorClientDateTime::dateTime() const
62 static char timestr[255];
72 int size = strftime(timestr, 255, m_format.toUtf8().data(), tmp);
77 return QString::fromLatin1(timestr, size);
80bool IndicatorClientDateTime::parseRootElement(const QString &type, QMap<int, QVariant> data)
82 if (type == "com.canonical.indicator.root.time") {
87 QVariant action = data[QDBusMenuModel::Action];
88 m_action = actionGroup()->action(action.toString());
89 if (m_action->isValid()) {
90 updateTimeFormat(m_action->state());
92 QObject::connect(m_action, SIGNAL(stateChanged(QVariant)), this, SLOT(updateTimeFormat(QVariant)));
99void IndicatorClientDateTime::updateTimeFormat(const QVariant &state)
101 if (state.isValid()) {
102 // (sssb) : time format, icon, accessible name format, visible
103 QVariantList states = state.toList();
104 if (states.size() == 4) {
105 m_format = states[0].toString();
106 setIcon(QUrl(states[1].toString()));
107 setVisible(states[2].toBool());
108 setAccessibleName(states[3].toString());
114QQmlComponent *IndicatorClientDateTime::createComponent(QQmlEngine *engine, QObject *parent) const
116 return new QQmlComponent(engine, QUrl("qrc:/indicatorsclient/datetime/qml/ClockPage.qml"), parent);
119void IndicatorClientDateTime::onTimeout()
121 QString newValue = dateTime();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list