/
Clock.h
71 lines (59 loc) · 2.46 KB
/
Clock.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/***********************************************************************************
* Adjustable Clock: Plasmoid to show date and time in adjustable format.
* Copyright (C) 2008 - 2013 Michal Dutkiewicz aka Emdek <emdeck@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
***********************************************************************************/
#ifndef ADJUSTABLECLOCKCLOCK_HEADER
#define ADJUSTABLECLOCKCLOCK_HEADER
#include "DataSource.h"
#include <QtScript/QScriptEngine>
namespace AdjustableClock
{
enum ThemeType
{
UnknownType = 0,
HtmlType = 1,
QmlType = 2
};
class Clock : public QObject
{
Q_OBJECT
public:
explicit Clock(DataSource *source, bool constant = false);
void setTheme(const QString &path, ThemeType type);
Q_INVOKABLE QVariant getColor(const QString &role = QString()) const;
Q_INVOKABLE QVariant getFile(const QString &path, bool base64 = true) const;
Q_INVOKABLE QVariant getFont(const QString &role = QString()) const;
Q_INVOKABLE QVariant getIcon(const QString &path, int size = 64) const;
Q_INVOKABLE QVariant getImage(const QString &path, bool base64 = true) const;
Q_INVOKABLE QVariant getOption(const QString &key, const QVariant &defaultValue = QVariant()) const;
Q_INVOKABLE QVariant getValue(int component, const QVariantMap &options = QVariantMap()) const;
QString evaluate(const QString &script);
static QString getComponentName(ClockComponent component);
static QLatin1String getComponentString(ClockComponent component);
private:
DataSource *m_source;
QScriptEngine m_engine;
QString m_path;
QString m_theme;
ThemeType m_type;
bool m_constant;
signals:
void componentChanged(ClockComponent component);
};
}
#endif