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