Warning, /plasma/plasma-desktop/containments/desktop/package/contents/ui/ConfigIcons.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2014 Eike Hein <hein@kde.org>
0003     SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 import QtQuick
0009 import QtQuick.Controls 2.15
0010 import QtQuick.Layouts 1.15
0011 
0012 import org.kde.plasma.plasmoid 2.0
0013 import org.kde.plasma.core as PlasmaCore
0014 import org.kde.plasma.extras 2.0 as PlasmaExtras
0015 import org.kde.iconthemes as KIconThemes
0016 import org.kde.config // for KAuthorized
0017 import org.kde.kirigami 2.20 as Kirigami
0018 
0019 import org.kde.private.desktopcontainment.folder 0.1 as Folder
0020 
0021 Item {
0022     id: configIcons
0023 
0024     property bool isPopup: (Plasmoid.location !== PlasmaCore.Types.Floating)
0025 
0026     property string cfg_icon: Plasmoid.configuration.icon
0027     property alias cfg_useCustomIcon: useCustomIcon.checked
0028     property alias cfg_arrangement: arrangement.currentIndex
0029     property alias cfg_alignment: alignment.currentIndex
0030     property bool cfg_locked
0031     property alias cfg_sortMode: sortMode.mode
0032     property alias cfg_sortDesc: sortDesc.checked
0033     property alias cfg_sortDirsFirst: sortDirsFirst.checked
0034     property alias cfg_toolTips: toolTips.checked
0035     property alias cfg_selectionMarkers: selectionMarkers.checked
0036     property alias cfg_renameInline: renameInline.checked
0037     property alias cfg_popups: popups.checked
0038     property alias cfg_previews: previews.checked
0039     property var cfg_previewPlugins
0040     property alias cfg_viewMode: viewMode.currentIndex
0041     property alias cfg_iconSize: iconSize.value
0042     property alias cfg_labelWidth: labelWidth.currentIndex
0043     property alias cfg_textLines: textLines.value
0044 
0045     readonly property bool lockedByKiosk: !KAuthorized.authorize("editable_desktop_icons")
0046 
0047     KIconThemes.IconDialog {
0048         id: iconDialog
0049         onIconNameChanged: cfg_icon = iconName || "folder-symbolic";
0050     }
0051 
0052     Kirigami.FormLayout {
0053         anchors {
0054             top: parent.top
0055             left: parent.left
0056             right: parent.right
0057         }
0058 
0059         // Panel button
0060         RowLayout {
0061             spacing: Kirigami.Units.smallSpacing
0062             visible: isPopup
0063 
0064             Kirigami.FormData.label: i18n("Panel button:")
0065 
0066             CheckBox {
0067                 id: useCustomIcon
0068                 visible: isPopup
0069                 checked: cfg_useCustomIcon
0070                 text: i18n("Use a custom icon")
0071             }
0072 
0073             Button {
0074                 id: iconButton
0075                 Layout.minimumWidth: Kirigami.Units.iconSizes.large + Kirigami.Units.smallSpacing * 2
0076                 Layout.maximumWidth: Layout.minimumWidth
0077                 Layout.minimumHeight: Layout.minimumWidth
0078                 Layout.maximumHeight: Layout.minimumWidth
0079 
0080                 checkable: true
0081                 enabled: useCustomIcon.checked
0082 
0083                 onClicked: {
0084                     checked = Qt.binding(() =>
0085                         iconMenu.status === PlasmaExtras.Menu.Open);
0086 
0087                     iconMenu.open(0, height);
0088                 }
0089 
0090                 Kirigami.Icon {
0091                     anchors.centerIn: parent
0092                     width: Kirigami.Units.iconSizes.large
0093                     height: width
0094                     source: cfg_icon
0095                 }
0096             }
0097 
0098             PlasmaExtras.Menu {
0099                 id: iconMenu
0100                 visualParent: iconButton
0101 
0102                 PlasmaExtras.MenuItem {
0103                     text: i18nc("@item:inmenu Open icon chooser dialog", "Choose…")
0104                     icon: "document-open-folder"
0105                     onClicked: iconDialog.open()
0106                 }
0107 
0108                 PlasmaExtras.MenuItem {
0109                     text: i18nc("@item:inmenu Reset icon to default", "Clear Icon")
0110                     icon: "edit-clear"
0111                     onClicked: cfg_icon = "folder-symbolic";
0112                 }
0113             }
0114         }
0115 
0116         Item {
0117             visible: isPopup
0118             Kirigami.FormData.isSection: true
0119         }
0120 
0121 
0122 
0123         // Arrangement section
0124         ComboBox {
0125             id: arrangement
0126             Layout.fillWidth: true
0127             visible: !isPopup || viewMode.currentIndex === 1 /* Icons mode */
0128 
0129             Kirigami.FormData.label: i18n("Arrangement:")
0130 
0131             model: [
0132                 Qt.application.layoutDirection === Qt.LeftToRight ?
0133                     i18nc("@item:inlistbox arrangement of icons", "Left to Right") :
0134                     i18nc("@item:inlistbox arrangement of icons", "Right to Left"),
0135                 i18nc("@item:inlistbox arrangement of icons", "Top to Bottom"),
0136             ]
0137         }
0138 
0139         ComboBox {
0140             id: alignment
0141             Layout.fillWidth: true
0142             visible: !isPopup || viewMode.currentIndex === 1 /* Icons mode */
0143 
0144             model: [i18nc("@item:inlistbox alignment of icons", "Align left"),
0145                     i18nc("@item:inlistbox alignment of icons", "Align right")]
0146         }
0147 
0148         CheckBox {
0149             id: locked
0150             visible: ("containmentType" in plasmoid)
0151             checked: cfg_locked || lockedByKiosk
0152             enabled: !lockedByKiosk
0153 
0154             onCheckedChanged: {
0155                 if (!lockedByKiosk) {
0156                     cfg_locked = checked;
0157                 }
0158             }
0159 
0160             text: i18n("Lock in place")
0161         }
0162 
0163         Item {
0164             Kirigami.FormData.isSection: true
0165             visible: !isPopup || viewMode.currentIndex === 1 /* Icons mode */
0166         }
0167 
0168 
0169         // Sorting section
0170         ComboBox {
0171             id: sortMode
0172             Layout.fillWidth: true
0173 
0174             Kirigami.FormData.label: i18n("Sorting:")
0175 
0176             property int mode
0177             // FIXME TODO HACK: This maps the combo box list model to the KDirModel::ModelColumns
0178             // enum, which should be done in C++.
0179             property var indexToMode: [-1, 0, 1, 6, 2]
0180             property var modeToIndex: {'-1': '0', '0': '1', '1': '2', '6': '3', '2': '4'}
0181 
0182             model: [i18nc("@item:inlistbox sort icons manually", "Manual"),
0183                     i18nc("@item:inlistbox sort icons by name", "Name"),
0184                     i18nc("@item:inlistbox sort icons by size", "Size"),
0185                     i18nc("@item:inlistbox sort icons by file type", "Type"),
0186                     i18nc("@item:inlistbox sort icons by date", "Date")]
0187 
0188             Component.onCompleted: currentIndex = modeToIndex[mode]
0189             onActivated: mode = indexToMode[index]
0190         }
0191 
0192         CheckBox {
0193             id: sortDesc
0194 
0195             enabled: sortMode.currentIndex !== 0
0196 
0197             text: i18nc("@option:check sort icons in descending order", "Descending")
0198         }
0199 
0200         CheckBox {
0201             id: sortDirsFirst
0202 
0203             enabled: sortMode.currentIndex !== 0
0204 
0205             text: i18nc("@option:check sort icons with folders first", "Folders first")
0206         }
0207 
0208         Item {
0209             Kirigami.FormData.isSection: true
0210         }
0211 
0212 
0213         // View Mode section (only if we're a pop-up)
0214         ComboBox {
0215             id: viewMode
0216             visible: isPopup
0217             Layout.fillWidth: true
0218 
0219             Kirigami.FormData.label: i18nc("whether to use icon or list view", "View mode:")
0220 
0221             model: [i18nc("@item:inlistbox show icons in a list", "List"),
0222                     i18nc("@item:inlistbox show icons in a grid", "Grid")]
0223         }
0224 
0225 
0226         // Size section
0227         Slider {
0228             id: iconSize
0229 
0230             Layout.fillWidth: true
0231             visible: !isPopup || viewMode.currentIndex === 1 /* Icons mode */
0232 
0233             Kirigami.FormData.label: i18n("Icon size:")
0234 
0235             from: 0
0236             to: 6
0237             stepSize: 1
0238             snapMode: Slider.SnapAlways
0239         }
0240 
0241         RowLayout {
0242             Layout.fillWidth: true
0243 
0244             Label {
0245                 Layout.alignment: Qt.AlignLeft
0246                 visible: !isPopup || viewMode.currentIndex === 1 /* Icons mode */
0247 
0248                 text: i18nc("@label:slider smallest icon size", "Small")
0249             }
0250             Item {
0251                 Layout.fillWidth: true
0252             }
0253             Label {
0254                 Layout.alignment: Qt.AlignRight
0255                 visible: !isPopup || viewMode.currentIndex === 1 /* Icons mode */
0256 
0257                 text: i18nc("@label:slider largest icon size", "Large")
0258             }
0259         }
0260 
0261         ComboBox {
0262             id: labelWidth
0263             visible: !isPopup || viewMode.currentIndex === 1 /* Icons mode */
0264             Layout.fillWidth: true
0265 
0266             Kirigami.FormData.label: i18n("Label width:")
0267 
0268             model: [
0269                 i18nc("@item:inlistbox how long a text label should be", "Narrow"),
0270                 i18nc("@item:inlistbox how long a text label should be", "Medium"),
0271                 i18nc("@item:inlistbox how long a text label should be", "Wide"),
0272             ]
0273         }
0274 
0275         SpinBox {
0276             id: textLines
0277             visible: !isPopup || viewMode.currentIndex === 1 /* Icons mode */
0278 
0279             Kirigami.FormData.label: i18n("Text lines:")
0280 
0281             from: 1
0282             to: 10
0283             stepSize: 1
0284         }
0285 
0286         Item {
0287             Kirigami.FormData.isSection: true
0288         }
0289 
0290 
0291         // Features section
0292         CheckBox {
0293             id: toolTips
0294 
0295             Kirigami.FormData.label: i18n("When hovering over icons:")
0296 
0297             text: i18n("Show tooltips")
0298         }
0299 
0300         CheckBox {
0301             id: selectionMarkers
0302             visible: Qt.styleHints.singleClickActivation
0303 
0304             text: i18n("Show selection markers")
0305         }
0306 
0307         CheckBox {
0308             id: popups
0309             visible: !isPopup
0310 
0311             text: i18n("Show folder preview popups")
0312         }
0313 
0314         Item {
0315             Kirigami.FormData.isSection: true
0316         }
0317 
0318         CheckBox {
0319             id: renameInline
0320 
0321             Kirigami.FormData.label: i18n("Rename:")
0322 
0323             visible: !selectionMarkers.visible
0324 
0325             text: i18n("Rename inline by clicking selected item's text")
0326         }
0327 
0328         Item {
0329             Kirigami.FormData.isSection: true
0330             visible: renameInline.visible
0331         }
0332 
0333         CheckBox {
0334             id: previews
0335 
0336             Kirigami.FormData.label: i18n("Previews:")
0337 
0338             text: i18n("Show preview thumbnails")
0339         }
0340 
0341         Button {
0342             id: previewSettings
0343             Layout.fillWidth: true
0344 
0345             icon.name: "configure"
0346             text: i18n("Configure Preview Plugins…")
0347 
0348             onClicked: {
0349                 const component = Qt.createComponent(Qt.resolvedUrl("FolderItemPreviewPluginsDialog.qml"));
0350                 component.incubateObject(configIcons.Window.window.contentItem, {
0351                     "previewPlugins": configIcons.cfg_previewPlugins,
0352                 }, Qt.Asynchronous);
0353                 component.destroy();
0354             }
0355         }
0356     }
0357 }