Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions QtQuick/Controls/ComboBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,25 @@ Item {

id: self

property var model: ['value1','value2','value3', 'value4']
property var model: ['option1', 'option2', 'option3', 'option4']

property int currentIndex: 0
property string currentText: model[currentIndex]
property int count: 0
property int count: model.length

Component.onCompleted: {
init();
}

function handleSelectItem(e){
var index = parseInt(e.target?e.target.value:currentIndex);
currentIndex = index;
currentIndex = parseInt(e.target?e.target.value:currentIndex);
}

function init() {
self.dom.style.pointerEvents = "auto";
var count = model.length;

count = model.length;
currentIndex = (currentIndex >= count) ? 0 : currentIndex;
self.dom.style.pointerEvents = "auto";
currentIndex = (currentIndex >= count)?0:currentIndex;

var str = '';
for(var i = 0; i < count; i++) {
Expand All @@ -46,9 +45,9 @@ Item {
onCurrentIndexChanged: {
var item = self.dom.firstChild;
if (item && currentIndex <= count) {
//currentText = model[currentIndex]
//debugger;
item.children[currentIndex].selected = true;
} else {
currentIndex = 0
}
}

Expand Down
56 changes: 56 additions & 0 deletions QtQuick/Controls/ProgressBar.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import QtQuick 2.1
import QtQuick.Controls 1.2

Embed {
height: 30
width: 200

id: self

property real maximumValue: 1
property real minimumValue: 0
property real value: 0
property bool indeterminate: true

property bool flag: true

Component.onCompleted: {
init();
}

function init() {
var html;
if (indeterminate) {
html = "<progress max='1'>indeterminate</progress>";
} else {
html = "<progress value='"+value+"' max='"
+maximumValue+"'> "+100*value/maximumValue+"% </progress>";
}
self.dom.innerHTML = html;
}

onIndeterminateChanged: {
init();
}

onMinimumValueChanged: {
minimumValue = maximumValue >= minimumValue?minimumValue:maximumValue;
value = value >= minimumValue?value:minimumValue;
}

onMaximumValueChanged: {
maximumValue = (maximumValue >= minimumValue)?maximumValue:minimumValue;

if (value <= maximumValue) {
init();
} else {
value = maximumValue;
}
}

onValueChanged: {
value = (value <= maximumValue)?(value >= minimumValue?value:minimumValue):maximumValue;
init();
}
}

3 changes: 2 additions & 1 deletion QtQuick/Controls/qmldir
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Embed 1.0 Embed.qml
FileSelect 1.0 FileSelect.qml
Slider 1.0 Slider.qml
ComboBox 1.0 ComboBox.qml
ComboBox 1.0 ComboBox.qml
ProgressBar 1.0 ProgressBar.qml
43 changes: 39 additions & 4 deletions test/test.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import QtQuick.Controls 1.2

Item {
width: 500
height: 500
height: 600

Column {
x:5
Expand Down Expand Up @@ -31,7 +31,6 @@ Item {
title: "GroupBox test"
width: parent.width
id: gbox

Column {
spacing:3

Expand All @@ -57,7 +56,43 @@ Item {
onFileChanged: console.log("selected file=",file.name);
}
}
GroupBox {
title: "ProgressBar test"

Column {
spacing: 5
Row {
ProgressBar {
id: progress
maximumValue: 2
indeterminate: true
value: 1.6
}

Text {
text: "value="+progress.value +
", indeterminate=" + progress.indeterminate +
", percent=" + 100*progress.value/progress.maximumValue + "%"
}
}
Row {
spacing: 5
Button {
id: btn5
width: 160
text: "set 0.9 and determinate"
onClicked: progress.value = 0.9, progress.indeterminate = false
}

Button {
id: btn7
width: 160
text: "maximumValue"
onClicked: progress.maximumValue = 1
}
}
}
}

GroupBox {
title: "ComboBox test"
Expand All @@ -69,7 +104,7 @@ Item {
spacing:5
ComboBox {
id: select
model: ['bla','bla2','bla3', 'bla4', 'bla5', 'bla6', 'bla7']
model: ['item1','item2','item3', 'item4', 'item5', 'item6', 'item7']
currentIndex: 0
}

Expand All @@ -81,7 +116,7 @@ Item {
Button {
id: btn3
text: "newModel"
onClicked: select.model = ['olo','olo2','olo3', 'olo5']
onClicked: select.model = ['option1', 'option2', 'option3', 'option4']
}

Button {
Expand Down