Commit 54eb5496 authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Add MultiChoiceList component for Dashboard

parent 89954301
......@@ -169,6 +169,7 @@ Project {
"import/QtCAN/CanTestBench.2/CircularGauge.qml",
"import/QtCAN/CanTestBench.2/LedLight.qml",
"import/QtCAN/CanTestBench.2/LinearGauge.qml",
"import/QtCAN/CanTestBench.2/MultiChoiceList.qml",
"import/QtCAN/CanTestBench.2/NumberValueDisplay.qml",
"import/QtCAN/CanTestBench.2/OnOffSwitcher.qml",
"import/QtCAN/CanTestBench.2/Oscilloscope.qml",
......
import QtQuick 2.1;
import QtQmlTricks.UiElements 2.0;
import QtCAN.CanTestBench 2.0;
Item {
id: frame;
width: implicitWidth;
height: implicitHeight;
implicitWidth: layout.width;
implicitHeight: layout.height;
property int size : 20;
property int side : Borders.TOP;
property var model : [];
property string legend : "";
property int currentIdx : 0;
readonly property var currentKey : (Array.isArray (model) && currentIdx >= 0 && currentIdx < model.length ? model [currentIdx]["key"] : undefined);
readonly property var currentValue : (Array.isArray (model) && currentIdx >= 0 && currentIdx < model.length ? model [currentIdx]["value"] : undefined);
StretchColumnContainer {
id: layout;
Repeater {
model: frame.model;
delegate: MouseArea {
implicitWidth: (txt.contentWidth + txt.anchors.margins * 2);
implicitHeight: (txt.contentHeight + txt.anchors.margins * 2);
onClicked: { currentIdx = model.index; }
Rectangle {
color: Style.colorSelection;
visible: (model.index === currentIdx);
anchors.fill: parent;
}
TextLabel {
id: txt;
text: modelData ["value"];
font.pixelSize: size;
anchors.margins: (size * 0.5);
anchors.centerIn: parent;
}
}
}
}
TextLabel {
id: lbl;
text: legend;
opacity: 0.65;
font.pixelSize: (size * 0.85);
states: [
State {
when: (side === Borders.TOP);
AnchorChanges {
target: lbl;
anchors.bottom: frame.top;
anchors.horizontalCenter: frame.horizontalCenter;
}
PropertyChanges {
target: lbl;
rotation: 0;
anchors.bottomMargin: Style.spacingSmall;
}
},
State {
when: (side === Borders.RIGHT);
AnchorChanges {
target: lbl;
anchors.verticalCenter: frame.verticalCenter;
anchors.horizontalCenter: frame.right;
}
PropertyChanges {
target: lbl;
rotation: -90;
anchors.horizontalCenterOffset: (Style.spacingSmall + Style.fontSizeNormal);
}
},
State {
when: (side === Borders.LEFT);
AnchorChanges {
target: lbl;
anchors.verticalCenter: frame.verticalCenter;
anchors.horizontalCenter: frame.left;
}
PropertyChanges {
target: lbl;
rotation: +90;
anchors.horizontalCenterOffset: -(Style.spacingSmall + Style.fontSizeNormal);
}
},
State {
when: (side === Borders.BOTTOM);
AnchorChanges {
target: lbl;
anchors.top: frame.bottom;
anchors.horizontalCenter: frame.horizontalCenter;
}
PropertyChanges {
target: lbl;
rotation: 0;
anchors.topMargin: Style.spacingSmall;
}
}
]
}
}
......@@ -10,3 +10,4 @@ RotativeKnob 2.0 RotativeKnob.qml
TicksJauge 2.0 TicksJauge.qml
Oscilloscope 2.0 Oscilloscope.qml
PlotParams 2.0 PlotParams.qml
MultiChoiceList 2.0 MultiChoiceList.qml
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment