Warning, /plasma/plasma-workspace/applets/clipboard/contents/ui/main.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
0003     SPDX-FileCopyrightText: 2014 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.Layouts 1.1
0010 import QtQuick.Controls 2.15 as QQC2 // For StackView
0011 import org.kde.plasma.plasmoid 2.0
0012 import org.kde.plasma.core as PlasmaCore
0013 import org.kde.ksvg 1.0 as KSvg
0014 import org.kde.plasma.plasma5support 2.0 as P5Support
0015 import org.kde.plasma.extras 2.0 as PlasmaExtras
0016 import org.kde.kirigami 2.20 as Kirigami
0017 
0018 PlasmoidItem {
0019     id: main
0020 
0021     property bool isClipboardEmpty: clipboardSource.data["clipboard"]["empty"]
0022     property bool editing: false
0023     property alias clearHistoryAction: clearAction
0024 
0025     signal clearSearchField
0026 
0027     switchWidth: Kirigami.Units.gridUnit * 5
0028     switchHeight: Kirigami.Units.gridUnit * 5
0029     Plasmoid.status: isClipboardEmpty ? PlasmaCore.Types.PassiveStatus : PlasmaCore.Types.ActiveStatus
0030     toolTipMainText: i18n("Clipboard Contents")
0031     toolTipSubText: isClipboardEmpty ? i18n("Clipboard is empty") : clipboardSource.data["clipboard"]["current"]
0032     toolTipTextFormat: Text.PlainText
0033     Plasmoid.icon: "klipper-symbolic"
0034 
0035     function action_configure() {
0036         clipboardSource.service("", "configureKlipper");
0037     }
0038 
0039     function action_clearHistory() {
0040         clipboardSource.service("", "clearHistory")
0041         clearSearchField()
0042     }
0043 
0044     onIsClipboardEmptyChanged: {
0045         if (isClipboardEmpty) {
0046             // We need to hide the applet before changing its status to passive
0047             // because only the active applet can hide itself
0048             if (main.hideOnWindowDeactivate)
0049                 main.expanded = false;
0050             Plasmoid.status = PlasmaCore.Types.HiddenStatus;
0051         } else {
0052             Plasmoid.status = PlasmaCore.Types.ActiveStatus
0053         }
0054     }
0055 
0056     Plasmoid.contextualActions: [
0057         PlasmaCore.Action {
0058             id: clearAction
0059             text: i18n("Clear History")
0060             icon.name: "edit-clear-history"
0061             visible: !main.isClipboardEmpty && !main.editing
0062             onTriggered: {
0063                 clipboardSource.service("", "clearHistory")
0064                 clearSearchField()
0065             }
0066         }
0067     ]
0068 
0069     PlasmaCore.Action {
0070         id: configureAction
0071         text: i18n("Configure Clipboard…")
0072         icon.name: "configure"
0073         shortcut: "alt+d, s"
0074         onTriggered: {
0075             clipboardSource.service("", "configureKlipper")
0076         }
0077     }
0078 
0079     Component.onCompleted: {
0080         Plasmoid.setInternalAction("configure", configureAction);
0081     }
0082 
0083     P5Support.DataSource {
0084         id: clipboardSource
0085         property bool editing: false;
0086         engine: "clipboard"
0087         connectedSources: "clipboard"
0088         function service(uuid, op) {
0089             var service = clipboardSource.serviceForSource(uuid);
0090             var operation = service.operationDescription(op);
0091             return service.startOperationCall(operation);
0092         }
0093         function edit(uuid, text) {
0094             clipboardSource.editing = true;
0095             const service = clipboardSource.serviceForSource(uuid);
0096             const operation = service.operationDescription("edit");
0097             operation.text = text;
0098             const job = service.startOperationCall(operation);
0099             job.finished.connect(function() {
0100                 clipboardSource.editing = false;
0101             });
0102         }
0103     }
0104 
0105     fullRepresentation: PlasmaExtras.Representation {
0106         id: dialogItem
0107         Layout.minimumWidth: Kirigami.Units.gridUnit * 24
0108         Layout.minimumHeight: Kirigami.Units.gridUnit * 24
0109         Layout.maximumWidth: Kirigami.Units.gridUnit * 80
0110         Layout.maximumHeight: Kirigami.Units.gridUnit * 40
0111         collapseMarginsHint: true
0112 
0113         focus: true
0114 
0115         header: stack.currentItem.header
0116 
0117         property alias listMargins: listItemSvg.margins
0118         readonly property var appletInterface: main
0119 
0120         KSvg.FrameSvgItem {
0121             id : listItemSvg
0122             imagePath: "widgets/listitem"
0123             prefix: "normal"
0124             visible: false
0125         }
0126 
0127         Keys.forwardTo: [stack.currentItem]
0128 
0129         QQC2.StackView {
0130             id: stack
0131             anchors.fill: parent
0132             initialItem: ClipboardPage {
0133             }
0134         }
0135     }
0136 }