Warning, /plasma/qqc2-breeze-style/style/qtquickcontrols/MobileTextActionsToolBar.qml is written in an unsupported language. File is not indexed.

0001 /* SPDX-FileCopyrightText: 2018 Marco Martin <mart@kde.org>
0002  * SPDX-FileCopyrightText: 2021 Noah Davis <noahadvs@gmail.com>
0003  * SPDX-License-Identifier: LGPL-2.0-or-later
0004  */
0005 
0006 import QtQuick 2.15
0007 import QtQuick.Layouts 1.15
0008 import QtQuick.Window 2.15
0009 import QtQuick.Controls 2.15
0010 import org.kde.kirigami 2.19 as Kirigami
0011 
0012 import "impl" as Impl
0013 
0014 Loader {
0015     id: root
0016     property Item target
0017     visible: Kirigami.Settings.tabletMode && target.selectedText.length > 0
0018     active: visible
0019     sourceComponent: Popup {
0020         id: popup
0021 
0022         property real xAlignHCenter: Math.round(Qt.inputMethod.anchorRectangle.x + (Qt.inputMethod.cursorRectangle.x - Qt.inputMethod.anchorRectangle.x - width)/2)
0023         property real yAlignOver: Math.round(Qt.inputMethod.anchorRectangle.y - height - fontMetrics.descent)
0024 
0025         visible: false
0026         parent: Overlay.overlay
0027         modal: false
0028         focus: false
0029         margins: Impl.Units.verySmallSpacing
0030         padding: 0
0031 
0032         x: xAlignHCenter
0033         y: yAlignOver
0034 
0035         // HACK: make it appear above most popups that show up in the
0036         // overlay in case any of them use TextField or TextArea
0037         z: 999
0038 
0039         contentItem: RowLayout {
0040             spacing: 0
0041             ToolButton {
0042                 focusPolicy: Qt.NoFocus
0043                 icon.name: "edit-cut"
0044                 visible: target && target.selectedText.length > 0 && (!target.hasOwnProperty("echoMode") || target.echoMode === TextInput.Normal)
0045                 onClicked: {
0046                     target.cut();
0047                 }
0048             }
0049             ToolButton {
0050                 focusPolicy: Qt.NoFocus
0051                 icon.name: "edit-copy"
0052                 visible: target && target.selectedText.length > 0 && (!target.hasOwnProperty("echoMode") || target.echoMode === TextInput.Normal)
0053                 onClicked: {
0054                     target.copy();
0055                 }
0056             }
0057             ToolButton {
0058                 focusPolicy: Qt.NoFocus
0059                 icon.name: "edit-paste"
0060                 visible: target && target.canPaste
0061                 onClicked: {
0062                     target.paste();
0063                 }
0064             }
0065         }
0066 
0067         FontMetrics {
0068             id: fontMetrics
0069             font: target.font
0070         }
0071     }
0072 }
0073