|
|
@ -0,0 +1,48 @@
|
|||
import sys
|
||||
import os
|
||||
import configparser
|
||||
from mouseevents import MouseEvents
|
||||
from pynput import mouse
|
||||
from sightfactory import SightFactory
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
from pynput.mouse import Controller
|
||||
|
||||
def init():
|
||||
global data, sights, mousectrl, app
|
||||
#init the basic values
|
||||
app = QApplication(sys.argv)
|
||||
mousectrl = Controller()
|
||||
sights = SightFactory()
|
||||
data = {}
|
||||
data["move"] = False
|
||||
data["active_sight"] = "main"
|
||||
data["sight_processes"] = {}
|
||||
data["mouse_distance_x"] = 0
|
||||
data["mouse_distance_y"] = 0
|
||||
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
|
||||
loadConfigTemplate()
|
||||
#Events
|
||||
mouseevent = MouseEvents()
|
||||
start()
|
||||
|
||||
def loadConfigTemplate():
|
||||
config = configparser.ConfigParser()
|
||||
config.sections()
|
||||
config.read(data["template_dir"]+"config.ini")
|
||||
if "DEFAULT" in config:
|
||||
data["default_template"] = config["DEFAULT"]["default_template"]
|
||||
data["default_template_dir"] = data["template_dir"]+data["default_template"]+os.path.sep
|
||||
data["sight_mode"] = config["DEFAULT"]["sight_mode"]
|
||||
print("Template config is loaded!")
|
||||
else:
|
||||
print("Missing 'DEFAULT' data from the templates config.ini folder. It can't start!")
|
||||
|
||||
def start():
|
||||
# Creating the main Sight
|
||||
sights.create("main","main");
|
||||
sights.processes();
|
||||
sights.show("main");
|
||||
|
||||
app.exec()
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
import sys
|
||||
import os
|
||||
import configparser
|
||||
from mouseevents import MouseEvents
|
||||
from pynput import mouse
|
||||
from sightfactory import SightFactory
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
from pynput.mouse import Controller
|
||||
|
||||
def init():
|
||||
global data, sights, mousectrl, app
|
||||
#init the basic values
|
||||
app = QApplication(sys.argv)
|
||||
mousectrl = Controller()
|
||||
sights = SightFactory()
|
||||
data = {}
|
||||
data["move"] = False
|
||||
data["active_sight"] = "main"
|
||||
data["sight_processes"] = {}
|
||||
data["mouse_distance_x"] = 0
|
||||
data["mouse_distance_y"] = 0
|
||||
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
|
||||
loadConfigTemplate()
|
||||
#Events
|
||||
mouseevent = MouseEvents()
|
||||
start()
|
||||
|
||||
def loadConfigTemplate():
|
||||
config = configparser.ConfigParser()
|
||||
config.sections()
|
||||
config.read(data["template_dir"]+"config.ini")
|
||||
if "DEFAULT" in config:
|
||||
data["default_template"] = config["DEFAULT"]["default_template"]
|
||||
data["default_template_dir"] = data["template_dir"]+data["default_template"]+os.path.sep
|
||||
print("Template config is loaded!")
|
||||
else:
|
||||
print("Missing 'DEFAULT' data from the templates config.ini folder. It can't start!")
|
||||
|
||||
def start():
|
||||
# Creating the main Sight
|
||||
sights.create("main","main");
|
||||
sights.processes();
|
||||
sights.show("main");
|
||||
|
||||
app.exec()
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import base
|
||||
|
||||
from PyQt6.QtWebChannel import QWebChannel
|
||||
from PyQt6.QtWebEngineWidgets import QWebEngineView
|
||||
from PyQt6.QtCore import QUrl
|
||||
|
||||
class Browser(QWebEngineView):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.channel = QWebChannel()
|
||||
|
||||
def addObject(self, id, call_handler):
|
||||
self.handler = call_handler
|
||||
self.channel.registerObject(id, self.handler)
|
||||
self.page().setWebChannel(self.channel)
|
||||
|
||||
def loadContent(self, type):
|
||||
print(base.data["default_template_dir"]+type+".html")
|
||||
self.load(QUrl.fromLocalFile(base.data["default_template_dir"]+type+".html"))
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import base
|
||||
|
||||
from PyQt6.QtWebChannel import QWebChannel
|
||||
from PyQt6.QtWebEngineWidgets import QWebEngineView
|
||||
from PyQt6.QtCore import QUrl
|
||||
|
||||
class Browser(QWebEngineView):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.channel = QWebChannel()
|
||||
|
||||
def addObject(self, id, call_handler):
|
||||
self.handler = call_handler
|
||||
self.channel.registerObject(id, self.handler)
|
||||
self.page().setWebChannel(self.channel)
|
||||
|
||||
def loadContent(self, type):
|
||||
print(base.data["default_template_dir"]+type+".html"))
|
||||
self.load(QUrl.fromLocalFile(base.data["default_template_dir"]+type+".html"))
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
import base
|
||||
import random
|
||||
from PyQt6.QtCore import QObject, pyqtSlot
|
||||
|
||||
class CallHandler(QObject):
|
||||
def __init__(self, sight):
|
||||
super().__init__()
|
||||
self.sight = sight
|
||||
|
||||
@pyqtSlot(str)
|
||||
def test(self, t):
|
||||
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)
|
||||
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):
|
||||
print("active")
|
||||
if base.data["active_sight"] != self.sight.getId():
|
||||
print(self.sight.getId())
|
||||
base.data["active_sight"] = self.sight.getId()
|
||||
|
||||
@pyqtSlot()
|
||||
def close(self):
|
||||
base.sights.close(self.sight.getId())
|
||||
|
||||
@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
|
||||
|
||||
|
||||
@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
|
||||
self.sight.resize( new_width, new_height)
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
import base
|
||||
import random
|
||||
from PyQt6.QtCore import QObject, pyqtSlot
|
||||
|
||||
class CallHandler(QObject):
|
||||
def __init__(self, sight):
|
||||
super().__init__()
|
||||
self.sight = sight
|
||||
|
||||
@pyqtSlot(str)
|
||||
def test(self, t):
|
||||
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)
|
||||
base.sights.show(new_id)
|
||||
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):
|
||||
print("active")
|
||||
if base.data["active_sight"] != self.sight.getId():
|
||||
print(self.sight.getId())
|
||||
base.data["active_sight"] = self.sight.getId()
|
||||
|
||||
@pyqtSlot()
|
||||
def close(self):
|
||||
base.sights.close(self.sight.getId())
|
||||
|
||||
@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
|
||||
|
||||
|
||||
@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
|
||||
self.sight.resize( new_width, new_height)
|
||||
|
|
@ -0,0 +1 @@
|
|||
<a href="#" id="screate" data-type="other" data-id="other">Create an "Other" sight!</a>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<a href="#" id="screate" data-type="other">Create an "Other" sight!</a>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<link rel="stylesheet" type="text/css" href="content/main_text/test.css">
|
||||
|
||||
<div id="example">This is a sentence.</div>
|
||||
<script>
|
||||
window.sight.test("This appear in the console from the content/main_text. The content files reach the window.sight.")
|
||||
</script>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<link rel="stylesheet" type="text/css" href="content/main_text/test.css">
|
||||
|
||||
<div id="example">This is a sentence.</div>
|
||||
<script>
|
||||
window.sight.test("This appear in the console. The content files reach the window.sight.")
|
||||
</script>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#example {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
body {
|
||||
background-color: white;
|
||||
}
|
||||
#sight #stitlebar {
|
||||
background-color: #4f9af3;
|
||||
}
|
||||
#sight #stitle {
|
||||
color: white;
|
||||
padding: 2px;
|
||||
font-weight: bold;
|
||||
font-family: monospace;
|
||||
font-size: larger;
|
||||
float: left;
|
||||
}
|
||||
#sight {
|
||||
border: 4px solid #4f9af3;
|
||||
}
|
||||
#sight #content {
|
||||
padding: 5px;
|
||||
}
|
||||
#sight #sclose:not([except]), #sight #sminimize:not([except]), #sight #stoggled:not([except]) {
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
float: right;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
body {
|
||||
background-color: white;
|
||||
}
|
||||
#sight #stitlebar {
|
||||
background-color: #4f9af3;
|
||||
}
|
||||
#sight #stitle {
|
||||
color: white;
|
||||
padding: 2px;
|
||||
font-weight: bold;
|
||||
font-family: monospace;
|
||||
font-size: larger;
|
||||
float: left;
|
||||
}
|
||||
#sight #sresize {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background-color: none;
|
||||
right: 0;
|
||||
float: right;
|
||||
bottom: 0;
|
||||
position: absolute;
|
||||
}
|
||||
#sight {
|
||||
border: 4px solid #4f9af3;
|
||||
}
|
||||
#sight #content {
|
||||
padding: 5px;
|
||||
}
|
||||
#sight #sclose:not([except]), #sight #sminimize:not([except]), #sight #stoggled:not([except]) {
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
float: right;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
After Width: | Height: | Size: 775 B |
|
After Width: | Height: | Size: 571 B |
|
After Width: | Height: | Size: 535 B |
|
After Width: | Height: | Size: 689 B |
|
|
@ -0,0 +1,40 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="../../css/sight.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/template.css">
|
||||
|
||||
<script src="template.js"></script>
|
||||
<script src="../../js/jquery-3.6.4.min.js"></script>
|
||||
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
|
||||
<script>
|
||||
var init_sight={
|
||||
'width' : 300,
|
||||
'height' : 300
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="../../js/sight.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
/*addData("name", "Balazs", true);
|
||||
getData("name");*/
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<main id="sight">
|
||||
<div id="stitlebar">
|
||||
<div id="stitle">Main Template</div>
|
||||
<div id="sclose"></div>
|
||||
<div id="stoggled"></div>
|
||||
<div id="sminimize"></div>
|
||||
</div>
|
||||
<div id="content">
|
||||
<div id="main_content"></div>
|
||||
MAIN
|
||||
<div id="main_text"></div>
|
||||
</div>
|
||||
<div id="sresize"></div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="../../css/sight.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/template.css">
|
||||
|
||||
<script src="template.js"></script>
|
||||
<script src="../../js/jquery-3.6.4.min.js"></script>
|
||||
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
|
||||
<script>
|
||||
var init_sight={
|
||||
'width' : 300,
|
||||
'height' : 300
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="../../js/sight.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
addData("name", "Balazs", true);
|
||||
getData("name");
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<main id="sight">
|
||||
<div id="stitlebar">
|
||||
<div id="stitle">Main Template</div>
|
||||
<div id="sclose"></div>
|
||||
<div id="stoggled"></div>
|
||||
<div id="sminimize"></div>
|
||||
</div>
|
||||
<div id="content">
|
||||
<div id="main_content"></div>
|
||||
MAIN
|
||||
<div id="main_text"></div>
|
||||
</div>
|
||||
<div id="sresize"></div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="../../css/sight.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/template.css">
|
||||
|
||||
<script src="../../js/jquery-3.6.4.min.js"></script>
|
||||
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
|
||||
<script src="../../js/sight.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
//getData("name", true);
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<main id="sight">
|
||||
<div id="stitlebar">
|
||||
<div id="stitle">TITLE</div>
|
||||
<div id="sclose"></div>
|
||||
<div id="stoggled"></div>
|
||||
<div id="sminimize"></div>
|
||||
</div>
|
||||
<div id="content">
|
||||
OTHER
|
||||
<a href="main.html">Open the main inside this sight!</a>
|
||||
</div>
|
||||
<div id="sresize"></div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="../../css/sight.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/template.css">
|
||||
|
||||
<script src="../../js/jquery-3.6.4.min.js"></script>
|
||||
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
|
||||
<script src="../../js/sight.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
getData("name", true);
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<main id="sight">
|
||||
<div id="stitlebar">
|
||||
<div id="stitle">TITLE</div>
|
||||
<div id="sclose"></div>
|
||||
<div id="stoggled"></div>
|
||||
<div id="sminimize"></div>
|
||||
</div>
|
||||
<div id="content">
|
||||
OTHER
|
||||
<a href="main.html">Open the main inside this sight!</a>
|
||||
</div>
|
||||
<div id="sresize"></div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
var s_template={
|
||||
'name' : "Base",
|
||||
'author' : 'Balazs Birtalan',
|
||||
'URL' : '/template/base',
|
||||
'created': '2023'
|
||||
}
|
||||
|
||||
// first element: "key" is the ID where the content html will be embedded
|
||||
// second element: "value" is the folder name of that content folder where the content.html file's contents will be embedded
|
||||
var s_contents={
|
||||
'main_content':"main",
|
||||
'main_text':"main_text",
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
var s_template={
|
||||
'name' : "Base",
|
||||
'author' : 'Balazs Birtalan',
|
||||
'URL' : '/template/base',
|
||||
'created': '2023'
|
||||
}
|
||||
|
||||
// first element "key" is the ID where the content html will be embedded
|
||||
// second element "value" is the folder name of that content folder where the content.html file's contents will be embedded
|
||||
var s_contents={
|
||||
'main_content':"main",
|
||||
'main_text':"main_text",
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
[DEFAULT]
|
||||
default_template = base
|
||||
sight_mode = single
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
[DEFAULT]
|
||||
default_template = base
|
||||
sight_mode = multiple
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import base
|
||||
base.init()
|
||||
"""
|
||||
base.sights.create("main");
|
||||
base.sights.processes();
|
||||
base.sights.show("main");
|
||||
|
||||
base.app.exec()
|
||||
"""
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
|
||||
block_cipher = None
|
||||
|
||||
|
||||
a = Analysis(['main.py'],
|
||||
pathex=['S:\\SIGHTPLACE\\DEV'],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=[],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False)
|
||||
pyz = PYZ(a.pure, a.zipped_data,
|
||||
cipher=block_cipher)
|
||||
|
||||
exe = EXE(pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='main',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=True,
|
||||
disable_windowed_traceback=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None )
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
import base
|
||||
from pynput import mouse
|
||||
|
||||
class MouseEvents():
|
||||
def __init__(self):
|
||||
listener = mouse.Listener(
|
||||
on_move=on_move,
|
||||
on_click=on_click,
|
||||
on_scroll=on_scroll)
|
||||
listener.start()
|
||||
|
||||
# MOUSE EVENTS/LISTENER
|
||||
def on_move(x, y):
|
||||
if base.data["move"]:
|
||||
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:
|
||||
base.data["mouse_distance_y"] = base.sights.get(base.data["active_sight"]).pos().y()-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))
|
||||
base.sights.get(base.data["active_sight"]).move(x_point, y_point)
|
||||
|
||||
def on_click(x, y, button, pressed):
|
||||
if pressed:
|
||||
print("pressed on " +base.data["active_sight"])
|
||||
else:
|
||||
print("released")
|
||||
base.data["mouse_distance_x"] = 0
|
||||
base.data["mouse_distance_y"] = 0
|
||||
base.data["move"] = False
|
||||
|
||||
def on_scroll(x, y, dx, dy):
|
||||
print('Scrolled {0} at {1}'.format(
|
||||
'down' if dy < 0 else 'up',
|
||||
(x, y)))
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
import base
|
||||
from pynput import mouse
|
||||
|
||||
class MouseEvents():
|
||||
def __init__(self):
|
||||
listener = mouse.Listener(
|
||||
on_move=on_move,
|
||||
on_click=on_click,
|
||||
on_scroll=on_scroll)
|
||||
listener.start()
|
||||
|
||||
# MOUSE EVENTS/LISTENER
|
||||
def on_move(x, y):
|
||||
if base.data["move"]:
|
||||
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:
|
||||
base.data["mouse_distance_y"] = base.sights.get(base.data["active_sight"]).pos().y()-y
|
||||
try:
|
||||
x_point = x+base.data["mouse_distance_x"]
|
||||
y_point = y+base.data["mouse_distance_y"]
|
||||
#print( str(x_point) + " x " + str(y_point))
|
||||
base.sights.get(base.data["active_sight"]).move(x_point, y_point)
|
||||
except:
|
||||
print("e")
|
||||
|
||||
def on_click(x, y, button, pressed):
|
||||
if pressed:
|
||||
print("pressed on " +base.data["active_sight"])
|
||||
else:
|
||||
print("released")
|
||||
base.data["mouse_distance_x"] = 0
|
||||
base.data["mouse_distance_y"] = 0
|
||||
base.data["move"] = False
|
||||
|
||||
def on_scroll(x, y, dx, dy):
|
||||
print('Scrolled {0} at {1}'.format(
|
||||
'down' if dy < 0 else 'up',
|
||||
(x, y)))
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
body {
|
||||
background-color: white;
|
||||
}
|
||||
* {
|
||||
cursor: default;
|
||||
}
|
||||
a {
|
||||
cursor: pointer;
|
||||
}
|
||||
body {
|
||||
margin: 0px;
|
||||
display: flex;
|
||||
}
|
||||
#sight #smove, #sight #sresize {
|
||||
-webkit-touch-callout: none; /* iOS Safari */
|
||||
-webkit-user-select: none; /* Chrome/Safari/Opera */
|
||||
-khtml-user-select: none; /* Konqueror */
|
||||
-moz-user-select: none; /* Firefox */
|
||||
-ms-user-select: none; /* Internet Explorer/Edge */
|
||||
user-select: none; /* Non-prefixed version, currently supported by any browser but < IE9 */
|
||||
}
|
||||
#sight #sresize {
|
||||
cursor: nw-resize;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background-color: none;
|
||||
right: 0;
|
||||
float: right;
|
||||
bottom: 0;
|
||||
position: absolute;
|
||||
}
|
||||
#sight {
|
||||
border: 4px solid grey;
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
#sight #stitlebar {
|
||||
width: 100%;
|
||||
height: 25px;
|
||||
background-color: grey;
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
body {
|
||||
background-color: white;
|
||||
}
|
||||
* {
|
||||
cursor: default;
|
||||
}
|
||||
a {
|
||||
cursor: pointer;
|
||||
}
|
||||
body {
|
||||
margin: 0px;
|
||||
display: flex;
|
||||
}
|
||||
#sight #smove, #sight #sresize {
|
||||
-webkit-touch-callout: none; /* iOS Safari */
|
||||
-webkit-user-select: none; /* Chrome/Safari/Opera */
|
||||
-khtml-user-select: none; /* Konqueror */
|
||||
-moz-user-select: none; /* Firefox */
|
||||
-ms-user-select: none; /* Internet Explorer/Edge */
|
||||
user-select: none; /* Non-prefixed version, currently supported by any browser but < IE9 */
|
||||
}
|
||||
#sight #sresize {
|
||||
cursor: nw-resize;
|
||||
}
|
||||
#sight {
|
||||
border: 4px solid grey;
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
#sight #stitlebar {
|
||||
width: 100%;
|
||||
height: 25px;
|
||||
background-color: grey;
|
||||
}
|
||||
|
|
@ -0,0 +1,207 @@
|
|||
if(navigator.userAgent.indexOf("QtWebEngine") > 0) {
|
||||
new QWebChannel(qt.webChannelTransport, function (channel) {
|
||||
// now I retrieve my object
|
||||
window.sight = channel.objects.handler;
|
||||
});
|
||||
}
|
||||
|
||||
(function ( $ ) {
|
||||
$.fn.s_create = function() {
|
||||
$(document).on( "click", "#screate", function() {
|
||||
event.preventDefault();
|
||||
window.sight.create($(this).data("id"), $(this).data("type"), function(sight_id) {
|
||||
/*alert(sight_id)*/
|
||||
});
|
||||
})
|
||||
};
|
||||
$.fn.s_close = function() {
|
||||
$("body").on( "click", "#sclose", function() {
|
||||
event.preventDefault();
|
||||
window.sight.close();
|
||||
})
|
||||
};
|
||||
$.fn.s_exit = function() {
|
||||
this.bind("click.s_exit", function (event) {
|
||||
event.preventDefault();
|
||||
window.sight.exit();
|
||||
});
|
||||
};
|
||||
$.fn.s_toggled = function() {
|
||||
this.bind("click.s_toggled", function (event) {
|
||||
event.preventDefault();
|
||||
$(this).empty();
|
||||
if($(this).attr('state') != "maximized") { // set to the maximized
|
||||
window.sight.setMaximized();
|
||||
$(this).attr("state", "maximized");
|
||||
$(this).prepend('<img src="img/restoredown.png" height="20px" />')
|
||||
} else { // set to the restore down
|
||||
window.sight.restoreDown();
|
||||
$(this).attr("state", "restoredown");
|
||||
$(this).prepend('<img src="img/maximized.png" height="20px" />')
|
||||
}
|
||||
});
|
||||
};
|
||||
$.fn.s_maximized = function() {
|
||||
this.bind("click.s_maximized", function (event) {
|
||||
if($(this).attr('state') != "maximized") {
|
||||
event.preventDefault();
|
||||
$("#stoggled").empty();
|
||||
window.sight.setMaximized()
|
||||
$("#stoggled").prepend('<img src="img/restoredown.png" height="20px" />')
|
||||
$("#stoggled").attr("state", "maximized");
|
||||
}
|
||||
});
|
||||
};
|
||||
$.fn.s_restoredown = function() {
|
||||
this.bind("click.s_restoredown", function (event) {
|
||||
if($(this).attr('state') != "restoredown") {
|
||||
event.preventDefault();
|
||||
$("#stoggled").empty();
|
||||
window.sight.restoreDown();
|
||||
$("#stoggled").attr("state", "restoredown");
|
||||
$("#stoggled").prepend('<img src="img/maximized.png" height="20px" />')
|
||||
}
|
||||
});
|
||||
};
|
||||
$.fn.s_minimize = function() {
|
||||
this.bind("click.s_minimize", function (event) {
|
||||
event.preventDefault();
|
||||
window.sight.setMinimize();
|
||||
});
|
||||
};
|
||||
$.fn.s_fullscreen = function() {
|
||||
this.bind("click.s_fullscreen", function (event) {
|
||||
event.preventDefault();
|
||||
window.sight.setFullscreen();
|
||||
});
|
||||
};
|
||||
$.fn.s_title = function() {
|
||||
$(this).text(window.sight.getTitle());
|
||||
};
|
||||
$.fn.s_titlebar = function() {
|
||||
/* DISABLE TEXT SELECT */
|
||||
$( this ).attr('unselectable', 'on').css('user-select', 'none').on('selectstart dragstart', false);
|
||||
$( this ).mousedown(function() {
|
||||
/*$( "body" ).attr('unselectable', 'on').css('user-select', 'none').on('selectstart dragstart', false);*/
|
||||
if($(this).children("#stoggled").attr('state') == "restoredown")
|
||||
window.sight.move();
|
||||
})
|
||||
.mouseup(function() {
|
||||
/*$( "body" ).attr('unselectable', 'off').css('user-select', 'yes').on('selectstart dragstart', true);*/
|
||||
window.sight.endmove();
|
||||
});
|
||||
|
||||
};
|
||||
$.fn.s_global_add = function() {
|
||||
this.bind("click.s_global_add", function (event) {
|
||||
event.preventDefault();
|
||||
//window.sight.global($(this));
|
||||
});
|
||||
};
|
||||
$(document).mousemove(function(e){
|
||||
if(resizing)
|
||||
window.sight.resize();
|
||||
});
|
||||
$(document).mouseup(function(e){
|
||||
resizing = false
|
||||
});
|
||||
$(document).mousedown(function(e){
|
||||
window.sight.activeSight();
|
||||
});
|
||||
var resizing = false;
|
||||
$.fn.s_resize = function() {
|
||||
$(this).mousemove(function(e){
|
||||
event.preventDefault();
|
||||
if(e.buttons==1)
|
||||
resizing = true
|
||||
});
|
||||
};
|
||||
}( jQuery ));
|
||||
function addData(key, value, is_global = false) {
|
||||
window.sight.addData(key,value, is_global);
|
||||
}
|
||||
function getData(key, is_global = false) {
|
||||
window.sight.getData(key, is_global, function(result) {
|
||||
alert(result)
|
||||
});
|
||||
}
|
||||
function sclose() {
|
||||
window.sight.close();
|
||||
}
|
||||
function setTitle(title) {
|
||||
$("#stitle").text(title);
|
||||
}
|
||||
$(document).ready(function(){
|
||||
// LOAD the contents into the Sight
|
||||
if (typeof s_contents !== 'undefined') {
|
||||
for ( const [id_name,content_folder] of Object.entries( s_contents ) ) {
|
||||
$("#"+id_name).load("content/"+content_folder+"/content.html");
|
||||
}
|
||||
}
|
||||
// INIT the Sight from init_sight variable
|
||||
if (typeof init_sight !== 'undefined') {
|
||||
|
||||
for ( const [key,value] of Object.entries( init_sight ) ) {
|
||||
window.sight.test(key + " - " + value)
|
||||
switch(key) {
|
||||
case 'width':
|
||||
window.sight.setWidth(value)
|
||||
break;
|
||||
case 'height':
|
||||
window.sight.setHeight(value)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// INIT
|
||||
/*window.sight.getDefaultTemplate(function(default_template) {
|
||||
$('a[href]:not([href^="http://"]), a[href]:not([href^="https://"]), a[href]:not([href^="#"])').each(function(){
|
||||
if(!$(this).hasClass( "nav-link" )) {
|
||||
window.sight.test($(this).attr("href") + " je1");
|
||||
var newUrl = './templates/'+default_template+'/'+$(this).attr("href");
|
||||
$(this).attr("href", newUrl);
|
||||
window.sight.test(newUrl + " je2");
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
if($("#stoggled").length) {
|
||||
var attr = $("#stoggled").attr("state")
|
||||
if (typeof attr !== 'undefined' && attr !== false && (attr == "restoredown" || attr == "maximized")) {
|
||||
|
||||
png_button = "restoredown"
|
||||
if(attr == "restoredown")
|
||||
png_button = "maximized"
|
||||
$("#stoggled").prepend('<img src="img/'+png_button+'.png" height="20px" />');
|
||||
|
||||
if(attr == "maximized")
|
||||
window.sight.setMaximized();
|
||||
} else {
|
||||
$("#stoggled").attr("state", "restoredown");
|
||||
$("#stoggled").prepend('<img src="img/maximized.png" height="20px" />');
|
||||
}
|
||||
}
|
||||
if($("#sclose").length) {
|
||||
$("#sclose:not([except])").empty();
|
||||
$("#sclose:not([except])").prepend('<img src="img/close.png" height="20px" />');
|
||||
}
|
||||
if($("#sminimize").length) {
|
||||
$("#sminimize").empty();
|
||||
$("#sminimize").prepend('<img src="img/minimize.png" height="20px" />');
|
||||
}
|
||||
/*window.sight.getTitle(function(result) {
|
||||
setTitle(result);
|
||||
});*/
|
||||
// INIT END
|
||||
|
||||
$( "#screate" ).s_create();
|
||||
$( "#sclose" ).s_close();
|
||||
$( "#sexit" ).s_exit();
|
||||
$( "#smaximized" ).s_maximized();
|
||||
$( "#sminimize" ).s_minimize();
|
||||
$( "#sresize" ).s_resize();
|
||||
$( "#srestoredown" ).s_restoredown();
|
||||
$( "#sfullscreen" ).s_fullscreen();
|
||||
$( "#stitlebar" ).s_titlebar();
|
||||
$( "#stoggled" ).s_toggled();
|
||||
});
|
||||
|
|
@ -0,0 +1,208 @@
|
|||
if(navigator.userAgent.indexOf("QtWebEngine") > 0) {
|
||||
new QWebChannel(qt.webChannelTransport, function (channel) {
|
||||
// now I retrieve my object
|
||||
window.sight = channel.objects.handler;
|
||||
});
|
||||
}
|
||||
|
||||
(function ( $ ) {
|
||||
$.fn.s_create = function() {
|
||||
$(document).on( "click", "#screate", function() {
|
||||
event.preventDefault();
|
||||
var data_id = ""
|
||||
window.sight.create(data_id, $(this).data("type"), function(sight_id) {
|
||||
/*alert(sight_id)*/
|
||||
});
|
||||
})
|
||||
};
|
||||
$.fn.s_close = function() {
|
||||
$("body").on( "click", "#sclose", function() {
|
||||
event.preventDefault();
|
||||
window.sight.close();
|
||||
})
|
||||
};
|
||||
$.fn.s_exit = function() {
|
||||
this.bind("click.s_exit", function (event) {
|
||||
event.preventDefault();
|
||||
window.sight.exit();
|
||||
});
|
||||
};
|
||||
$.fn.s_toggled = function() {
|
||||
this.bind("click.s_toggled", function (event) {
|
||||
event.preventDefault();
|
||||
$(this).empty();
|
||||
if($(this).attr('state') != "maximized") { // set to the maximized
|
||||
window.sight.setMaximized();
|
||||
$(this).attr("state", "maximized");
|
||||
$(this).prepend('<img src="img/restoredown.png" height="20px" />')
|
||||
} else { // set to the restore down
|
||||
window.sight.restoreDown();
|
||||
$(this).attr("state", "restoredown");
|
||||
$(this).prepend('<img src="img/maximized.png" height="20px" />')
|
||||
}
|
||||
});
|
||||
};
|
||||
$.fn.s_maximized = function() {
|
||||
this.bind("click.s_maximized", function (event) {
|
||||
if($(this).attr('state') != "maximized") {
|
||||
event.preventDefault();
|
||||
$("#stoggled").empty();
|
||||
window.sight.setMaximized()
|
||||
$("#stoggled").prepend('<img src="img/restoredown.png" height="20px" />')
|
||||
$("#stoggled").attr("state", "maximized");
|
||||
}
|
||||
});
|
||||
};
|
||||
$.fn.s_restoredown = function() {
|
||||
this.bind("click.s_restoredown", function (event) {
|
||||
if($(this).attr('state') != "restoredown") {
|
||||
event.preventDefault();
|
||||
$("#stoggled").empty();
|
||||
window.sight.restoreDown();
|
||||
$("#stoggled").attr("state", "restoredown");
|
||||
$("#stoggled").prepend('<img src="img/maximized.png" height="20px" />')
|
||||
}
|
||||
});
|
||||
};
|
||||
$.fn.s_minimize = function() {
|
||||
this.bind("click.s_minimize", function (event) {
|
||||
event.preventDefault();
|
||||
window.sight.setMinimize();
|
||||
});
|
||||
};
|
||||
$.fn.s_fullscreen = function() {
|
||||
this.bind("click.s_fullscreen", function (event) {
|
||||
event.preventDefault();
|
||||
window.sight.setFullscreen();
|
||||
});
|
||||
};
|
||||
$.fn.s_title = function() {
|
||||
$(this).text(window.sight.getTitle());
|
||||
};
|
||||
$.fn.s_titlebar = function() {
|
||||
/* DISABLE TEXT SELECT */
|
||||
$( this ).attr('unselectable', 'on').css('user-select', 'none').on('selectstart dragstart', false);
|
||||
$( this ).mousedown(function() {
|
||||
/*$( "body" ).attr('unselectable', 'on').css('user-select', 'none').on('selectstart dragstart', false);*/
|
||||
if($(this).children("#stoggled").attr('state') == "restoredown")
|
||||
window.sight.move();
|
||||
})
|
||||
.mouseup(function() {
|
||||
/*$( "body" ).attr('unselectable', 'off').css('user-select', 'yes').on('selectstart dragstart', true);*/
|
||||
window.sight.endmove();
|
||||
});
|
||||
|
||||
};
|
||||
$.fn.s_global_add = function() {
|
||||
this.bind("click.s_global_add", function (event) {
|
||||
event.preventDefault();
|
||||
//window.sight.global($(this));
|
||||
});
|
||||
};
|
||||
$(document).mousemove(function(e){
|
||||
if(resizing)
|
||||
window.sight.resize();
|
||||
});
|
||||
$(document).mouseup(function(e){
|
||||
resizing = false
|
||||
});
|
||||
$(document).mousedown(function(e){
|
||||
window.sight.activeSight();
|
||||
});
|
||||
var resizing = false;
|
||||
$.fn.s_resize = function() {
|
||||
$(this).mousemove(function(e){
|
||||
event.preventDefault();
|
||||
if(e.buttons==1)
|
||||
resizing = true
|
||||
});
|
||||
};
|
||||
}( jQuery ));
|
||||
function addData(key, value, is_global = false) {
|
||||
window.sight.addData(key,value, is_global);
|
||||
}
|
||||
function getData(key, is_global = false) {
|
||||
window.sight.getData(key, is_global, function(result) {
|
||||
alert(result)
|
||||
});
|
||||
}
|
||||
function sclose() {
|
||||
window.sight.close();
|
||||
}
|
||||
function setTitle(title) {
|
||||
$("#stitle").text(title);
|
||||
}
|
||||
$(document).ready(function(){
|
||||
// LOAD the contents into the Sight
|
||||
if (typeof s_contents !== 'undefined') {
|
||||
for ( const [id_name,content_folder] of Object.entries( s_contents ) ) {
|
||||
$("#"+id_name).load("content/"+content_folder+"/content.html");
|
||||
}
|
||||
}
|
||||
// INIT the Sight from init_sight variable
|
||||
if (typeof init_sight !== 'undefined') {
|
||||
|
||||
for ( const [key,value] of Object.entries( init_sight ) ) {
|
||||
window.sight.test(key + " - " + value)
|
||||
switch(key) {
|
||||
case 'width':
|
||||
window.sight.setWidth(value)
|
||||
break;
|
||||
case 'height':
|
||||
window.sight.setHeight(value)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// INIT
|
||||
/*window.sight.getDefaultTemplate(function(default_template) {
|
||||
$('a[href]:not([href^="http://"]), a[href]:not([href^="https://"]), a[href]:not([href^="#"])').each(function(){
|
||||
if(!$(this).hasClass( "nav-link" )) {
|
||||
window.sight.test($(this).attr("href") + " je1");
|
||||
var newUrl = './templates/'+default_template+'/'+$(this).attr("href");
|
||||
$(this).attr("href", newUrl);
|
||||
window.sight.test(newUrl + " je2");
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
if($("#stoggled").length) {
|
||||
var attr = $("#stoggled").attr("state")
|
||||
if (typeof attr !== 'undefined' && attr !== false && (attr == "restoredown" || attr == "maximized")) {
|
||||
|
||||
png_button = "restoredown"
|
||||
if(attr == "restoredown")
|
||||
png_button = "maximized"
|
||||
$("#stoggled").prepend('<img src="img/'+png_button+'.png" height="20px" />');
|
||||
|
||||
if(attr == "maximized")
|
||||
window.sight.setMaximized();
|
||||
} else {
|
||||
$("#stoggled").attr("state", "restoredown");
|
||||
$("#stoggled").prepend('<img src="img/maximized.png" height="20px" />');
|
||||
}
|
||||
}
|
||||
if($("#sclose").length) {
|
||||
$("#sclose:not([except])").empty();
|
||||
$("#sclose:not([except])").prepend('<img src="img/close.png" height="20px" />');
|
||||
}
|
||||
if($("#sminimize").length) {
|
||||
$("#sminimize").empty();
|
||||
$("#sminimize").prepend('<img src="img/minimize.png" height="20px" />');
|
||||
}
|
||||
/*window.sight.getTitle(function(result) {
|
||||
setTitle(result);
|
||||
});*/
|
||||
// INIT END
|
||||
|
||||
$( "#screate" ).s_create();
|
||||
$( "#sclose" ).s_close();
|
||||
$( "#sexit" ).s_exit();
|
||||
$( "#smaximized" ).s_maximized();
|
||||
$( "#sminimize" ).s_minimize();
|
||||
$( "#sresize" ).s_resize();
|
||||
$( "#srestoredown" ).s_restoredown();
|
||||
$( "#sfullscreen" ).s_fullscreen();
|
||||
$( "#stitlebar" ).s_titlebar();
|
||||
$( "#stoggled" ).s_toggled();
|
||||
});
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
|
||||
<meta name="viewport" id="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
<link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
|
||||
<title>jQuery xtr.js plugin Demo</title>
|
||||
<style>
|
||||
body { font-family:'Roboto'; background-color:#333; color:#fafafa;}
|
||||
#wrapper {
|
||||
margin: 150px auto;
|
||||
width: 400px;
|
||||
text-align: center
|
||||
}
|
||||
#wrapper div {
|
||||
color:#fff;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="jquery-script-menu">
|
||||
<div class="jquery-script-center">
|
||||
<ul>
|
||||
<li><a href="http://www.jqueryscript.net/text/jQuery-Client-side-Translation-xtr/">Download This Plugin</a></li>
|
||||
<li><a href="http://www.jqueryscript.net/">Back To jQueryScript.Net</a></li>
|
||||
</ul>
|
||||
<div class="jquery-script-ads"><script type="text/javascript"><!--
|
||||
google_ad_client = "ca-pub-2783044520727903";
|
||||
/* jQuery_demo */
|
||||
google_ad_slot = "2780937993";
|
||||
google_ad_width = 728;
|
||||
google_ad_height = 90;
|
||||
//-->
|
||||
</script>
|
||||
<script type="text/javascript"
|
||||
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
|
||||
</script></div>
|
||||
<div class="jquery-script-clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="wrapper">
|
||||
<h1>jQuery xtr.js plugin Demo</h1>
|
||||
<div xtr>Welcome</div>
|
||||
<div xtr>Hello</div>
|
||||
<div data-xtr-key="bye">Good Bye</div>
|
||||
|
||||
<label for="lang">Current language</label>
|
||||
<select name="lang" id="lang">
|
||||
<option value="reset">EN</option>
|
||||
<option value="de">DE</option>
|
||||
<option value="fr">FR</option>
|
||||
<option value="es">ES</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
|
||||
<script src="../jquery.xtr.min.js"></script>
|
||||
<script>
|
||||
$('body').xtr({t: data});
|
||||
|
||||
$('#lang').on('change', function() {
|
||||
$('body').data('plugin_xtr').lang($(this).val());
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-36251023-1']);
|
||||
_gaq.push(['_setDomainName', 'jqueryscript.net']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
#wrapper {
|
||||
font: 16px/18px Calibri;
|
||||
margin: 0 auto;
|
||||
width: 200px;
|
||||
text-align: center
|
||||
}
|
||||
|
||||
#wrapper div {
|
||||
background: #28b7ff;
|
||||
padding: 15px;
|
||||
margin: 10px;
|
||||
text-align: center
|
||||
}
|
||||
|
||||
label {
|
||||
font-weight: 700;
|
||||
margin: 25px 0 5px;
|
||||
display: block
|
||||
}
|
||||
|
||||
select {
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
outline: 0;
|
||||
cursor: pointer
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#wrapper {
|
||||
font: 16px / 18px Calibri;
|
||||
margin: 0 auto;
|
||||
width: 200px;
|
||||
text-align: center;
|
||||
div {
|
||||
background: #28b7ff;
|
||||
padding: 15px;
|
||||
margin: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
label {
|
||||
font-weight: bold;
|
||||
margin: 25px 0 5px;
|
||||
display: block;
|
||||
}
|
||||
select {
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
var data = {
|
||||
"close": {
|
||||
en: "close",
|
||||
hu: "Bezar",
|
||||
it: "Vicino"
|
||||
},
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/*!
|
||||
* July 2017
|
||||
* xtr 1.0.0
|
||||
* @author Mario Vidov
|
||||
* @url http://vidov.it
|
||||
* @twitter MarioVidov
|
||||
* MIT license
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
var pluginName = 'xtr';
|
||||
|
||||
var settings = {
|
||||
default: 'en',
|
||||
lang: 'en',
|
||||
regExp: {
|
||||
'': /\s/g,
|
||||
'_': /[&<>"'`\/=]/g
|
||||
}
|
||||
};
|
||||
|
||||
var config = {
|
||||
defaultClass: 'data-xtr-default',
|
||||
langClass: 'data-xtr-lang',
|
||||
langKey : 'data-xtr-key',
|
||||
langOrig : 'data-xtr-original'
|
||||
};
|
||||
|
||||
function Plugin(element, options) {
|
||||
options = options || {};
|
||||
this.$element = $(element);
|
||||
this.options = $.extend(true, {}, settings, options);
|
||||
this.selector = '[xtr]';
|
||||
this.regExp = this.options.regExp;
|
||||
this.default = this.options.default;
|
||||
this.t = this.options.t;
|
||||
this.l = this.options.lang;
|
||||
|
||||
this.$element.attr(config.langClass, this.l)
|
||||
.attr(config.defaultClass, this.default);
|
||||
this.init();
|
||||
}
|
||||
|
||||
Plugin.prototype.lang = function(l) {
|
||||
if (l && l === 'reset') {
|
||||
this.l = this.default;
|
||||
} else if (l) {
|
||||
this.l = l;
|
||||
}
|
||||
this.init();
|
||||
};
|
||||
|
||||
Plugin.prototype.set = function(index) {
|
||||
var $el = $('[' + config.langKey + '="' + index + '"]');
|
||||
var original = $el && $el.attr(config.langOrig) || index;
|
||||
return (this.t && this.t[index] && this.t[index][this.l]) ? this.t[index][this.l] : original;
|
||||
};
|
||||
|
||||
Plugin.prototype.init = function() {
|
||||
var self = this;
|
||||
this.$element.attr(config.langClass, this.l);
|
||||
$(self.selector).add('[' + config.langKey + ']').each(function () {
|
||||
var $this = $(this);
|
||||
var key = $this.attr(config.langKey);
|
||||
var original = $this.attr(config.langOrig);
|
||||
var text = $this.text();
|
||||
if (!key) {
|
||||
key = text;
|
||||
for (var i in self.regExp) {
|
||||
key = key.replace(self.regExp[i], i);
|
||||
}
|
||||
$this.attr(config.langKey, key);
|
||||
}
|
||||
if (!original) {
|
||||
$this.attr(config.langOrig, text);
|
||||
}
|
||||
$this.html(self.set(key));
|
||||
});
|
||||
};
|
||||
|
||||
$.fn[pluginName] = function (options) {
|
||||
return this.each(function () {
|
||||
if (!$.data(this, 'plugin_' + pluginName)) {
|
||||
$.data(this, 'plugin_' + pluginName, new Plugin(this, options));
|
||||
}
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
|
|
@ -0,0 +1 @@
|
|||
(function(t){var i="xtr";var a={"default":"en",lang:"en",regExp:{"":/\s/g,_:/[&<>"'`\/=]/g}};var e={defaultClass:"data-xtr-default",langClass:"data-xtr-lang",langKey:"data-xtr-key",langOrig:"data-xtr-original"};function s(i,s){s=s||{};this.$element=t(i);this.options=t.extend(true,{},a,s);this.selector="[xtr]";this.regExp=this.options.regExp;this.default=this.options.default;this.t=this.options.t;this.l=this.options.lang;this.$element.attr(e.langClass,this.l).attr(e.defaultClass,this.default);this.init()}s.prototype.lang=function(t){if(t&&t==="reset"){this.l=this.default}else if(t){this.l=t}this.init()};s.prototype.set=function(i){var a=t("["+e.langKey+'="'+i+'"]');var s=a&&a.attr(e.langOrig)||i;return this.t&&this.t[i]&&this.t[i][this.l]?this.t[i][this.l]:s};s.prototype.init=function(){var i=this;this.$element.attr(e.langClass,this.l);t(i.selector).add("["+e.langKey+"]").each(function(){var a=t(this);var s=a.attr(e.langKey);var n=a.attr(e.langOrig);var r=a.text();if(!s){s=r;for(var l in i.regExp){s=s.replace(i.regExp[l],l)}a.attr(e.langKey,s)}if(!n){a.attr(e.langOrig,r)}a.html(i.set(s))})};t.fn[i]=function(a){return this.each(function(){if(!t.data(this,"plugin_"+i)){t.data(this,"plugin_"+i,new s(this,a))}})}})(jQuery);
|
||||
|
|
@ -0,0 +1 @@
|
|||
<a href="#" id="screate" data-type="other" data-id="other">Create an "Other" sight!</a>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<a href="#" id="screate" data-type="other">Create an "Other" sight!</a>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<link rel="stylesheet" type="text/css" href="content/main_text/test.css">
|
||||
|
||||
<div id="example">This is a sentence.</div>
|
||||
<script>
|
||||
window.sight.test("This appear in the console from the content/main_text. The content files reach the window.sight.")
|
||||
</script>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<link rel="stylesheet" type="text/css" href="content/main_text/test.css">
|
||||
|
||||
<div id="example">This is a sentence.</div>
|
||||
<script>
|
||||
window.sight.test("This appear in the console. The content files reach the window.sight.")
|
||||
</script>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#example {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
body {
|
||||
background-color: white;
|
||||
}
|
||||
#sight #stitlebar {
|
||||
background-color: #4f9af3;
|
||||
}
|
||||
#sight #stitle {
|
||||
color: white;
|
||||
padding: 2px;
|
||||
font-weight: bold;
|
||||
font-family: monospace;
|
||||
font-size: larger;
|
||||
float: left;
|
||||
}
|
||||
#sight {
|
||||
border: 4px solid #4f9af3;
|
||||
}
|
||||
#sight #content {
|
||||
padding: 5px;
|
||||
}
|
||||
#sight #sclose:not([except]), #sight #sminimize:not([except]), #sight #stoggled:not([except]) {
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
float: right;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
body {
|
||||
background-color: white;
|
||||
}
|
||||
#sight #stitlebar {
|
||||
background-color: #4f9af3;
|
||||
}
|
||||
#sight #stitle {
|
||||
color: white;
|
||||
padding: 2px;
|
||||
font-weight: bold;
|
||||
font-family: monospace;
|
||||
font-size: larger;
|
||||
float: left;
|
||||
}
|
||||
#sight #sresize {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background-color: none;
|
||||
right: 0;
|
||||
float: right;
|
||||
bottom: 0;
|
||||
position: absolute;
|
||||
}
|
||||
#sight {
|
||||
border: 4px solid #4f9af3;
|
||||
}
|
||||
#sight #content {
|
||||
padding: 5px;
|
||||
}
|
||||
#sight #sclose:not([except]), #sight #sminimize:not([except]), #sight #stoggled:not([except]) {
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
float: right;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
After Width: | Height: | Size: 775 B |
|
After Width: | Height: | Size: 571 B |
|
After Width: | Height: | Size: 535 B |
|
After Width: | Height: | Size: 689 B |
|
|
@ -0,0 +1,40 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="../../css/sight.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/template.css">
|
||||
|
||||
<script src="template.js"></script>
|
||||
<script src="../../js/jquery-3.6.4.min.js"></script>
|
||||
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
|
||||
<script>
|
||||
var init_sight={
|
||||
'width' : 300,
|
||||
'height' : 300
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="../../js/sight.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
/*addData("name", "Balazs", true);
|
||||
getData("name");*/
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<main id="sight">
|
||||
<div id="stitlebar">
|
||||
<div id="stitle">Main Template</div>
|
||||
<div id="sclose"></div>
|
||||
<div id="stoggled"></div>
|
||||
<div id="sminimize"></div>
|
||||
</div>
|
||||
<div id="content">
|
||||
<div id="main_content"></div>
|
||||
MAIN
|
||||
<div id="main_text"></div>
|
||||
</div>
|
||||
<div id="sresize"></div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="../../css/sight.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/template.css">
|
||||
|
||||
<script src="template.js"></script>
|
||||
<script src="../../js/jquery-3.6.4.min.js"></script>
|
||||
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
|
||||
<script>
|
||||
var init_sight={
|
||||
'width' : 300,
|
||||
'height' : 300
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="../../js/sight.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
addData("name", "Balazs", true);
|
||||
getData("name");
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<main id="sight">
|
||||
<div id="stitlebar">
|
||||
<div id="stitle">Main Template</div>
|
||||
<div id="sclose"></div>
|
||||
<div id="stoggled"></div>
|
||||
<div id="sminimize"></div>
|
||||
</div>
|
||||
<div id="content">
|
||||
<div id="main_content"></div>
|
||||
MAIN
|
||||
<div id="main_text"></div>
|
||||
</div>
|
||||
<div id="sresize"></div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="../../css/sight.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/template.css">
|
||||
|
||||
<script src="../../js/jquery-3.6.4.min.js"></script>
|
||||
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
|
||||
<script src="../../js/sight.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
//getData("name", true);
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<main id="sight">
|
||||
<div id="stitlebar">
|
||||
<div id="stitle">TITLE</div>
|
||||
<div id="sclose"></div>
|
||||
<div id="stoggled"></div>
|
||||
<div id="sminimize"></div>
|
||||
</div>
|
||||
<div id="content">
|
||||
OTHER
|
||||
<a href="main.html">Open the main inside this sight!</a>
|
||||
</div>
|
||||
<div id="sresize"></div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="../../css/sight.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/template.css">
|
||||
|
||||
<script src="../../js/jquery-3.6.4.min.js"></script>
|
||||
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
|
||||
<script src="../../js/sight.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
getData("name", true);
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<main id="sight">
|
||||
<div id="stitlebar">
|
||||
<div id="stitle">TITLE</div>
|
||||
<div id="sclose"></div>
|
||||
<div id="stoggled"></div>
|
||||
<div id="sminimize"></div>
|
||||
</div>
|
||||
<div id="content">
|
||||
OTHER
|
||||
<a href="main.html">Open the main inside this sight!</a>
|
||||
</div>
|
||||
<div id="sresize"></div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
var s_template={
|
||||
'name' : "Base",
|
||||
'author' : 'Balazs Birtalan',
|
||||
'URL' : '/template/base',
|
||||
'created': '2023'
|
||||
}
|
||||
|
||||
// first element: "key" is the ID where the content html will be embedded
|
||||
// second element: "value" is the folder name of that content folder where the content.html file's contents will be embedded
|
||||
var s_contents={
|
||||
'main_content':"main",
|
||||
'main_text':"main_text",
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
var s_template={
|
||||
'name' : "Base",
|
||||
'author' : 'Balazs Birtalan',
|
||||
'URL' : '/template/base',
|
||||
'created': '2023'
|
||||
}
|
||||
|
||||
// first element "key" is the ID where the content html will be embedded
|
||||
// second element "value" is the folder name of that content folder where the content.html file's contents will be embedded
|
||||
var s_contents={
|
||||
'main_content':"main",
|
||||
'main_text':"main_text",
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
[DEFAULT]
|
||||
default_template = base
|
||||
sight_mode = single
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
[DEFAULT]
|
||||
default_template = base
|
||||
sight_mode = multiple
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
def init():
|
||||
global data
|
||||
data = []
|
||||
|
|
@ -0,0 +1,194 @@
|
|||
import os
|
||||
import sys
|
||||
import random
|
||||
|
||||
import base
|
||||
from PyQt6.QtCore import QUrl, QObject, pyqtSlot, Qt
|
||||
from PyQt6.QtWebEngineWidgets import QWebEngineView
|
||||
from PyQt6.QtWidgets import QMainWindow
|
||||
from PyQt6.QtWebChannel import QWebChannel
|
||||
from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout
|
||||
|
||||
class CallHandler(QObject):
|
||||
def __init__(self, sight):
|
||||
super().__init__()
|
||||
self.sight = sight
|
||||
|
||||
@pyqtSlot(str)
|
||||
def test(self, t):
|
||||
print(t)
|
||||
|
||||
@pyqtSlot(str, result=str)
|
||||
def test2(self, t):
|
||||
print(t)
|
||||
return t+"_return"
|
||||
|
||||
@pyqtSlot(str)
|
||||
def create(self, t):
|
||||
id = str(random.randrange(1000,9999))
|
||||
createSight(id)
|
||||
base.data["sight_processes"][id].show()
|
||||
|
||||
@pyqtSlot()
|
||||
def activeSight(self):
|
||||
print("active")
|
||||
if base.data["active_sight"] != self.sight.getId():
|
||||
print(self.sight.getId())
|
||||
base.data["active_sight"] = self.sight.getId()
|
||||
|
||||
@pyqtSlot()
|
||||
def close(self):
|
||||
closeSight(self.sight.id)
|
||||
"""if self.sight.id == "main":
|
||||
app.exit(0)
|
||||
else:
|
||||
try:
|
||||
base.data["sight_processes"][self.sight.id].close()
|
||||
base.data["sight_processes"][self.sight.id].destroy()
|
||||
del base.data["sight_processes"][self.sight.id]
|
||||
print("The '"+self.sight.id+"' is closed now!")
|
||||
base.processSight()
|
||||
except KeyError:
|
||||
print("KeyError: when closing "+self.sight.id)"""
|
||||
|
||||
@pyqtSlot()
|
||||
def setMaximized(self):
|
||||
self.sight.showMaximized()
|
||||
|
||||
@pyqtSlot()
|
||||
def setMinimize(self):
|
||||
self.sight.showMinimized()
|
||||
|
||||
@pyqtSlot()
|
||||
def restoreDown(self):
|
||||
self.sight.showNormal()
|
||||
|
||||
@pyqtSlot()
|
||||
def setFullscreen(self):
|
||||
self.sight.showFullScreen()
|
||||
|
||||
@pyqtSlot(result=str)
|
||||
def getTitle(self):
|
||||
print("IIIIID: ")
|
||||
return self.sight.getTitle();
|
||||
|
||||
@pyqtSlot()
|
||||
def move(self):
|
||||
base.data["move"] = True
|
||||
|
||||
|
||||
@pyqtSlot()
|
||||
def endmove(self):
|
||||
base.data["move"] = False
|
||||
|
||||
@pyqtSlot()
|
||||
def resize(self):
|
||||
global mousectrl
|
||||
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
|
||||
self.sight.resize( new_width, new_height)
|
||||
|
||||
|
||||
class Browser(QWebEngineView):
|
||||
def __init__(self, sight_id):
|
||||
super().__init__()
|
||||
self.id = sight_id
|
||||
self.channel = QWebChannel()
|
||||
self.handler = CallHandler(self)
|
||||
self.channel.registerObject('handler', self.handler)
|
||||
self.page().setWebChannel(self.channel)
|
||||
self.title = sight_id
|
||||
|
||||
def getId(self):
|
||||
return self.id
|
||||
def setTitle(self, title):
|
||||
self.title = title
|
||||
def getTitle(self):
|
||||
return self.title
|
||||
|
||||
def mouseMoveEvent(self, e):
|
||||
print("mouseMoveEvent")
|
||||
|
||||
def mousePressEvent(self, e):
|
||||
print("mousePressEvent")
|
||||
|
||||
def mouseReleaseEvent(self, e):
|
||||
print("mouseReleaseEvent")
|
||||
|
||||
def mouseDoubleClickEvent(self, e):
|
||||
print("mouseDoubleClickEvent")
|
||||
|
||||
class Sight(QWidget):
|
||||
def __init__(self, sight_id):
|
||||
super().__init__()
|
||||
|
||||
self.id = sight_id
|
||||
base.data["active_sight"] = self.id
|
||||
self.title = sight_id
|
||||
self.setWindowFlags(Qt.WindowType.FramelessWindowHint | self.windowFlags())
|
||||
|
||||
self.browser = Browser(sight_id)
|
||||
|
||||
|
||||
|
||||
current_folder = os.path.abspath(os.getcwd())
|
||||
html_file = current_folder + os.path.sep + "place" + os.path.sep + "templates" + os.path.sep + "base" + os.path.sep + "index.html"
|
||||
print(html_file)
|
||||
url = QUrl.fromLocalFile(html_file)
|
||||
|
||||
self.browser.load(url)
|
||||
|
||||
lay = QVBoxLayout(self)
|
||||
lay.setSpacing(0);
|
||||
lay.setContentsMargins(0, 0, 0, 0);
|
||||
lay.addWidget(self.browser)
|
||||
#self.setCentralWidget(self.browser)
|
||||
|
||||
def mouseMoveEvent(self, e):
|
||||
print("mouseMoveEvent")
|
||||
|
||||
def mousePressEvent(self, e):
|
||||
print("mousePressEvent")
|
||||
|
||||
def mouseReleaseEvent(self, e):
|
||||
print("mouseReleaseEvent")
|
||||
|
||||
def mouseDoubleClickEvent(self, e):
|
||||
print("mouseDoubleClickEvent")
|
||||
|
||||
|
||||
|
||||
|
||||
def getId(self):
|
||||
return self.id
|
||||
|
||||
def createSight(id):
|
||||
if id != "main":
|
||||
base.data["sight_processes"][id] = Sight(id)
|
||||
base.data["sight_processes"][id].show()
|
||||
print("The '"+id+"' is opened now!")
|
||||
base.processSight()
|
||||
else:
|
||||
print("The 'main' id is the main active windows which is occupied!")
|
||||
|
||||
def closeSight(id):
|
||||
if id == "main":
|
||||
app.exit(0)
|
||||
else:
|
||||
try:
|
||||
base.data["sight_processes"][id] .close()
|
||||
base.data["sight_processes"][id] .destroy()
|
||||
del base.data["sight_processes"][id]
|
||||
print("The '"+id+"' is closed now!")
|
||||
base.processSight()
|
||||
except KeyError:
|
||||
print("KeyError: when closing "+id)
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
base.data["sight_processes"]["main"] = Sight("main")
|
||||
base.data["sight_processes"]["main"].show()
|
||||
app.exec()
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
import base
|
||||
from callhandler import CallHandler
|
||||
from browser import Browser
|
||||
from PyQt6.QtCore import Qt
|
||||
from PyQt6.QtWidgets import QMainWindow, QWidget, QVBoxLayout
|
||||
|
||||
class Sight(QWidget):
|
||||
def __init__(self, id, type):
|
||||
super().__init__()
|
||||
|
||||
self.id = id
|
||||
self.type = type
|
||||
self.data = {} # private data(s) of the sight
|
||||
|
||||
base.data["active_sight"] = self.id
|
||||
self.title = id
|
||||
|
||||
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(type)
|
||||
|
||||
self.layout = QVBoxLayout()
|
||||
self.layout.addWidget(self.browser)
|
||||
self.layout.setSpacing(0);
|
||||
self.layout.setContentsMargins(1, 1, 1, 1); #Need 1,1,1,1 if it is 0,0,0,0 I got setgeometry warnings
|
||||
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def setLayoutContentMargins(self,a,b,c,d):
|
||||
self.layout.setContentsMargins(a, b, c, d)
|
||||
|
||||
def setTitle(self, title):
|
||||
self.title = title
|
||||
def getTitle(self):
|
||||
return self.title
|
||||
def getId(self):
|
||||
return self.id
|
||||
def addData(self, key, value):
|
||||
self.data[key] = value
|
||||
def getData(self, key):
|
||||
if key in self.data:
|
||||
return self.data[key]
|
||||
return None
|
||||
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
import os
|
||||
import sys
|
||||
import random
|
||||
|
||||
import base
|
||||
from PyQt6.QtCore import QUrl, QObject, pyqtSlot, Qt
|
||||
from PyQt6.QtWebEngineWidgets import QWebEngineView
|
||||
from PyQt6.QtWidgets import QMainWindow
|
||||
from PyQt6.QtWebChannel import QWebChannel
|
||||
from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout
|
||||
|
||||
class CallHandler(QObject):
|
||||
def __init__(self, sight):
|
||||
super().__init__()
|
||||
self.sight = sight
|
||||
|
||||
@pyqtSlot(str)
|
||||
def test(self, t):
|
||||
print(t)
|
||||
|
||||
@pyqtSlot(str, result=str)
|
||||
def test2(self, t):
|
||||
print(t)
|
||||
return t+"_return"
|
||||
|
||||
@pyqtSlot(str)
|
||||
def create(self, t):
|
||||
id = str(random.randrange(1000,9999))
|
||||
createSight(id)
|
||||
base.data["sight_processes"][id].show()
|
||||
|
||||
@pyqtSlot()
|
||||
def activeSight(self):
|
||||
print("active")
|
||||
if base.data["active_sight"] != self.sight.getId():
|
||||
print(self.sight.getId())
|
||||
base.data["active_sight"] = self.sight.getId()
|
||||
|
||||
@pyqtSlot()
|
||||
def close(self):
|
||||
closeSight(self.sight.id)
|
||||
"""if self.sight.id == "main":
|
||||
app.exit(0)
|
||||
else:
|
||||
try:
|
||||
base.data["sight_processes"][self.sight.id].close()
|
||||
base.data["sight_processes"][self.sight.id].destroy()
|
||||
del base.data["sight_processes"][self.sight.id]
|
||||
print("The '"+self.sight.id+"' is closed now!")
|
||||
base.processSight()
|
||||
except KeyError:
|
||||
print("KeyError: when closing "+self.sight.id)"""
|
||||
|
||||
@pyqtSlot()
|
||||
def setMaximized(self):
|
||||
self.sight.showMaximized()
|
||||
|
||||
@pyqtSlot()
|
||||
def setMinimize(self):
|
||||
self.sight.showMinimized()
|
||||
|
||||
@pyqtSlot()
|
||||
def restoreDown(self):
|
||||
self.sight.showNormal()
|
||||
|
||||
@pyqtSlot()
|
||||
def setFullscreen(self):
|
||||
self.sight.showFullScreen()
|
||||
|
||||
@pyqtSlot(result=str)
|
||||
def getTitle(self):
|
||||
print("IIIIID: ")
|
||||
return self.sight.getTitle();
|
||||
|
||||
@pyqtSlot()
|
||||
def move(self):
|
||||
base.data["move"] = True
|
||||
|
||||
|
||||
@pyqtSlot()
|
||||
def endmove(self):
|
||||
base.data["move"] = False
|
||||
|
||||
@pyqtSlot()
|
||||
def resize(self):
|
||||
global mousectrl
|
||||
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
|
||||
self.sight.resize( new_width, new_height)
|
||||
|
||||
|
||||
class Browser(QWebEngineView):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.channel = QWebChannel()
|
||||
|
||||
def addHandler(self, id, call_handler):
|
||||
self.handler = call_handler
|
||||
self.channel.registerObject(id, self.handler)
|
||||
self.page().setWebChannel(self.channel)
|
||||
|
||||
class Sight(QWidget):
|
||||
def __init__(self, sight_id):
|
||||
super().__init__()
|
||||
|
||||
self.id = sight_id
|
||||
base.data["active_sight"] = self.id
|
||||
self.title = sight_id
|
||||
self.setWindowFlags(Qt.WindowType.FramelessWindowHint | self.windowFlags())
|
||||
|
||||
self.browser = Browser()
|
||||
self.browser.addHandler('handler', CallHandler(self) )
|
||||
#self.channel = QWebChannel()
|
||||
#self.handler = CallHandler(self)
|
||||
#self.channel.registerObject('handler', self.handler)
|
||||
#self.browser.page().setWebChannel(self.channel)
|
||||
|
||||
current_folder = os.path.abspath(os.getcwd())
|
||||
html_file = current_folder + os.path.sep + "place" + os.path.sep + "templates" + os.path.sep + "base" + os.path.sep + "index.html"
|
||||
print(html_file)
|
||||
url = QUrl.fromLocalFile(html_file)
|
||||
|
||||
self.browser.load(url)
|
||||
|
||||
lay = QVBoxLayout(self)
|
||||
lay.setSpacing(0);
|
||||
lay.setContentsMargins(0, 0, 0, 0);
|
||||
lay.addWidget(self.browser)
|
||||
#self.setCentralWidget(self.browser)
|
||||
|
||||
def setTitle(self, title):
|
||||
self.title = title
|
||||
def getTitle(self):
|
||||
return self.title
|
||||
|
||||
def getId(self):
|
||||
return self.id
|
||||
|
||||
def createSight(id):
|
||||
if id != "main":
|
||||
base.data["sight_processes"][id] = Sight(id)
|
||||
base.data["sight_processes"][id].show()
|
||||
print("The '"+id+"' is opened now!")
|
||||
base.processSight()
|
||||
else:
|
||||
print("The 'main' id is the main active windows which is occupied!")
|
||||
|
||||
def closeSight(id):
|
||||
if id == "main":
|
||||
app.exit(0)
|
||||
else:
|
||||
try:
|
||||
base.data["sight_processes"][id] .close()
|
||||
base.data["sight_processes"][id] .destroy()
|
||||
del base.data["sight_processes"][id]
|
||||
print("The '"+id+"' is closed now!")
|
||||
base.processSight()
|
||||
except KeyError:
|
||||
print("KeyError: when closing "+id)
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
base.data["sight_processes"]["main"] = Sight("main")
|
||||
base.data["sight_processes"]["main"].show()
|
||||
app.exec()
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
import base
|
||||
from callhandler import CallHandler
|
||||
from browser import Browser
|
||||
from PyQt6.QtCore import Qt
|
||||
from PyQt6.QtWidgets import QMainWindow, QWidget, QVBoxLayout
|
||||
|
||||
class Sight(QWidget):
|
||||
def __init__(self, id, type):
|
||||
super().__init__()
|
||||
|
||||
self.id = id
|
||||
self.type = type
|
||||
self.data = {} # private data of the sight
|
||||
|
||||
base.data["active_sight"] = self.id
|
||||
self.title = id
|
||||
|
||||
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(type)
|
||||
|
||||
self.layout = QVBoxLayout()
|
||||
self.layout.addWidget(self.browser)
|
||||
self.layout.setSpacing(0);
|
||||
self.layout.setContentsMargins(1, 1, 1, 1); #Need 1,1,1,1 if it is 0,0,0,0 I got setgeometry warnings
|
||||
|
||||
self.setLayout(self.layout)
|
||||
|
||||
def setLayoutContentMargins(self,a,b,c,d):
|
||||
self.layout.setContentsMargins(a, b, c, d)
|
||||
|
||||
def setTitle(self, title):
|
||||
self.title = title
|
||||
def getTitle(self):
|
||||
return self.title
|
||||
def getId(self):
|
||||
return self.id
|
||||
def addData(self, key, value):
|
||||
self.data[key] = value
|
||||
def getData(self, key):
|
||||
if key in self.data:
|
||||
return self.data[key]
|
||||
return None
|
||||
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
import base
|
||||
import random
|
||||
from sight import Sight
|
||||
|
||||
class SightFactory():
|
||||
def __init__(self):
|
||||
self.list = {}
|
||||
self.data = {} #Global data(s) for the sight(s)
|
||||
|
||||
def create(self, id, type):
|
||||
print("----- "+type+"-"+str(id)+"-------")
|
||||
|
||||
if str(id) == "main" and self.checkKey(id):
|
||||
print("The 'main' window already exist! You can't create more than one 'main' type window!")
|
||||
return None
|
||||
|
||||
if base.data["sight_mode"] == "single":
|
||||
if len(id) == 0:
|
||||
print("No ID was given! In single mode need declare an ID to the Sight in advance!")
|
||||
return None
|
||||
if self.checkKey(id):
|
||||
print("This ['"+type+"'-'"+str(id)+"'] already exist!")
|
||||
return None
|
||||
if base.data["sight_mode"] == "multiple":
|
||||
if len(id) == 0:
|
||||
id = self.createUniqueId()
|
||||
if len(id) > 0 and self.checkKey(id) and str(id) != "main":
|
||||
id = self.createUniqueId()
|
||||
|
||||
self.list[id] = Sight(id,type)
|
||||
print("The ['"+type+"'-'"+str(id)+"'] is created now!")
|
||||
return id
|
||||
|
||||
def show(self, id):
|
||||
if self.checkKey(id):
|
||||
self.list[id].show()
|
||||
print("The '"+str(id)+"' sight is showed!")
|
||||
return True
|
||||
print("This '"+str(id)+"' id isn't exist to show!")
|
||||
return False
|
||||
|
||||
def get(self, id):
|
||||
if self.checkKey(id):
|
||||
return self.list[id]
|
||||
print("This '"+str(id)+"' id isn't exist to get!")
|
||||
|
||||
def close(self, id):
|
||||
if self.checkKey(id):
|
||||
if id == "main":
|
||||
print("Program Exit!")
|
||||
base.app.exit(0)
|
||||
self.list[id].close()
|
||||
self.list[id].deleteLater()
|
||||
del self.list[id]
|
||||
print("The '"+str(id)+"' is closed now!")
|
||||
return True
|
||||
else:
|
||||
print("The '"+str(id)+"' isn't exist'")
|
||||
return False
|
||||
|
||||
def processes(self):
|
||||
print(self.list)
|
||||
|
||||
def checkKey(self, id):
|
||||
if id in self.list:
|
||||
return True
|
||||
return False
|
||||
def addGlobalData(self, key, value):
|
||||
self.data[key] = value
|
||||
def getGlobalData(self, key):
|
||||
if key in self.data:
|
||||
return self.data[key]
|
||||
return None
|
||||
|
||||
def createUniqueId(self):
|
||||
new_id = str(random.randint(1000, 9999))
|
||||
if self.checkKey(new_id):
|
||||
self.createUniqueId()
|
||||
return new_id
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
import base
|
||||
import random
|
||||
from sight import Sight
|
||||
|
||||
class SightFactory():
|
||||
def __init__(self):
|
||||
self.list = {}
|
||||
self.data = {} #Global data(s) for the sight(s)
|
||||
|
||||
def create(self, id, type):
|
||||
print("----- "+type+"-"+str(id)+"-------")
|
||||
|
||||
if str(id) == "main" and self.checkKey(id):
|
||||
print("The 'main' window already exist! You can't create more than one 'main' type window!")
|
||||
return None
|
||||
|
||||
if base.data["sight_mode"] == "single":
|
||||
if len(id) == 0:
|
||||
print("No ID was given! In single mode need declare an ID to the Sight in advance!")
|
||||
return None
|
||||
if self.checkKey(id):
|
||||
print("This ['"+type+"'-'"+str(id)+"'] already exist!")
|
||||
return None
|
||||
if base.data["sight_mode"] == "multiple":
|
||||
if len(id) == 0:
|
||||
id = self.createUniqueId()
|
||||
if len(id) > 0 and self.checkKey(id) and str(id) != "main":
|
||||
id = self.createUniqueId()
|
||||
|
||||
self.list[id] = Sight(id,type)
|
||||
print("The ['"+type+"'-'"+str(id)+"'] is created now!")
|
||||
return id
|
||||
|
||||
def show(self, id):
|
||||
if self.checkKey(id):
|
||||
self.list[id].show()
|
||||
print("The '"+str(id)+"' sight is showed!")
|
||||
return True
|
||||
print("This '"+str(id)+"' id isn't exist to show!")
|
||||
return False
|
||||
|
||||
def get(self, id):
|
||||
if self.checkKey(id):
|
||||
return self.list[id]
|
||||
print("This '"+str(id)+"' id isn't exist to get!")
|
||||
|
||||
def close(self, id):
|
||||
if self.checkKey(id):
|
||||
if id == "main":
|
||||
print("Program Exit!")
|
||||
base.app.exit(0)
|
||||
self.list[id].close()
|
||||
self.list[id].destroy()
|
||||
del self.list[id]
|
||||
print("The '"+str(id)+"' is closed now!")
|
||||
return True
|
||||
else:
|
||||
print("The '"+str(id)+"' isn't exist'")
|
||||
return False
|
||||
|
||||
def processes(self):
|
||||
print(self.list)
|
||||
|
||||
def checkKey(self, id):
|
||||
if id in self.list:
|
||||
return True
|
||||
return False
|
||||
def addGlobalData(self, key, value):
|
||||
self.data[key] = value
|
||||
def getGlobalData(self, key):
|
||||
if key in self.data:
|
||||
return self.data[key]
|
||||
return None
|
||||
|
||||
def createUniqueId(self):
|
||||
new_id = str(random.randint(1000, 9999))
|
||||
if self.checkKey(new_id):
|
||||
self.createUniqueId()
|
||||
return new_id
|
||||