diff --git a/wallpapers/potd/contents/ui/config.qml b/wallpapers/potd/contents/ui/config.qml index 72e82873c..97fc1824a 100644 --- a/wallpapers/potd/contents/ui/config.qml +++ b/wallpapers/potd/contents/ui/config.qml @@ -1,265 +1,246 @@ /* * Copyright 2016 Weng Xuetian * * 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.4 as QQC1 -import org.kde.kquickcontrols 2.0 as KQuickControls +import QtQuick.Controls 2.8 as QQC2 +import org.kde.kquickcontrols 2.0 as KQC2 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.kirigami 2.5 as Kirigami Kirigami.FormLayout { id: root twinFormLayouts: parentLayout - anchors.left: parent.left - anchors.right: parent.right property string cfg_Provider property string cfg_Category property int cfg_FillMode property alias cfg_Color: colorButton.color property alias formLayout: root 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; } } } - // TODO: port to QQC2 version once we've fixed https://bugs.kde.org/show_bug.cgi?id=403153 - QQC1.ComboBox { + + QQC2.ComboBox { id: providerComboBox - TextMetrics { - id: providerTextMetrics - text: providerComboBox.currentText - } - implicitWidth: Math.max(providerTextMetrics.width + Kirigami.Units.gridUnit * 2 + Kirigami.Units.smallSpacing * 2, pluginComboBox.width) //QQC1 Combobox default sizing is broken Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Provider:") model: providerModel textRole: "name" onCurrentIndexChanged: { cfg_Provider = providerModel.get(currentIndex)["id"] } } - - // TODO: port to QQC2 version once we've fixed https://bugs.kde.org/show_bug.cgi?id=403153 - QQC1.ComboBox { + + QQC2.ComboBox { id: categoryComboBox visible: cfg_Provider === 'unsplash' - TextMetrics { - id: categoryTextMetrics - text: categoryComboBox.currentText - } - implicitWidth: Math.max(providerTextMetrics.width + Kirigami.Units.gridUnit * 2 + Kirigami.Units.smallSpacing * 2, pluginComboBox.width) //QQC1 Combobox default sizing is broken Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Category:") model: [ { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "All"), 'value': '1065976' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "1080p"), 'value': '1339107' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "4K"), 'value': '1339090' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Ultra Wide"), 'value': '1339089' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Background"), 'value': '1339276' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Lock Screen"), 'value': '1339070' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Nature"), 'value': '1065376' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Tumblr"), 'value': '1111644' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Black"), 'value': '1101680' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Flower"), 'value': '1100232' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Funny"), 'value': '1111682' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Cute"), 'value': '1111680' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Cool"), 'value': '1111678' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Fall"), 'value': '1100229' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Love"), 'value': '1066280' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Design"), 'value': '1066276' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Christmas"), 'value': '1066273' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Travel"), 'value': '1065428' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Beach"), 'value': '1065423' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Car"), 'value': '1065408' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Sports"), 'value': '1065402' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Animal"), 'value': '1065390' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "People"), 'value': '1065386' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Music"), 'value': '1065384' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Summer"), 'value': '1065380' }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Galaxy"), 'value': '1065374' }, ] textRole: "label" onCurrentIndexChanged: { cfg_Category = model[currentIndex]["value"] } Component.onCompleted: { for (var i = 0; i < model.length; i++) { if (model[i]["value"] == wallpaper.configuration.Category) { categoryComboBox.currentIndex = i; } } } } - // TODO: port to QQC2 version once we've fixed https://bugs.kde.org/show_bug.cgi?id=403153 - QQC1.ComboBox { + QQC2.ComboBox { id: resizeComboBox - TextMetrics { - id: resizeTextMetrics - text: resizeComboBox.currentText - } - implicitWidth: Math.max(resizeTextMetrics.width + Kirigami.Units.gridUnit * 2 + Kirigami.Units.smallSpacing * 2, pluginComboBox.width) //QQC1 Combobox default sizing is broken Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Positioning:") model: [ { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled and Cropped"), 'fillMode': Image.PreserveAspectCrop }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled"), 'fillMode': Image.Stretch }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled, Keep Proportions"), 'fillMode': Image.PreserveAspectFit }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Centered"), 'fillMode': Image.Pad }, { 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "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; } } } } - KQuickControls.ColorButton { + KQC2.ColorButton { id: colorButton Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:chooser", "Background color:") dialogTitle: i18ndc("plasma_wallpaper_org.kde.potd", "@title:window", "Select Background Color") } }