feat(StatusItemPicker): Added `radioButtonSize` property

Added properties `namePixelSize` and `radioButtonSize`.
Some fixes when shortName is undefined.
This commit is contained in:
Noelia 2022-08-23 17:00:20 +02:00 committed by Noelia
parent 9d6cea7051
commit db0f8e9fb5
1 changed files with 22 additions and 6 deletions

View File

@ -50,6 +50,12 @@ Rectangle {
*/ */
property string name property string name
/*!
\qmlproperty int StatusItemPicker::namePixelSize
This property holds pixel size of the name to be displayed.
*/
property int namePixelSize: 15
/*! /*!
\qmlproperty string StatusItemPicker::shortName \qmlproperty string StatusItemPicker::shortName
This property holds the secondary text or short name to be displayed. This property holds the secondary text or short name to be displayed.
@ -81,6 +87,15 @@ Rectangle {
*/ */
property ButtonGroup radioGroup property ButtonGroup radioGroup
/*!
\qmlproperty int StatusItemPicker::radioButtonSize
This property holds size type of the radio button.
Possible values are:
- Small
- Large (default size)
*/
property int radioButtonSize: StatusRadioButton.Size.Large
/*! /*!
\qmlsignal StatusItemPicker::checkedChanged(bool checked) \qmlsignal StatusItemPicker::checkedChanged(bool checked)
This signal is emitted when the item is selected by pressing the radiobutton or the checkbox. This signal is emitted when the item is selected by pressing the radiobutton or the checkbox.
@ -95,7 +110,7 @@ Rectangle {
QtObject { QtObject {
id: d id: d
property int minShortNameWidth: 50 readonly property int minShortNameWidth: root.shortName ? 50 : 0
function availableTextWidth() { function availableTextWidth() {
return root.width - imageItem.width - row.spacing - shortNameItem.anchors.rightMargin - selector.width - selector.anchors.rightMargin - 24/*Margin between both texts*/ return root.width - imageItem.width - row.spacing - shortNameItem.anchors.rightMargin - selector.width - selector.anchors.rightMargin - 24/*Margin between both texts*/
@ -112,10 +127,10 @@ Rectangle {
StatusIcon { StatusIcon {
id: imageItem id: imageItem
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
source: root.image.source ? root.image.source : "" source: root.image && root.image.source ? root.image.source : ""
width: root.image.width width: root.image ? root.image.width : 0
height: root.image.height height: root.image ? root.image.height : 0
visible: root.image.source !== undefined visible: root.image && root.image.source !== undefined
} }
StatusBaseText { StatusBaseText {
@ -126,7 +141,7 @@ Rectangle {
dummyNameItem.width dummyNameItem.width
text: root.name text: root.name
color: Theme.palette.directColor1 color: Theme.palette.directColor1
font.pixelSize: 15 font.pixelSize: root.namePixelSize
clip: true clip: true
elide: Text.ElideRight elide: Text.ElideRight
} }
@ -167,6 +182,7 @@ Rectangle {
Component { Component {
id: radioBtn id: radioBtn
StatusRadioButton { StatusRadioButton {
size: root.radioButtonSize
ButtonGroup.group: root.radioGroup ButtonGroup.group: root.radioGroup
checked: root.selected checked: root.selected
onCheckedChanged: { onCheckedChanged: {