fix(@desktop/statusq): Change id for StatusListItem to root.

Fix some equal signs to be === and !==.
Removed iconHoverEnabled property for StatusListItem.

Fixes #8599
This commit is contained in:
Ivan Belyakov 2023-02-24 15:24:02 +03:00 committed by IvanBelyakoff
parent 19436c0e58
commit 1c7c0d7d81
3 changed files with 42 additions and 44 deletions

View File

@ -10,7 +10,7 @@ import QtGraphicalEffects 1.14
import "private"
Rectangle {
id: statusListItem
id: root
property string itemId: ""
property string titleId: ""
@ -34,7 +34,6 @@ Rectangle {
property Component inlineTagDelegate
property bool loading: false
property bool loadingFailed: false
property bool iconHoverEnabled: false
property StatusAssetSettings asset: StatusAssetSettings {
height: isImage ? 40 : 20
@ -97,7 +96,7 @@ Rectangle {
return Math.max(64, statusListItemTitleArea.height + 90)
}
color: {
if (sensor.containsMouse || statusListItem.highlighted) {
if (sensor.containsMouse || root.highlighted) {
switch(type) {
case StatusListItem.Type.Primary:
return Theme.palette.baseColor2
@ -123,7 +122,7 @@ Rectangle {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
statusListItem.clicked(statusListItem.itemId, mouse)
root.clicked(root.itemId, mouse)
}
}
@ -138,19 +137,18 @@ Rectangle {
StatusSmartIdenticon {
id: iconOrImage
anchors.left: parent.left
anchors.leftMargin: statusListItem.leftPadding
anchors.leftMargin: root.leftPadding
anchors.verticalCenter: parent.verticalCenter
asset: statusListItem.asset
name: statusListItem.title
active: statusListItem.asset.isLetterIdenticon ||
!!statusListItem.asset.name ||
!!statusListItem.asset.emoji
badge.border.color: statusListItem.color
ringSettings: statusListItem.ringSettings
loading: statusListItem.loading
hoverEnabled: statusListItem.iconHoverEnabled
asset: root.asset
name: root.title
active: root.asset.isLetterIdenticon ||
!!root.asset.name ||
!!root.asset.emoji
badge.border.color: root.color
ringSettings: root.ringSettings
loading: root.loading
onClicked: statusListItem.iconClicked(mouse)
onClicked: root.iconClicked(mouse)
}
Item {
@ -161,20 +159,20 @@ Rectangle {
if(titleIconsRow.item) {
isIconsRowVisible = true//titleIconsRow.item.visible
}
return !statusListItem.titleAsideText && !isIconsRowVisible ? statusListItemTitleArea.right : undefined
return !root.titleAsideText && !isIconsRowVisible ? statusListItemTitleArea.right : undefined
}
anchors.left: iconOrImage.active ? iconOrImage.right : parent.left
anchors.right: statusListItemLabel.visible ? statusListItemLabel.left : statusListItemComponentsSlot.left
anchors.leftMargin: iconOrImage.active ? 16 : statusListItem.leftPadding
anchors.rightMargin: Math.max(statusListItem.rightPadding, titleIconsRow.requiredWidth)
anchors.leftMargin: iconOrImage.active ? 16 : root.leftPadding
anchors.rightMargin: Math.max(root.rightPadding, titleIconsRow.requiredWidth)
anchors.verticalCenter: bottomModel.length === 0 ? parent.verticalCenter : undefined
height: childrenRect.height
StatusTextWithLoadingState {
id: statusListItemTitle
text: statusListItem.title
text: root.title
font.pixelSize: 15
height: visible ? contentHeight : 0
elide: Text.ElideRight
@ -183,10 +181,10 @@ Rectangle {
anchors.topMargin: bottomModel.length === 0 ? undefined : 20
width: Math.min(implicitWidth, parent.width)
customColor: {
if (!statusListItem.enabled) {
if (!root.enabled) {
return Theme.palette.baseColor1
}
switch (statusListItem.type) {
switch (root.type) {
case StatusListItem.Type.Primary:
return Theme.palette.directColor1
case StatusListItem.Type.Secondary:
@ -195,16 +193,16 @@ Rectangle {
return Theme.palette.dangerColor1
}
}
loading: statusListItem.loading
loading: root.loading
StatusIcon {
width: visible ? 12 : 0
height: visible ? 12 : 0
visible: !!statusListItem.titleTextIcon
visible: !!root.titleTextIcon
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: statusListItemTitle.contentWidth + 6
icon: statusListItem.titleTextIcon
icon: root.titleTextIcon
}
StatusToolTip {
@ -217,12 +215,12 @@ Rectangle {
MouseArea {
id: statusListItemTitleMouseArea
anchors.fill: parent
enabled: statusListItem.enabled
enabled: root.enabled
cursorShape: sensor.enabled && containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
hoverEnabled: true
propagateComposedEvents: statusListItem.propagateTitleClicks
propagateComposedEvents: root.propagateTitleClicks
onClicked: {
statusListItem.titleClicked(statusListItem.titleId)
root.titleClicked(root.titleId)
mouse.accepted = false
}
}
@ -235,11 +233,11 @@ Rectangle {
anchors.verticalCenter: statusListItemTitle.verticalCenter
anchors.top: bottomModel.length === 0 ? undefined: parent.top
anchors.topMargin: bottomModel.length === 0 ? undefined : 20
text: statusListItem.titleAsideText
text: root.titleAsideText
font.pixelSize: 10
customColor: Theme.palette.baseColor1
visible: !!statusListItem.titleAsideText
loading: statusListItem.loading
visible: !!root.titleAsideText
loading: root.loading
}
Loader {
@ -247,7 +245,7 @@ Rectangle {
readonly property int requiredWidth: active ? width + anchors.leftMargin * 2 : 0
anchors.left: !statusListItem.titleAsideText ? statusListItemTitle.right : statusListItemTitleAsideText.right
anchors.left: !root.titleAsideText ? statusListItemTitle.right : statusListItemTitleAsideText.right
anchors.verticalCenter: statusListItemTitle.verticalCenter
anchors.leftMargin: 4
}
@ -265,13 +263,13 @@ Rectangle {
Layout.alignment: Qt.AlignVCenter
Layout.preferredWidth: inlineTagModelRepeater.count > 0 ? contentWidth : parent.width
text: statusListItem.subTitle
text: root.subTitle
font.pixelSize: 15
customColor: !statusListItem.enabled || !statusListItem.tertiaryTitle ?
customColor: !root.enabled || !root.tertiaryTitle ?
Theme.palette.baseColor1 : Theme.palette.directColor1
visible: !!statusListItem.subTitle
visible: !!root.subTitle
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
loading: statusListItem.loading
loading: root.loading
}
StatusTextWithLoadingState {
@ -315,12 +313,12 @@ Rectangle {
anchors.top: statusListItemSubtitleTagsRow.bottom
width: parent.width
height: visible ? contentHeight : 0
text: statusListItem.tertiaryTitle
text: root.tertiaryTitle
customColor: Theme.palette.baseColor1
font.pixelSize: 13
visible: !!statusListItem.tertiaryTitle
visible: !!root.tertiaryTitle
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
loading: statusListItem.loading
loading: root.loading
}
StatusListItemBadge {
@ -375,17 +373,17 @@ Rectangle {
anchors.right: statusListItemComponentsSlot.left
anchors.rightMargin: statusListItemComponentsSlot.width > 0 ? 10 : 0
text: statusListItem.label
text: root.label
font.pixelSize: 15
customColor: Theme.palette.baseColor1
visible: !!statusListItem.label
loading: statusListItem.loading
visible: !!root.label
loading: root.loading
}
Row {
id: statusListItemComponentsSlot
anchors.right: parent.right
anchors.rightMargin: statusListItem.rightPadding
anchors.rightMargin: root.rightPadding
anchors.verticalCenter: bottomModel.length === 0 ? parent.verticalCenter : undefined
anchors.top: bottomModel.length === 0 ? undefined: parent.top
anchors.topMargin: bottomModel.length === 0 ? undefined : 12

View File

@ -144,7 +144,7 @@ Loader {
Connections {
target: item
enabled: status == Loader.Ready
enabled: status === Loader.Ready
ignoreUnknownSignals: true
function onClicked(mouse) {

View File

@ -368,7 +368,7 @@ Item {
onCursorRectangleChanged: Utils.ensureVisible(flick, cursorRectangle)
onActiveFocusChanged: if (root.pristine) root.pristine = false
onTextChanged: {
if (previousText === text || (previousText == "" && length == 0 && length != text.length)) {
if (previousText === text || (previousText === "" && length === 0 && length !== text.length)) {
// Not sure why, but the textChanged event was triggered even if it didn't really
// Avoid further processing on initial condition when previousText is empty