Warning, /frameworks/qqc2-desktop-style/org.kde.desktop/private/MobileCursor.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 import QtQuick
0008 import org.kde.kirigami as Kirigami
0009 import org.kde.desktop.private as Private
0010
0011 Item {
0012 id: root
0013 width: 1 //<-important that this is actually a single device pixel
0014 height: Kirigami.Units.gridUnit
0015
0016 property Item target
0017
0018 property bool selectionStartHandle: false
0019
0020 visible: Kirigami.Settings.tabletMode && ((target.activeFocus && !selectionStartHandle) || target.selectedText.length > 0)
0021
0022 Rectangle {
0023 width: 3
0024 anchors {
0025 horizontalCenter: parent.horizontalCenter
0026 top: parent.top
0027 bottom: parent.bottom
0028 }
0029 color: Qt.tint(Kirigami.Theme.highlightColor, Qt.rgba(1,1,1,0.4))
0030 radius: width
0031 Rectangle {
0032 width: Math.round(Kirigami.Units.gridUnit/1.5)
0033 height: width
0034 visible: Private.MobileTextActionsToolBar.shouldBeVisible
0035 anchors {
0036 horizontalCenter: parent.horizontalCenter
0037 verticalCenter: parent.bottom
0038 }
0039 radius: width
0040 color: Qt.tint(Kirigami.Theme.highlightColor, Qt.rgba(1,1,1,0.4))
0041 }
0042 MouseArea {
0043 anchors {
0044 fill: parent
0045 margins: -Kirigami.Units.gridUnit
0046 }
0047 preventStealing: true
0048 onPositionChanged: mouse => {
0049 var pos = mapToItem(target, mouse.x, mouse.y);
0050 pos = target.positionAt(pos.x, pos.y);
0051
0052 if (target.selectedText.length > 0) {
0053 if (selectionStartHandle) {
0054 target.select(Math.min(pos, target.selectionEnd - 1), target.selectionEnd);
0055 } else {
0056 target.select(target.selectionStart, Math.max(pos, target.selectionStart + 1));
0057 }
0058 } else {
0059 target.cursorPosition = pos;
0060 }
0061 }
0062 }
0063 }
0064 }
0065