diff --git a/base.py.bak b/base.py.bak deleted file mode 100644 index 1b5a350..0000000 --- a/base.py.bak +++ /dev/null @@ -1,47 +0,0 @@ -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() \ No newline at end of file diff --git a/browser.py.bak b/browser.py.bak deleted file mode 100644 index 519aadf..0000000 --- a/browser.py.bak +++ /dev/null @@ -1,19 +0,0 @@ -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")) \ No newline at end of file diff --git a/callhandler.py.bak b/callhandler.py.bak deleted file mode 100644 index 794d4fe..0000000 --- a/callhandler.py.bak +++ /dev/null @@ -1,100 +0,0 @@ -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) \ No newline at end of file diff --git a/main.py.bak b/main.py.bak deleted file mode 100644 index 57d869c..0000000 --- a/main.py.bak +++ /dev/null @@ -1,9 +0,0 @@ -import base -base.init() -""" -base.sights.create("main"); -base.sights.processes(); -base.sights.show("main"); - -base.app.exec() -""" \ No newline at end of file diff --git a/mouseevents.py.bak b/mouseevents.py.bak deleted file mode 100644 index 379f7b1..0000000 --- a/mouseevents.py.bak +++ /dev/null @@ -1,39 +0,0 @@ -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))) \ No newline at end of file diff --git a/settings.py.bak b/settings.py.bak deleted file mode 100644 index 91b3cc2..0000000 --- a/settings.py.bak +++ /dev/null @@ -1,4 +0,0 @@ - -def init(): - global data - data = [] \ No newline at end of file diff --git a/sight.py.bak b/sight.py.bak deleted file mode 100644 index 7b11e5b..0000000 --- a/sight.py.bak +++ /dev/null @@ -1,47 +0,0 @@ -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 - \ No newline at end of file diff --git a/sightfactory.py.bak b/sightfactory.py.bak deleted file mode 100644 index d9823f5..0000000 --- a/sightfactory.py.bak +++ /dev/null @@ -1,79 +0,0 @@ -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 \ No newline at end of file