Warning, /plasma/latte-dock/declarativeimports/components/private/MobileTextActionsToolBar.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2018 Marco Martin <mart@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 pragma Singleton
0008 
0009 import QtQuick 2.1
0010 import QtQuick.Layouts 1.2
0011 import QtQuick.Window 2.2
0012 import QtQuick.Controls 2.2
0013 import org.kde.plasma.core 2.0 as PlasmaCore
0014 import org.kde.kirigami 2.5 as Kirigami
0015 
0016 Popup {
0017     id: root
0018 
0019     property Item controlRoot
0020     parent: controlRoot ? controlRoot.Window.contentItem : undefined
0021     modal: false
0022     focus: false
0023     closePolicy: Popup.NoAutoClose
0024 
0025     x: controlRoot ? Math.min(Math.max(0, controlRoot.mapToItem(root.parent, controlRoot.positionToRectangle(controlRoot.selectionStart).x, 0).x - root.width/2), controlRoot.Window.contentItem.width - root.width) : 0
0026 
0027     y: {
0028         if (!controlRoot) {
0029             return false;
0030         }
0031         var desiredY = controlRoot.mapToItem(root.parent, 0, controlRoot.positionToRectangle(controlRoot.selectionStart).y).y  - root.height;
0032 
0033         if (desiredY >= 0) {
0034             return Math.min(desiredY, controlRoot.Window.contentItem.height - root.height);
0035         } else {
0036             return Math.min(Math.max(0, controlRoot.mapToItem(root.parent, 0, controlRoot.positionToRectangle(controlRoot.selectionEnd).y + Math.round(units.gridUnit*1.5)).y), controlRoot.Window.contentItem.height - root.height);
0037         }
0038     }
0039 
0040 
0041     visible: controlRoot ? Kirigami.Settings.tabletMode && (controlRoot.selectedText.length > 0 || controlRoot.canPaste) : false
0042 
0043     width: contentItem.implicitWidth + leftPadding + rightPadding
0044 
0045     contentItem: RowLayout {
0046         ToolButton {
0047             focusPolicy: Qt.NoFocus
0048             icon.name: "edit-cut"
0049             visible: controlRoot.selectedText.length > 0
0050             onClicked: {
0051                 controlRoot.cut();
0052             }
0053         }
0054         ToolButton {
0055             focusPolicy: Qt.NoFocus
0056             icon.name: "edit-copy"
0057             visible: controlRoot.selectedText.length > 0
0058             onClicked: {
0059                 controlRoot.copy();
0060             }
0061         }
0062         ToolButton {
0063             focusPolicy: Qt.NoFocus
0064             icon.name: "edit-paste"
0065             onClicked: {
0066                 controlRoot.paste();
0067             }
0068         }
0069     }
0070 }