MainToolBar.qml 11.1 KB
Newer Older
dogmaphobic's avatar
dogmaphobic committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*=====================================================================

QGroundControl Open Source Ground Control Station

(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

This file is part of the QGROUNDCONTROL project

    QGROUNDCONTROL is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QGROUNDCONTROL is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

======================================================================*/

/**
 * @file
 *   @brief QGC Main Tool Bar
 *   @author Gus Grubba <mavlink@grubba.com>
 */

dogmaphobic's avatar
dogmaphobic committed
30
import QtQuick 2.5
dogmaphobic's avatar
dogmaphobic committed
31 32 33
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2

Don Gagne's avatar
Don Gagne committed
34
import QGroundControl                       1.0
35 36 37 38 39
import QGroundControl.Controls              1.0
import QGroundControl.FactControls          1.0
import QGroundControl.Palette               1.0
import QGroundControl.MultiVehicleManager   1.0
import QGroundControl.ScreenTools           1.0
40
import QGroundControl.Controllers           1.0
dogmaphobic's avatar
dogmaphobic committed
41

42
Rectangle {
dogmaphobic's avatar
dogmaphobic committed
43
    id:     toolBar
dogmaphobic's avatar
dogmaphobic committed
44
    color:  opaqueBackground ? "#404040" : (isBackgroundDark ? Qt.rgba(0,0,0,0.75) : Qt.rgba(0,0,0,0.5))
dogmaphobic's avatar
dogmaphobic committed
45

Don Gagne's avatar
Don Gagne committed
46
    QGCPalette { id: qgcPal; colorGroupEnabled: true }
47

dogmaphobic's avatar
dogmaphobic committed
48
    property var  activeVehicle:        multiVehicleManager.activeVehicle
dogmaphobic's avatar
dogmaphobic committed
49
    property var  mainWindow:           null
dogmaphobic's avatar
dogmaphobic committed
50 51
    property bool isMessageImportant:   activeVehicle ? !activeVehicle.messageTypeNormal && !activeVehicle.messageTypeNone : false
    property bool isBackgroundDark:     true
dogmaphobic's avatar
dogmaphobic committed
52
    property bool opaqueBackground:     false
53

dogmaphobic's avatar
dogmaphobic committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
    /*
        Dev System (Mac OS)

        qml: Main Window Width:   1008
        qml: Toolbar height:      51.2
        qml: Default font:        12.8
        qml: Font (.75):          9.600000000000001
        qml: Font (.85):          10.88
        qml: Font 1.5):           19.200000000000003
        qml: Default Font Width:  8.328125
        qml: Default Font Height: 12.8
        qml: --
        qml: Real Font Height:    16
        qml: fontHRatio:          1
        qml: --
        qml: cellHeight:          38
        qml: tbFontSmall:         10
        qml: tbFontNormal:        12
        qml: tbFontLarge:         18
        qml: tbSpacing:           9.54

        Nexus 9

        qml: Main Window Width:   2048
        qml: Toolbar height:      90.9312
        qml: Default font:        38
        qml: Font (.75):          28.5
        qml: Font (.85):          32.3
        qml: Font 1.5):           57
        qml: Default Font Width:  20.0625
        qml: Default Font Height: 38
        qml: --
        qml: Real Font Height:    38
        qml: fontHRatio:          2.375
        qml: --
        qml: cellHeight:          68
        qml: tbFontSmall:         23.75
        qml: tbFontNormal:        28.5
        qml: tbFontLarge:         42.75
        qml: tbSpacing:           16.87552

        Nexus 7

        qml: Main Window Width:   1920
        qml: Toolbar height:      85.248
        qml: Default font:        38
        qml: Font (.75):          28.5
        qml: Font (.85):          32.3
        qml: Font 1.5):           57
        qml: Default Font Width:  20.140625
        qml: Default Font Height: 38
        qml: --
        qml: Real Font Height:    38
        qml: fontHRatio:          2.375
        qml: --
        qml: cellHeight:          63
        qml: tbFontSmall:         23.75
        qml: tbFontNormal:        28.5
        qml: tbFontLarge:         42.75
        qml: tbSpacing:           15.820800000000002

        Nexus 4

        qml: Main Window Width:   1196
        qml: Toolbar height:      79.65360000000001
        qml: Default font:        38
        qml: Font (.75):          28.5
        qml: Font (.85):          32.3
        qml: Font 1.5):           57
        qml: Default Font Width:  20.140625
        qml: Default Font Height: 38
        qml: --
        qml: Real Font Height:    38
        qml: fontHRatio:          2.375
        qml: --
        qml: cellHeight:          59
        qml: tbFontSmall:         23.75
        qml: tbFontNormal:        28.5
        qml: tbFontLarge:         42.75
        qml: tbSpacing:           9.85504

    */

    readonly property real  tbFontSmall:    10 * ScreenTools.fontHRatio
    readonly property real  tbFontNormal:   12 * ScreenTools.fontHRatio
    readonly property real  tbFontLarge:    18 * ScreenTools.fontHRatio
dogmaphobic's avatar
dogmaphobic committed
140

dogmaphobic's avatar
dogmaphobic committed
141 142 143 144 145 146
    readonly property var   colorGreen:     "#05f068"
    readonly property var   colorOrange:    "#f0ab06"
    readonly property var   colorRed:       "#fc4638"
    readonly property var   colorGrey:      "#7f7f7f"
    readonly property var   colorBlue:      "#636efe"
    readonly property var   colorWhite:     "#ffffff"
147

148
    MainToolBarController { id: _controller }
dogmaphobic's avatar
dogmaphobic committed
149

150 151 152
    function showToolbarMessage(message) {
        toolBarMessage.text = message
        toolBarMessageArea.visible = true
Don Gagne's avatar
Don Gagne committed
153 154
    }

dogmaphobic's avatar
dogmaphobic committed
155
    function showMavStatus() {
Don Gagne's avatar
Don Gagne committed
156
         return (multiVehicleManager.activeVehicleAvailable && activeVehicle.heartbeatTimeout === 0);
dogmaphobic's avatar
dogmaphobic committed
157 158
    }

dogmaphobic's avatar
dogmaphobic committed
159 160 161 162
    Component.onCompleted: {
        //-- TODO: Get this from the actual state
        flyButton.checked = true
    }
163

dogmaphobic's avatar
dogmaphobic committed
164 165 166 167 168 169
    Connections {
        target:         controller
        onShowFlyView:  { flyButton.checked   = true }
        onShowPlanView: { planButton.checked  = true }
        onShowSetupView:{ setupButton.checked = true }
    }
170

dogmaphobic's avatar
dogmaphobic committed
171 172
    Row {
        id:             viewRow
dogmaphobic's avatar
dogmaphobic committed
173 174
        height:         mainWindow.tbCellHeight
        spacing:        mainWindow.tbSpacing
dogmaphobic's avatar
dogmaphobic committed
175
        anchors.left:   parent.left
dogmaphobic's avatar
dogmaphobic committed
176
        anchors.leftMargin:     mainWindow.tbSpacing
dogmaphobic's avatar
dogmaphobic committed
177 178 179 180
        anchors.verticalCenter: parent.verticalCenter

        ExclusiveGroup { id: mainActionGroup }

dogmaphobic's avatar
dogmaphobic committed
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
        QGCToolBarButton {
            id:                 preferencesButton
            width:              mainWindow.tbButtonWidth
            height:             mainWindow.tbCellHeight
            source:             "/qmlimages/Hamburger.svg"
            onClicked: {
                mainWindow.showLeftMenu();
                preferencesButton.checked = false;
            }
        }

        Rectangle {
            height: mainWindow.tbCellHeight
            width:  1
            color: Qt.rgba(1,1,1,0.45)
        }

dogmaphobic's avatar
dogmaphobic committed
198 199
        QGCToolBarButton {
            id:                 setupButton
dogmaphobic's avatar
dogmaphobic committed
200 201
            width:              mainWindow.tbButtonWidth
            height:             mainWindow.tbCellHeight
dogmaphobic's avatar
dogmaphobic committed
202
            exclusiveGroup:     mainActionGroup
dogmaphobic's avatar
dogmaphobic committed
203
            source:             "/qmlimages/Gears.svg"
dogmaphobic's avatar
dogmaphobic committed
204
            onClicked: {
205
                _controller.onSetupView();
dogmaphobic's avatar
dogmaphobic committed
206 207
            }
        }
208

dogmaphobic's avatar
dogmaphobic committed
209
        Rectangle {
dogmaphobic's avatar
dogmaphobic committed
210
            height: mainWindow.tbCellHeight
dogmaphobic's avatar
dogmaphobic committed
211 212 213
            width:  1
            color: Qt.rgba(1,1,1,0.45)
        }
214

dogmaphobic's avatar
dogmaphobic committed
215 216
        QGCToolBarButton {
            id:                 planButton
dogmaphobic's avatar
dogmaphobic committed
217 218
            width:              mainWindow.tbButtonWidth
            height:             mainWindow.tbCellHeight
dogmaphobic's avatar
dogmaphobic committed
219
            exclusiveGroup:     mainActionGroup
dogmaphobic's avatar
dogmaphobic committed
220
            source:             "/qmlimages/Plan.svg"
dogmaphobic's avatar
dogmaphobic committed
221
            onClicked: {
222
                _controller.onPlanView();
dogmaphobic's avatar
dogmaphobic committed
223 224
            }
        }
Don Gagne's avatar
Don Gagne committed
225

dogmaphobic's avatar
dogmaphobic committed
226
        Rectangle {
dogmaphobic's avatar
dogmaphobic committed
227
            height: mainWindow.tbCellHeight
dogmaphobic's avatar
dogmaphobic committed
228 229
            width:  1
            color: Qt.rgba(1,1,1,0.45)
Don Gagne's avatar
Don Gagne committed
230
        }
dogmaphobic's avatar
dogmaphobic committed
231

dogmaphobic's avatar
dogmaphobic committed
232 233
        QGCToolBarButton {
            id:                 flyButton
dogmaphobic's avatar
dogmaphobic committed
234 235
            width:              mainWindow.tbButtonWidth
            height:             mainWindow.tbCellHeight
dogmaphobic's avatar
dogmaphobic committed
236
            exclusiveGroup:     mainActionGroup
dogmaphobic's avatar
dogmaphobic committed
237
            source:             "/qmlimages/PaperPlane.svg"
dogmaphobic's avatar
dogmaphobic committed
238 239
            onClicked: {
                _controller.onFlyView();
240
            }
Don Gagne's avatar
Don Gagne committed
241
        }
242

Don Gagne's avatar
Don Gagne committed
243
        Rectangle {
dogmaphobic's avatar
dogmaphobic committed
244
            height: mainWindow.tbCellHeight
dogmaphobic's avatar
dogmaphobic committed
245 246
            width:  1
            color: Qt.rgba(1,1,1,0.45)
Don Gagne's avatar
Don Gagne committed
247
        }
248

dogmaphobic's avatar
dogmaphobic committed
249
    }
250

dogmaphobic's avatar
dogmaphobic committed
251 252
    Item {
        visible:                showMavStatus() && !connectionStatus.visible
dogmaphobic's avatar
dogmaphobic committed
253
        height:                 mainWindow.tbCellHeight
Don Gagne's avatar
Don Gagne committed
254
        width:                  (toolBar.width - viewRow.width)
dogmaphobic's avatar
dogmaphobic committed
255
        anchors.left:           viewRow.right
dogmaphobic's avatar
dogmaphobic committed
256
        anchors.leftMargin:     mainWindow.tbSpacing * 2
dogmaphobic's avatar
dogmaphobic committed
257 258 259 260 261
        anchors.verticalCenter: parent.verticalCenter
        Loader {
            source:             multiVehicleManager.activeVehicleAvailable ? "MainToolBarIndicators.qml" : ""
            anchors.left:       parent.left
            anchors.verticalCenter:   parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
262
        }
dogmaphobic's avatar
dogmaphobic committed
263
    }
dogmaphobic's avatar
dogmaphobic committed
264

dogmaphobic's avatar
dogmaphobic committed
265 266 267 268 269 270 271 272
    QGCLabel {
        id:             connectionStatus
        visible:        (_controller.connectionCount > 0 && multiVehicleManager.activeVehicleAvailable && activeVehicle.heartbeatTimeout != 0)
        text:           "CONNECTION LOST"
        font.pixelSize: tbFontLarge
        font.weight:    Font.DemiBold
        color:          colorRed
        anchors.left:           viewRow.right
dogmaphobic's avatar
dogmaphobic committed
273
        anchors.leftMargin:     mainWindow.tbSpacing * 2
dogmaphobic's avatar
dogmaphobic committed
274 275
        anchors.verticalCenter: parent.verticalCenter
    }
dogmaphobic's avatar
dogmaphobic committed
276

277 278
    // Progress bar
    Rectangle {
Don Gagne's avatar
Don Gagne committed
279
        id:             progressBar
dogmaphobic's avatar
dogmaphobic committed
280 281
        anchors.bottom: parent.bottom
        height:         toolBar.height * 0.05
282
        width:          parent.width * _controller.progressBarValue
dogmaphobic's avatar
dogmaphobic committed
283
        color:          colorGreen
284
    }
dogmaphobic's avatar
dogmaphobic committed
285

Don Gagne's avatar
Don Gagne committed
286 287
    // Toolbar message area
    Rectangle {
dogmaphobic's avatar
dogmaphobic committed
288 289 290 291 292 293 294
        id:             toolBarMessageArea
        x:              toolBar.parent.width * 0.225
        y:              toolBar.parent.height - (ScreenTools.defaultFontPixelHeight * ScreenTools.fontHRatio * 6)
        width:          toolBar.parent.width * 0.55
        height:         ScreenTools.defaultFontPixelHeight * ScreenTools.fontHRatio * 6
        color:          Qt.rgba(0,0,0,0.65)
        visible:        false
dogmaphobic's avatar
dogmaphobic committed
295
        ScrollView {
dogmaphobic's avatar
dogmaphobic committed
296 297 298
            width:              toolBarMessageArea.width - toolBarMessageCloseButton.width
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
dogmaphobic's avatar
dogmaphobic committed
299 300 301 302 303 304 305
            frameVisible:       false
            horizontalScrollBarPolicy:  Qt.ScrollBarAlwaysOff
            verticalScrollBarPolicy:    Qt.ScrollBarAlwaysOff
            QGCLabel {
                id:                 toolBarMessage
                width:              toolBarMessageArea.width - toolBarMessageCloseButton.width
                wrapMode:           Text.WordWrap
dogmaphobic's avatar
dogmaphobic committed
306
                color:              "#e4e428"
dogmaphobic's avatar
dogmaphobic committed
307 308
                lineHeightMode:     Text.ProportionalHeight
                lineHeight:         1.15
dogmaphobic's avatar
dogmaphobic committed
309
                anchors.margins:    mainWindow.tbSpacing
dogmaphobic's avatar
dogmaphobic committed
310
            }
Don Gagne's avatar
Don Gagne committed
311 312
        }
        QGCButton {
dogmaphobic's avatar
dogmaphobic committed
313 314
            id:                 toolBarMessageCloseButton
            primary:            true
dogmaphobic's avatar
dogmaphobic committed
315
            text:               "Close"
dogmaphobic's avatar
dogmaphobic committed
316 317
            anchors.right:      parent.right
            anchors.bottom:     parent.bottom
dogmaphobic's avatar
dogmaphobic committed
318
            anchors.margins:    mainWindow.tbSpacing
Don Gagne's avatar
Don Gagne committed
319
            onClicked: {
dogmaphobic's avatar
dogmaphobic committed
320
                toolBarMessageArea.visible = false
321
                _controller.onToolBarMessageClosed()
Don Gagne's avatar
Don Gagne committed
322 323 324
            }
        }
    }
Don Gagne's avatar
Don Gagne committed
325

Don Gagne's avatar
Don Gagne committed
326
} // Rectangle