Changeset View
Changeset View
Standalone View
Standalone View
src/plasma/applets/worldclock/package/contents/ui/main.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2016 Friedrich W. H. Kossebau <kossebau@kde.org> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU Lesser General Public | ||||
6 | * License as published by the Free Software Foundation; either | ||||
7 | * version 2.1 of the License, or (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
12 | * Lesser General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Lesser General Public | ||||
15 | * License along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
16 | */ | ||||
17 | | ||||
18 | import QtQuick 2.1 | ||||
19 | import QtQuick.Layouts 1.1 | ||||
20 | | ||||
21 | import org.kde.plasma.plasmoid 2.0 | ||||
22 | import org.kde.plasma.core 2.0 as PlasmaCore | ||||
23 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||||
24 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||||
25 | | ||||
26 | import org.kde.marble.private.plasma 0.20 | ||||
27 | | ||||
28 | Item { | ||||
29 | id: root | ||||
30 | | ||||
31 | readonly property date currentDateTime: dataSource.data.Local ? dataSource.data.Local.DateTime : new Date() | ||||
32 | | ||||
33 | Plasmoid.toolTipMainText: Qt.formatTime(currentDateTime) | ||||
34 | Plasmoid.toolTipSubText: Qt.formatDate(currentDateTime, Qt.locale().dateFormat(Locale.LongFormat)) | ||||
35 | | ||||
36 | PlasmaCore.DataSource { | ||||
37 | id: dataSource | ||||
38 | engine: "time" | ||||
39 | connectedSources: ["Local"] | ||||
40 | interval: 60000 | ||||
41 | intervalAlignment: PlasmaCore.Types.AlignToMinute | ||||
42 | } | ||||
43 | | ||||
44 | Plasmoid.compactRepresentation: Component { | ||||
45 | MouseArea { | ||||
46 | id: compactRoot | ||||
47 | onClicked: plasmoid.expanded = !plasmoid.expanded | ||||
48 | | ||||
49 | PlasmaCore.IconItem { | ||||
50 | width: height | ||||
51 | height: compactRoot.height | ||||
52 | source: currentWeatherIconName | ||||
53 | } | ||||
54 | } | ||||
55 | } | ||||
56 | | ||||
57 | | ||||
58 | Plasmoid.fullRepresentation: MarbleItem { | ||||
59 | id: marbleItem | ||||
60 | | ||||
61 | enabled: false // do not handle input | ||||
62 | Layout.minimumWidth: units.gridUnit * 20 | ||||
63 | Layout.minimumHeight: units.gridUnit * 20 | ||||
64 | | ||||
65 | radius: { | ||||
66 | var ratio = width/height; | ||||
67 | if (projection === MarbleItem.Equirectangular) { | ||||
68 | if (ratio > 2) { | ||||
69 | return height; | ||||
70 | } | ||||
71 | return width / 4; | ||||
72 | } else { | ||||
73 | if (ratio > 1) { | ||||
74 | return height / 4; | ||||
75 | } | ||||
76 | return width / 4 | ||||
77 | } | ||||
78 | } | ||||
79 | | ||||
80 | // Theme settings. | ||||
81 | projection: (plasmoid.configuration.projection === 0) ? MarbleItem.Equirectangular : MarbleItem.Mercator | ||||
82 | mapThemeId: "earth/bluemarble/bluemarble.dgml" | ||||
83 | | ||||
84 | // Visibility of layers/plugins. | ||||
85 | showAtmosphere: false | ||||
86 | showClouds: false | ||||
87 | showBackground: false | ||||
88 | | ||||
89 | showGrid: false | ||||
90 | showCrosshairs: false | ||||
91 | showCompass: false | ||||
92 | showOverviewMap: false | ||||
93 | showScaleBar: false | ||||
94 | // TODO: showCredit: false | ||||
95 | | ||||
96 | Component.onCompleted: { | ||||
97 | marbleMap.setShowSunShading(true); | ||||
98 | marbleMap.setShowCityLights(true); | ||||
99 | | ||||
100 | marbleMap.setShowPlaces(false); | ||||
101 | marbleMap.setShowOtherPlaces(false); | ||||
102 | marbleMap.setShowCities(false); | ||||
103 | marbleMap.setShowTerrain(false); | ||||
104 | | ||||
105 | // will depend on plasmoid.configuration.centerSun | ||||
106 | marbleMap.setLockToSubSolarPoint(true); | ||||
107 | marbleMap.setSubSolarPointIconVisible(true); | ||||
108 | } | ||||
109 | | ||||
110 | ColumnLayout { | ||||
111 | anchors.centerIn: parent | ||||
112 | | ||||
113 | PlasmaExtras.Heading { | ||||
114 | id: timeLabel | ||||
115 | | ||||
116 | Layout.alignment: Qt.AlignHCenter | ||||
117 | | ||||
118 | level: 1 | ||||
119 | text: plasmoid.configuration.showDate ? Qt.formatDateTime(currentDateTime) : Qt.formatTime(currentDateTime) | ||||
120 | | ||||
121 | verticalAlignment: Text.AlignVCenter | ||||
122 | horizontalAlignment: Text.AlignHCenter | ||||
123 | } | ||||
124 | /* | ||||
125 | PlasmaExtras.Heading { | ||||
126 | id: timezoneLabel | ||||
127 | | ||||
128 | Layout.alignment: Qt.AlignHCenter | ||||
129 | | ||||
130 | level: 3 | ||||
131 | text: "Internet" | ||||
132 | | ||||
133 | visible: text.length > 0 | ||||
134 | horizontalAlignment: Text.AlignHCenter | ||||
135 | } | ||||
136 | */ | ||||
137 | } | ||||
138 | } | ||||
139 | } |