The data-type is now data-page and everywhere where "type" was given as named by "page" in the code.
New function is available from the javascript is the window.sight.system() (return: Linux, Windows, Darwin) return back with that system type where the app runs.main
parent
976fee0004
commit
6250541e22
6
base.py
6
base.py
|
|
@ -1,5 +1,6 @@
|
|||
import sys
|
||||
import os
|
||||
import platform
|
||||
import configparser
|
||||
from mouseevents import MouseEvents
|
||||
from pynput import mouse
|
||||
|
|
@ -16,6 +17,8 @@ def init():
|
|||
data = {}
|
||||
data["move"] = False
|
||||
data["active_sight"] = "main"
|
||||
data["platform"] = {}
|
||||
data["platform"]["system"] = platform.system()
|
||||
data["sight_processes"] = {}
|
||||
data["mouse_distance_x"] = 0
|
||||
data["mouse_distance_y"] = 0
|
||||
|
|
@ -33,6 +36,7 @@ def loadConfigTemplate():
|
|||
config.read(data["template_dir"]+"config.ini")
|
||||
if "DEFAULT" in config:
|
||||
data["default_template"] = config["DEFAULT"]["default_template"]
|
||||
data["default_template_page"] = config["DEFAULT"]["default_template_page"]
|
||||
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!")
|
||||
|
|
@ -41,7 +45,7 @@ def loadConfigTemplate():
|
|||
|
||||
def start():
|
||||
# Creating the main Sight
|
||||
sights.create("main","main");
|
||||
sights.create("main", data["default_template_page"]);
|
||||
sights.processes();
|
||||
sights.show("main");
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ class Browser(QWebEngineView):
|
|||
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"))
|
||||
def loadContent(self, page):
|
||||
print(base.data["default_template_dir"]+page+".html")
|
||||
self.load(QUrl.fromLocalFile(base.data["default_template_dir"]+page+".html"))
|
||||
|
|
@ -30,9 +30,13 @@ class CallHandler(QObject):
|
|||
def setHeight(self, height):
|
||||
self.sight.resize(self.sight.width(), height);
|
||||
|
||||
@pyqtSlot(result=str)
|
||||
def system(self):
|
||||
return base.data["platform"]["system"]
|
||||
|
||||
@pyqtSlot(str, str, result=str)
|
||||
def create(self, id, type):
|
||||
new_id = base.sights.create(id, type)
|
||||
def create(self, id, page):
|
||||
new_id = base.sights.create(id, page)
|
||||
if new_id is not None:
|
||||
base.sights.show(new_id)
|
||||
""" The id will be added to its parent. When parent close will be its children closed as well """
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ if(navigator.userAgent.indexOf("QtWebEngine") > 0) {
|
|||
$.fn.s_create = function() {
|
||||
$(document).on( "click", "#screate", function(event) {
|
||||
event.preventDefault();
|
||||
window.sight.create($(this).data("id"), $(this).data("type"), function(sight_id) {
|
||||
window.sight.create($(this).data("id"), $(this).data("page"), function(sight_id) {
|
||||
|
||||
});
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
<a href="#" id="screate" data-type="other" data-id="other">Create an "Other" sight!</a>
|
||||
<a href="#" id="screate" data-page="other" data-id="other">Create an "Other" sight!</a>
|
||||
|
||||
<a href="#" id="screate" data-type="other">Create an "Other" no id sight!</a>
|
||||
<a href="#" id="screate" data-page="other">Create an "Other" no id sight!</a>
|
||||
|
|
@ -20,8 +20,9 @@
|
|||
$(document).ready(function(){
|
||||
/*addData("name", "Balazs", true);
|
||||
getData("name");*/
|
||||
|
||||
|
||||
window.sight.system(function(result) {
|
||||
alert(result)
|
||||
});
|
||||
});
|
||||
|
||||
function message(label, data) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
[DEFAULT]
|
||||
default_template = base
|
||||
default_template_page = main
|
||||
sight_mode = normal
|
||||
6
sight.py
6
sight.py
|
|
@ -5,11 +5,11 @@ from PyQt6.QtCore import Qt
|
|||
from PyQt6.QtWidgets import QMainWindow, QWidget, QVBoxLayout
|
||||
|
||||
class Sight(QWidget):
|
||||
def __init__(self, id, type):
|
||||
def __init__(self, id, page):
|
||||
super().__init__()
|
||||
|
||||
self.id = id
|
||||
self.type = type
|
||||
self.page = page
|
||||
self.data = {} # private data(s) of the sight
|
||||
self.children = []
|
||||
self.parent = None
|
||||
|
|
@ -22,7 +22,7 @@ class Sight(QWidget):
|
|||
|
||||
self.browser = Browser()
|
||||
self.browser.addObject('handler', CallHandler(self) )
|
||||
self.browser.loadContent(type)
|
||||
self.browser.loadContent(page)
|
||||
|
||||
self.layout = QVBoxLayout()
|
||||
self.layout.addWidget(self.browser)
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ class SightFactory():
|
|||
self.list = {}
|
||||
self.data = {} #Global data(s) for the sight(s)
|
||||
|
||||
def create(self, id, type):
|
||||
print("----- "+type+"-"+str(id)+"-------")
|
||||
def create(self, id, page):
|
||||
print("----- "+page+"-"+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!")
|
||||
print("The 'main' window already exist! You can't create more than one 'main' page sight!")
|
||||
return None
|
||||
|
||||
if base.data["sight_mode"] == "unique":
|
||||
|
|
@ -19,7 +19,7 @@ class SightFactory():
|
|||
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!")
|
||||
print("This ['"+page+"'-'"+str(id)+"'] already exist!")
|
||||
return None
|
||||
if base.data["sight_mode"] == "auto":
|
||||
if len(id) == 0:
|
||||
|
|
@ -28,13 +28,13 @@ class SightFactory():
|
|||
id = self.createUniqueId()
|
||||
if base.data["sight_mode"] == "normal":
|
||||
if self.checkKey(id) and len(id) != 0:
|
||||
print("This ['"+type+"'-'"+str(id)+"'] already exist!")
|
||||
print("This ['"+page+"'-'"+str(id)+"'] already exist!")
|
||||
return None
|
||||
if len(id) == 0:
|
||||
id = self.createUniqueId()
|
||||
|
||||
self.list[id] = Sight(id, type)
|
||||
print("The ['"+type+"'-'"+str(id)+"'] is created now!")
|
||||
self.list[id] = Sight(id, page)
|
||||
print("The ['"+page+"'-'"+str(id)+"'] is created now!")
|
||||
return id
|
||||
|
||||
def show(self, id):
|
||||
|
|
|
|||
Loading…
Reference in New Issue