chore: extract input cursor delegate into StatusCursorDelegate

- unified UI/UX; no code changes, just reduces code duplication
- use the correct OS/platform blink interval with
  `Qt.styleHints.cursorFlashTime`
This commit is contained in:
Lukáš Tinkl 2023-04-05 16:27:43 +02:00 committed by Lukáš Tinkl
parent 01e96318e9
commit 19e7c42cc2
8 changed files with 35 additions and 88 deletions

View File

@ -0,0 +1,22 @@
import QtQuick 2.15
import StatusQ.Core.Theme 0.1
Rectangle {
id: root
required property bool cursorVisible
color: Theme.palette.primaryColor1
implicitWidth: 2
implicitHeight: 22
radius: 1
visible: cursorVisible
SequentialAnimation on visible {
loops: Animation.Infinite
running: root.cursorVisible
PropertyAnimation { to: false; duration: Qt.styleHints.cursorFlashTime / 2 }
PropertyAnimation { to: true; duration: Qt.styleHints.cursorFlashTime / 2 }
}
}

View File

@ -9,6 +9,7 @@ StatusChatListItem 0.1 StatusChatListItem.qml
StatusChatListCategory 0.1 StatusChatListCategory.qml StatusChatListCategory 0.1 StatusChatListCategory.qml
StatusChatListCategoryItem 0.1 StatusChatListCategoryItem.qml StatusChatListCategoryItem 0.1 StatusChatListCategoryItem.qml
StatusChatListAndCategories 0.1 StatusChatListAndCategories.qml StatusChatListAndCategories 0.1 StatusChatListAndCategories.qml
StatusCursorDelegate 0.1 StatusCursorDelegate.qml
StatusToolBar 0.1 StatusToolBar.qml StatusToolBar 0.1 StatusToolBar.qml
StatusContactRequestsIndicatorListItem 0.1 StatusContactRequestsIndicatorListItem.qml StatusContactRequestsIndicatorListItem 0.1 StatusContactRequestsIndicatorListItem.qml
StatusEmoji 0.1 StatusEmoji.qml StatusEmoji 0.1 StatusEmoji.qml

View File

@ -411,19 +411,8 @@ Item {
} }
} }
cursorDelegate: Rectangle { cursorDelegate: StatusCursorDelegate {
color: Theme.palette.primaryColor1 cursorVisible: edit.cursorVisible
implicitWidth: 2
implicitHeight: 22
radius: 1
visible: edit.cursorVisible
SequentialAnimation on visible {
loops: Animation.Infinite
running: edit.cursorVisible
PropertyAnimation { to: false; duration: 600; }
PropertyAnimation { to: true; duration: 600; }
}
} }
StatusBaseText { StatusBaseText {

View File

@ -2,6 +2,7 @@ import QtQuick 2.14
import QtQuick.Controls 2.14 import QtQuick.Controls 2.14
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1
/*! /*!
\qmltype StatusTextArea \qmltype StatusTextArea
@ -74,6 +75,7 @@ TextArea {
} }
selectByMouse: true selectByMouse: true
persistentSelection: true
wrapMode: TextEdit.WordWrap wrapMode: TextEdit.WordWrap
activeFocusOnTab: enabled activeFocusOnTab: enabled
@ -94,18 +96,7 @@ TextArea {
} }
} }
cursorDelegate: Rectangle { cursorDelegate: StatusCursorDelegate {
color: Theme.palette.primaryColor1 cursorVisible: root.cursorVisible
implicitWidth: 2
implicitHeight: 22
radius: 1
visible: root.cursorVisible
SequentialAnimation on visible {
loops: Animation.Infinite
running: root.cursorVisible
PropertyAnimation { to: false; duration: 600 }
PropertyAnimation { to: true; duration: 600 }
}
} }
} }

View File

@ -25,6 +25,7 @@
<file>StatusQ/Components/StatusCommunityTags.qml</file> <file>StatusQ/Components/StatusCommunityTags.qml</file>
<file>StatusQ/Components/StatusContactRequestsIndicatorListItem.qml</file> <file>StatusQ/Components/StatusContactRequestsIndicatorListItem.qml</file>
<file>StatusQ/Components/StatusContactVerificationIcons.qml</file> <file>StatusQ/Components/StatusContactVerificationIcons.qml</file>
<file>StatusQ/Components/StatusCursorDelegate.qml</file>
<file>StatusQ/Components/StatusDatePicker.qml</file> <file>StatusQ/Components/StatusDatePicker.qml</file>
<file>StatusQ/Components/StatusDescriptionListItem.qml</file> <file>StatusQ/Components/StatusDescriptionListItem.qml</file>
<file>StatusQ/Components/StatusEmoji.qml</file> <file>StatusQ/Components/StatusEmoji.qml</file>

View File

@ -5,6 +5,7 @@ import QtGraphicalEffects 1.0
import StatusQ.Core 0.1 import StatusQ.Core 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1 import StatusQ.Core.Utils 0.1
import StatusQ.Popups.Dialog 0.1 import StatusQ.Popups.Dialog 0.1
@ -107,17 +108,8 @@ Item {
selectionColor: Theme.palette.primaryColor2 selectionColor: Theme.palette.primaryColor2
selectedTextColor: color selectedTextColor: color
cursorDelegate: Rectangle { cursorDelegate: StatusCursorDelegate {
color: Theme.palette.primaryColor1 cursorVisible: edit.cursorVisible
implicitWidth: 2
radius: 1
visible: edit.cursorVisible
SequentialAnimation on visible {
loops: Animation.Infinite
running: edit.cursorVisible
PropertyAnimation { to: false; duration: 600; }
PropertyAnimation { to: true; duration: 600; }
}
} }
onTextEdited: if (suggestionsDialog.forceHide && !pasteOperation) onTextEdited: if (suggestionsDialog.forceHide && !pasteOperation)

View File

@ -10,8 +10,6 @@ import utils 1.0
StatusInput { StatusInput {
id: cursorInput id: cursorInput
property string cursorColor: Theme.palette.primaryColor1
leftPadding: 0 leftPadding: 0
rightPadding: 0 rightPadding: 0
topPadding: 0 topPadding: 0
@ -25,40 +23,4 @@ StatusInput {
input.edit.padding: 0 input.edit.padding: 0
input.background.color: "transparent" input.background.color: "transparent"
input.background.border.width: 0 input.background.border.width: 0
// To-do this needs to be removed once https://github.com/status-im/StatusQ/issues/578 is implemented and cursor is moved to StatusInput
input.edit.cursorDelegate: Rectangle {
id: cursor
visible: input.edit.cursorVisible
color: cursorColor
width: 2
SequentialAnimation {
loops: Animation.Infinite
running: input.edit.cursorVisible
PropertyAction {
target: cursor
property: 'visible'
value: true
}
PauseAnimation {
duration: 600
}
PropertyAction {
target: cursor
property: 'visible'
value: false
}
PauseAnimation {
duration: 600
}
onStopped: {
cursor.visible = false
}
}
}
} }

View File

@ -1350,19 +1350,8 @@ Rectangle {
} }
} }
cursorDelegate: Rectangle { cursorDelegate: StatusCursorDelegate {
color: Theme.palette.primaryColor1 cursorVisible: messageInputField.cursorVisible
implicitWidth: 2
implicitHeight: 22
radius: 1
visible: messageInputField.cursorVisible
SequentialAnimation on visible {
loops: Animation.Infinite
running: messageInputField.cursorVisible
PropertyAnimation { to: false; duration: 600; }
PropertyAnimation { to: true; duration: 600; }
}
} }
StatusSyntaxHighlighter { StatusSyntaxHighlighter {