diff --git a/resources/main_window.qml b/resources/main_window.qml index a924382..48e159a 100644 --- a/resources/main_window.qml +++ b/resources/main_window.qml @@ -1,28 +1,115 @@ import QtQuick 2.15 +import QtQuick.Window 2.15 import QtQuick.Controls 2.15 ApplicationWindow { id: mainWindow visible: true - width: 600 - height: 500 - title: "HelloApp" - - Text { - anchors.horizontalCenter: parent.horizontalCenter - y: 0 - height: parent.height * 0.1 - text: "Hello World" - font.pixelSize: 24 - } + width: 800 + height: 600 + title: "StarSky Presenter" + flags: Qt.FramelessWindowHint Button { anchors.horizontalCenter: parent.horizontalCenter - width: parent.width - y: parent.height * 0.9 + width: parent.width * 0.9 + y: parent.height * 0.85 height: parent.height * 0.1 text: "Close" - onClicked: controller_backend.test_function() + onClicked: controller_backend.close_application() + } + + Text { + x: parent.width * 0.1 / 9 / 2 + y: parent.height * 0.1 / 5 / 2 + width: parent.width * 0.9 + height: parent.height * 0.1 + text: "Scene 1" + font.pixelSize: 60 + color: "white" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + Button { + x: (parent.width * 0.1 / 9) * (0 + 0.5) + (parent.width * 0.9 / 9) * 0 + y: (parent.height * 0.1 / 5) * (0 + 0.5) + (parent.height * 0.9 / 5) * 1 + width: parent.width * 0.1 + height: parent.height * 0.1 + text: "Scene 1" + onClicked: controller_backend.select_scene(1) + } + + Button { + x: (parent.width * 0.1 / 9) * (1 + 0.5) + (parent.width * 0.9 / 9) * 1 + y: (parent.height * 0.1 / 5) * (0 + 0.5) + (parent.height * 0.9 / 5) * 1 + width: parent.width * 0.1 + height: parent.height * 0.1 + text: "Scene 2" + onClicked: controller_backend.select_scene(2) + } + + Button { + x: (parent.width * 0.1 / 9) * (2 + 0.5) + (parent.width * 0.9 / 9) * 2 + y: (parent.height * 0.1 / 5) * (0 + 0.5) + (parent.height * 0.9 / 5) * 1 + width: parent.width * 0.1 + height: parent.height * 0.1 + text: "Scene 3" + onClicked: controller_backend.select_scene(3) + } + + Button { + x: (parent.width * 0.1 / 9) * (3 + 0.5) + (parent.width * 0.9 / 9) * 3 + y: (parent.height * 0.1 / 5) * (0 + 0.5) + (parent.height * 0.9 / 5) * 1 + width: parent.width * 0.1 + height: parent.height * 0.1 + text: "Scene 4" + onClicked: controller_backend.select_scene(4) + } + + Button { + x: (parent.width * 0.1 / 9) * (4 + 0.5) + (parent.width * 0.9 / 9) * 4 + y: (parent.height * 0.1 / 5) * (0 + 0.5) + (parent.height * 0.9 / 5) * 1 + width: parent.width * 0.1 + height: parent.height * 0.1 + text: "Scene 5" + onClicked: controller_backend.select_scene(5) + } + + Button { + x: (parent.width * 0.1 / 9) * (5 + 0.5) + (parent.width * 0.9 / 9) * 5 + y: (parent.height * 0.1 / 5) * (0 + 0.5) + (parent.height * 0.9 / 5) * 1 + width: parent.width * 0.1 + height: parent.height * 0.1 + text: "Scene 6" + onClicked: controller_backend.select_scene(6) + } + + Button { + x: (parent.width * 0.1 / 9) * (6 + 0.5) + (parent.width * 0.9 / 9) * 6 + y: (parent.height * 0.1 / 5) * (0 + 0.5) + (parent.height * 0.9 / 5) * 1 + width: parent.width * 0.1 + height: parent.height * 0.1 + text: "Scene 7" + onClicked: controller_backend.select_scene(7) + } + + Button { + x: (parent.width * 0.1 / 9) * (7 + 0.5) + (parent.width * 0.9 / 9) * 7 + y: (parent.height * 0.1 / 5) * (0 + 0.5) + (parent.height * 0.9 / 5) * 1 + width: parent.width * 0.1 + height: parent.height * 0.1 + text: "Scene 8" + onClicked: controller_backend.select_scene(8) + } + + Button { + x: (parent.width * 0.1 / 9) * (8 + 0.5) + (parent.width * 0.9 / 9) * 8 + y: (parent.height * 0.1 / 5) * (0 + 0.5) + (parent.height * 0.9 / 5) * 1 + width: parent.width * 0.1 + height: parent.height * 0.1 + text: "Scene 9" + onClicked: controller_backend.select_scene(9) } } \ No newline at end of file diff --git a/src/controller/controller.py b/src/controller/controller.py index af7abfa..868e497 100644 --- a/src/controller/controller.py +++ b/src/controller/controller.py @@ -1,13 +1,28 @@ from PyQt6.QtCore import QObject, pyqtSlot +from time import time class Controller(QObject): def __init__(self, window, parent=None): super().__init__(parent) self.window = window + self.last_close_press = 0 + self.successful_clicks = 0 @pyqtSlot() - def test_function(self): - print("test function") - self.window.running = False \ No newline at end of file + def close_application(self): + now = time() + if now - self.last_close_press < 0.2: + self.successful_clicks += 1 + else: + self.successful_clicks = 0 + + if self.successful_clicks > 1: + self.window.running = False + + self.last_close_press = now + + @pyqtSlot(int) + def select_scene(self, scene: int): + self.window.selected_scene = scene \ No newline at end of file diff --git a/src/main.py b/src/main.py index 87d34bd..02da1b5 100644 --- a/src/main.py +++ b/src/main.py @@ -16,6 +16,7 @@ def cli_main(): stars = [ Star(**{ + "_id": i, "x": random(), "y": random(), "alpha": random() * 360, @@ -24,7 +25,7 @@ def cli_main(): "offset": random(), "image": image }) - for _ in range(4) + for i in range(4) ] control_window = ControlWindow() diff --git a/src/projection/screen.py b/src/projection/screen.py index 11eafb4..17000c8 100644 --- a/src/projection/screen.py +++ b/src/projection/screen.py @@ -6,7 +6,8 @@ from time import time, sleep from random import random class Star: - def __init__(self, x: int, y: int, alpha: float, rot: float, scale: float, offset: float, image: pygame.Surface): + def __init__(self, _id: int, x: int, y: int, alpha: float, rot: float, scale: float, offset: float, image: pygame.Surface): + self.id = _id self.x = x self.y = y self.rot = rot @@ -19,10 +20,11 @@ class Screen: def __init__(self, stars: list[Star]) -> None: if not pygame.get_init(): pygame.init() - self.screen = pygame.display.set_mode((800, 600)) + self.screen = pygame.display.set_mode((1920, 1080)) self.clock = pygame.time.Clock() self.stars = stars self.last = time() + self.brightness = 1.0 def update(self): @@ -32,17 +34,13 @@ class Screen: self.last = now for star in self.stars: star.alpha += star.rot * delta - #rotated = transform.rotate(star.image, star.alpha) - #scaled = transform.smoothscale_by(rotated, star.scale) scaled = transform.rotozoom(star.image, star.alpha, star.scale) (w, h) = scaled.get_size() pos = (star.x*self.screen.get_width() - w/2, star.y*self.screen.get_height() - h/2) self.screen.blit(scaled, pos) - #self.screen.blit(scaled, dest=pos) - - overlay = pygame.surface.Surface((800, 600), depth=32) - overlay.set_alpha(128) + overlay = pygame.surface.Surface((1920, 1080), depth=32) + overlay.set_alpha(int(255 * (1 - self.brightness))) self.screen.blit(overlay, (0, 0)) pygame.display.flip()