diff --git a/TODO.md b/TODO.md index 14f42bec..e4b9aa0b 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,7 @@ - Current focus - Merge login page - Just import nio? + - TextInput.accepted() for SendBox - Refactoring - Migrate more JS functions to their own files / Implement in Python instead diff --git a/harmonyqml/backend/client.py b/harmonyqml/backend/client.py index 36aea5cc..5c772edb 100644 --- a/harmonyqml/backend/client.py +++ b/harmonyqml/backend/client.py @@ -115,8 +115,7 @@ class Client(QObject): self.net_sync.http_disconnect() - @pyqtSlot() - @futurize() + @futurize(pyqt=False) def startSyncing(self) -> None: while True: self._on_sync(self.net_sync.talk( diff --git a/harmonyqml/backend/client_manager.py b/harmonyqml/backend/client_manager.py index 05c537e7..46e96fe8 100644 --- a/harmonyqml/backend/client_manager.py +++ b/harmonyqml/backend/client_manager.py @@ -61,7 +61,7 @@ class ClientManager(QObject): @pyqtSlot(str, str, str) - @pyqtSlot(str, str, str) + @pyqtSlot(str, str, str, str) def new(self, hostname: str, username: str, password: str, device_id: str = "") -> None: diff --git a/harmonyqml/backend/pyqt_future.py b/harmonyqml/backend/pyqt_future.py index 5113f82a..9045cdee 100644 --- a/harmonyqml/backend/pyqt_future.py +++ b/harmonyqml/backend/pyqt_future.py @@ -67,7 +67,8 @@ class PyQtFuture(QObject): _RUNNING: List[Tuple[Executor, Callable, tuple, dict]] = [] -def futurize(max_instances: Optional[int] = None) -> Callable: +def futurize(max_instances: Optional[int] = None, pyqt: bool = True + ) -> Callable: def decorator(func: Callable) -> Callable: @@ -89,7 +90,8 @@ def futurize(max_instances: Optional[int] = None) -> Callable: return None _RUNNING.append((self.pool, func, args, kws)) - return PyQtFuture(self.pool.submit(run_and_catch_errs), self) + future = self.pool.submit(run_and_catch_errs) + return PyQtFuture(future, self) if pyqt else future return wrapper diff --git a/harmonyqml/backend/signal_manager.py b/harmonyqml/backend/signal_manager.py index 0305cdfc..e1e7e088 100644 --- a/harmonyqml/backend/signal_manager.py +++ b/harmonyqml/backend/signal_manager.py @@ -33,6 +33,7 @@ class SignalManager(QObject): def onClientAdded(self, client: Client) -> None: + print(client) self.connectClient(client) self.backend.models.accounts.append(User( userId = client.userId, diff --git a/harmonyqml/components/pages/LoginPage.qml b/harmonyqml/components/pages/LoginPage.qml index 82575f5a..935bc5ce 100644 --- a/harmonyqml/components/pages/LoginPage.qml +++ b/harmonyqml/components/pages/LoginPage.qml @@ -10,6 +10,12 @@ Image { cache: false source: "../../images/login_background.jpg" + function login() { + Backend.clientManager.new( + "matrix.org", identifierField.text, passwordField.text + ) + } + Rectangle { color: Qt.hsla(1, 1, 1, 0.3) @@ -80,11 +86,14 @@ Image { } Base.HTextField { + id: identifierField placeholderText: qsTr( loginWithEmailButton.checked ? "Email" : loginWithPhoneButton.checked ? "Phone" : "Username" ) + onAccepted: login() + Component.onCompleted: forceActiveFocus() Layout.fillWidth: true Layout.margins: mainColumn.hMargin @@ -93,7 +102,10 @@ Image { } Base.HTextField { + id: passwordField placeholderText: qsTr("Password") + echoMode: TextField.Password + onAccepted: login() Layout.fillWidth: true Layout.margins: mainColumn.hMargin @@ -112,6 +124,10 @@ Image { text: qsTr("Login") Layout.fillWidth: true + MouseArea { + anchors.fill: parent + onClicked: login() + } } Base.HButton { text: qsTr("Forgot?")