From 677117983a4b41fbf8e567e2049653ad98706e6c Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 21 Apr 2019 16:30:56 -0400 Subject: [PATCH] Set hourglass icon when clicking accept/decline PyQtFuture's gotResult signal can now be used from QML/JS. --- TODO.md | 3 ++- harmonyqml/backend/pyqt_future.py | 6 ++++-- harmonyqml/components/chat/Banner.qml | 21 +++++++++++++++++---- harmonyqml/icons/hourglass.svg | 7 +++++++ 4 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 harmonyqml/icons/hourglass.svg diff --git a/TODO.md b/TODO.md index 0f82857f..b707f29d 100644 --- a/TODO.md +++ b/TODO.md @@ -22,6 +22,7 @@ - Proper button background componant - Collapsible roomList sections, + button - Prevent using the SendBox if no permission (power levels) + - Spinner when loading past room events, images or clicking buttons - Reorganize SidePane - Proper theme, with components taking their colors from theme settings - Settings page @@ -38,7 +39,6 @@ - Client improvements - On sync, check messages API, if a limited sync timeline was received - Markdown: don't turn #things into title (space), disable __ syntax - - Spinner when loading past room events or images - Push instead of replacing in stack view - Make links in room subtitle clickable, formatting? - `
` scrollbar on overflow
@@ -49,6 +49,7 @@
     it should be the peer's display name instead.
 
 - Missing nio support
+  - Forget room
   - Left room events
   - `org.matrix.room.preview_urls` event
   - `m.room.aliases` event
diff --git a/harmonyqml/backend/pyqt_future.py b/harmonyqml/backend/pyqt_future.py
index 142401b6..5113f82a 100644
--- a/harmonyqml/backend/pyqt_future.py
+++ b/harmonyqml/backend/pyqt_future.py
@@ -12,14 +12,16 @@ from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal, pyqtSlot
 
 
 class PyQtFuture(QObject):
-    gotResult = pyqtSignal()
+    gotResult = pyqtSignal("QVariant")
 
     def __init__(self, future: Future, parent: QObject) -> None:
         super().__init__(parent)
         self.future  = future
         self._result = None
 
-        self.future.add_done_callback(lambda _: self.gotResult.emit())
+        self.future.add_done_callback(
+            lambda future: self.gotResult.emit(future.result())
+        )
 
 
     def __repr__(self) -> str:
diff --git a/harmonyqml/components/chat/Banner.qml b/harmonyqml/components/chat/Banner.qml
index 0fdb2d63..48e42558 100644
--- a/harmonyqml/components/chat/Banner.qml
+++ b/harmonyqml/components/chat/Banner.qml
@@ -73,16 +73,29 @@ Rectangle {
                 model: []
 
                 Base.HButton {
-                    id: declineButton
+                    property bool alreadyClicked: false
+
                     text: modelData.text
                     iconName: modelData.iconName
                     icon.color: modelData.iconColor
                     icon.width: 32
                     display: bannerButtons.displayMode
 
-                    onClicked:
-                        Backend.clientManager.clients[chatPage.userId].
-                        call(modelData.clientFunction, modelData.clientArgs)
+                    onClicked: {
+                        if (alreadyClicked) { console.log("all"); return }
+
+                        iconName       = "hourglass"
+                        alreadyClicked = true
+
+                        var future =
+                            Backend.clientManager.clients[chatPage.userId].
+                            call(modelData.clientFunction,
+                                 modelData.clientArgs)
+
+                        future.onGotResult.connect(
+                            function() { iconName = modelData.iconName }
+                        )
+                    }
 
                     Layout.maximumWidth: bannerButtons.compact ? height : -1
                     Layout.fillHeight: true
diff --git a/harmonyqml/icons/hourglass.svg b/harmonyqml/icons/hourglass.svg
new file mode 100644
index 00000000..e3bb8bb9
--- /dev/null
+++ b/harmonyqml/icons/hourglass.svg
@@ -0,0 +1,7 @@
+
+
+
+
+ Svg Vector Icons : http://www.onlinewebfonts.com/icon 
+
+
\ No newline at end of file