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