Warning, /plasma/plasma-desktop/applets/kicker/package/contents/ui/ConfigGeneral.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2014 Eike Hein <hein@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 import QtQuick.Controls 2.15 0009 0010 import org.kde.draganddrop 2.0 as DragDrop 0011 import org.kde.kirigami 2.5 as Kirigami 0012 import org.kde.iconthemes as KIconThemes 0013 import org.kde.plasma.core as PlasmaCore 0014 import org.kde.kirigami 2.20 as Kirigami 0015 import org.kde.ksvg 1.0 as KSvg 0016 import org.kde.plasma.plasmoid 2.0 0017 import org.kde.kcmutils as KCM 0018 0019 KCM.SimpleKCM { 0020 id: configGeneral 0021 0022 property bool isDash: (Plasmoid.pluginName === "org.kde.plasma.kickerdash") 0023 0024 property string cfg_icon: Plasmoid.configuration.icon 0025 property bool cfg_useCustomButtonImage: Plasmoid.configuration.useCustomButtonImage 0026 property string cfg_customButtonImage: Plasmoid.configuration.customButtonImage 0027 0028 property alias cfg_appNameFormat: appNameFormat.currentIndex 0029 property alias cfg_limitDepth: limitDepth.checked 0030 property alias cfg_alphaSort: alphaSort.checked 0031 property alias cfg_showIconsRootLevel: showIconsRootLevel.checked 0032 0033 property alias cfg_recentOrdering: recentOrdering.currentIndex 0034 property alias cfg_showRecentApps: showRecentApps.checked 0035 property alias cfg_showRecentDocs: showRecentDocs.checked 0036 0037 property alias cfg_useExtraRunners: useExtraRunners.checked 0038 property alias cfg_alignResultsToBottom: alignResultsToBottom.checked 0039 0040 Kirigami.FormLayout { 0041 anchors.left: parent.left 0042 anchors.right: parent.right 0043 0044 Button { 0045 id: iconButton 0046 0047 Kirigami.FormData.label: i18n("Icon:") 0048 0049 implicitWidth: previewFrame.width + Kirigami.Units.smallSpacing * 2 0050 implicitHeight: previewFrame.height + Kirigami.Units.smallSpacing * 2 0051 0052 // Just to provide some visual feedback when dragging; 0053 // cannot have checked without checkable enabled 0054 checkable: true 0055 checked: dropArea.containsAcceptableDrag 0056 0057 onPressed: iconMenu.opened ? iconMenu.close() : iconMenu.open() 0058 0059 DragDrop.DropArea { 0060 id: dropArea 0061 0062 property bool containsAcceptableDrag: false 0063 0064 anchors.fill: parent 0065 0066 onDragEnter: { 0067 // Cannot use string operations (e.g. indexOf()) on "url" basic type. 0068 var urlString = event.mimeData.url.toString(); 0069 0070 // This list is also hardcoded in KIconDialog. 0071 var extensions = [".png", ".xpm", ".svg", ".svgz"]; 0072 containsAcceptableDrag = urlString.indexOf("file:///") === 0 && extensions.some(function (extension) { 0073 return urlString.indexOf(extension) === urlString.length - extension.length; // "endsWith" 0074 }); 0075 0076 if (!containsAcceptableDrag) { 0077 event.ignore(); 0078 } 0079 } 0080 onDragLeave: containsAcceptableDrag = false 0081 0082 onDrop: { 0083 if (containsAcceptableDrag) { 0084 // Strip file:// prefix, we already verified in onDragEnter that we have only local URLs. 0085 iconDialog.setCustomButtonImage(event.mimeData.url.toString().substr("file://".length)); 0086 } 0087 containsAcceptableDrag = false; 0088 } 0089 } 0090 0091 KIconThemes.IconDialog { 0092 id: iconDialog 0093 0094 function setCustomButtonImage(image) { 0095 configGeneral.cfg_customButtonImage = image || configGeneral.cfg_icon || "start-here-kde-symbolic" 0096 configGeneral.cfg_useCustomButtonImage = true; 0097 } 0098 0099 onIconNameChanged: setCustomButtonImage(iconName); 0100 } 0101 0102 KSvg.FrameSvgItem { 0103 id: previewFrame 0104 anchors.centerIn: parent 0105 imagePath: Plasmoid.location === PlasmaCore.Types.Vertical || Plasmoid.location === PlasmaCore.Types.Horizontal 0106 ? "widgets/panel-background" : "widgets/background" 0107 width: Kirigami.Units.iconSizes.large + fixedMargins.left + fixedMargins.right 0108 height: Kirigami.Units.iconSizes.large + fixedMargins.top + fixedMargins.bottom 0109 0110 Kirigami.Icon { 0111 anchors.centerIn: parent 0112 width: Kirigami.Units.iconSizes.large 0113 height: width 0114 source: configGeneral.cfg_useCustomButtonImage ? configGeneral.cfg_customButtonImage : configGeneral.cfg_icon 0115 } 0116 } 0117 0118 Menu { 0119 id: iconMenu 0120 0121 // Appear below the button 0122 y: +parent.height 0123 0124 onClosed: iconButton.checked = false; 0125 0126 MenuItem { 0127 text: i18nc("@item:inmenu Open icon chooser dialog", "Choose…") 0128 icon.name: "document-open-folder" 0129 onClicked: iconDialog.open() 0130 } 0131 MenuItem { 0132 text: i18nc("@item:inmenu Reset icon to default", "Clear Icon") 0133 icon.name: "edit-clear" 0134 onClicked: { 0135 configGeneral.cfg_icon = "start-here-kde-symbolic" 0136 configGeneral.cfg_useCustomButtonImage = false 0137 } 0138 } 0139 } 0140 } 0141 0142 0143 Item { 0144 Kirigami.FormData.isSection: true 0145 } 0146 0147 ComboBox { 0148 id: appNameFormat 0149 0150 Kirigami.FormData.label: i18n("Show applications as:") 0151 0152 model: [i18n("Name only"), i18n("Description only"), i18n("Name (Description)"), i18n("Description (Name)")] 0153 } 0154 0155 Item { 0156 Kirigami.FormData.isSection: true 0157 } 0158 0159 CheckBox { 0160 id: alphaSort 0161 0162 Kirigami.FormData.label: i18n("Behavior:") 0163 0164 text: i18n("Sort applications alphabetically") 0165 } 0166 0167 CheckBox { 0168 id: limitDepth 0169 0170 visible: !isDash 0171 0172 text: i18n("Flatten sub-menus to a single level") 0173 } 0174 0175 CheckBox { 0176 id: showIconsRootLevel 0177 0178 visible: !configGeneral.isDash 0179 0180 text: i18n("Show icons on the root level of the menu") 0181 } 0182 0183 Item { 0184 Kirigami.FormData.isSection: true 0185 } 0186 0187 CheckBox { 0188 id: showRecentApps 0189 0190 Kirigami.FormData.label: i18n("Show categories:") 0191 0192 text: recentOrdering.currentIndex == 0 0193 ? i18n("Recent applications") 0194 : i18n("Often used applications") 0195 } 0196 0197 CheckBox { 0198 id: showRecentDocs 0199 0200 text: recentOrdering.currentIndex == 0 0201 ? i18n("Recent files") 0202 : i18n("Often used files") 0203 } 0204 0205 ComboBox { 0206 id: recentOrdering 0207 0208 Kirigami.FormData.label: i18n("Sort items in categories by:") 0209 model: [i18nc("@item:inlistbox Sort items in categories by [Recently used | Often used]", "Recently used"), i18nc("@item:inlistbox Sort items in categories by [Recently used | Ofetn used]", "Often used")] 0210 } 0211 0212 Item { 0213 Kirigami.FormData.isSection: true 0214 } 0215 0216 CheckBox { 0217 id: useExtraRunners 0218 0219 Kirigami.FormData.label: i18n("Search:") 0220 0221 text: i18n("Expand search to bookmarks, files and emails") 0222 } 0223 0224 CheckBox { 0225 id: alignResultsToBottom 0226 0227 visible: !configGeneral.isDash 0228 0229 text: i18n("Align search results to bottom") 0230 } 0231 } 0232 }