fix(@desktop/statusq): Fix StatusQ and shared components as part of

new saved addresses UI implementation
  - Fixed StatusInput and StatusBaseInput to respect rich text.
  - Fixed AddressInput's height that breaks the layout when inside
of QtQuick Layout.
  - Added support for icon clicks in StatusListItem.
  - Fixed broken right alignment in ContactsListAndSearch.

Fixes #8599
This commit is contained in:
Ivan Belyakov 2023-02-17 15:22:37 +03:00 committed by IvanBelyakoff
parent 2a1ea3b0ae
commit bfdd9092e1
9 changed files with 53 additions and 22 deletions

View File

@ -34,6 +34,7 @@ Rectangle {
property Component inlineTagDelegate property Component inlineTagDelegate
property bool loading: false property bool loading: false
property bool loadingFailed: false property bool loadingFailed: false
property bool iconHoverEnabled: false
property StatusAssetSettings asset: StatusAssetSettings { property StatusAssetSettings asset: StatusAssetSettings {
height: isImage ? 40 : 20 height: isImage ? 40 : 20
@ -80,6 +81,7 @@ Rectangle {
signal clicked(string itemId, var mouse) signal clicked(string itemId, var mouse)
signal titleClicked(string titleId) signal titleClicked(string titleId)
signal iconClicked(var mouse)
enum Type { enum Type {
Primary, Primary,
@ -146,6 +148,9 @@ Rectangle {
badge.border.color: statusListItem.color badge.border.color: statusListItem.color
ringSettings: statusListItem.ringSettings ringSettings: statusListItem.ringSettings
loading: statusListItem.loading loading: statusListItem.loading
hoverEnabled: statusListItem.iconHoverEnabled
onClicked: statusListItem.iconClicked(mouse)
} }
Item { Item {

View File

@ -13,12 +13,13 @@ Rectangle {
bgWidth: 40 bgWidth: 40
bgHeight: 40 bgHeight: 40
bgColor: Theme.palette.primaryColor3 bgColor: Theme.palette.primaryColor3
bgRadius: bgWidth / 2
} }
color: asset.bgColor color: asset.bgColor
implicitWidth: asset.bgWidth implicitWidth: asset.bgWidth
implicitHeight: asset.bgHeight implicitHeight: asset.bgHeight
radius: asset.bgWidth / 2 radius: asset.bgRadius
StatusIcon { StatusIcon {

View File

@ -15,6 +15,7 @@ Loader {
property StatusAssetSettings asset: StatusAssetSettings { property StatusAssetSettings asset: StatusAssetSettings {
width: 40 width: 40
height: 40 height: 40
bgRadius: bgWidth / 2
} }
property StatusIdenticonRingSettings ringSettings: StatusIdenticonRingSettings { property StatusIdenticonRingSettings ringSettings: StatusIdenticonRingSettings {
@ -27,6 +28,10 @@ Loader {
!root.asset.isImage ? roundedIcon : roundedImage !root.asset.isImage ? roundedIcon : roundedImage
property bool loading: false property bool loading: false
property bool hoverEnabled: false
readonly property bool hovered: (sourceComponent == roundedIcon && item) ?
item.hovered : false
signal clicked()
Component { Component {
id: roundedImage id: roundedImage
@ -35,7 +40,6 @@ Loader {
width: root.asset.width width: root.asset.width
height: root.asset.height height: root.asset.height
StatusRoundedImage { StatusRoundedImage {
id: statusRoundImage id: statusRoundImage
width: parent.width width: parent.width
@ -65,15 +69,20 @@ Loader {
Component { Component {
id: roundedIcon id: roundedIcon
StatusRoundIcon {
asset.bgWidth: root.asset.bgWidth StatusRoundButton {
asset.bgHeight: root.asset.bgHeight width: root.asset.bgWidth
asset.bgColor: root.asset.bgColor height: root.asset.bgHeight
asset.width: root.asset.width color: root.asset.bgColor
asset.height: root.asset.height icon.width: root.asset.width
asset.name: root.asset.name icon.height: root.asset.height
asset.rotation: root.asset.rotation icon.name: root.asset.name
asset.color: root.asset.color icon.rotation: root.asset.rotation
icon.color: root.asset.color
icon.hoverColor: root.asset.hoverColor
radius: root.asset.bgRadius
hoverEnabled: root.hoverEnabled
onClicked: root.clicked()
} }
} }

View File

@ -378,8 +378,8 @@ Item {
if (utf8Length > root.maximumLength) { if (utf8Length > root.maximumLength) {
var cursor = cursorPosition var cursor = cursorPosition
text = previousText text = previousText
if (cursor > text.length) { if (cursor > length) {
cursorPosition = text.length cursorPosition = length
} else { } else {
cursorPosition = cursor - 1 cursorPosition = cursor - 1
} }
@ -405,7 +405,7 @@ Item {
StatusBaseText { StatusBaseText {
id: placeholder id: placeholder
visible: (edit.text.length === 0) visible: (edit.length === 0)
anchors.fill: parent anchors.fill: parent
verticalAlignment: parent.verticalAlignment verticalAlignment: parent.verticalAlignment
font.pixelSize: 15 font.pixelSize: 15
@ -436,7 +436,7 @@ Item {
id: clearButton id: clearButton
StatusFlatRoundButton { StatusFlatRoundButton {
visible: edit.text.length != 0 && root.clearable && !root.multiline visible: edit.length != 0 && root.clearable && !root.multiline
&& edit.activeFocus && edit.activeFocus
type: StatusFlatRoundButton.Type.Secondary type: StatusFlatRoundButton.Type.Secondary
width: 24 width: 24

View File

@ -263,10 +263,11 @@ Item {
} }
statusBaseInput.valid = true statusBaseInput.valid = true
const rawText = statusBaseInput.edit.getText(0, statusBaseInput.edit.length)
if (validators.length) { if (validators.length) {
for (let idx in validators) { for (let idx in validators) {
let validator = validators[idx] let validator = validators[idx]
let result = validator.validate(statusBaseInput.text) let result = validator.validate(rawText)
if (typeof result === "boolean" && result) { if (typeof result === "boolean" && result) {
statusBaseInput.valid = statusBaseInput.valid && true statusBaseInput.valid = statusBaseInput.valid && true
@ -284,6 +285,7 @@ Item {
// the only way to trigger bindings for var property // the only way to trigger bindings for var property
errors = errors errors = errors
result.errorMessage = validator.errorMessage result.errorMessage = validator.errorMessage
statusBaseInput.valid = statusBaseInput.valid && false statusBaseInput.valid = statusBaseInput.valid && false
@ -297,8 +299,8 @@ Item {
// Undo the last input // Undo the last input
const cursor = statusBaseInput.cursorPosition; const cursor = statusBaseInput.cursorPosition;
statusBaseInput.text = _previousText; statusBaseInput.text = _previousText;
if (statusBaseInput.cursor > statusBaseInput.text.length) { if (statusBaseInput.cursor > statusBaseInput.edit.length) {
statusBaseInput.cursorPosition = statusBaseInput.text.length; statusBaseInput.cursorPosition = statusBaseInput.edit.length;
} else { } else {
statusBaseInput.cursorPosition = cursor-1; statusBaseInput.cursorPosition = cursor-1;
} }
@ -319,7 +321,7 @@ Item {
}) })
root.pending = true root.pending = true
pendingValidators.push(asyncValidator.name) pendingValidators.push(asyncValidator.name)
asyncValidator.asyncOperationInternal(statusBaseInput.text) asyncValidator.asyncOperationInternal(rawText)
} }
} else if (!asyncValidators.length && !Object.values(errors).length) { } else if (!asyncValidators.length && !Object.values(errors).length) {
root.validatedValue = root.text root.validatedValue = root.text

View File

@ -23,6 +23,8 @@ Rectangle {
return Theme.palette.primaryColor1; return Theme.palette.primaryColor1;
case StatusRoundButton.Type.Quaternary: case StatusRoundButton.Type.Quaternary:
return Theme.palette.dangerColor1; return Theme.palette.dangerColor1;
case StatusRoundButton.Type.Quinary:
return Theme.palette.directColor1;
} }
} }
@ -36,6 +38,8 @@ Rectangle {
return Theme.palette.baseColor1; return Theme.palette.baseColor1;
case StatusRoundButton.Type.Quaternary: case StatusRoundButton.Type.Quaternary:
return Theme.palette.dangerColor1; return Theme.palette.dangerColor1;
case StatusRoundButton.Type.Quinary:
return Theme.palette.directColor1;
} }
} }
@ -49,6 +53,8 @@ Rectangle {
return Theme.palette.baseColor1; return Theme.palette.baseColor1;
case StatusRoundButton.Type.Quaternary: case StatusRoundButton.Type.Quaternary:
return Theme.palette.baseColor1; return Theme.palette.baseColor1;
case StatusRoundButton.Type.Quinary:
return Theme.palette.baseColor1;
} }
} }
} }
@ -56,6 +62,7 @@ Rectangle {
property bool loading: false property bool loading: false
property alias hovered: sensor.containsMouse property alias hovered: sensor.containsMouse
property alias hoverEnabled: sensor.hoverEnabled
property bool highlighted: false property bool highlighted: false
@ -70,7 +77,8 @@ Rectangle {
Primary, Primary,
Secondary, Secondary,
Tertiary, Tertiary,
Quaternary Quaternary,
Quinary
} }
/// Implementation /// Implementation
@ -87,6 +95,8 @@ Rectangle {
return "transparent"; return "transparent";
case StatusRoundButton.Type.Quaternary: case StatusRoundButton.Type.Quaternary:
return Theme.palette.dangerColor3; return Theme.palette.dangerColor3;
case StatusRoundButton.Type.Quinary:
return "transparent";
} }
} }
@ -100,6 +110,8 @@ Rectangle {
return Theme.palette.primaryColor3; return Theme.palette.primaryColor3;
case StatusRoundButton.Type.Quaternary: case StatusRoundButton.Type.Quaternary:
return Theme.palette.dangerColor2; return Theme.palette.dangerColor2;
case StatusRoundButton.Type.Quinary:
return Theme.palette.primaryColor3;
} }
} }
@ -113,6 +125,8 @@ Rectangle {
return "transparent"; return "transparent";
case StatusRoundButton.Type.Quaternary: case StatusRoundButton.Type.Quaternary:
return Theme.palette.baseColor2; return Theme.palette.baseColor2;
case StatusRoundButton.Type.Quinary:
return "transparent";
} }
} }
} }

View File

@ -29,6 +29,7 @@ QtObject {
property real bgHeight property real bgHeight
property int bgRadius property int bgRadius
property color bgColor: "transparent" property color bgColor: "transparent"
property color bgBorderColor: "transparent"
//image //image
property bool isImage: false property bool isImage: false

View File

@ -23,7 +23,7 @@ Item {
property alias wrongInputValidationError: contactFieldAndList.wrongInputValidationError property alias wrongInputValidationError: contactFieldAndList.wrongInputValidationError
property alias ownAddressError: contactFieldAndList.ownAddressError property alias ownAddressError: contactFieldAndList.ownAddressError
height: contactFieldAndList.chatKey.height implicitHeight: contactFieldAndList.chatKey.height
onSelectedAddressChanged: validate() onSelectedAddressChanged: validate()

View File

@ -67,7 +67,6 @@ Item {
ColumnLayout { ColumnLayout {
id: column id: column
anchors.fill: parent anchors.fill: parent
anchors.rightMargin: Style.current.bigPadding
spacing: Style.current.smallPadding spacing: Style.current.smallPadding
Input { Input {