iconbrowser: improve the QML UI

Set different icons on the button depending on whether it's checked or
not (since in Qt Quick we always ask for QIcon's pixmap in the "Off"
state), and use Qt Quick Controls and layouts instead of positioners for
proper alignments of labels and text fields.

Change-Id: I1c5bd368560042ec4af8cf4bf1b9104d0257ac40
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Volker Hilsheimer 2024-11-28 18:08:16 +01:00
parent bf714c246b
commit 6fb39cefe3

View File

@ -3,29 +3,50 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
Column { ColumnLayout {
Row { anchors.left: parent.left
ToolButton { anchors.right: parent.right
id: normalButton ToolBar {
icon.name: iconName.text RowLayout {
} anchors.fill: parent
ToolButton { ToolButton {
id: disabledButton id: normalButton
enabled: false checkable: true
icon.name: iconName.text icon.name: checked ? iconNameOn.text : iconNameOff.text
} }
ToolButton { ToolButton {
id: checkedButton id: checkedButton
checked: true checked: true
icon.name: iconName.text checkable: true
icon.name: checked ? iconNameOn.text : iconNameOff.text
}
ToolButton {
id: disabledButton
enabled: false
icon.name: checked ? iconNameOn.text : iconNameOff.text
}
} }
} }
TextField {
id: iconName RowLayout {
text: "folder" Label {
text: "Off:"
}
TextField {
id: iconNameOff
text: "mail-mark-read"
}
Label {
text: "On:"
}
TextField {
id: iconNameOn
text: "mail-mark-unread"
}
} }
} }
} }