mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mobile/UI: add template for editable combo box
This makes the code easier to read and manage. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
48c3e017d6
commit
d6456d490f
3 changed files with 31 additions and 40 deletions
|
@ -154,14 +154,10 @@ Item {
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
text: qsTr("Location:")
|
text: qsTr("Location:")
|
||||||
}
|
}
|
||||||
TemplateComboBox {
|
TemplateEditComboBox {
|
||||||
id: locationBox
|
id: locationBox
|
||||||
editable: true
|
|
||||||
flat: true
|
|
||||||
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
||||||
manager.locationList : null
|
manager.locationList : null
|
||||||
inputMethodHints: Qt.ImhNoPredictiveText
|
|
||||||
Layout.fillWidth: true
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
focus = false
|
focus = false
|
||||||
gpsText = manager.getGpsFromSiteName(editText)
|
gpsText = manager.getGpsFromSiteName(editText)
|
||||||
|
@ -261,20 +257,10 @@ Item {
|
||||||
font.pointSize: subsurfaceTheme.smallPointSize
|
font.pointSize: subsurfaceTheme.smallPointSize
|
||||||
color: subsurfaceTheme.textColor
|
color: subsurfaceTheme.textColor
|
||||||
}
|
}
|
||||||
TemplateComboBox {
|
TemplateEditComboBox {
|
||||||
id: suitBox
|
id: suitBox
|
||||||
editable: true
|
|
||||||
flat: true
|
|
||||||
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
||||||
manager.suitList : null
|
manager.suitList : null
|
||||||
inputMethodHints: Qt.ImhNoPredictiveText
|
|
||||||
Layout.fillWidth: true
|
|
||||||
onActivated: {
|
|
||||||
focus = false
|
|
||||||
}
|
|
||||||
onAccepted: {
|
|
||||||
focus = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
|
@ -283,19 +269,10 @@ Item {
|
||||||
font.pointSize: subsurfaceTheme.smallPointSize
|
font.pointSize: subsurfaceTheme.smallPointSize
|
||||||
color: subsurfaceTheme.textColor
|
color: subsurfaceTheme.textColor
|
||||||
}
|
}
|
||||||
TemplateComboBox {
|
TemplateEditComboBox {
|
||||||
id: buddyBox
|
id: buddyBox
|
||||||
editable: true
|
|
||||||
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
||||||
manager.buddyList : null
|
manager.buddyList : null
|
||||||
inputMethodHints: Qt.ImhNoPredictiveText
|
|
||||||
Layout.fillWidth: true
|
|
||||||
onActivated: {
|
|
||||||
focus = false
|
|
||||||
}
|
|
||||||
onAccepted: {
|
|
||||||
focus = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
|
@ -304,19 +281,10 @@ Item {
|
||||||
font.pointSize: subsurfaceTheme.smallPointSize
|
font.pointSize: subsurfaceTheme.smallPointSize
|
||||||
color: subsurfaceTheme.textColor
|
color: subsurfaceTheme.textColor
|
||||||
}
|
}
|
||||||
TemplateComboBox {
|
TemplateEditComboBox {
|
||||||
id: divemasterBox
|
id: divemasterBox
|
||||||
editable: true
|
|
||||||
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
||||||
manager.divemasterList : null
|
manager.divemasterList : null
|
||||||
inputMethodHints: Qt.ImhNoPredictiveText
|
|
||||||
Layout.fillWidth: true
|
|
||||||
onActivated: {
|
|
||||||
focus = false
|
|
||||||
}
|
|
||||||
onAccepted: {
|
|
||||||
focus = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
|
|
22
mobile-widgets/qml/TemplateEditComboBox.qml
Normal file
22
mobile-widgets/qml/TemplateEditComboBox.qml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
import QtQuick 2.11
|
||||||
|
import QtQuick.Controls 2.4
|
||||||
|
import QtQuick.Layouts 1.11
|
||||||
|
import org.kde.kirigami 2.4 as Kirigami
|
||||||
|
|
||||||
|
// this reuses our themed combo box, but makes it editable and behave consistently
|
||||||
|
// for the dive edit page - this reduces redundant code on that page
|
||||||
|
TemplateComboBox {
|
||||||
|
id: ecb
|
||||||
|
editable: true
|
||||||
|
inputMethodHints: Qt.ImhNoPredictiveText
|
||||||
|
onActivated: {
|
||||||
|
focus = false
|
||||||
|
}
|
||||||
|
onAccepted: {
|
||||||
|
focus = false
|
||||||
|
}
|
||||||
|
onEditTextChanged: { // this allows us to set the initial text in DiveDetails / startEditMode()
|
||||||
|
displayText = editText
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
<file>TemplateButton.qml</file>
|
<file>TemplateButton.qml</file>
|
||||||
<file>TemplateCheckBox.qml</file>
|
<file>TemplateCheckBox.qml</file>
|
||||||
<file>TemplateComboBox.qml</file>
|
<file>TemplateComboBox.qml</file>
|
||||||
|
<file>TemplateEditComboBox.qml</file>
|
||||||
<file>TemplateLabel.qml</file>
|
<file>TemplateLabel.qml</file>
|
||||||
<file>TemplateLabelSmall.qml</file>
|
<file>TemplateLabelSmall.qml</file>
|
||||||
<file>TemplateLine.qml</file>
|
<file>TemplateLine.qml</file>
|
||||||
|
|
Loading…
Add table
Reference in a new issue