Changeset View
Changeset View
Standalone View
Standalone View
applets/binary-clock/package/contents/ui/main.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2014 Joseph Wenninger <jowenn@kde.org> | ||||
3 | * | ||||
4 | * Based on fuzzy-clock main.qml: | ||||
5 | * Copyright 2013 Heena Mahour <heena393@gmail.com> | ||||
6 | * Copyright 2013 Sebastian Kügler <sebas@kde.org> | ||||
7 | * Copyright 2014 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
8 | * | ||||
9 | * This program is free software; you can redistribute it and/or | ||||
10 | * modify it under the terms of the GNU General Public License as | ||||
11 | * published by the Free Software Foundation; either version 2 of | ||||
12 | * the License, or (at your option) any later version. | ||||
13 | * | ||||
14 | * This program is distributed in the hope that it will be useful, | ||||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
17 | * GNU General Public License for more details. | ||||
18 | * | ||||
19 | * You should have received a copy of the GNU General Public License | ||||
20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
21 | */ | ||||
22 | import QtQuick 2.0 | ||||
23 | import QtQuick.Layouts 1.1 | ||||
24 | | ||||
25 | import org.kde.plasma.plasmoid 2.0 | ||||
26 | import org.kde.plasma.core 2.0 as PlasmaCore | ||||
27 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||||
28 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||||
29 | import org.kde.plasma.calendar 2.0 as PlasmaCalendar | ||||
30 | | ||||
31 | Item { | ||||
32 | id: root | ||||
33 | | ||||
34 | property bool showSeconds:plasmoid.configuration.showSeconds | ||||
35 | property int hours | ||||
36 | property int minutes | ||||
37 | property int seconds | ||||
38 | width: units.gridUnit * 10 | ||||
39 | height: units.gridUnit * 4 | ||||
40 | | ||||
41 | Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation | ||||
42 | | ||||
43 | Plasmoid.toolTipMainText: Qt.formatDate(dataSource.data["Local"]["DateTime"],"dddd") | ||||
44 | Plasmoid.toolTipSubText: Qt.formatDate(dataSource.data["Local"]["DateTime"], Qt.locale().dateFormat(Locale.LongFormat).replace(/(^dddd.?\s)|(,?\sdddd$)/, "")) | ||||
45 | | ||||
46 | PlasmaCore.DataSource { | ||||
47 | id: dataSource | ||||
48 | engine: "time" | ||||
49 | connectedSources: ["Local"] | ||||
50 | interval: showSeconds?1000:30000 | ||||
51 | onDataChanged: { | ||||
52 | var date = new Date(data["Local"]["DateTime"]); | ||||
53 | hours = date.getHours(); | ||||
54 | minutes = date.getMinutes(); | ||||
55 | seconds = date.getSeconds(); | ||||
56 | } | ||||
57 | Component.onCompleted: { | ||||
58 | onDataChanged(); | ||||
59 | } | ||||
60 | } | ||||
61 | | ||||
62 | Plasmoid.compactRepresentation: BinaryClock { } | ||||
63 | | ||||
64 | Plasmoid.fullRepresentation: PlasmaCalendar.MonthView { | ||||
65 | Layout.minimumWidth: units.gridUnit * 20 | ||||
66 | Layout.minimumHeight: units.gridUnit * 20 | ||||
67 | | ||||
68 | today: dataSource.data["Local"]["DateTime"] | ||||
69 | } | ||||
70 | } |