From 871e29d03189d55f2ba725e284132b39da3d94e7 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 11 Jan 2021 08:49:23 -0800 Subject: [PATCH] mobile/UI: add another variation of the combo box This one is designed to be fixed size and space efficient, non editable. It's used in the statistics page for now and looks much better than what we have elsewhere, so the style should propagate to the rest of them as well, but this is trickier for the once that are editable - and of course the fixed width might also not be appropriate in other places. Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/StatisticsPage.qml | 12 +++++------ mobile-widgets/qml/TemplateSlimComboBox.qml | 22 +++++++++++++++++++++ mobile-widgets/qml/mobile-resources.qrc | 1 + 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 mobile-widgets/qml/TemplateSlimComboBox.qml diff --git a/mobile-widgets/qml/StatisticsPage.qml b/mobile-widgets/qml/StatisticsPage.qml index fe6e3666d..2948dd067 100644 --- a/mobile-widgets/qml/StatisticsPage.qml +++ b/mobile-widgets/qml/StatisticsPage.qml @@ -43,11 +43,10 @@ Kirigami.Page { TemplateLabelSmall { text: qsTr("Base variable") } - TemplateComboBox { + TemplateSlimComboBox { id: var1 model: statsManager.var1List currentIndex: statsManager.var1Index; - Layout.fillWidth: false onCurrentIndexChanged: { statsManager.var1Changed(currentIndex) } @@ -61,11 +60,10 @@ Kirigami.Page { TemplateLabelSmall { text: qsTr("Binning") } - TemplateComboBox { + TemplateSlimComboBox { id: var1Binner model: statsManager.binner1List currentIndex: statsManager.binner1Index; - Layout.fillWidth: false onCurrentIndexChanged: { statsManager.var1BinnerChanged(currentIndex) } @@ -79,7 +77,7 @@ Kirigami.Page { TemplateLabelSmall { text: qsTr("Data") } - TemplateComboBox { + TemplateSlimComboBox { id: var2 model: statsManager.var2List currentIndex: statsManager.var2Index; @@ -97,7 +95,7 @@ Kirigami.Page { TemplateLabelSmall { text: qsTr("Binning") } - TemplateComboBox { + TemplateSlimComboBox { id: var2Binner model: statsManager.binner2List currentIndex: statsManager.binner2Index; @@ -115,7 +113,7 @@ Kirigami.Page { TemplateLabelSmall { text: qsTr("Operation") } - TemplateComboBox { + TemplateSlimComboBox { id: var2Operation model: statsManager.operation2List currentIndex: statsManager.operation2Index; diff --git a/mobile-widgets/qml/TemplateSlimComboBox.qml b/mobile-widgets/qml/TemplateSlimComboBox.qml new file mode 100644 index 000000000..36137770a --- /dev/null +++ b/mobile-widgets/qml/TemplateSlimComboBox.qml @@ -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 + +TemplateComboBox { + id: cb + Layout.fillWidth: false + Layout.preferredHeight: Kirigami.Units.gridUnit * 2 + Layout.preferredWidth: Kirigami.Units.gridUnit * 8 + contentItem: Text { + text: cb.displayText + font.pointSize: subsurfaceTheme.regularPointSize + anchors.right: indicator.left + anchors.left: cb.left + color: subsurfaceTheme.textColor + leftPadding: Kirigami.Units.smallSpacing * 0.5 + rightPadding: Kirigami.Units.smallSpacing * 0.5 + verticalAlignment: Text.AlignVCenter + } +} diff --git a/mobile-widgets/qml/mobile-resources.qrc b/mobile-widgets/qml/mobile-resources.qrc index d0b285ab6..ffbaaac88 100644 --- a/mobile-widgets/qml/mobile-resources.qrc +++ b/mobile-widgets/qml/mobile-resources.qrc @@ -4,6 +4,7 @@ TemplateButton.qml TemplateCheckBox.qml TemplateComboBox.qml + TemplateSlimComboBox.qml TemplateEditComboBox.qml TemplateLabel.qml TemplateLabelSmall.qml