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

0001 /*
0002  *   Copyright (C) 2018 by Marco Martin <mart@kde.org>
0003  *
0004  *   This program is free software; you can redistribute it and/or modify
0005  *   it under the terms of the GNU Library General Public License as
0006  *   published by the Free Software Foundation; either version 2, or
0007  *   (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *   GNU Library General Public License for more details
0013  *
0014  *   You should have received a copy of the GNU Library General Public
0015  *   License along with this program; if not, write to the
0016  *   Free Software Foundation, Inc.,
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  2.010-1301, USA.
0018  */
0019 
0020 pragma Singleton
0021 
0022 import QtQuick 2.1
0023 import QtQuick.Layouts 1.2
0024 import QtQuick.Window 2.2
0025 import QtQuick.Controls 2.2
0026 import org.kde.plasma.core 2.0 as PlasmaCore
0027 import org.kde.kirigami 2.5 as Kirigami
0028 
0029 Popup {
0030     id: root
0031 
0032     property Item controlRoot
0033     parent: controlRoot ? controlRoot.Window.contentItem : undefined
0034     modal: false
0035     focus: false
0036     closePolicy: Popup.NoAutoClose
0037 
0038     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
0039 
0040     y: {
0041         if (!controlRoot) {
0042             return false;
0043         }
0044         var desiredY = controlRoot.mapToItem(root.parent, 0, controlRoot.positionToRectangle(controlRoot.selectionStart).y).y  - root.height;
0045 
0046         if (desiredY >= 0) {
0047             return Math.min(desiredY, controlRoot.Window.contentItem.height - root.height);
0048         } else {
0049             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);
0050         }
0051     }
0052 
0053 
0054     visible: controlRoot ? Kirigami.Settings.tabletMode && (controlRoot.selectedText.length > 0 || controlRoot.canPaste) : false
0055 
0056     width: contentItem.implicitWidth + leftPadding + rightPadding
0057 
0058     contentItem: RowLayout {
0059         ToolButton {
0060             focusPolicy: Qt.NoFocus
0061             icon.name: "edit-cut"
0062             visible: controlRoot.selectedText.length > 0
0063             onClicked: {
0064                 controlRoot.cut();
0065             }
0066         }
0067         ToolButton {
0068             focusPolicy: Qt.NoFocus
0069             icon.name: "edit-copy"
0070             visible: controlRoot.selectedText.length > 0
0071             onClicked: {
0072                 controlRoot.copy();
0073             }
0074         }
0075         ToolButton {
0076             focusPolicy: Qt.NoFocus
0077             icon.name: "edit-paste"
0078             onClicked: {
0079                 controlRoot.paste();
0080             }
0081         }
0082     }
0083 }