QGCViewDialog.qml 1.16 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
Item {
Don Gagne's avatar
Don Gagne committed
20 21 22

    signal hideDialog

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

Don Gagne's avatar
Don Gagne committed
33
    function accept() {
34 35 36 37
        if (acceptAllowed) {
            Qt.inputMethod.hide()
            hideDialog()
        }
Don Gagne's avatar
Don Gagne committed
38 39 40
    }

    function reject() {
41 42 43 44
        if (rejectAllowed) {
            Qt.inputMethod.hide()
            hideDialog()
        }
Don Gagne's avatar
Don Gagne committed
45 46 47
    }

}