summary refs log tree commit diff
path: root/resources/qml/dialogs/ReCaptchaDialog.qml
blob: 0da62cbc03c3275b48dfdbea08630a38b4ed1d04 (plain) (blame)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick
import QtQuick.Controls
import im.nheko

ApplicationWindow {
    id: recaptchaRoot

    required property ReCaptcha recaptcha

    function accept() {
        recaptcha.confirm();
        recaptchaRoot.close();
    }

    function reject() {
        recaptcha.cancel();
        recaptchaRoot.close();
    }

    color: palette.window
    title: recaptcha.context
    flags: Qt.Tool | Qt.WindowStaysOnTopHint | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
    height: msg.implicitHeight + footer.implicitHeight
    width: Math.max(msg.implicitWidth, footer.implicitWidth)

    Shortcut {
        sequence: StandardKey.Cancel
        onActivated: recaptchaRoot.reject()
    }

    Label {
        id: msg

        anchors.fill: parent
        padding: 8
        text: qsTr("Solve the reCAPTCHA and press the confirm button")
    }

    footer: DialogButtonBox {
        onAccepted: recaptchaRoot.accept()
        onRejected: recaptchaRoot.reject()

        Button {
            text: qsTr("Open reCAPTCHA")
            onClicked: recaptcha.openReCaptcha()
        }

        Button {
            text: qsTr("Cancel")
            DialogButtonBox.buttonRole: DialogButtonBox.RejectRole
        }

        Button {
            text: qsTr("Confirm")
            DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
        }
    }

}