From 17927de45e769d4dbac5b1547464b2618150cfb4 Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Fri, 10 Apr 2020 17:44:23 +0200
Subject: Implemented login page
---
qml/Square.qml | 2 +-
qml/harbour-sailchess.qml | 9 ++++++++-
qml/images/bb.svg | 17 ----------------
qml/images/bk.svg | 25 -----------------------
qml/images/bn.svg | 14 -------------
qml/images/bp.svg | 7 -------
qml/images/bq.svg | 34 -------------------------------
qml/images/br.svg | 39 ------------------------------------
qml/images/wb.svg | 17 ----------------
qml/images/wk.svg | 27 -------------------------
qml/images/wn.svg | 13 ------------
qml/images/wp.svg | 7 -------
qml/images/wq.svg | 33 -------------------------------
qml/images/wr.svg | 25 -----------------------
qml/pages/Board.qml | 24 ++++++++++++++++++++++
qml/pages/Login.qml | 45 ++++++++++++++++++++++++++++++++++++++++++
qml/resources/css/external.css | 3 +++
qml/resources/images/bb.svg | 17 ++++++++++++++++
qml/resources/images/bk.svg | 25 +++++++++++++++++++++++
qml/resources/images/bn.svg | 14 +++++++++++++
qml/resources/images/bp.svg | 7 +++++++
qml/resources/images/bq.svg | 34 +++++++++++++++++++++++++++++++
qml/resources/images/br.svg | 39 ++++++++++++++++++++++++++++++++++++
qml/resources/images/wb.svg | 17 ++++++++++++++++
qml/resources/images/wk.svg | 27 +++++++++++++++++++++++++
qml/resources/images/wn.svg | 13 ++++++++++++
qml/resources/images/wp.svg | 7 +++++++
qml/resources/images/wq.svg | 33 +++++++++++++++++++++++++++++++
qml/resources/images/wr.svg | 25 +++++++++++++++++++++++
qml/resources/resources.qrc | 17 ++++++++++++++++
30 files changed, 356 insertions(+), 260 deletions(-)
delete mode 100644 qml/images/bb.svg
delete mode 100644 qml/images/bk.svg
delete mode 100644 qml/images/bn.svg
delete mode 100644 qml/images/bp.svg
delete mode 100644 qml/images/bq.svg
delete mode 100644 qml/images/br.svg
delete mode 100644 qml/images/wb.svg
delete mode 100644 qml/images/wk.svg
delete mode 100644 qml/images/wn.svg
delete mode 100644 qml/images/wp.svg
delete mode 100644 qml/images/wq.svg
delete mode 100644 qml/images/wr.svg
create mode 100644 qml/pages/Login.qml
create mode 100644 qml/resources/css/external.css
create mode 100644 qml/resources/images/bb.svg
create mode 100644 qml/resources/images/bk.svg
create mode 100644 qml/resources/images/bn.svg
create mode 100644 qml/resources/images/bp.svg
create mode 100644 qml/resources/images/bq.svg
create mode 100644 qml/resources/images/br.svg
create mode 100644 qml/resources/images/wb.svg
create mode 100644 qml/resources/images/wk.svg
create mode 100644 qml/resources/images/wn.svg
create mode 100644 qml/resources/images/wp.svg
create mode 100644 qml/resources/images/wq.svg
create mode 100644 qml/resources/images/wr.svg
create mode 100644 qml/resources/resources.qrc
(limited to 'qml')
diff --git a/qml/Square.qml b/qml/Square.qml
index b1e3e0c..2169290 100644
--- a/qml/Square.qml
+++ b/qml/Square.qml
@@ -3,7 +3,7 @@ import QtQuick 2.0
Rectangle {
property int i: 0
property string piece: ""
- property string image: piece !== "" ? "images/" + piece + ".svg" : ""
+ property string image: piece !== "" ? "qrc:///images/" + piece + ".svg" : ""
width: page.width / 8
height: this.width
diff --git a/qml/harbour-sailchess.qml b/qml/harbour-sailchess.qml
index ddc0046..6142693 100644
--- a/qml/harbour-sailchess.qml
+++ b/qml/harbour-sailchess.qml
@@ -1,10 +1,17 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
+import org.nemomobile.configuration 1.0
import "pages"
ApplicationWindow
{
- initialPage: Component { Board { } }
+ initialPage: Qt.resolvedUrl(access_token.value === "" ? "pages/Login.qml" : "pages/Board.qml")
cover: Qt.resolvedUrl("cover/CoverPage.qml")
allowedOrientations: Orientation.Portrait
+
+ ConfigurationValue {
+ id: access_token
+ key: "/com/sailchess/access_token"
+ defaultValue: ""
+ }
}
diff --git a/qml/images/bb.svg b/qml/images/bb.svg
deleted file mode 100644
index 4ce248f..0000000
--- a/qml/images/bb.svg
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
diff --git a/qml/images/bk.svg b/qml/images/bk.svg
deleted file mode 100644
index d90dc73..0000000
--- a/qml/images/bk.svg
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
diff --git a/qml/images/bn.svg b/qml/images/bn.svg
deleted file mode 100644
index 02b0894..0000000
--- a/qml/images/bn.svg
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
diff --git a/qml/images/bp.svg b/qml/images/bp.svg
deleted file mode 100644
index 072f2fe..0000000
--- a/qml/images/bp.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
diff --git a/qml/images/bq.svg b/qml/images/bq.svg
deleted file mode 100644
index 6f1e4a5..0000000
--- a/qml/images/bq.svg
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
diff --git a/qml/images/br.svg b/qml/images/br.svg
deleted file mode 100644
index 337af8f..0000000
--- a/qml/images/br.svg
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
diff --git a/qml/images/wb.svg b/qml/images/wb.svg
deleted file mode 100644
index 0f28d08..0000000
--- a/qml/images/wb.svg
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
diff --git a/qml/images/wk.svg b/qml/images/wk.svg
deleted file mode 100644
index 8b2d7b7..0000000
--- a/qml/images/wk.svg
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
diff --git a/qml/images/wn.svg b/qml/images/wn.svg
deleted file mode 100644
index 644d6e8..0000000
--- a/qml/images/wn.svg
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
diff --git a/qml/images/wp.svg b/qml/images/wp.svg
deleted file mode 100644
index 1142516..0000000
--- a/qml/images/wp.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
diff --git a/qml/images/wq.svg b/qml/images/wq.svg
deleted file mode 100644
index 97043c5..0000000
--- a/qml/images/wq.svg
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
diff --git a/qml/images/wr.svg b/qml/images/wr.svg
deleted file mode 100644
index 8d2d932..0000000
--- a/qml/images/wr.svg
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
diff --git a/qml/pages/Board.qml b/qml/pages/Board.qml
index 4bb5d9c..35e2e5e 100644
--- a/qml/pages/Board.qml
+++ b/qml/pages/Board.qml
@@ -1,5 +1,6 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
+import org.nemomobile.configuration 1.0
import ".."
Page {
@@ -14,6 +15,17 @@ Page {
anchors.fill: parent
contentHeight: column.height
+ PullDownMenu {
+ MenuItem {
+ text: qsTr("Login")
+ onClicked: {
+ access_token.value = "";
+ refresh_token.value = "";
+ pageStack.push(Qt.resolvedUrl("Login.qml"))
+ }
+ }
+ }
+
Column {
id: column
@@ -44,4 +56,16 @@ Page {
}
}
}
+
+ ConfigurationValue {
+ id: access_token
+ key: "/com/sailchess/access_token"
+ defaultValue: ""
+ }
+
+ ConfigurationValue {
+ id: refresh_token
+ key: "/com/sailchess/refresh_token"
+ defaultValue: ""
+ }
}
diff --git a/qml/pages/Login.qml b/qml/pages/Login.qml
new file mode 100644
index 0000000..2f57e39
--- /dev/null
+++ b/qml/pages/Login.qml
@@ -0,0 +1,45 @@
+import QtQuick 2.2
+import Sailfish.Silica 1.0
+import QtWebKit 3.0
+import org.nemomobile.configuration 1.0
+
+Page {
+ SilicaWebView {
+ property real device_ratio: Math.round(1.5 * Theme.pixelRatio * 10) / 10.0
+
+ id: login
+ anchors.fill: parent
+ experimental.preferences.javascriptEnabled: false
+ experimental.userStyleSheets: [Qt.resolvedUrl("qrc:///css/external.css")]
+ experimental.customLayoutWidth: parent.width / device_ratio
+ url: "https://marvinborner.de/lichess/"
+
+ onNavigationRequested: {
+ if (request.url.toString().lastIndexOf("https://marvinborner.de/lichess/callback", 0) === 0) {
+ request.action = WebView.IgnoreRequest;
+
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", request.url, false);
+ xhr.send();
+ if (xhr.status === 200) {
+ const data = JSON.parse(xhr.responseText);
+ access_token.value = data["access_token"];
+ refresh_token.value = data["refresh_token"];
+ pageStack.push(Qt.resolvedUrl("Board.qml"))
+ }
+ }
+ }
+
+ ConfigurationValue {
+ id: access_token
+ key: "/com/sailchess/access_token"
+ defaultValue: ""
+ }
+
+ ConfigurationValue {
+ id: refresh_token
+ key: "/com/sailchess/refresh_token"
+ defaultValue: ""
+ }
+ }
+}
diff --git a/qml/resources/css/external.css b/qml/resources/css/external.css
new file mode 100644
index 0000000..b1281e1
--- /dev/null
+++ b/qml/resources/css/external.css
@@ -0,0 +1,3 @@
+nav, .alternative, header {
+ display: none;
+}
diff --git a/qml/resources/images/bb.svg b/qml/resources/images/bb.svg
new file mode 100644
index 0000000..4ce248f
--- /dev/null
+++ b/qml/resources/images/bb.svg
@@ -0,0 +1,17 @@
+
+
+
diff --git a/qml/resources/images/bk.svg b/qml/resources/images/bk.svg
new file mode 100644
index 0000000..d90dc73
--- /dev/null
+++ b/qml/resources/images/bk.svg
@@ -0,0 +1,25 @@
+
+
+
diff --git a/qml/resources/images/bn.svg b/qml/resources/images/bn.svg
new file mode 100644
index 0000000..02b0894
--- /dev/null
+++ b/qml/resources/images/bn.svg
@@ -0,0 +1,14 @@
+
+
+
diff --git a/qml/resources/images/bp.svg b/qml/resources/images/bp.svg
new file mode 100644
index 0000000..072f2fe
--- /dev/null
+++ b/qml/resources/images/bp.svg
@@ -0,0 +1,7 @@
+
+
+
diff --git a/qml/resources/images/bq.svg b/qml/resources/images/bq.svg
new file mode 100644
index 0000000..6f1e4a5
--- /dev/null
+++ b/qml/resources/images/bq.svg
@@ -0,0 +1,34 @@
+
+
+
diff --git a/qml/resources/images/br.svg b/qml/resources/images/br.svg
new file mode 100644
index 0000000..337af8f
--- /dev/null
+++ b/qml/resources/images/br.svg
@@ -0,0 +1,39 @@
+
+
+
diff --git a/qml/resources/images/wb.svg b/qml/resources/images/wb.svg
new file mode 100644
index 0000000..0f28d08
--- /dev/null
+++ b/qml/resources/images/wb.svg
@@ -0,0 +1,17 @@
+
+
+
diff --git a/qml/resources/images/wk.svg b/qml/resources/images/wk.svg
new file mode 100644
index 0000000..8b2d7b7
--- /dev/null
+++ b/qml/resources/images/wk.svg
@@ -0,0 +1,27 @@
+
+
+
diff --git a/qml/resources/images/wn.svg b/qml/resources/images/wn.svg
new file mode 100644
index 0000000..644d6e8
--- /dev/null
+++ b/qml/resources/images/wn.svg
@@ -0,0 +1,13 @@
+
+
+
diff --git a/qml/resources/images/wp.svg b/qml/resources/images/wp.svg
new file mode 100644
index 0000000..1142516
--- /dev/null
+++ b/qml/resources/images/wp.svg
@@ -0,0 +1,7 @@
+
+
+
diff --git a/qml/resources/images/wq.svg b/qml/resources/images/wq.svg
new file mode 100644
index 0000000..97043c5
--- /dev/null
+++ b/qml/resources/images/wq.svg
@@ -0,0 +1,33 @@
+
+
+
diff --git a/qml/resources/images/wr.svg b/qml/resources/images/wr.svg
new file mode 100644
index 0000000..8d2d932
--- /dev/null
+++ b/qml/resources/images/wr.svg
@@ -0,0 +1,25 @@
+
+
+
diff --git a/qml/resources/resources.qrc b/qml/resources/resources.qrc
new file mode 100644
index 0000000..629a705
--- /dev/null
+++ b/qml/resources/resources.qrc
@@ -0,0 +1,17 @@
+
+
+ images/bb.svg
+ images/bk.svg
+ images/bn.svg
+ images/bp.svg
+ images/bq.svg
+ images/br.svg
+ images/wb.svg
+ images/wk.svg
+ images/wn.svg
+ images/wp.svg
+ images/wq.svg
+ images/wr.svg
+ css/external.css
+
+
--
cgit v1.2.3