mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-01 19:18:28 -04:00
@@ -846,6 +846,13 @@ Item {
|
|||||||
cursorPosition -= 1;
|
cursorPosition -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteForward() {
|
||||||
|
clampCursorPosition();
|
||||||
|
if (cursorPosition === text.length)
|
||||||
|
return;
|
||||||
|
text = text.slice(0, cursorPosition) + text.slice(cursorPosition + 1);
|
||||||
|
}
|
||||||
|
|
||||||
function isPrintableText(value) {
|
function isPrintableText(value) {
|
||||||
if (value.length === 0)
|
if (value.length === 0)
|
||||||
return false;
|
return false;
|
||||||
@@ -915,16 +922,38 @@ Item {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
|
switch (event.key) {
|
||||||
|
case Qt.Key_Return:
|
||||||
|
case Qt.Key_Enter:
|
||||||
accepted();
|
accepted();
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
return;
|
return;
|
||||||
}
|
case Qt.Key_Backspace:
|
||||||
|
|
||||||
if (event.key === Qt.Key_Backspace) {
|
|
||||||
backspace();
|
backspace();
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
return;
|
return;
|
||||||
|
case Qt.Key_Delete:
|
||||||
|
deleteForward();
|
||||||
|
event.accepted = true;
|
||||||
|
return;
|
||||||
|
case Qt.Key_Left:
|
||||||
|
clampCursorPosition();
|
||||||
|
cursorPosition = Math.max(0, cursorPosition - 1);
|
||||||
|
event.accepted = true;
|
||||||
|
return;
|
||||||
|
case Qt.Key_Right:
|
||||||
|
clampCursorPosition();
|
||||||
|
cursorPosition = Math.min(text.length, cursorPosition + 1);
|
||||||
|
event.accepted = true;
|
||||||
|
return;
|
||||||
|
case Qt.Key_Home:
|
||||||
|
cursorPosition = 0;
|
||||||
|
event.accepted = true;
|
||||||
|
return;
|
||||||
|
case Qt.Key_End:
|
||||||
|
cursorPosition = text.length;
|
||||||
|
event.accepted = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPrintableText(event.text)) {
|
if (isPrintableText(event.text)) {
|
||||||
@@ -1028,6 +1057,8 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
|
id: passwordDisplay
|
||||||
|
|
||||||
anchors.left: lockIconContainer.right
|
anchors.left: lockIconContainer.right
|
||||||
anchors.leftMargin: Theme.spacingM
|
anchors.leftMargin: Theme.spacingM
|
||||||
anchors.right: (revealButton.visible ? revealButton.left : (virtualKeyboardButton.visible ? virtualKeyboardButton.left : (securityKeyButton.visible ? securityKeyButton.left : (enterButton.visible ? enterButton.left : (loadingSpinner.visible ? loadingSpinner.left : parent.right)))))
|
anchors.right: (revealButton.visible ? revealButton.left : (virtualKeyboardButton.visible ? virtualKeyboardButton.left : (securityKeyButton.visible ? securityKeyButton.left : (enterButton.visible ? enterButton.left : (loadingSpinner.visible ? loadingSpinner.left : parent.right)))))
|
||||||
@@ -1057,6 +1088,33 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextMetrics {
|
||||||
|
id: passwordCursorMetrics
|
||||||
|
font: passwordDisplay.font
|
||||||
|
text: passwordDisplay.text.slice(0, passwordField.cursorPosition)
|
||||||
|
}
|
||||||
|
|
||||||
|
DankTextCursor {
|
||||||
|
id: passwordCursor
|
||||||
|
|
||||||
|
x: passwordDisplay.x + passwordCursorMetrics.advanceWidth + Math.min(0, passwordDisplay.width - passwordDisplay.implicitWidth)
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
height: passwordDisplay.font.pixelSize + 4
|
||||||
|
shown: !demoMode && passwordField.activeFocus && !pam.passwd.active && !pam.u2fPending && !root.unlocking
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: passwordField
|
||||||
|
|
||||||
|
function onCursorPositionChanged() {
|
||||||
|
passwordCursor.resetBlink();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onTextChanged() {
|
||||||
|
passwordCursor.resetBlink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DankActionButton {
|
DankActionButton {
|
||||||
id: revealButton
|
id: revealButton
|
||||||
|
|
||||||
|
|||||||
@@ -598,29 +598,20 @@ Column {
|
|||||||
topPadding: Theme.spacingM
|
topPadding: Theme.spacingM
|
||||||
rightPadding: Theme.spacingM
|
rightPadding: Theme.spacingM
|
||||||
bottomPadding: Theme.spacingM
|
bottomPadding: Theme.spacingM
|
||||||
cursorDelegate: Rectangle {
|
cursorDelegate: DankTextCursor {
|
||||||
|
id: notepadCursor
|
||||||
width: 1.5
|
width: 1.5
|
||||||
radius: 1
|
|
||||||
color: Theme.surfaceText
|
color: Theme.surfaceText
|
||||||
x: textArea.cursorRectangle.x
|
x: textArea.cursorRectangle.x
|
||||||
y: textArea.cursorRectangle.y
|
y: textArea.cursorRectangle.y
|
||||||
height: textArea.cursorRectangle.height
|
height: textArea.cursorRectangle.height
|
||||||
opacity: 1.0
|
shown: textArea.cursorVisible
|
||||||
|
|
||||||
SequentialAnimation on opacity {
|
Connections {
|
||||||
running: textArea.activeFocus
|
target: textArea
|
||||||
loops: Animation.Infinite
|
|
||||||
OpacityAnimator {
|
function onCursorPositionChanged() {
|
||||||
from: 1.0
|
notepadCursor.resetBlink();
|
||||||
to: 0.0
|
|
||||||
duration: 650
|
|
||||||
easing.type: Easing.InOutQuad
|
|
||||||
}
|
|
||||||
OpacityAnimator {
|
|
||||||
from: 0.0
|
|
||||||
to: 1.0
|
|
||||||
duration: 650
|
|
||||||
easing.type: Easing.InOutQuad
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import QtQuick
|
||||||
|
import qs.Common
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property bool shown: true
|
||||||
|
property bool blinkOn: true
|
||||||
|
|
||||||
|
readonly property int flashTime: Qt.styleHints.cursorFlashTime
|
||||||
|
|
||||||
|
function resetBlink() {
|
||||||
|
blinkOn = true;
|
||||||
|
blinkTimer.restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
width: 2
|
||||||
|
radius: 1
|
||||||
|
color: Theme.primary
|
||||||
|
visible: shown && blinkOn
|
||||||
|
|
||||||
|
onShownChanged: resetBlink()
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: blinkTimer
|
||||||
|
running: root.shown && root.flashTime > 1
|
||||||
|
interval: root.flashTime / 2
|
||||||
|
repeat: true
|
||||||
|
onTriggered: root.blinkOn = !root.blinkOn
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user