QGCViewDialog.qml 1.16 KB
Newer Older
1 2
/****************************************************************************
 *
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8
 *
 * 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
12
import QtQuick.Dialogs  1.3
Don Gagne's avatar
Don Gagne committed
13

14 15 16 17 18
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
19

20 21
Item {
    property var buttons: StandardButton.NoButton
Don Gagne's avatar
Don Gagne committed
22 23 24

    signal hideDialog

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

Don Gagne's avatar
Don Gagne committed
35
    function accept() {
36 37 38
        if (acceptAllowed) {
            hideDialog()
        }
Don Gagne's avatar
Don Gagne committed
39 40 41
    }

    function reject() {
42 43 44
        if (rejectAllowed) {
            hideDialog()
        }
Don Gagne's avatar
Don Gagne committed
45 46
    }
}