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);
50 m_timer.start(1000 * 10);
53void IndicatorClientDateTime::shutdown()
59QString IndicatorClientDateTime::dateTime() const
61 static char timestr[255];
71 int size = strftime(timestr, 255, m_format.toUtf8().data(), tmp);
76 return QString::fromLatin1(timestr, size);
79bool IndicatorClientDateTime::parseRootElement(const QString &type, QMap<int, QVariant> data)
81 if (type == "com.canonical.indicator.root.time") {
86 QVariant action = data[QDBusMenuModel::Action];
87 m_action = actionGroup()->action(action.toString());
88 if (m_action->isValid()) {
89 updateTimeFormat(m_action->state());
91 QObject::connect(m_action, SIGNAL(stateChanged(QVariant)), this, SLOT(updateTimeFormat(QVariant)));
98void IndicatorClientDateTime::updateTimeFormat(const QVariant &state)
100 if (state.isValid()) {
101 // (sssb) : time format, icon, accessible name format, visible
102 QVariantList states = state.toList();
103 if (states.size() == 4) {
104 m_format = states[0].toString();
105 setIcon(QUrl(states[1].toString()));
106 setVisible(states[2].toBool());
112QUrl IndicatorClientDateTime::componentSource() const
114 return QUrl("qrc:/indicatorsclient/qml/DatetimeIndicator.qml");
117void IndicatorClientDateTime::onTimeout()
119 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