Added: frameSupported() method. If it is False then remove titlebar and any other functions which is related with mouse or windows event from html, and use the standard OS interface (like in wayland) if it is True then it use the html frame and switch automatically.
Fixed the children closing method on linux (wayland) and every sight closing method happen in the sightfactory.py (moved from the callhandler).main
parent
a91cc436bd
commit
abcc4f41eb
14
base.py
14
base.py
|
|
@ -7,6 +7,7 @@ from pynput import mouse
|
|||
from sightfactory import SightFactory
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
from pynput.mouse import Controller
|
||||
import subprocess
|
||||
|
||||
def init():
|
||||
global data, sights, mousectrl, app
|
||||
|
|
@ -22,6 +23,12 @@ def init():
|
|||
data["sight_processes"] = {}
|
||||
data["mouse_distance_x"] = 0
|
||||
data["mouse_distance_y"] = 0
|
||||
data["display_server"] = ""
|
||||
if data["platform"]["system"] == "Linux":
|
||||
args = ["echo -n $XDG_SESSION_TYPE"]
|
||||
result = subprocess.check_output(args, shell=True)
|
||||
data["display_server"] = result.decode('ascii')
|
||||
print("D "+data["display_server"])
|
||||
data["base_dir"]=os.path.abspath(os.getcwd())+os.path.sep
|
||||
data["template_dir"]=data["base_dir"]+"place"+os.path.sep+"templates"+os.path.sep
|
||||
#LOAD the template config content
|
||||
|
|
@ -30,6 +37,11 @@ def init():
|
|||
mouseevent = MouseEvents()
|
||||
start()
|
||||
|
||||
def frameSupported():
|
||||
if data["display_server"] == "wayland":
|
||||
return False
|
||||
return True
|
||||
|
||||
def loadConfigTemplate():
|
||||
config = configparser.ConfigParser()
|
||||
config.sections()
|
||||
|
|
@ -49,4 +61,4 @@ def start():
|
|||
sights.processes();
|
||||
sights.show("main");
|
||||
|
||||
app.exec()
|
||||
app.exec()
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@ class CallHandler(QObject):
|
|||
def getDefaultTemplate(self):
|
||||
return base.data["default_template"]
|
||||
|
||||
@pyqtSlot(result=int)
|
||||
def frameSupported(self):
|
||||
return base.frameSupported()
|
||||
|
||||
@pyqtSlot(int)
|
||||
def setWidth(self, width):
|
||||
self.sight.resize(width, self.sight.height());
|
||||
|
|
@ -43,6 +47,7 @@ class CallHandler(QObject):
|
|||
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())
|
||||
print("PARENT " + str(base.sights.get(new_id).getParent()))
|
||||
return new_id;
|
||||
|
||||
@pyqtSlot(str, str, bool)
|
||||
|
|
@ -64,19 +69,8 @@ class CallHandler(QObject):
|
|||
print("Active - " + self.sight.getId())
|
||||
base.data["active_sight"] = self.sight.getId()
|
||||
|
||||
|
||||
|
||||
@pyqtSlot()
|
||||
def close(self):
|
||||
""" 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())
|
||||
base.sights.close(self.sight.getId())
|
||||
|
||||
@pyqtSlot()
|
||||
|
|
|
|||
|
|
@ -8,10 +8,12 @@ class MouseEvents():
|
|||
on_click=on_click,
|
||||
on_scroll=on_scroll)
|
||||
listener.start()
|
||||
|
||||
|
||||
# MOUSE EVENTS/LISTENER
|
||||
def on_move(x, y):
|
||||
if base.data["move"]:
|
||||
print("MOVING")
|
||||
|
||||
if base.data["mouse_distance_x"] == 0:
|
||||
base.data["mouse_distance_x"] = base.sights.get(base.data["active_sight"]).pos().x()-x
|
||||
if base.data["mouse_distance_y"] == 0:
|
||||
|
|
@ -19,7 +21,8 @@ def on_move(x, y):
|
|||
|
||||
x_point = x+base.data["mouse_distance_x"]
|
||||
y_point = y+base.data["mouse_distance_y"]
|
||||
#print( str(x_point) + " x " + str(y_point))
|
||||
|
||||
print( str(x_point) + " x " + str(y_point))
|
||||
base.sights.get(base.data["active_sight"]).move(x_point, y_point)
|
||||
|
||||
def on_click(x, y, button, pressed):
|
||||
|
|
@ -34,4 +37,5 @@ def on_click(x, y, button, pressed):
|
|||
def on_scroll(x, y, dx, dy):
|
||||
print('Scrolled {0} at {1}'.format(
|
||||
'down' if dy < 0 else 'up',
|
||||
(x, y)))
|
||||
(x, y)))
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ body {
|
|||
-ms-user-select: none; /* Internet Explorer/Edge */
|
||||
user-select: none; /* Non-prefixed version, currently supported by any browser but < IE9 */
|
||||
}
|
||||
#sight #sresize {
|
||||
#sight #sresize[display="show"] {
|
||||
cursor: nw-resize;
|
||||
width: 15px;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background-color: none;
|
||||
right: 0;
|
||||
|
|
@ -29,13 +29,26 @@ body {
|
|||
bottom: 0;
|
||||
position: absolute;
|
||||
}
|
||||
#sight {
|
||||
border: 4px solid grey;
|
||||
#sight #sresize {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#sight {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
#sight[display="show"] {
|
||||
border: 4px solid grey;
|
||||
}
|
||||
#sight {
|
||||
border = 0;
|
||||
}
|
||||
#sight #stitlebar[display="show"] {
|
||||
display: block;
|
||||
}
|
||||
#sight #stitlebar {
|
||||
display: none;
|
||||
width: 100%;
|
||||
height: 25px;
|
||||
background-color: grey;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,13 @@ if(navigator.userAgent.indexOf("QtWebEngine") > 0) {
|
|||
new QWebChannel(qt.webChannelTransport, function (channel) {
|
||||
// now I retrieve my object
|
||||
window.sight = channel.objects.handler;
|
||||
window.sight.frameSupported(function(result) {
|
||||
if(result == 1) {
|
||||
document.querySelector("#stitlebar").setAttribute("display","show")
|
||||
document.querySelector("#sresize").setAttribute("display","show")
|
||||
document.querySelector("#sight").setAttribute("display","show")
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -168,6 +175,11 @@ function load(url, element)
|
|||
}
|
||||
*/
|
||||
$(document).ready(function(){
|
||||
if(typeof window.sight.console === "undefined") {
|
||||
/* Maybe the document ready but still the window.sight didnt loaded in the time */
|
||||
location.reload();
|
||||
}
|
||||
|
||||
const scontent = document.querySelectorAll('[scontent]');
|
||||
scontent.forEach((element) => {
|
||||
$("[scontent="+element.getAttribute("scontent")+"]").load("content/"+element.getAttribute("scontent")+"/content.html");
|
||||
|
|
@ -177,6 +189,7 @@ $(document).ready(function(){
|
|||
// INIT the Sight from init_sight variable
|
||||
if (typeof init_sight !== 'undefined') {
|
||||
for ( const [key,value] of Object.entries( init_sight ) ) {
|
||||
|
||||
window.sight.console(key + " - " + value)
|
||||
switch(key) {
|
||||
case 'width':
|
||||
|
|
@ -239,4 +252,4 @@ $(document).ready(function(){
|
|||
$( "#sfullscreen" ).s_fullscreen();
|
||||
$( "#stitlebar" ).s_titlebar();
|
||||
$( "#stoggled" ).s_toggled();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ body {
|
|||
font-size: larger;
|
||||
float: left;
|
||||
}
|
||||
#sight {
|
||||
border: 4px solid #4f9af3;
|
||||
#sight[display="show"]{
|
||||
border: 4px solid #4f9af3;
|
||||
}
|
||||
#sight #content {
|
||||
padding: 5px;
|
||||
|
|
|
|||
|
|
@ -50,4 +50,4 @@
|
|||
<div id="sresize"></div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
15
sight.py
15
sight.py
|
|
@ -17,10 +17,10 @@ class Sight(QWidget):
|
|||
base.data["active_sight"] = self.id
|
||||
self.title = id
|
||||
|
||||
if base.data["platform"]["system"] != "Linux":
|
||||
if base.frameSupported():
|
||||
self.setWindowFlags(Qt.WindowType(0x00000800)) # remove the os windows frame (borders, close and other buttons
|
||||
self.setAttribute(Qt.WidgetAttribute(0x78)) # (int: 120)) # Make Transparent
|
||||
|
||||
|
||||
self.browser = Browser()
|
||||
self.browser.addObject('handler', CallHandler(self) )
|
||||
self.browser.loadContent(page)
|
||||
|
|
@ -32,6 +32,10 @@ class Sight(QWidget):
|
|||
|
||||
self.setLayout(self.layout)
|
||||
|
||||
# use when the frameSupported is False (for instance wayland)
|
||||
def closeEvent(self, event):
|
||||
base.sights.close(self.id)
|
||||
|
||||
def getParent(self):
|
||||
return self.parent
|
||||
|
||||
|
|
@ -46,8 +50,9 @@ class Sight(QWidget):
|
|||
return self.children
|
||||
|
||||
def removeChild(self, id):
|
||||
self.children.remove(id)
|
||||
print(self.children)
|
||||
if id in self.children:
|
||||
self.children.remove(id)
|
||||
print(self.children)
|
||||
|
||||
def setLayoutContentMargins(self,a,b,c,d):
|
||||
self.layout.setContentsMargins(a, b, c, d)
|
||||
|
|
@ -65,4 +70,4 @@ class Sight(QWidget):
|
|||
if key in self.data:
|
||||
return self.data[key]
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ class SightFactory():
|
|||
id = self.createUniqueId()
|
||||
|
||||
self.list[id] = Sight(id, page)
|
||||
print("The ['"+page+"'-'"+str(id)+"'] is created now!")
|
||||
return id
|
||||
|
||||
def show(self, id):
|
||||
|
|
@ -52,16 +51,33 @@ class SightFactory():
|
|||
if self.checkKey(id):
|
||||
return self.list[id]
|
||||
"""print("This '"+str(id)+"' id isn't exist to get!")"""
|
||||
|
||||
def closeChildren(self, id, removeFromParent = True):
|
||||
""" CLOSE ITS CHILDREN. It doesnt close the children's children just the current parent children
|
||||
will be closed. """
|
||||
for cid in self.get(id).getChildren():
|
||||
self.close(cid)
|
||||
print("CLOSED - " + cid)
|
||||
if removeFromParent:
|
||||
""" If the parent doesn't exist anymore! """
|
||||
if self.get(self.get(id).getParent()) is not None:
|
||||
children = self.get(self.get(id).getParent()).getChildren()
|
||||
if len(children) > 0:
|
||||
self.get(self.get(id).getParent()).removeChild(id)
|
||||
print("AFTER REMOVED CHILDREN " + str(self.get(self.get(id).getParent()).getChildren()) )
|
||||
|
||||
def close(self, id):
|
||||
def close(self, id, closeChildrenToo=True):
|
||||
if closeChildrenToo:
|
||||
self.closeChildren(id)
|
||||
if self.checkKey(id):
|
||||
self.eventMessage("CLOSING", "sight", id)
|
||||
if id == "main":
|
||||
print("Program Exit!")
|
||||
base.app.exit(0)
|
||||
self.list[id].close()
|
||||
self.list[id].deleteLater()
|
||||
del self.list[id]
|
||||
if id in self.list:
|
||||
self.list[id].deleteLater()
|
||||
del self.list[id]
|
||||
"""print("The '"+str(id)+"' is closed now!")"""
|
||||
self.eventMessage("CLOSED", "sight", id)
|
||||
return True
|
||||
|
|
@ -97,4 +113,4 @@ class SightFactory():
|
|||
new_id = str(random.randint(1000, 9999))
|
||||
if self.checkKey(new_id):
|
||||
self.createUniqueId()
|
||||
return new_id
|
||||
return new_id
|
||||
|
|
|
|||
Loading…
Reference in New Issue