QGCViewDialog.qml 1.4 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
Don Gagne's avatar
Don Gagne committed
9

10
import QtQuick          2.3
11
import QtQuick.Controls 1.2
Don Gagne's avatar
Don Gagne committed
12

13 14 15 16 17
import QGroundControl.Controls      1.0
import QGroundControl.Palette       1.0
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
import QGroundControl.ScreenTools   1.0
Don Gagne's avatar
Don Gagne committed
18 19

FactPanel {
20 21 22
    property real defaultTextWidth:     ScreenTools.defaultFontPixelWidth
    property real defaultTextHeight:    ScreenTools.defaultFontPixelHeight

Don Gagne's avatar
Don Gagne committed
23
    QGCPalette { id: __qgcPal; colorGroupEnabled: enabled }
Don Gagne's avatar
Don Gagne committed
24 25 26

    signal hideDialog

27
    Keys.onReleased: {
28
        if (event.key === Qt.Key_Escape) {
29 30
            reject()
            event.accepted = true
31
        } else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
32 33 34 35 36
            accept()
            event.accepted = true
        }
    }

Don Gagne's avatar
Don Gagne committed
37
    function accept() {
38 39 40 41
        if (acceptAllowed) {
            Qt.inputMethod.hide()
            hideDialog()
        }
Don Gagne's avatar
Don Gagne committed
42 43 44
    }

    function reject() {
45 46 47 48
        if (rejectAllowed) {
            Qt.inputMethod.hide()
            hideDialog()
        }
Don Gagne's avatar
Don Gagne committed
49 50
    }

Don Gagne's avatar
Don Gagne committed
51
    color: __qgcPal.windowShadeDark
Don Gagne's avatar
Don Gagne committed
52
}