It's now fullscreen. It looks like nothing changed, that's the point

This commit is contained in:
N0\A
2025-11-08 11:22:35 +01:00
parent aa2c23537c
commit c4b90aaba6
2 changed files with 56 additions and 22 deletions

View File

@@ -69,13 +69,6 @@ def main():
dukto_handler.initialize() dukto_handler.initialize()
dukto_handler.say_hello() dukto_handler.say_hello()
# bottom right corner
screen_geometry = app.primaryScreen().availableGeometry()
pet_geometry = pet.frameGeometry()
x = screen_geometry.width() - pet_geometry.width()
y = screen_geometry.height() - pet_geometry.height()
pet.move(x, y)
pet.show() pet.show()
app.aboutToQuit.connect(presence.end) app.aboutToQuit.connect(presence.end)

View File

@@ -59,17 +59,18 @@ class MainWindow(QtWidgets.QMainWindow):
self.setWindowFlags(flags) self.setWindowFlags(flags)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground) #type: ignore self.setAttribute(QtCore.Qt.WA_TranslucentBackground) #type: ignore
pix = QtGui.QPixmap(str(ASSET))
# Load the image
pix = QtGui.QPixmap(str(ASSET))
self.image_size = pix.size()
# Create a label for the image
self.label = QtWidgets.QLabel(self) self.label = QtWidgets.QLabel(self)
self.label.setPixmap(pix) self.label.setPixmap(pix)
self.label.resize(pix.size()) self.label.resize(pix.size())
self.resize(pix.size())
img = pix.toImage() # Install event filter on the image to handle clicks
mask_img = img.createAlphaMask() self.label.installEventFilter(self)
mask = QtGui.QBitmap.fromImage(mask_img)
self.setMask(mask)
self.dukto_handler = dukto_handler self.dukto_handler = dukto_handler
self.progress_dialog = None self.progress_dialog = None
@@ -119,6 +120,41 @@ class MainWindow(QtWidgets.QMainWindow):
if config.get("hotkey") != None and config.get("hotkey") != "none" and config.get("hotkey") != "": if config.get("hotkey") != None and config.get("hotkey") != "none" and config.get("hotkey") != "":
self.start_hotkey_listener() self.start_hotkey_listener()
def showEvent(self, event):
super().showEvent(event)
screen = QtWidgets.QApplication.primaryScreen()
screen_geometry = screen.availableGeometry()
self.setGeometry(screen_geometry)
# Position the image bottom right
label_x = screen_geometry.width() - self.image_size.width()
label_y = screen_geometry.height() - self.image_size.height()
self.label.move(label_x, label_y)
# Create a mask for the window based on the image position
self.update_mask()
self.raise_()
def update_mask(self):
# Create a mask that only includes the image area
mask = QtGui.QRegion(0, 0, 0, 0) # Empty (duh, it says 0)
# Add the image region
image_rect = self.label.geometry()
pixmap = self.label.pixmap()
if pixmap and not pixmap.isNull():
img = pixmap.toImage()
alpha_mask = img.createAlphaMask()
bitmap_mask = QtGui.QBitmap.fromImage(alpha_mask)
image_region = QtGui.QRegion(bitmap_mask)
image_region.translate(image_rect.x(), image_rect.y())
mask = mask.united(image_region)
self.setMask(mask)
def build_menus(self): def build_menus(self):
s = self.strings["main_window"]["right_menu"] s = self.strings["main_window"]["right_menu"]
@@ -252,15 +288,20 @@ class MainWindow(QtWidgets.QMainWindow):
if self.isVisible() and not self.left_menu.isVisible() and not self.tray.contextMenu().isVisible(): if self.isVisible() and not self.left_menu.isVisible() and not self.tray.contextMenu().isVisible():
self.raise_() self.raise_()
def showEvent(self, event): def eventFilter(self, obj, event): #type: ignore
super().showEvent(event) # Handle mouse events on the image
self.raise_() if obj == self.label:
if event.type() == QtCore.QEvent.MouseButtonPress: #type: ignore
if event.button() == QtCore.Qt.LeftButton: #type: ignore
self.left_menu.popup(event.globalPosition().toPoint())
return True
elif event.button() == QtCore.Qt.RightButton: #type: ignore
self.tray.contextMenu().popup(event.globalPosition().toPoint())
return True
return super().eventFilter(obj, event)
def mousePressEvent(self, event: QtGui.QMouseEvent): def mousePressEvent(self, event: QtGui.QMouseEvent):
if event.button() == QtCore.Qt.LeftButton: #type: ignore pass
self.left_menu.popup(event.globalPosition().toPoint())
elif event.button() == QtCore.Qt.RightButton: #type: ignore
self.tray.contextMenu().popup(event.globalPosition().toPoint())
def handle_tray_activated(self, reason): def handle_tray_activated(self, reason):
if reason == QtWidgets.QSystemTrayIcon.ActivationReason.Trigger: if reason == QtWidgets.QSystemTrayIcon.ActivationReason.Trigger: