Commit 44d080ff authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Plasma wallpaper/worldclock: add option to center on current location

parent 36c94290
......@@ -18,6 +18,7 @@
<choices>
<choice name="Daylight" />
<choice name="Longitude" />
<choice name="Position" />
</choices>
<default>Daylight</default>
</entry>
......
......@@ -72,7 +72,8 @@ ColumnLayout {
Layout.column: 1
model: [
i18n("Daylight"),
i18n("Longitude")
i18n("Longitude"),
i18n("Location")
]
onCurrentIndexChanged: {
cfg_centerMode = currentIndex;
......
......@@ -28,18 +28,21 @@ import org.kde.marble.private.plasma 0.20
Item {
id: root
readonly property date currentDateTime: dataSource.data.Local ? dataSource.data.Local.DateTime : new Date()
Plasmoid.toolTipMainText: Qt.formatTime(currentDateTime)
Plasmoid.toolTipSubText: Qt.formatDate(currentDateTime, Qt.locale().dateFormat(Locale.LongFormat))
readonly property date currentDateTime: timeDataSource.data.Local ? timeDataSource.data.Local.DateTime : new Date()
PlasmaCore.DataSource {
id: dataSource
id: timeDataSource
engine: "time"
connectedSources: ["Local"]
interval: 60000
intervalAlignment: PlasmaCore.Types.AlignToMinute
}
PlasmaCore.DataSource {
id: geolocationDataSource
engine: "geolocation"
connectedSources: (marbleItem.centerMode === 2) ? ["location"] : []
interval: 10 * 60 * 1000 // every 30 minutes, might be still too large for users on the ISS :P
}
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
......@@ -48,6 +51,7 @@ Item {
readonly property int centerMode: plasmoid.configuration.centerMode
readonly property double fixedLongitude: plasmoid.configuration.fixedLongitude
readonly property double locationLongitude: geolocationDataSource.data.longitude
enabled: false // do not handle input
Layout.minimumWidth: units.gridUnit * 20
......@@ -88,9 +92,12 @@ Item {
function handleCenterModeChange() {
if (centerMode === 0) {
marbleMap.setLockToSubSolarPoint(true);
} else {
} else if (centerMode === 1) {
marbleMap.setLockToSubSolarPoint(false);
marbleMap.centerOn(fixedLongitude, 0.0);
} else {
marbleMap.setLockToSubSolarPoint(false);
marbleMap.centerOn(locationLongitude, 0.0);
}
}
......@@ -100,6 +107,12 @@ Item {
}
}
onLocationLongitudeChanged: {
if (centerMode === 2) {
marbleMap.centerOn(locationLongitude, 0.0);
}
}
Component.onCompleted: {
marbleMap.setShowSunShading(true);
marbleMap.setShowCityLights(true);
......
......@@ -18,6 +18,7 @@
<choices>
<choice name="Daylight" />
<choice name="Longitude" />
<choice name="Position" />
</choices>
<default>Daylight</default>
</entry>
......
......@@ -79,7 +79,8 @@ ColumnLayout {
id: centerModeComboBox
model: [
i18nd("plasma_wallpaper_org.kde.plasma.worldmap", "Daylight"),
i18nd("plasma_wallpaper_org.kde.plasma.worldmap", "Longitude")
i18nd("plasma_wallpaper_org.kde.plasma.worldmap", "Longitude"),
i18nd("plasma_wallpaper_org.kde.plasma.worldmap", "Location")
]
onCurrentIndexChanged: {
cfg_centerMode = currentIndex;
......
......@@ -17,6 +17,7 @@
import QtQuick 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.marble.private.plasma 0.20
......@@ -26,6 +27,7 @@ MarbleItem {
readonly property int centerMode: wallpaper.configuration.centerMode
readonly property double fixedLongitude: wallpaper.configuration.fixedLongitude
readonly property double locationLongitude: geolocationDataSource.data.longitude
enabled: false // do not handle input
......@@ -63,9 +65,12 @@ MarbleItem {
function handleCenterModeChange() {
if (centerMode === 0) {
marbleMap.setLockToSubSolarPoint(true);
} else {
} else if (centerMode === 1) {
marbleMap.setLockToSubSolarPoint(false);
marbleMap.centerOn(fixedLongitude, 0.0);
} else {
marbleMap.setLockToSubSolarPoint(false);
marbleMap.centerOn(locationLongitude, 0.0);
}
}
......@@ -75,6 +80,12 @@ MarbleItem {
}
}
onLocationLongitudeChanged: {
if (centerMode === 2) {
marbleMap.centerOn(locationLongitude, 0.0);
}
}
Component.onCompleted: {
marbleMap.setShowSunShading(true);
marbleMap.setShowCityLights(true);
......@@ -86,4 +97,11 @@ MarbleItem {
handleCenterModeChange();
}
PlasmaCore.DataSource {
id: geolocationDataSource
engine: "geolocation"
connectedSources: (marbleItem.centerMode === 2) ? ["location"] : []
interval: 10 * 60 * 1000 // every 30 minutes, might be still too large for users on the ISS :P
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment