diff --git a/src/plasma/wallpapers/CMakeLists.txt b/src/plasma/wallpapers/CMakeLists.txt --- a/src/plasma/wallpapers/CMakeLists.txt +++ b/src/plasma/wallpapers/CMakeLists.txt @@ -1 +1,2 @@ plasma_install_package(worldmap org.kde.plasma.worldmap wallpapers wallpaper) +plasma_install_package(earthglobe org.kde.plasma.earthglobe wallpapers wallpaper) diff --git a/src/plasma/wallpapers/earthglobe/Messages.sh b/src/plasma/wallpapers/earthglobe/Messages.sh new file mode 100644 --- /dev/null +++ b/src/plasma/wallpapers/earthglobe/Messages.sh @@ -0,0 +1,2 @@ +#! /usr/bin/env bash +$XGETTEXT `find . -name \*.qml` -o $podir/plasma_wallpaper_org.kde.plasma.earthglobe.pot diff --git a/src/plasma/wallpapers/earthglobe/contents/config/main.xml b/src/plasma/wallpapers/earthglobe/contents/config/main.xml new file mode 100644 --- /dev/null +++ b/src/plasma/wallpapers/earthglobe/contents/config/main.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + Daylight + + + + 0 + + + 0 + + + + diff --git a/src/plasma/wallpapers/earthglobe/contents/ui/config.qml b/src/plasma/wallpapers/earthglobe/contents/ui/config.qml new file mode 100644 --- /dev/null +++ b/src/plasma/wallpapers/earthglobe/contents/ui/config.qml @@ -0,0 +1,115 @@ +/* + * Copyright 2018 Friedrich W. H. Kossebau + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see . + */ + +import QtQuick 2.1 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 1.0 as QtControls + +// for "units" +import org.kde.plasma.core 2.0 as PlasmaCore + + +ColumnLayout { + id: root + + property int cfg_centerMode: wallpaper.configuration.centerMode // Enum needs manual set/get for now + property alias cfg_fixedLongitude: longitudeSpinBox.value + property alias cfg_fixedLatitude: latitudeSpinBox.value + + // To allow aligned integration in the settings form, + // "formAlignment" is a property injected by the config containment + // which defines the offset of the value fields + readonly property int labelWidth: formAlignment - units.largeSpacing + + RowLayout { + spacing: units.largeSpacing / 2 + + QtControls.Label { + Layout.minimumWidth: labelWidth + Layout.maximumWidth: labelWidth + horizontalAlignment: Text.AlignRight + anchors { + verticalCenter: centerModeComboBox.verticalCenter + } + text: i18nd("plasma_wallpaper_org.kde.plasma.earthglobe", "Center on:") + } + + QtControls.ComboBox { + id: centerModeComboBox + model: [ + i18nd("plasma_wallpaper_org.kde.plasma.earthglobe", "Daylight"), + i18nd("plasma_wallpaper_org.kde.plasma.earthglobe", "Longitude/Latitude"), + i18nd("plasma_wallpaper_org.kde.plasma.earthglobe", "Location") + ] + onCurrentIndexChanged: { + cfg_centerMode = currentIndex; + } + Component.onCompleted: { + currentIndex = wallpaper.configuration.centerMode; + } + } + + } + RowLayout { + spacing: units.largeSpacing / 2 + + QtControls.Label { + Layout.minimumWidth: labelWidth + Layout.maximumWidth: labelWidth + horizontalAlignment: Text.AlignRight + anchors { + verticalCenter: longitudeSpinBox.verticalCenter + } + enabled: (cfg_centerMode === 1) + text: i18nd("plasma_wallpaper_org.kde.plasma.earthglobe", "Longitude:") + } + + QtControls.SpinBox { + enabled: (cfg_centerMode === 1) + id: longitudeSpinBox + maximumValue: 180.0 + minimumValue: -180.0 + decimals: 5 + } + } + RowLayout { + spacing: units.largeSpacing / 2 + + QtControls.Label { + Layout.minimumWidth: labelWidth + Layout.maximumWidth: labelWidth + horizontalAlignment: Text.AlignRight + anchors { + verticalCenter: latitudeSpinBox.verticalCenter + } + enabled: (cfg_centerMode === 1) + text: i18nd("plasma_wallpaper_org.kde.plasma.earthglobe", "Latitude:") + } + + QtControls.SpinBox { + enabled: (cfg_centerMode === 1) + id: latitudeSpinBox + maximumValue: 90.0 + minimumValue: -90.0 + decimals: 5 + } + } + + Item { // tighten layout + Layout.fillHeight: true + } +} diff --git a/src/plasma/wallpapers/earthglobe/contents/ui/main.qml b/src/plasma/wallpapers/earthglobe/contents/ui/main.qml new file mode 100644 --- /dev/null +++ b/src/plasma/wallpapers/earthglobe/contents/ui/main.qml @@ -0,0 +1,109 @@ +/* + * Copyright 2018 Friedrich W. H. Kossebau + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see . + */ + +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 + +MarbleItem { + id: marbleItem + + readonly property int centerMode: wallpaper.configuration.centerMode + readonly property double fixedLongitude: wallpaper.configuration.fixedLongitude + readonly property double fixedLatitude: wallpaper.configuration.fixedLatitude + readonly property double locationLongitude: geolocationDataSource.data.longitude + readonly property double locationLatitude: geolocationDataSource.data.latitude + + enabled: false // do not handle input + + radius: { + var ratio = width/height; + if (ratio > 1) { + return height / 2.5; + } + return width / 2.5 + } + + // Theme settings. + projection: MarbleItem.Spherical + mapThemeId: "earth/bluemarble/bluemarble.dgml" + + // Visibility of layers/plugins. + showAtmosphere: true + showClouds: true + // TODO: enabling the stars crashes the rendering somewhere in QtQuick opengl rendering + // also do we want further control about plugin settings like not showing constellation + showBackground: false + + showGrid: false + showCrosshairs: false + showCompass: false + showOverviewMap: false + showScaleBar: false + + onCenterModeChanged: handleCenterModeChange() + function handleCenterModeChange() { + if (centerMode === 0) { + marbleMap.setLockToSubSolarPoint(true); + } else if (centerMode === 1) { + marbleMap.setLockToSubSolarPoint(false); + marbleMap.centerOn(fixedLongitude, fixedLatitude); + } else { + marbleMap.setLockToSubSolarPoint(false); + marbleMap.centerOn(locationLongitude, locationLatitude); + } + } + + onFixedLongitudeChanged: handleFixedLonLatChange() + onFixedLatitudeChanged: handleFixedLonLatChange() + function handleFixedLonLatChange() { + if (centerMode === 1) { + marbleMap.centerOn(fixedLongitude, fixedLatitude); + } + } + + onLocationLongitudeChanged:handleLocationChange() + onLocationLatitudeChanged:handleLocationChange() + function handleLocationChange() { + if (centerMode === 2) { + marbleMap.centerOn(locationLongitude, locationLatitude); + } + } + + Component.onCompleted: { + marbleMap.setShowSunShading(true); + // TODO: no way to have clouds and citylights? + marbleMap.setShowCityLights(false); + + marbleMap.setShowPlaces(false); + marbleMap.setShowCities(false); + marbleMap.setShowTerrain(false); + marbleMap.setShowOtherPlaces(false); + + 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 + } +} diff --git a/src/plasma/wallpapers/earthglobe/metadata.desktop b/src/plasma/wallpapers/earthglobe/metadata.desktop new file mode 100644 --- /dev/null +++ b/src/plasma/wallpapers/earthglobe/metadata.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Name=Earth Globe +Type=Service +Icon=marble + +X-KDE-ServiceTypes=Plasma/Wallpaper +X-KDE-PluginInfo-Author=Friedrich W. H. Kossebau +X-KDE-PluginInfo-Email=kossebau@kde.org +X-KDE-PluginInfo-License=LGPL +X-KDE-PluginInfo-Name=org.kde.plasma.earthglobe +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website=https://marble.kde.org/ +X-Plasma-MainScript=ui/main.qml