From 617bbe47cc769a2ffa033af1d2d94f460ff35272 Mon Sep 17 00:00:00 2001 From: Balazs Birtalan Date: Thu, 26 Oct 2023 19:47:39 +0100 Subject: [PATCH] They can send message to each other using the window.sight.message function. It will run "runJavaScript" a "message()" function from the every sights which run and their executes if it needs. --- callhandler.py | 14 +++++++++++--- place/js/sight.js | 6 ++++++ place/templates/base/main.html | 13 ++++++++++++- place/templates/base/other.html | 7 +++++++ sightfactory.py | 5 ++++- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/callhandler.py b/callhandler.py index 5e724dd..d581572 100644 --- a/callhandler.py +++ b/callhandler.py @@ -97,8 +97,7 @@ class CallHandler(QObject): @pyqtSlot() def move(self): base.data["move"] = True - - + @pyqtSlot() def endmove(self): base.data["move"] = False @@ -111,4 +110,13 @@ class CallHandler(QObject): new_height = 250 if(new_width<250): new_width = 250 - self.sight.resize( new_width, new_height) \ No newline at end of file + self.sight.resize( new_width, new_height) + + @pyqtSlot(str) + def message(self, label): + print("label - " + label) + for sight in base.sights.getSights().values(): + sight.browser.page().runJavaScript("message('"+label+"')", self.ready) + + def ready(self, returnValue): + print(returnValue) \ No newline at end of file diff --git a/place/js/sight.js b/place/js/sight.js index 40cbde9..1d3d3e3 100644 --- a/place/js/sight.js +++ b/place/js/sight.js @@ -148,6 +148,11 @@ function load(url, element) xhttp.send(); } +/*function message(label) { + alert("what") + return "message came" +} +*/ $(document).ready(function(){ const scontent = document.querySelectorAll('[scontent]'); scontent.forEach((element) => { @@ -204,6 +209,7 @@ $(document).ready(function(){ $("#sminimize").empty(); $("#sminimize").prepend(''); } + /*window.sight.getTitle(function(result) { setTitle(result); });*/ diff --git a/place/templates/base/main.html b/place/templates/base/main.html index d382806..d24f384 100644 --- a/place/templates/base/main.html +++ b/place/templates/base/main.html @@ -11,14 +11,25 @@ 'width' : 300, 'height' : 300 } + + - + diff --git a/place/templates/base/other.html b/place/templates/base/other.html index 0b5204f..d46be26 100644 --- a/place/templates/base/other.html +++ b/place/templates/base/other.html @@ -9,7 +9,14 @@ diff --git a/sightfactory.py b/sightfactory.py index ac6a225..363ef11 100644 --- a/sightfactory.py +++ b/sightfactory.py @@ -44,7 +44,10 @@ class SightFactory(): return True print("This '"+str(id)+"' id isn't exist to show!") return False - + + def getSights(self): + return self.list + def get(self, id): if self.checkKey(id): return self.list[id]