summary refs log tree commit diff
path: root/resources/qml
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2023-08-10 07:01:52 +0000
committerGitHub <noreply@github.com>2023-08-10 07:01:52 +0000
commitff079f6b6ae4b7fd020218263b05079ae4d0bfea (patch)
treefb5abe783bcbc6464c696aba1579568ab4b6d24d /resources/qml
parentRemove usage of creator (diff)
parentQML the fallback auth dialog (diff)
downloadnheko-ff079f6b6ae4b7fd020218263b05079ae4d0bfea.tar.xz
Merge pull request #1523 from Nheko-Reborn/qmlFallbackAuth
QML the fallback auth dialog
Diffstat (limited to 'resources/qml')
-rw-r--r--resources/qml/Root.qml12
-rw-r--r--resources/qml/dialogs/FallbackAuthDialog.qml63
2 files changed, 75 insertions, 0 deletions
diff --git a/resources/qml/Root.qml b/resources/qml/Root.qml
index fb0c6036..1e8a6a27 100644
--- a/resources/qml/Root.qml
+++ b/resources/qml/Root.qml
@@ -385,6 +385,18 @@ Pane {
                 console.error("Failed to create component: " + component.errorString());
             }
         }
+        function onFallbackAuth(fallback) {
+            var component = Qt.createComponent("qrc:/resources/qml/dialogs/FallbackAuthDialog.qml");
+            if (component.status == Component.Ready) {
+                var dialog = component.createObject(timelineRoot, {
+                        "fallback": fallback
+                    });
+                dialog.show();
+                destroyOnClose(dialog);
+            } else {
+                console.error("Failed to create component: " + component.errorString());
+            }
+        }
 
         target: UIA
     }
diff --git a/resources/qml/dialogs/FallbackAuthDialog.qml b/resources/qml/dialogs/FallbackAuthDialog.qml
new file mode 100644
index 00000000..d9a7ac8f
--- /dev/null
+++ b/resources/qml/dialogs/FallbackAuthDialog.qml
@@ -0,0 +1,63 @@
+// SPDX-FileCopyrightText: Nheko Contributors
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+import QtQuick
+import QtQuick.Controls
+import im.nheko
+
+ApplicationWindow {
+    id: fallbackRoot
+
+    required property FallbackAuth fallback
+
+    function accept() {
+        fallback.confirm();
+        fallbackRoot.close();
+    }
+
+    function reject() {
+        fallback.cancel();
+        fallbackRoot.close();
+    }
+
+    color: palette.window
+    title: qsTr("Fallback authentication")
+    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: fallbackRoot.reject()
+    }
+
+    Label {
+        id: msg
+
+        anchors.fill: parent
+        padding: 8
+        text: qsTr("Open the fallback, follow the steps, and confirm after completing them.")
+    }
+
+    footer: DialogButtonBox {
+        onAccepted: fallbackRoot.accept()
+        onRejected: fallbackRoot.reject()
+
+        Button {
+            text: qsTr("Open Fallback in Browser")
+            onClicked: fallback.openFallbackAuth()
+        }
+
+        Button {
+            text: qsTr("Cancel")
+            DialogButtonBox.buttonRole: DialogButtonBox.RejectRole
+        }
+
+        Button {
+            text: qsTr("Confirm")
+            DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
+        }
+    }
+
+}