Libplasma

MobileTextActionsToolBarImpl.qml
1/*
2 SPDX-FileCopyrightText: 2018 Marco Martin <mart@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7import QtQuick
8import QtQuick.Layouts
9import QtQuick.Controls
10import org.kde.kirigami as Kirigami
11
12Popup {
13 id: root
14
15 parent: controlRoot.Window.window.contentItem
16 modal: false
17 focus: false
18 closePolicy: Popup.NoAutoClose
19
20 x: parent ? Math.min(Math.max(0, controlRoot.mapToItem(root.parent, controlRoot.positionToRectangle(controlRoot.selectionStart).x, 0).x - root.width/2), parent.width - root.width) : 0
21
22 y: {
23 if (!parent) {
24 return false;
25 }
26 var desiredY = controlRoot.mapToItem(root.parent, 0, controlRoot.positionToRectangle(controlRoot.selectionStart).y).y - root.height;
27
28 if (desiredY >= 0) {
29 return Math.min(desiredY, parent.height - root.height);
30 } else {
31 return Math.min(Math.max(0, controlRoot.mapToItem(root.parent, 0, controlRoot.positionToRectangle(controlRoot.selectionEnd).y + Math.round(Kirigami.Units.gridUnit * 1.5)).y), parent.height - root.height);
32 }
33 }
34
35 width: contentItem.implicitWidth + leftPadding + rightPadding
36 visible: true
37
38 contentItem: RowLayout {
39 ToolButton {
40 focusPolicy: Qt.NoFocus
41 icon.name: "edit-cut"
42 visible: controlRoot.selectedText.length > 0 && (!controlRoot.hasOwnProperty("echoMode") || controlRoot.echoMode === TextInput.Normal)
43 onClicked: {
44 controlRoot.cut();
45 }
46 }
47 ToolButton {
48 focusPolicy: Qt.NoFocus
49 icon.name: "edit-copy"
50 visible: controlRoot.selectedText.length > 0 && (!controlRoot.hasOwnProperty("echoMode") || controlRoot.echoMode === TextInput.Normal)
51 onClicked: {
52 controlRoot.copy();
53 }
54 }
55 ToolButton {
56 focusPolicy: Qt.NoFocus
57 icon.name: "edit-paste"
58 visible: controlRoot.canPaste
59 onClicked: {
60 controlRoot.paste();
61 }
62 }
63 }
64}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:10:41 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.