From: Kate Alhola Date: Mon, 11 Jun 2012 07:52:46 +0000 (+0300) Subject: improved desktop UI X-Git-Url: http://git.maemo.org/git/?p=mardrone;a=commitdiff_plain;h=04dd9eeea7b747c1cee4882673a7e1c17519fe1a improved desktop UI --- diff --git a/mardrone/BarGauge.qml b/mardrone/BarGauge.qml index d28594b..3c19dec 100644 --- a/mardrone/BarGauge.qml +++ b/mardrone/BarGauge.qml @@ -2,9 +2,7 @@ import QtQuick 1.0 Rectangle { color:"#00000000" - border.color: "black" - width: 20 - height: 100 + border.color: "darkGrey" property bool horiz:false property real val:0 property real max:100 diff --git a/mardrone/CalibrateDialogDesktop.qml b/mardrone/CalibrateDialogDesktop.qml index 849444f..9816b8a 100644 --- a/mardrone/CalibrateDialogDesktop.qml +++ b/mardrone/CalibrateDialogDesktop.qml @@ -4,8 +4,8 @@ Dialog { property color textColor:"black" property int textSize:30 id:calibrateDialog - width: 800 - height: 600 + width: 900 + height: 500 data: JoyStickCalibratorDesktop { id:jsCalibrator diff --git a/mardrone/ConfigDialog.qml b/mardrone/ConfigDialog.qml index f306388..c680851 100644 --- a/mardrone/ConfigDialog.qml +++ b/mardrone/ConfigDialog.qml @@ -2,18 +2,11 @@ import QtQuick 1.0 import com.nokia.meego 1.0 import JoyStick 1.0 Page { - property color textColor:"black" + property color textColor:"White" property int textSize:30 id:dialog tools:commonTools - Menu { - id:uiMenu - visualParent:pageStack - MenuLayout { - MenuItem { text:"MeeGo/Harmattan 854x480"; onClicked: { drone.confActiveUI="ardrone_harmattan.qml" }} - 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 ) { diff --git a/mardrone/ConfigDialogAndroid.qml b/mardrone/ConfigDialogAndroid.qml index d3f719f..e1e2897 100644 --- a/mardrone/ConfigDialogAndroid.qml +++ b/mardrone/ConfigDialogAndroid.qml @@ -5,15 +5,8 @@ Page { property color textColor:"white" property int textSize:30 id:dialog - tools:commonTools - Menu { - id:uiMenu - visualParent:pageStack - MenuLayout { - MenuItem { text:"MeeGo/Harmattan 854x480"; onClicked: { drone.confActiveUI="ardrone_harmattan.qml" }} - MenuItem { text:"Desktop"; onClicked: { drone.confActiveUI="ardrone_desktop.qml"}} - } - } + // tools:commonTools + Component.onCompleted: { console.debug("Appending items to choices",uiList.count()) for(var j = 0; j < uiList.count();++j ) { diff --git a/mardrone/JoyStickCalibratorDesktop.qml b/mardrone/JoyStickCalibratorDesktop.qml index 5893d42..6e78f5f 100644 --- a/mardrone/JoyStickCalibratorDesktop.qml +++ b/mardrone/JoyStickCalibratorDesktop.qml @@ -4,11 +4,12 @@ import QtDesktop 0.1 Item { width: 600 - height: 800 + height: 600 property int textSize:22 property int ctrlSize:40 ListModel { id: axisMapModel + ListElement { text:"none"; mapAxis:0 } ListElement { text:"Aileron"; mapAxis:1 } ListElement { text:"Elevator"; mapAxis:2 } ListElement { text:"Throtle"; mapAxis:3 } @@ -156,17 +157,17 @@ Item { } Column { Button{ - text:"Reset" + width:160 + text:"Calibrate" onClicked:{ - js.calibrate=false - pageStack.pop(); + js.calibrate=true } } Button{ + width:160 text:"Save" onClicked:{ js.calibrate=false - pageStack.pop(); } } } @@ -176,7 +177,7 @@ Item { columns:7 Text { font.pixelSize :textSize - text:" Raw" + text:" Raw" } Text { font.pixelSize :textSize @@ -238,18 +239,17 @@ Item { width:200; model: axisMapModel onSelectedIndexChanged: { - console.debug("onSelectedIndexChanged " + selectedText + ", " + selectedIndex); - js.mapAxis1=selectedIndex+1; + console.debug("onSelectedIndexChanged axis1:" + selectedText + ", " + selectedIndex); + // js.mapAxis1=selectedIndex; } - selectedIndex:js.mapAxis1-1 + + selectedIndex:js.mapAxis1 } -/* Button{ - width:200;height:ctrlSize - text:js.mapAxis1==1?"Aileron":js.mapAxis1==2?"Elevator":js.mapAxis1==3?"Throtle":js.mapAxis1==4?"Rudder":"none" - onClicked:js1map.open() + Binding { + target:js + property:"mapAxis1" + value:axisMap1UICombo.selectedIndex } -*/ - Text { font.pixelSize :textSize @@ -278,12 +278,16 @@ Item { checked:js.invertAxis2 onCheckedChanged:{js.invertAxis2=checked;} } - Button{ - width:200;height:ctrlSize - text:js.mapAxis2==1?"Aileron":js.mapAxis2==2?"Elevator":js.mapAxis2==3?"Throtle":js.mapAxis2==4?"Rudder":"none" - onClicked:js2map.open() - } - + ComboBox { + id: axisMap2UICombo; + width:200; + model: axisMapModel + onSelectedIndexChanged: { + console.debug("onSelectedIndexChanged " + selectedText + ", " + selectedIndex); + // js.mapAxis2=selectedIndex+1; + } + selectedIndex:js.mapAxis2 + } Text { @@ -313,12 +317,16 @@ Item { checked:js.invertAxis3 onCheckedChanged:{js.invertAxis3=checked;} } - Button{ - width:200;height:ctrlSize - text:js.mapAxis3==1?"Aileron":js.mapAxis3==2?"Elevator":js.mapAxis3==3?"Throtle":js.mapAxis3==4?"Rudder":"none" - onClicked:js3map.open() - } - + ComboBox { + id: axisMap3UICombo; + width:200; + model: axisMapModel + onSelectedIndexChanged: { + console.debug("onSelectedIndexChanged " + selectedText + ", " + selectedIndex); + // js.mapAxis3=selectedIndex+1; + } + selectedIndex:js.mapAxis3 + } Text { font.pixelSize :textSize text:js.rawAxis4 @@ -346,12 +354,16 @@ Item { checked:js.invertAxis4 onCheckedChanged:{js.invertAxis4=checked;} } - Button{ - width:200;height:ctrlSize - text:js.mapAxis4==1?"Aileron":js.mapAxis4==2?"Elevator":js.mapAxis4==3?"Throtle":js.mapAxis4==4?"Rudder":"none" - onClicked:js4map.open() - } - + ComboBox { + id: axisMap4UICombo; + width:200; + model: axisMapModel + onSelectedIndexChanged: { + console.debug("onSelectedIndexChanged " + selectedText + ", " + selectedIndex); + // js.mapAxis4=selectedIndex+1; + } + selectedIndex:js.mapAxis4 + } Text { font.pixelSize :textSize text:js.rawAxis5 @@ -379,12 +391,16 @@ Item { checked:js.invertAxis5 onCheckedChanged:{js.invertAxis5=checked;} } - Button{ - width:200;height:ctrlSize - text:js.mapAxis5==1?"Aileron":js.mapAxis5==2?"Elevator":js.mapAxis5==3?"Throtle":js.mapAxis5==4?"Rudder":"none" - onClicked:js5map.open() - } - + ComboBox { + id: axisMap5UICombo; + width:200; + model: axisMapModel + onSelectedIndexChanged: { + console.debug("onSelectedIndexChanged " + selectedText + ", " + selectedIndex); + // js.mapAxis5=selectedIndex+1; + } + selectedIndex:js.mapAxis5 + } Text { font.pixelSize :textSize text:js.rawAxis6 @@ -412,11 +428,16 @@ Item { checked:js.invertAxis6 onCheckedChanged:{js.invertAxis6=checked;} } - Button{ - width:200;height:ctrlSize - text:js.mapAxis6==1?"Aileron":js.mapAxis6==2?"Elevator":js.mapAxis6==3?"Throtle":js.mapAxis6==4?"Rudder":"none" - onClicked:js6map.open() - } + ComboBox { + id: axisMap6UICombo; + width:200; + model: axisMapModel + onSelectedIndexChanged: { + console.debug("onSelectedIndexChanged " + selectedText + ", " + selectedIndex); + // js.mapAxis6=selectedIndex+1; + } + selectedIndex:js.mapAxis6 + } } } diff --git a/mardrone/ardrone_android.qml b/mardrone/ardrone_android.qml index c035488..4e24d26 100644 --- a/mardrone/ardrone_android.qml +++ b/mardrone/ardrone_android.qml @@ -13,15 +13,6 @@ PageStackWindow { property Component dialogComponent // property alias m: mainPage - /* - ToolBarLayout { - id: commonTools - visible: false - ToolItem { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); } - // ToolItem { iconId: "icon-m-toolbar-home"; onClicked: pageStack.pop(); } - ToolItem { iconId: "icon-m-toolbar-view-menu"; onClicked: myMenu.open(); } - } - */ ToolBarLayout { id: commonTools ToolButton { @@ -41,6 +32,30 @@ PageStackWindow { onRudderChanged: {if(drone.confUseJoyStick) drone.yaw=rudder;} } + Keys.onUpPressed: { + console.debug("QML:Keys.onUpPressed",event.key) + if (event.key == Qt.Key_TopMenu) + console.debug("QML: opening menu!") + else if (event.key == Qt.Key_MediaPrevious) { + console.debug("QML: closing! (maybe)") + pageStack.depth <= 1 ? Qt.quit() : pageStack.pop() + } + } + Keys.onPressed: { + console.debug("QML:Keys.onPressed",event.key) + if (event.key == Qt.Key_TopMenu) + console.debug("QML: opening menu!") + else if (event.key == Qt.Key_MediaPrevious) { + console.debug("QML: closing! (maybe)") + pageStack.depth <= 1 ? Qt.quit() : pageStack.pop() + } + } + + function backKey() { + console.debug("QML: backKey") + pageStack.depth <= 1 ? Qt.quit() : pageStack.pop() + } + Component { id: mainpageComponent @@ -219,7 +234,7 @@ PageStackWindow { Button { x:400 - width:60 + width:80 height:50 id:flyButton anchors.bottom:parent.bottom @@ -232,7 +247,7 @@ PageStackWindow { } Button { x:500; - width:80 + width:90 height:50 id:emergencyButton anchors.bottom:parent.bottom diff --git a/mardrone/ardrone_desktop.qml b/mardrone/ardrone_desktop.qml index 196182a..d5bf0b8 100644 --- a/mardrone/ardrone_desktop.qml +++ b/mardrone/ardrone_desktop.qml @@ -8,12 +8,12 @@ import JoyStick 1.0 Window { title: "MArdrone" id:mainWindow - width: 1024 + width: 700 height: 800 maximumHeight: mainWindow.height minimumHeight: 800 maximumWidth: 1280 - minimumWidth: 800 + minimumWidth: 700 visible: true @@ -62,10 +62,11 @@ Window { Column { width:parent.width - spacing:5 + // spacing:5 Rectangle { id:mainWiew width:parent.width + color:"black" height:480 //onEntered:(mainWindow.fullscreen=true) @@ -206,8 +207,21 @@ Window { onPressedChanged: { drone.ctrlActive=pressed;} } } + + Rectangle { + width:parent.width + // width:chlidrenRect.width + // height:childrenRect.height + height:320 + color: "black" + + + Row { + id:instrumentPanel spacing:5 + anchors.fill:parent + anchors.margins:5 EfisPFD { id:pDF @@ -239,88 +253,176 @@ Window { pitch:drone.dronePitch bezel:"bezel.png" } - HeadingGauge { + Item { width:120 height:120 - id:hdgGauge - value:drone.droneYaw - bezel:"bezel.png" - } + + GaugeArc { - width:120 - height:120 - id:fuelGauge - anchors.margins:10 - displayScale:0.85 + anchors.fill:parent + id:speedGauge + // anchors.margins:10 + displayScale:0.95 font.pixelSize:10 - tickIncrement:10 + tickIncrement:20 tickSpacing:24 tickMinor:5 lowPosition:220 highPosition:120 low:0 - high:100 + high:200 gaugeStyle:2 color:"white" - value:drone.droneVBat + value:drone.droneSpeed lineWidth:2 backColor:"black" } - GaugeHSI{ - anchors.margins:10 - displayScale:0.5 + Image { + anchors.fill:parent + source:"bezel.png" + } + } + + Item { width:120 height:120 + + + GaugeArc { + anchors.fill:parent + id:fuelGauge + // anchors.margins:10 + displayScale:0.95 font.pixelSize:10 - tickIncrement:30 - tickSpacing:10 + tickIncrement:10 + tickSpacing:22 tickMinor:5 + lowPosition:240 + highPosition:120 + low:0 + high:100 gaugeStyle:2 color:"white" + value:drone.droneVBat + lineWidth:2 backColor:"black" - id:hsi } + Image { + anchors.fill:parent + source:"bezel.png" + } + } + Item { + width:120 + height:120 + HeadingGauge { + width:120 + height:120 + id:hdgGauge + value:drone.droneYaw + bezel:"bezel.png" + } + } + Item { + width:120 + height:120 + Rectangle { + anchors.fill:parent + anchors.margins:5 + color:"gray" + } Row { + anchors.centerIn:parent spacing: 5 - anchors.rightMargin: 10 - height:100 + anchors.margins: 30 + height:90 BarGauge { val:drone.pwm_motor1; max: 255 - height:100 + height:parent.height + width:10 } BarGauge { val:drone.pwm_motor2; max: 255 - height:100 + height:parent.height + width:10 } BarGauge { val:drone.pwm_motor3; max: 255 - height:100 + height:parent.height + width:10 } BarGauge { val:drone.pwm_motor4; max: 255 - height:100 + height:parent.height + width:10 } + /* BarGauge { val:drone.droneVBat max: 100 - height:100 + height:parent.height + width:10 + } + */ + } + Image { + anchors.fill:parent + source:"bezel.png" } } + Button { + + width:80 + height:50 + id:flyButton + // anchors.bottom:parent.bottom + anchors.margins:15 + text:"Fly"; + checkable:true + onClicked:{drone.fly=checked; + // mainWindow.fullsecreen=checked; + } + } + Button { + + width:90 + height:50 + id:emergencyButton + // anchors.bottom:parent.bottom + anchors.margins:15 + text:"Emrg"; + checkable:true + onClicked:{drone.emergency=checked;} + } + + Button { + + width:100 + height:50 + id:recordButton + // anchors.bottom:parent.bottom + anchors.margins:15 + text:"Rec"; + checkable:true + onClicked:{droneVideo.recVideo=checked; drone.logFileName=droneVideo.videoFileName; drone.recordLog=checked;} + } } // Grid if instruments - } // Column ( Main window content ) + } + } // Column ( Main window content ) + } Dialog { id:configDialog width:800 height:600 data:ConfigDialogDesktop {} } - } + } // Main page diff --git a/mardrone/ardrone_harmattan.qml b/mardrone/ardrone_harmattan.qml index 7451b9a..49c3fe5 100644 --- a/mardrone/ardrone_harmattan.qml +++ b/mardrone/ardrone_harmattan.qml @@ -35,6 +35,20 @@ PageStackWindow { onRudderChanged: {if(drone.confUseJoyStick) drone.yaw=rudder;} } + Keys.onPressed: { + console.debug("QML:Keys.onPressed",event.key) + if (event.key == Qt.Key_TopMenu) + console.debug("QML: opening menu!") + else if (event.key == Qt.Key_Close) { + console.debug("QML: closing! (maybe)") + pageStack.depth <= 1 ? Qt.quit() : pageStack.pop() + } + } + + function backKey() { + console.debug("QML: backKey") + pageStack.depth <= 1 ? Qt.quit() : pageStack.pop() + } Component { id: mainpageComponent diff --git a/mardrone/dronelib/joystick.cpp b/mardrone/dronelib/joystick.cpp index 5cc8bee..6f4dcc5 100644 --- a/mardrone/dronelib/joystick.cpp +++ b/mardrone/dronelib/joystick.cpp @@ -78,6 +78,7 @@ void JoyStick::setCalibrate(bool val) { if(m_joyCal && !val ) saveCalibration(); m_joyCal=val; + emit joyStickConfigChanged(); }; diff --git a/mardrone/dronelib/joystick.h b/mardrone/dronelib/joystick.h index 7cb8034..31b9c91 100644 --- a/mardrone/dronelib/joystick.h +++ b/mardrone/dronelib/joystick.h @@ -12,8 +12,9 @@ class JoyStick : public QObject { Q_OBJECT - Q_PROPERTY(bool haveJoyStick READ haveJoyStick NOTIFY joyStickChanged) - Q_PROPERTY(QString joyStickName READ joyStickName NOTIFY joyStickChanged) + Q_PROPERTY(bool haveJoyStick READ haveJoyStick NOTIFY joyStickConfigChanged) + Q_PROPERTY(bool calibrate READ calibrate WRITE setCalibrate NOTIFY joyStickConfigChanged) + Q_PROPERTY(QString joyStickName READ joyStickName NOTIFY joyStickConfigChanged) Q_PROPERTY(int rawAxis1 READ rawAxis1 NOTIFY joyStickChanged) Q_PROPERTY(int rawAxis2 READ rawAxis2 NOTIFY joyStickChanged) Q_PROPERTY(int rawAxis3 READ rawAxis3 NOTIFY joyStickChanged) @@ -48,20 +49,19 @@ class JoyStick : public QObject Q_PROPERTY(float elevator READ axis2 NOTIFY joyStickChanged) Q_PROPERTY(float throtle READ axis3 NOTIFY joyStickChanged) Q_PROPERTY(float rudder READ axis4 NOTIFY joyStickChanged) - Q_PROPERTY(int mapAxis1 READ mapAxis1 WRITE setMapAxis1 NOTIFY joyStickChanged) - Q_PROPERTY(int mapAxis2 READ mapAxis2 WRITE setMapAxis2 NOTIFY joyStickChanged) - Q_PROPERTY(int mapAxis3 READ mapAxis3 WRITE setMapAxis3 NOTIFY joyStickChanged) - Q_PROPERTY(int mapAxis4 READ mapAxis4 WRITE setMapAxis4 NOTIFY joyStickChanged) - Q_PROPERTY(int mapAxis5 READ mapAxis5 WRITE setMapAxis5 NOTIFY joyStickChanged) - Q_PROPERTY(int mapAxis6 READ mapAxis6 WRITE setMapAxis6 NOTIFY joyStickChanged) - Q_PROPERTY(bool invertAxis1 READ invertAxis1 WRITE setInvertAxis1 NOTIFY joyStickChanged) - Q_PROPERTY(bool invertAxis2 READ invertAxis2 WRITE setInvertAxis2 NOTIFY joyStickChanged) - Q_PROPERTY(bool invertAxis3 READ invertAxis3 WRITE setInvertAxis3 NOTIFY joyStickChanged) - Q_PROPERTY(bool invertAxis4 READ invertAxis4 WRITE setInvertAxis4 NOTIFY joyStickChanged) - Q_PROPERTY(bool invertAxis5 READ invertAxis5 WRITE setInvertAxis5 NOTIFY joyStickChanged) - Q_PROPERTY(bool invertAxis6 READ invertAxis6 WRITE setInvertAxis6 NOTIFY joyStickChanged) - Q_PROPERTY(bool calibrate READ calibrate WRITE setCalibrate) -public: + Q_PROPERTY(int mapAxis1 READ mapAxis1 WRITE setMapAxis1 NOTIFY joyStickConfigChanged) + Q_PROPERTY(int mapAxis2 READ mapAxis2 WRITE setMapAxis2 NOTIFY joyStickConfigChanged) + Q_PROPERTY(int mapAxis3 READ mapAxis3 WRITE setMapAxis3 NOTIFY joyStickConfigChanged) + Q_PROPERTY(int mapAxis4 READ mapAxis4 WRITE setMapAxis4 NOTIFY joyStickConfigChanged) + Q_PROPERTY(int mapAxis5 READ mapAxis5 WRITE setMapAxis5 NOTIFY joyStickConfigChanged) + Q_PROPERTY(int mapAxis6 READ mapAxis6 WRITE setMapAxis6 NOTIFY joyStickConfigChanged) + Q_PROPERTY(bool invertAxis1 READ invertAxis1 WRITE setInvertAxis1 NOTIFY joyStickConfigChanged) + Q_PROPERTY(bool invertAxis2 READ invertAxis2 WRITE setInvertAxis2 NOTIFY joyStickConfigChanged) + Q_PROPERTY(bool invertAxis3 READ invertAxis3 WRITE setInvertAxis3 NOTIFY joyStickConfigChanged) + Q_PROPERTY(bool invertAxis4 READ invertAxis4 WRITE setInvertAxis4 NOTIFY joyStickConfigChanged) + Q_PROPERTY(bool invertAxis5 READ invertAxis5 WRITE setInvertAxis5 NOTIFY joyStickConfigChanged) + Q_PROPERTY(bool invertAxis6 READ invertAxis6 WRITE setInvertAxis6 NOTIFY joyStickConfigChanged) + public: explicit JoyStick(QObject *parent = 0); ~JoyStick(); // JoyStick configuration @@ -109,18 +109,18 @@ public: int invertAxis4() { return m_invertAxis4; }; int invertAxis5() { return m_invertAxis5; }; int invertAxis6() { return m_invertAxis6; }; - void setInvertAxis1(bool val) { m_invertAxis1=val; }; - void setInvertAxis2(bool val) { m_invertAxis2=val; }; - void setInvertAxis3(bool val) { m_invertAxis3=val; }; - void setInvertAxis4(bool val) { m_invertAxis4=val; }; - void setInvertAxis5(bool val) { m_invertAxis5=val; }; - void setInvertAxis6(bool val) { m_invertAxis6=val; }; - void setMapAxis1(int val) { m_mapAxis[0]=val; }; - void setMapAxis2(int val) { m_mapAxis[1]=val; }; - void setMapAxis3(int val) { m_mapAxis[2]=val; }; - void setMapAxis4(int val) { m_mapAxis[3]=val; }; - void setMapAxis5(int val) { m_mapAxis[4]=val; }; - void setMapAxis6(int val) { m_mapAxis[5]=val; }; + void setInvertAxis1(bool val) { m_invertAxis1=val;emit joyStickConfigChanged(); }; + void setInvertAxis2(bool val) { m_invertAxis2=val;emit joyStickConfigChanged(); }; + void setInvertAxis3(bool val) { m_invertAxis3=val;emit joyStickConfigChanged(); }; + void setInvertAxis4(bool val) { m_invertAxis4=val;emit joyStickConfigChanged(); }; + void setInvertAxis5(bool val) { m_invertAxis5=val;emit joyStickConfigChanged(); }; + void setInvertAxis6(bool val) { m_invertAxis6=val;emit joyStickConfigChanged(); }; + void setMapAxis1(int val) { if(m_mapAxis[0]!=val) emit joyStickConfigChanged();m_mapAxis[0]=val; }; + void setMapAxis2(int val) { if(m_mapAxis[1]!=val) emit joyStickConfigChanged();m_mapAxis[1]=val; }; + void setMapAxis3(int val) { if(m_mapAxis[2]!=val) emit joyStickConfigChanged();m_mapAxis[2]=val; }; + void setMapAxis4(int val) { if(m_mapAxis[3]!=val) emit joyStickConfigChanged();m_mapAxis[3]=val; }; + void setMapAxis5(int val) { if(m_mapAxis[4]!=val) emit joyStickConfigChanged();m_mapAxis[4]=val; }; + void setMapAxis6(int val) { if(m_mapAxis[5]!=val) emit joyStickConfigChanged();m_mapAxis[5]=val; }; float getMapped(int axis); void setMapped(int axis,float value); bool calibrate() { return m_joyCal; }; @@ -131,6 +131,7 @@ public: signals: void joyStickChanged(); + void joyStickConfigChanged(); public slots: void updateJoyStick(); private: