Warning, /plasma/kdeplasma-addons/wallpapers/potd/package/contents/ui/config.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Weng Xuetian <wengxt@gmail.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.5 0008 import QtQuick.Controls 2.8 as QQC2 0009 import QtQuick.Layouts 1.15 0010 import QtQuick.Window 2.15 0011 0012 import org.kde.kcmutils as KCM 0013 import org.kde.kquickcontrols 2.0 as KQC2 0014 import org.kde.kirigami 2.20 as Kirigami 0015 0016 import org.kde.plasma.wallpapers.potd 1.0 0017 0018 Kirigami.FormLayout { 0019 id: root 0020 twinFormLayouts: parentLayout 0021 0022 property string cfg_Provider 0023 property int cfg_FillMode 0024 property alias cfg_Color: colorButton.color 0025 property int cfg_UpdateOverMeteredConnection 0026 property alias formLayout: root 0027 0028 PotdBackend { 0029 id: backend 0030 identifier: cfg_Provider 0031 arguments: { 0032 if (identifier === "bing") { 0033 // Bing supports 1366/1920/UHD resolutions 0034 const w = Screen.width * Screen.devicePixelRatio > 1920 ? 3840 : 1920; 0035 const h = Screen.height * Screen.devicePixelRatio > 1080 ? 2160 : 1080; 0036 return [w, h]; 0037 } 0038 return []; 0039 } 0040 updateOverMeteredConnection: wallpaper.configuration.UpdateOverMeteredConnection 0041 } 0042 0043 Row { 0044 Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Provider:") 0045 0046 QQC2.ComboBox { 0047 id: providerComboBox 0048 model: PotdProviderModel { } 0049 currentIndex: model.indexOf(cfg_Provider) 0050 textRole: "display" 0051 valueRole: "id" 0052 onCurrentValueChanged: { 0053 if (currentIndex < 0) { 0054 return; 0055 } 0056 cfg_Provider = currentValue; 0057 } 0058 } 0059 0060 KCM.ContextualHelpButton { 0061 anchors.verticalCenter: providerComboBox.verticalCenter 0062 visible: providerComboBox.model.isNSFW(providerComboBox.currentIndex) 0063 toolTipText: i18ndc("plasma_wallpaper_org.kde.potd", "@info:tooltip", "This wallpaper provider does not filter out images that may be sensitive or objectionable. Use caution if these images will be displayed in public.") 0064 } 0065 } 0066 0067 QQC2.CheckBox { 0068 id: updateOverMeteredConnectionCheckBox 0069 0070 checked: root.cfg_UpdateOverMeteredConnection === 1 0071 visible: backend.networkInfomationAvailable 0072 text: i18ndc("plasma_wallpaper_org.kde.potd", "@option:check", "Update when using metered network connection") 0073 0074 onToggled: { 0075 root.cfg_UpdateOverMeteredConnection = checked ? 1 : 0; 0076 } 0077 } 0078 0079 QQC2.ComboBox { 0080 id: resizeComboBox 0081 Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:listbox", "Positioning:") 0082 model: [ 0083 { 0084 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled and Cropped"), 0085 'fillMode': Image.PreserveAspectCrop 0086 }, 0087 { 0088 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled"), 0089 'fillMode': Image.Stretch 0090 }, 0091 { 0092 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Scaled, Keep Proportions"), 0093 'fillMode': Image.PreserveAspectFit 0094 }, 0095 { 0096 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Centered"), 0097 'fillMode': Image.Pad 0098 }, 0099 { 0100 'label': i18ndc("plasma_wallpaper_org.kde.potd", "@item:inlistbox", "Tiled"), 0101 'fillMode': Image.Tile 0102 } 0103 ] 0104 0105 textRole: "label" 0106 onCurrentIndexChanged: cfg_FillMode = model[currentIndex]["fillMode"] 0107 Component.onCompleted: setMethod(); 0108 0109 function setMethod() { 0110 for (var i = 0; i < model.length; i++) { 0111 if (model[i]["fillMode"] == wallpaper.configuration.FillMode) { 0112 resizeComboBox.currentIndex = i; 0113 var tl = model[i]["label"].length; 0114 } 0115 } 0116 } 0117 } 0118 0119 KQC2.ColorButton { 0120 id: colorButton 0121 Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label:chooser", "Background color:") 0122 dialogTitle: i18ndc("plasma_wallpaper_org.kde.potd", "@title:window", "Select Background Color") 0123 } 0124 0125 Kirigami.Separator { 0126 id: previewSeparator 0127 Kirigami.FormData.isSection: true 0128 visible: wallpaperPreview.visible 0129 } 0130 0131 WallpaperPreview { 0132 id: wallpaperPreview 0133 Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label", "Today's picture:") 0134 backgroundColor: root.cfg_Color 0135 visible: !!wallpaper.configuration.Provider 0136 } 0137 0138 Item { 0139 width: wallpaperPreview.implicitWidth 0140 height: wallpaperPreview.shadowOffset 0141 } 0142 0143 Item { 0144 Kirigami.FormData.isSection: false 0145 } 0146 0147 Kirigami.SelectableLabel { 0148 id: titleLabel 0149 Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label", "Title:") 0150 Layout.fillWidth: true 0151 Layout.maximumWidth: wallpaperPreview.implicitWidth * 1.5 0152 visible: wallpaperPreview.visible && backend.title.length > 0 0153 font.bold: true 0154 text: backend.title 0155 Accessible.name: titleLabel.Kirigami.FormData.label 0156 } 0157 0158 Item { 0159 Kirigami.FormData.isSection: false 0160 } 0161 0162 Kirigami.SelectableLabel { 0163 id: authorLabel 0164 Kirigami.FormData.label: i18ndc("plasma_wallpaper_org.kde.potd", "@label", "Author:") 0165 Layout.fillWidth: true 0166 Layout.maximumWidth: wallpaperPreview.implicitWidth * 1.5 0167 visible: wallpaperPreview.visible && backend.author.length > 0 0168 text: backend.author 0169 Accessible.name: authorLabel.Kirigami.FormData.label 0170 } 0171 0172 Kirigami.InlineMessage { 0173 id: saveMessage 0174 0175 Kirigami.FormData.isSection: true 0176 Layout.fillWidth: true 0177 0178 showCloseButton: true 0179 0180 actions: [ 0181 Kirigami.Action { 0182 icon.name: "document-open-folder" 0183 text: i18ndc("plasma_wallpaper_org.kde.potd", "@action:button", "Open Containing Folder") 0184 visible: backend.saveStatus === Global.Successful 0185 onTriggered: Qt.openUrlExternally(backend.savedFolder) 0186 0187 Accessible.description: i18ndc("plasma_wallpaper_org.kde.potd", "@info:whatsthis for a button", "Open the destination folder where the wallpaper image was saved.") 0188 } 0189 ] 0190 0191 onLinkActivated: Qt.openUrlExternally(backend.savedUrl) 0192 0193 Connections { 0194 target: backend 0195 0196 function onSaveStatusChanged() { 0197 switch (backend.saveStatus) { 0198 case Global.Successful: 0199 saveMessage.text = backend.saveStatusMessage; 0200 saveMessage.type = Kirigami.MessageType.Positive; 0201 break; 0202 case Global.Failed: 0203 saveMessage.text = backend.saveStatusMessage; 0204 saveMessage.type = Kirigami.MessageType.Error; 0205 break; 0206 default: 0207 return; 0208 } 0209 0210 saveMessage.visible = true; 0211 } 0212 } 0213 } 0214 }