sync repo
[mardrone] / mardrone / ConfigDialog.qml
index 655cc0f..81c94fe 100644 (file)
@@ -14,6 +14,33 @@ Page {
                 MenuItem { text:"Desktop";  onClicked: { drone.confActiveUI="ardrone_desktop.qml"}}
            }
         }
+        Component.onCompleted: {
+            console.debug("Appending items to choices",uiList.count())
+            for(var j = 0; j < uiList.count();++j ) {
+                var data = {'name':uiList.get(j).name,'file':uiList.get(j).file };
+ //                 var data = {'name':uiList.get(j).name };
+                console.debug("appending ",uiList.get(j).name,uiList.get(j).file);
+                choices.append(data);
+                if(uiList.get(j).file==drone.confActiveUI) activeUIDialog.selectedIndex=j;
+            }
+        }
+
+        ListModel {
+             id: choices
+             ListElement {
+                 name:"none";
+                 file:"none.qml"
+             }
+        }
+        SelectionDialog {
+            id: activeUIDialog;
+            model:choices
+            onSelectedIndexChanged: {
+                          console.debug("onSelectedIndexChanged " + model.get(selectedIndex).name + ", " + model.get(selectedIndex).file);
+                          drone.confActiveUI=choices.get(selectedIndex).file
+                      }
+
+            }
         Flickable {
           id: dialogscrolarea
           anchors.fill: parent
@@ -35,7 +62,11 @@ Page {
               Button {
                   text:drone.confActiveUI
                   anchors.right:parent.right
-                  onClicked:uiMenu.open()
+                  onClicked: {
+                  //    activeUIDialog.setSelectedIndex(text);
+                      activeUIDialog.open();
+                  }
+             //     onClicked:uiMenu.open()
               }
           Text {
               width:350
@@ -205,13 +236,13 @@ Page {
                 property int textSize:30
                 id:calibrateDialog
                 tools:commonTools
+                Component.onCompleted: {
+                if (calibrateDialog.status != Component.Ready)
+                    console.log("Error loading component:", calibrateDialog.errorString());
+                }
                 JoyStickCalibrator {
                     id:jc
-                //    jStick:js
-                    Component.onCompleted: {
-                        if (jc.status != Component.Ready)
-                                    console.log("Error loading component:", jc.errorString());
-                    }
+
                 }
 
         }