From 98ad7852673843cfd53dce9d5dc99a76ad75aa3e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 3 Mar 2016 00:04:15 +1300 Subject: [PATCH] Get ComboBox working --- .../resources/qml/controls-uit/ComboBox.qml | 28 +++++++++++++++---- .../preferences/ComboBoxPreference.qml | 21 ++++++++------ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/interface/resources/qml/controls-uit/ComboBox.qml b/interface/resources/qml/controls-uit/ComboBox.qml index 40bbddc0fb..1382815462 100644 --- a/interface/resources/qml/controls-uit/ComboBox.qml +++ b/interface/resources/qml/controls-uit/ComboBox.qml @@ -12,18 +12,26 @@ import QtQuick 2.5 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 +import "../styles-uit" +import "../controls-uit" as HifiControls import "." as VrControls FocusScope { id: root + property alias model: comboBox.model; + property alias comboBox: comboBox readonly property alias currentText: comboBox.currentText; property alias currentIndex: comboBox.currentIndex; + + property int colorScheme: hifi.colorSchemes.light + readonly property bool isLightColorScheme: colorScheme == hifi.colorSchemes.light + property string label: "" + property real controlHeight: height + (comboBoxLabel.visible ? comboBoxLabel.height + comboBoxLabel.anchors.bottomMargin : 0) + implicitHeight: comboBox.height; focus: true - readonly property ComboBox control: comboBox - Rectangle { id: background gradient: Gradient { @@ -61,9 +69,10 @@ FocusScope { anchors { right: parent.right; verticalCenter: parent.verticalCenter } width: 20 height: textField.height - VrControls.FontAwesome { - anchors.centerIn: parent; size: 16; - text: "\uf0d7" + HiFiGlyphs { + anchors.centerIn: parent + size: hifi.dimensions.spinnerSize + text: hifi.glyphs.caratDn } } @@ -157,4 +166,13 @@ FocusScope { } } + HifiControls.Label { + id: comboBoxLabel + text: root.label + colorScheme: root.colorScheme + anchors.left: parent.left + anchors.bottom: parent.top + anchors.bottomMargin: 4 + visible: label != "" + } } diff --git a/interface/resources/qml/dialogs/preferences/ComboBoxPreference.qml b/interface/resources/qml/dialogs/preferences/ComboBoxPreference.qml index be5c017bbd..c7f8bafca3 100644 --- a/interface/resources/qml/dialogs/preferences/ComboBoxPreference.qml +++ b/interface/resources/qml/dialogs/preferences/ComboBoxPreference.qml @@ -10,30 +10,33 @@ import QtQuick 2.5 -import "../../controls-uit" +import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles 1.4 +import "../../controls-uit" as HiFiControls +import "../../styles-uit" Preference { id: root - property alias comboBox: comboBox - height: comboBox.controlHeight + height: dataComboBox.controlHeight Component.onCompleted: { - comboBox.currentIndex = comboBox.find(preference.value); + dataComboBox.currentIndex = dataComboBox.comboBox.find(preference.value); } function save() { - preference.value = comboBox.currentText; + preference.value = dataComboBox.currentText; + //preference.value = comboBox.currentText; preference.save(); } - Label { + HiFiControls.Label { text: root.label + ":" colorScheme: hifi.colorSchemes.dark - anchors.verticalCenter: comboBox.verticalCenter + anchors.verticalCenter: dataComboBox.verticalCenter } - ComboBox { - id: comboBox + HiFiControls.ComboBox { + id: dataComboBox model: preference.items width: 150 anchors { right: parent.right }