2023-05-17 10:16:15 +00:00
|
|
|
import base
|
|
|
|
|
import random
|
|
|
|
|
from PyQt6.QtCore import QObject, pyqtSlot
|
|
|
|
|
|
|
|
|
|
class CallHandler(QObject):
|
|
|
|
|
def __init__(self, sight):
|
|
|
|
|
super().__init__()
|
|
|
|
|
self.sight = sight
|
|
|
|
|
|
|
|
|
|
@pyqtSlot(str)
|
2023-10-26 10:27:01 +00:00
|
|
|
def console(self, t):
|
2023-05-17 10:16:15 +00:00
|
|
|
print(t)
|
|
|
|
|
|
|
|
|
|
@pyqtSlot(str, result=str)
|
|
|
|
|
def test2(self, t):
|
|
|
|
|
print(t)
|
|
|
|
|
return t+"_return"
|
|
|
|
|
|
|
|
|
|
@pyqtSlot(result=str)
|
|
|
|
|
def getDefaultTemplate(self):
|
|
|
|
|
return base.data["default_template"]
|
|
|
|
|
|
|
|
|
|
@pyqtSlot(int)
|
|
|
|
|
def setWidth(self, width):
|
|
|
|
|
self.sight.resize(width, self.sight.height());
|
|
|
|
|
|
|
|
|
|
@pyqtSlot(int)
|
|
|
|
|
def setHeight(self, height):
|
|
|
|
|
self.sight.resize(self.sight.width(), height);
|
|
|
|
|
|
|
|
|
|
@pyqtSlot(str, str, result = str)
|
|
|
|
|
def create(self, id, type):
|
|
|
|
|
new_id = base.sights.create(id, type)
|
|
|
|
|
if new_id is not None:
|
|
|
|
|
base.sights.show(new_id)
|
2023-10-26 17:43:59 +00:00
|
|
|
""" The id will be added to its parent. When parent close will be its children closed as well """
|
|
|
|
|
self.sight.addChild(new_id)
|
|
|
|
|
""" The child remember its parent. When the child is closed the parent will be know about that. """
|
|
|
|
|
base.sights.get(new_id).setParent(self.sight.getId())
|
2023-05-17 10:16:15 +00:00
|
|
|
return new_id;
|
|
|
|
|
|
|
|
|
|
@pyqtSlot(str, str, bool)
|
|
|
|
|
def addData(self, key, value, is_global = False):
|
|
|
|
|
if is_global:
|
|
|
|
|
base.sights.addGlobalData(key,value)
|
|
|
|
|
else:
|
|
|
|
|
self.sight.addData(key,value)
|
|
|
|
|
|
|
|
|
|
@pyqtSlot(str, bool, result=str)
|
|
|
|
|
def getData(self, key, is_global = False):
|
|
|
|
|
if is_global:
|
|
|
|
|
return base.sights.getGlobalData(key)
|
|
|
|
|
return self.sight.getData(key)
|
|
|
|
|
|
|
|
|
|
@pyqtSlot()
|
|
|
|
|
def activeSight(self):
|
|
|
|
|
if base.data["active_sight"] != self.sight.getId():
|
2023-10-26 15:58:46 +00:00
|
|
|
print("Active - " + self.sight.getId())
|
|
|
|
|
base.data["active_sight"] = self.sight.getId()
|
2023-05-17 10:16:15 +00:00
|
|
|
|
|
|
|
|
@pyqtSlot()
|
|
|
|
|
def close(self):
|
2023-10-26 17:43:59 +00:00
|
|
|
""" CLOSE ITS CHILDREN. It doesnt close the children's children just the current parent children
|
|
|
|
|
will be closed. """
|
|
|
|
|
for cid in self.sight.getChildren():
|
|
|
|
|
base.sights.close(cid)
|
|
|
|
|
print("CLOSED - "+cid)
|
|
|
|
|
""" If the parent doesn't exist anymore! """
|
|
|
|
|
if base.sights.get(self.sight.getParent()) is not None:
|
|
|
|
|
""" The child will be removed from his parent. So the parent wont be know about that because its child closed. """
|
|
|
|
|
base.sights.get(self.sight.getParent()).removeChild(self.sight.getId())
|
2023-05-17 10:16:15 +00:00
|
|
|
base.sights.close(self.sight.getId())
|
2023-10-26 17:43:59 +00:00
|
|
|
|
2023-05-17 10:16:15 +00:00
|
|
|
|
|
|
|
|
@pyqtSlot()
|
|
|
|
|
def setMaximized(self):
|
|
|
|
|
self.sight.showMaximized()
|
|
|
|
|
self.sight.setLayoutContentMargins(0,0,0,0) #because there will be a transparented line as a border
|
|
|
|
|
|
|
|
|
|
@pyqtSlot()
|
|
|
|
|
def setMinimize(self):
|
|
|
|
|
self.sight.showMinimized()
|
|
|
|
|
|
|
|
|
|
@pyqtSlot()
|
|
|
|
|
def restoreDown(self):
|
|
|
|
|
self.sight.showNormal()
|
|
|
|
|
self.sight.setLayoutContentMargins(1,1,1,1) #because if it is no border then I get setgeometry warning what can't be set
|
|
|
|
|
|
|
|
|
|
@pyqtSlot()
|
|
|
|
|
def setFullscreen(self):
|
|
|
|
|
self.sight.showFullScreen()
|
|
|
|
|
|
|
|
|
|
"""@pyqtSlot(result=str)
|
|
|
|
|
def getTitle(self):
|
|
|
|
|
return self.sight.getTitle();
|
|
|
|
|
"""
|
|
|
|
|
@pyqtSlot()
|
|
|
|
|
def move(self):
|
|
|
|
|
base.data["move"] = True
|
2023-10-26 18:47:39 +00:00
|
|
|
|
2023-05-17 10:16:15 +00:00
|
|
|
@pyqtSlot()
|
|
|
|
|
def endmove(self):
|
|
|
|
|
base.data["move"] = False
|
|
|
|
|
|
|
|
|
|
@pyqtSlot()
|
|
|
|
|
def resize(self):
|
|
|
|
|
new_height = base.mousectrl.position[1]-self.sight.pos().y()
|
|
|
|
|
new_width = base.mousectrl.position[0]-self.sight.pos().x()
|
|
|
|
|
if(new_height<250):
|
|
|
|
|
new_height = 250
|
|
|
|
|
if(new_width<250):
|
|
|
|
|
new_width = 250
|
2023-10-26 18:47:39 +00:00
|
|
|
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)
|