Make the banner buttons work
For invitation accept/decline. Forget remains to be implemented in nio.
This commit is contained in:
parent
ac70634256
commit
99d5fb551c
|
@ -4,13 +4,13 @@
|
|||
import time
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from threading import Event
|
||||
from typing import DefaultDict, Tuple
|
||||
from typing import Any, DefaultDict, Dict, Optional, Tuple
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal, pyqtSlot
|
||||
|
||||
import nio
|
||||
import nio.responses as nr
|
||||
import nio.events as ne
|
||||
import nio.responses as nr
|
||||
|
||||
from .network_manager import NetworkManager
|
||||
from .pyqt_future import futurize
|
||||
|
@ -78,6 +78,16 @@ class Client(QObject):
|
|||
return self.nio.user_id
|
||||
|
||||
|
||||
@pyqtSlot(str, result="QVariant")
|
||||
@pyqtSlot(str, list, result="QVariant")
|
||||
@pyqtSlot(str, list, "QVariantMap", result="QVariant")
|
||||
def call(self,
|
||||
method: str,
|
||||
args: Optional[list] = None,
|
||||
kwargs: Optional[Dict[str, Any]] = None) -> Any:
|
||||
return getattr(self, method)(*args or [], **kwargs or {})
|
||||
|
||||
|
||||
@pyqtSlot(str)
|
||||
@pyqtSlot(str, str)
|
||||
@futurize()
|
||||
|
@ -232,3 +242,21 @@ class Client(QObject):
|
|||
)
|
||||
|
||||
return send(self)
|
||||
|
||||
|
||||
@pyqtSlot(str)
|
||||
@futurize()
|
||||
def joinRoom(self, room_id: str) -> None:
|
||||
return self.net.talk(self.nio.join, room_id=room_id)
|
||||
|
||||
|
||||
@pyqtSlot(str)
|
||||
@futurize()
|
||||
def leaveRoom(self, room_id: str) -> None:
|
||||
return self.net.talk(self.nio.room_leave, room_id=room_id)
|
||||
|
||||
|
||||
@pyqtSlot(str)
|
||||
@futurize()
|
||||
def forgetRoom(self, room_id: str) -> None:
|
||||
raise NotImplementedError()
|
||||
|
|
|
@ -80,6 +80,10 @@ Rectangle {
|
|||
icon.width: 32
|
||||
display: bannerButtons.displayMode
|
||||
|
||||
onClicked:
|
||||
Backend.clientManager.clients[chatPage.userId].
|
||||
call(modelData.clientFunction, modelData.clientArgs)
|
||||
|
||||
Layout.maximumWidth: bannerButtons.compact ? height : -1
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
|
|
@ -19,11 +19,15 @@ Banner {
|
|||
text: "Accept",
|
||||
iconName: "accept",
|
||||
iconColor: Qt.hsla(0.45, 0.9, 0.3, 1),
|
||||
clientFunction: "joinRoom",
|
||||
clientArgs: [chatPage.roomId],
|
||||
},
|
||||
{
|
||||
text: "Decline",
|
||||
iconName: "decline",
|
||||
iconColor: Qt.hsla(0.95, 0.9, 0.35, 1),
|
||||
clientFunction: "leaveRoom",
|
||||
clientArgs: [chatPage.roomId],
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ Banner {
|
|||
text: "Forget",
|
||||
iconName: "trash_can",
|
||||
iconColor: Qt.hsla(0.95, 0.9, 0.35, 1),
|
||||
clientFunction: "forgetRoom",
|
||||
clientArgs: [chatPage.roomId],
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user