Changeset View
Changeset View
Standalone View
Standalone View
src/plasma/wallpapers/earthglobe/contents/ui/main.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2018 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 | | ||||
20 | import org.kde.plasma.core 2.0 as PlasmaCore | ||||
21 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||||
22 | | ||||
23 | import org.kde.marble.private.plasma 0.20 | ||||
24 | | ||||
25 | MarbleItem { | ||||
26 | id: marbleItem | ||||
27 | | ||||
28 | readonly property int centerMode: wallpaper.configuration.centerMode | ||||
29 | readonly property double fixedLongitude: wallpaper.configuration.fixedLongitude | ||||
30 | readonly property double fixedLatitude: wallpaper.configuration.fixedLatitude | ||||
31 | readonly property double locationLongitude: geolocationDataSource.data.longitude | ||||
32 | readonly property double locationLatitude: geolocationDataSource.data.latitude | ||||
33 | | ||||
34 | enabled: false // do not handle input | ||||
35 | | ||||
36 | radius: { | ||||
37 | var ratio = width/height; | ||||
38 | if (ratio > 1) { | ||||
39 | return height / 2.5; | ||||
40 | } | ||||
41 | return width / 2.5 | ||||
42 | } | ||||
43 | | ||||
44 | // Theme settings. | ||||
45 | projection: MarbleItem.Spherical | ||||
46 | mapThemeId: "earth/bluemarble/bluemarble.dgml" | ||||
47 | | ||||
48 | // Visibility of layers/plugins. | ||||
49 | showAtmosphere: true | ||||
50 | showClouds: true | ||||
51 | // TODO: enabling the stars crashes the rendering somewhere in QtQuick opengl rendering | ||||
52 | // also do we want further control about plugin settings like not showing constellation | ||||
53 | showBackground: false | ||||
54 | | ||||
55 | showGrid: false | ||||
56 | showCrosshairs: false | ||||
57 | showCompass: false | ||||
58 | showOverviewMap: false | ||||
59 | showScaleBar: false | ||||
60 | | ||||
61 | onCenterModeChanged: handleCenterModeChange() | ||||
62 | function handleCenterModeChange() { | ||||
63 | if (centerMode === 0) { | ||||
64 | marbleMap.setLockToSubSolarPoint(true); | ||||
65 | } else if (centerMode === 1) { | ||||
66 | marbleMap.setLockToSubSolarPoint(false); | ||||
67 | marbleMap.centerOn(fixedLongitude, fixedLatitude); | ||||
68 | } else { | ||||
69 | marbleMap.setLockToSubSolarPoint(false); | ||||
70 | marbleMap.centerOn(locationLongitude, locationLatitude); | ||||
71 | } | ||||
72 | } | ||||
73 | | ||||
74 | onFixedLongitudeChanged: handleFixedLonLatChange() | ||||
75 | onFixedLatitudeChanged: handleFixedLonLatChange() | ||||
76 | function handleFixedLonLatChange() { | ||||
77 | if (centerMode === 1) { | ||||
78 | marbleMap.centerOn(fixedLongitude, fixedLatitude); | ||||
79 | } | ||||
80 | } | ||||
81 | | ||||
82 | onLocationLongitudeChanged:handleLocationChange() | ||||
83 | onLocationLatitudeChanged:handleLocationChange() | ||||
84 | function handleLocationChange() { | ||||
85 | if (centerMode === 2) { | ||||
86 | marbleMap.centerOn(locationLongitude, locationLatitude); | ||||
87 | } | ||||
88 | } | ||||
89 | | ||||
90 | Component.onCompleted: { | ||||
91 | marbleMap.setShowSunShading(true); | ||||
92 | // TODO: no way to have clouds and citylights? | ||||
93 | marbleMap.setShowCityLights(false); | ||||
94 | | ||||
95 | marbleMap.setShowPlaces(false); | ||||
96 | marbleMap.setShowCities(false); | ||||
97 | marbleMap.setShowTerrain(false); | ||||
98 | marbleMap.setShowOtherPlaces(false); | ||||
99 | | ||||
100 | handleCenterModeChange(); | ||||
101 | } | ||||
102 | | ||||
103 | PlasmaCore.DataSource { | ||||
104 | id: geolocationDataSource | ||||
105 | engine: "geolocation" | ||||
106 | connectedSources: (marbleItem.centerMode === 2) ? ["location"] : [] | ||||
107 | interval: 10 * 60 * 1000 // every 30 minutes, might be still too large for users on the ISS :P | ||||
108 | } | ||||
109 | } |