[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdeplasma-addons] wallpapers/potd: Bring potd wallpaper back to life.
From:       Weng Xuetian <wengxt () gmail ! com>
Date:       2016-11-15 19:24:43
Message-ID: E1c6jLX-000089-Ng () code ! kde ! org
[Download RAW message or body]

Git commit 8f1310dd1e9a780da967191335f8de84d46cc477 by Weng Xuetian.
Committed on 15/11/2016 at 19:24.
Pushed by xuetianweng into branch 'master'.

Bring potd wallpaper back to life.

Summary: Port the potd wallpaper plugin to KF5/QML.

Test Plan: Test manually with plasmashell

Reviewers: #plasma, mart

Reviewed By: mart

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D3184

A  +23   -0    wallpapers/potd/contents/config/main.xml
A  +167  -0    wallpapers/potd/contents/ui/config.qml     [License: LGPL (v2+)]
A  +49   -0    wallpapers/potd/contents/ui/main.qml     [License: LGPL (v2+)]
A  +105  -0    wallpapers/potd/metadata.desktop

http://commits.kde.org/kdeplasma-addons/8f1310dd1e9a780da967191335f8de84d46cc477

diff --git a/wallpapers/potd/contents/config/main.xml b/wallpapers/potd/contents/config/main.xml
new file mode 100644
index 0000000..152e0be
--- /dev/null
+++ b/wallpapers/potd/contents/config/main.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+      http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+  <kcfgfile name=""/>
+
+  <group name="General">
+    <entry name="Provider" type="String">
+      <label>Provider of Picture of the Day</label>
+      <default>apod</default>
+    </entry>
+    <entry name="FillMode" type="int">
+      <label>Sizing, cropping and positioning of the wallpaper image</label>
+      <default>0</default>
+    </entry>
+    <entry name="Color" type="Color">
+      <label>Color of the wallpaper</label>
+      <default>#000000</default>
+    </entry>
+  </group>
+
+</kcfg>
diff --git a/wallpapers/potd/contents/ui/config.qml b/wallpapers/potd/contents/ui/config.qml
new file mode 100644
index 0000000..012d7c7
--- /dev/null
+++ b/wallpapers/potd/contents/ui/config.qml
@@ -0,0 +1,167 @@
+/*
+ *   Copyright 2016 Weng Xuetian <wengxt@gmail.com>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Library General Public License as
+ *   published by the Free Software Foundation; either version 2 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 Library General Public License for more details
+ *
+ *   You should have received a copy of the GNU Library General Public
+ *   License along with this program; if not, write to the
+ *   Free Software Foundation, Inc.,
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+import QtQuick 2.5
+import QtQuick.Controls 1.0 as QtControls
+import QtQuick.Dialogs 1.1 as QtDialogs
+import org.kde.plasma.core 2.0 as PlasmaCore
+
+Column {
+    id: root
+    property string cfg_Provider
+    property int cfg_FillMode
+    property alias cfg_Color: colorDialog.color
+    ListModel {
+        id: providerModel
+    }
+
+    function populateProviders() {
+        providerModel.clear();
+        var providers = engine.data["Providers"];
+        if (providers) {
+            var provider;
+            for (provider in providers) {
+                providerModel.append({'id': provider, 'name': providers[provider]})
+            }
+        }
+    }
+
+    PlasmaCore.DataSource {
+        id: engine
+        engine: "potd"
+        connectedSources: ["Providers"]
+        onDataChanged: populateProviders()
+    }
+
+    Component.onCompleted: {
+        populateProviders()
+        for (var i = 0; i < providerModel.count; i++) {
+            if (providerModel.get(i)["id"] == wallpaper.configuration.Provider) {
+                providerComboBox.currentIndex = i;
+                break;
+            }
+        }
+    }
+
+    Row {
+        spacing: units.largeSpacing / 2
+        QtControls.Label {
+            width: formAlignment - units.largeSpacing
+            horizontalAlignment: Text.AlignRight
+            text: i18nd("plasma_applet_org.kde.potd", "Providers:")
+            anchors.verticalCenter: providerComboBox.verticalCenter
+        }
+        QtControls.ComboBox {
+            id: providerComboBox
+            property int textLength: 24
+            width: theme.mSize(theme.defaultFont).width * textLength
+            model: providerModel
+            textRole: "name"
+            onCurrentIndexChanged: {
+                cfg_Provider = providerModel.get(currentIndex)["id"]
+            }
+        }
+    }
+
+    Row {
+        //x: formAlignment - positionLabel.paintedWidth
+        spacing: units.largeSpacing / 2
+        QtControls.Label {
+            id: positionLabel
+            width: formAlignment - units.largeSpacing
+            anchors {
+                verticalCenter: resizeComboBox.verticalCenter
+            }
+            text: i18nd("plasma_applet_org.kde.potd", "Positioning:")
+            horizontalAlignment: Text.AlignRight
+        }
+        QtControls.ComboBox {
+            id: resizeComboBox
+            property int textLength: 24
+            width: theme.mSize(theme.defaultFont).width * textLength
+            model: [
+                        {
+                            'label': i18nd("plasma_applet_org.kde.potd", "Scaled and Cropped"),
+                            'fillMode': Image.PreserveAspectCrop
+                        },
+                        {
+                            'label': i18nd("plasma_applet_org.kde.potd","Scaled"),
+                            'fillMode': Image.Stretch
+                        },
+                        {
+                            'label': i18nd("plasma_applet_org.kde.potd","Scaled, Keep Proportions"),
+                            'fillMode': Image.PreserveAspectFit
+                        },
+                        {
+                            'label': i18nd("plasma_applet_org.kde.potd", "Centered"),
+                            'fillMode': Image.Pad
+                        },
+                        {
+                            'label': i18nd("plasma_applet_org.kde.potd","Tiled"),
+                            'fillMode': Image.Tile
+                        }
+                    ]
+
+            textRole: "label"
+            onCurrentIndexChanged: cfg_FillMode = model[currentIndex]["fillMode"]
+            Component.onCompleted: setMethod();
+
+            function setMethod() {
+                for (var i = 0; i < model.length; i++) {
+                    if (model[i]["fillMode"] == wallpaper.configuration.FillMode) {
+                        resizeComboBox.currentIndex = i;
+                        var tl = model[i]["label"].length;
+                    }
+                }
+            }
+        }
+    }
+
+    QtDialogs.ColorDialog {
+        id: colorDialog
+        modality: Qt.WindowModal
+        showAlphaChannel: false
+        title: i18nd("plasma_applet_org.kde.potd", "Select Background Color")
+    }
+
+    Row {
+        id: colorRow
+        spacing: units.largeSpacing / 2
+        QtControls.Label {
+            width: formAlignment - units.largeSpacing
+            anchors.verticalCenter: colorButton.verticalCenter
+            horizontalAlignment: Text.AlignRight
+            text: i18nd("plasma_applet_org.kde.potd", "Background Color:")
+        }
+        QtControls.Button {
+            id: colorButton
+            width: units.gridUnit * 3
+            text: " " // needed to it gets a proper height...
+            onClicked: colorDialog.open()
+
+            Rectangle {
+                id: colorRect
+                anchors.centerIn: parent
+                width: parent.width - 2 * units.smallSpacing
+                height: theme.mSize(theme.defaultFont).height
+                color: colorDialog.color
+            }
+        }
+    }
+}
diff --git a/wallpapers/potd/contents/ui/main.qml b/wallpapers/potd/contents/ui/main.qml
new file mode 100644
index 0000000..c986b52
--- /dev/null
+++ b/wallpapers/potd/contents/ui/main.qml
@@ -0,0 +1,49 @@
+/*
+ *   Copyright 2016 Weng Xuetian <wengxt@gmail.com>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Library General Public License as
+ *   published by the Free Software Foundation; either version 2 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 Library General Public License for more details
+ *
+ *   You should have received a copy of the GNU Library General Public
+ *   License along with this program; if not, write to the
+ *   Free Software Foundation, Inc.,
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+import QtQuick 2.5
+import org.kde.plasma.core 2.0 as PlasmaCore
+import org.kde.kquickcontrolsaddons 2.0
+
+Rectangle {
+    id: root
+
+    readonly property string provider: wallpaper.configuration.Provider
+
+    PlasmaCore.DataSource {
+        id: engine
+        engine: "potd"
+        connectedSources: [provider]
+    }
+
+    Rectangle {
+        id: backgroundColor
+        anchors.fill: parent
+        color: wallpaper.configuration.Color
+        Behavior on color {
+            ColorAnimation { duration: units.longDuration }
+        }
+    }
+
+    QImageItem {
+        anchors.fill: parent
+        image: engine.data[provider]["Image"]
+        fillMode: wallpaper.configuration.FillMode
+    }
+}
diff --git a/wallpapers/potd/metadata.desktop b/wallpapers/potd/metadata.desktop
new file mode 100644
index 0000000..94c3217
--- /dev/null
+++ b/wallpapers/potd/metadata.desktop
@@ -0,0 +1,105 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=Picture of the Day
+Name[ar]=صورة اليوم
+Name[ast]=Imaxe del día
+Name[bs]=Slika dana
+Name[ca]=Imatge del dia
+Name[ca@valencia]=Imatge del dia
+Name[cs]=Obrázek dne
+Name[da]=Dagens billede
+Name[de]=Bild des Tages
+Name[el]=Φωτογραφία της ημέρας
+Name[en_GB]=Picture of the Day
+Name[es]=Imagen del día
+Name[et]=Päevapilt
+Name[fi]=Päivän kuva
+Name[fr]=Image du jour
+Name[ga]=Grianghraf an Lae
+Name[gl]=Imaxe do día
+Name[hr]=Slika dana
+Name[hu]=A nap képe
+Name[is]=Myndir dagsins
+Name[it]=Immagine del giorno
+Name[ja]=今日の写真
+Name[kk]=Тәулік суреті
+Name[km]=រូបភាព​ប្រចាំ​ថ្ងៃ
+Name[ko]=오늘의 그림
+Name[lt]=Dienos paveiksliukas
+Name[lv]=Dienas attēls
+Name[mr]=दिवसाचे चित्र
+Name[nb]=Dagens bilde
+Name[nds]=Bild för Vundaag
+Name[nl]=Afbeelding van de dag
+Name[nn]=Dagens bilete
+Name[pa]=ਅੱਜ ਦੀ ਤਸਵੀਰ
+Name[pl]=Obraz dnia
+Name[pt]=Imagem do Dia
+Name[pt_BR]=Imagem do dia
+Name[ro]=Imaginea zilei
+Name[ru]=Изображение дня
+Name[sk]=Obrázok dňa
+Name[sl]=Slika dneva
+Name[sr]=слика дана
+Name[sr@ijekavian]=слика дана
+Name[sr@ijekavianlatin]=slika dana
+Name[sr@latin]=slika dana
+Name[sv]=Dagens bild
+Name[tr]=Günün Resmi
+Name[uk]=Картинка дня
+Name[wa]=Imådje do djoû
+Name[x-test]=xxPicture of the Dayxx
+Name[zh_CN]=每日一图
+Name[zh_TW]=本日圖片
+Comment=A new picture from the Internet each day
+Comment[ar]=صورة من السابكة كل يوم
+Comment[bs]=Nova slika sa Interneta svaki dan
+Comment[ca]=Una imatge nova des d'Internet cada dia
+Comment[ca@valencia]=Una imatge nova des d'Internet cada dia
+Comment[cs]=Nový obrázek z internetu denně
+Comment[da]=Et nyt billede fra internettet hver dag
+Comment[de]=Täglich ein Bild aus dem Internet anzeigen
+Comment[el]=Κάθε μέρα μια νέα εικόνα από το διαδίκτυο
+Comment[en_GB]=A new picture from the Internet each day
+Comment[es]=Una nueva imagen desde Internet cada día
+Comment[et]=Iga päev uus pilt internetist
+Comment[fi]=Joka päivä uusi kuva Internetistä
+Comment[fr]=Une nouvelle image chaque jour provenant d'Internet
+Comment[gl]=Mostra imaxes de internet cada día.
+Comment[hu]=Minden nap új kép az internetről
+Comment[it]=Una nuova immagine ogni giorno da Internet.
+Comment[kk]=Күнде Интернеттен жаңа сурет
+Comment[ko]=인터넷에서 매일 새 그림 가 오기
+Comment[nb]=Et nytt bilde  fra Internett hver dag
+Comment[nds]=Elk Dag en nieg Bild ut dat Internet halen
+Comment[nl]=Elke dag een nieuw plaatje uit het internet
+Comment[nn]=Eit nytt bilete  frå Internett kvar dag
+Comment[pl]=Każdego dnia nowe zdjęcie z internetu
+Comment[pt]=Uma nova imagem diária da Internet
+Comment[pt_BR]=Uma nova imagem diária da Internet
+Comment[ro]=O nouă imagine din Internet în fiecare zi
+Comment[ru]=Новое изображение из Интернета каждый день
+Comment[sk]=Nový obrázok z Internetu každý deň
+Comment[sl]=Nova slika z interneta vsak dan
+Comment[sr]=Сваки дан нова слика са Интернета
+Comment[sr@ijekavian]=Сваки дан нова слика са Интернета
+Comment[sr@ijekavianlatin]=Svaki dan nova slika sa Interneta
+Comment[sr@latin]=Svaki dan nova slika sa Interneta
+Comment[sv]=En ny bild från Internet varje dag
+Comment[tr]=Her gün İnternet'ten yeni bir resim göster
+Comment[uk]=Нове зображення з інтернету щодня
+Comment[x-test]=xxA new picture from the Internet each dayxx
+Comment[zh_CN]=每天从互联网获取新图片
+Comment[zh_TW]=網際網路上的每日新圖片
+
+Type=Service
+ServiceTypes=Plasma/Wallpaper
+Icon=office-calendar
+X-Plasma-MainScript=ui/main.qml
+X-KDE-PluginInfo-Author=Weng Xuetian
+X-KDE-PluginInfo-Email=wengxt@gmail.com
+X-KDE-PluginInfo-Name=org.kde.potd
+X-KDE-PluginInfo-Version=1.0
+X-KDE-PluginInfo-Website=http://kde.org/
+X-KDE-PluginInfo-License=LGPL
+X-KDE-PluginInfo-EnabledByDefault=true
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic