mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mobile/UI: improve layout of styled ComboBox and TextField
This makes the TextFields (and the editable ComboBoxes with them) have a tighter visual experience. It also moves the indicater closer to the right edge in the ComboBox and doesn't use preferredWidth for the slim combo box as that implies a maximum width which could lead to unnecessary clipping. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9aa660e06e
commit
74bb2c49bf
3 changed files with 27 additions and 2 deletions
|
@ -11,9 +11,30 @@ Controls.TextField {
|
||||||
property var flickable
|
property var flickable
|
||||||
property bool firstTime: true
|
property bool firstTime: true
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set inComboBox if the TextField is used in an editable ComboBox
|
||||||
|
* this ensures that the baseline that is used to visually indicate that the user can
|
||||||
|
* edit the text as well as use the drop down is placed much closer to the actual text
|
||||||
|
*/
|
||||||
|
property bool inComboBox: false
|
||||||
|
|
||||||
id: stf
|
id: stf
|
||||||
|
background: Item {
|
||||||
|
Rectangle {
|
||||||
|
width: parent.width - Kirigami.Units.smallSpacing
|
||||||
|
x: inComboBox ? Kirigami.Units.smallSpacing : -1
|
||||||
|
height: 1
|
||||||
|
color: stf.focus ? subsurfaceTheme.primaryColor : Qt.darker(subsurfaceTheme.backgroundColor, 1.2)
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.bottomMargin: inComboBox ? Kirigami.Units.largeSpacing : 1
|
||||||
|
visible: !stf.readOnly
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// while we are at it, let's put some common settings here into the shared element
|
// while we are at it, let's put some common settings here into the shared element
|
||||||
|
font.pointSize: subsurfaceTheme.regularPointSize
|
||||||
|
topPadding: 0
|
||||||
|
bottomPadding: 0
|
||||||
color: subsurfaceTheme.textColor
|
color: subsurfaceTheme.textColor
|
||||||
onEditingFinished: {
|
onEditingFinished: {
|
||||||
focus = false
|
focus = false
|
||||||
|
|
|
@ -6,10 +6,12 @@ import org.kde.kirigami 2.4 as Kirigami
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: cb
|
id: cb
|
||||||
|
editable: false
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 2.5
|
Layout.preferredHeight: Kirigami.Units.gridUnit * 2.0
|
||||||
inputMethodHints: Qt.ImhNoPredictiveText
|
inputMethodHints: Qt.ImhNoPredictiveText
|
||||||
font.pointSize: subsurfaceTheme.regularPointSize
|
font.pointSize: subsurfaceTheme.regularPointSize
|
||||||
|
rightPadding: Kirigami.Units.smallSpacing
|
||||||
property var flickable // used to ensure the combobox is visible on screen
|
property var flickable // used to ensure the combobox is visible on screen
|
||||||
delegate: ItemDelegate {
|
delegate: ItemDelegate {
|
||||||
width: cb.width
|
width: cb.width
|
||||||
|
@ -49,6 +51,7 @@ ComboBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: SsrfTextField {
|
contentItem: SsrfTextField {
|
||||||
|
inComboBox: cb.editable
|
||||||
readOnly: !cb.editable
|
readOnly: !cb.editable
|
||||||
anchors.right: indicator.left
|
anchors.right: indicator.left
|
||||||
anchors.left: cb.left
|
anchors.left: cb.left
|
||||||
|
@ -59,6 +62,7 @@ ComboBox {
|
||||||
font: cb.font
|
font: cb.font
|
||||||
color: subsurfaceTheme.textColor
|
color: subsurfaceTheme.textColor
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
if (readOnly) {
|
if (readOnly) {
|
||||||
if (cb.popup.opened) {
|
if (cb.popup.opened) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ TemplateComboBox {
|
||||||
id: cb
|
id: cb
|
||||||
Layout.fillWidth: false
|
Layout.fillWidth: false
|
||||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
|
||||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 8
|
Layout.minimumWidth: Kirigami.Units.gridUnit * 8
|
||||||
contentItem: Text {
|
contentItem: Text {
|
||||||
text: cb.displayText
|
text: cb.displayText
|
||||||
font.pointSize: subsurfaceTheme.regularPointSize
|
font.pointSize: subsurfaceTheme.regularPointSize
|
||||||
|
|
Loading…
Add table
Reference in a new issue