mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 09:59:41 +02:00
feat: add image opacity, config migration, settings
Add image overlay opacity support and related UI/settings, plus robust config migration and error handling. Key changes: - UI: image overlay now uses QGraphicsOpacityEffect, hides when disabled, and updates opacity on state changes (src/interface/dialogs/image.py). - New NotificationPopup dialog for user alerts (src/interface/dialogs/notificationpopup.py). - Settings dialog: added Image Opacity control, adjusted labels, persist/rollback behavior on cancel, and include opacity when saving (src/interface/dialogs/settings.py). - State: added properties for image_opacity and image_enabled with change notifications; renamed image_width setter param for clarity (src/utils/data/state.py). - Config: switch from config.yml to config.ini, implement one-time migration, typed read/write of values, validation/error handling, automatic backups of corrupted files and user notification (src/utils/config/config.py). - Settings save: accept and persist image_opacity (src/utils/config/settings.py). - Startup: initialize QApplication earlier and pass app to run_gui (src/main.py). - Minor: removed an extra blank line in log handler and small import cleanups. These changes enable adjustable overlay transparency, improve config reliability, and surface errors to users while preserving/backuping old configs.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from PySide6.QtWidgets import QLabel, QGraphicsOpacityEffect
|
||||
from PySide6.QtCore import Qt, QSize, QEvent, QObject
|
||||
from PySide6.QtGui import QImage, QPixmap
|
||||
from PySide6.QtWidgets import QLabel
|
||||
from utils.data.state import state
|
||||
import os
|
||||
|
||||
@@ -11,10 +11,12 @@ class Image(QObject):
|
||||
self.application = parent
|
||||
self.overlay_label = QLabel(parent)
|
||||
self.overlay_label.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, True)
|
||||
|
||||
self.opacity_effect = QGraphicsOpacityEffect()
|
||||
self.overlay_label.setGraphicsEffect(self.opacity_effect)
|
||||
|
||||
self._current_image_path = None
|
||||
|
||||
parent.installEventFilter(self)
|
||||
|
||||
state.image_changed.connect(self.update_image_overlay)
|
||||
|
||||
if state.image_path and os.path.exists(state.image_path):
|
||||
@@ -28,6 +30,7 @@ class Image(QObject):
|
||||
|
||||
def _load_and_display(self, image_path):
|
||||
if state.image_enabled is not True:
|
||||
self.overlay_label.hide()
|
||||
return
|
||||
self._current_image_path = image_path
|
||||
parent = self.application
|
||||
@@ -56,8 +59,12 @@ class Image(QObject):
|
||||
|
||||
x = parent.width() - self.overlay_label.width() - int(state.image_offset)
|
||||
y = parent.height() - self.overlay_label.height() - int(state.image_offset)
|
||||
|
||||
self.opacity_effect.setOpacity(state.image_opacity / 100)
|
||||
|
||||
self.overlay_label.move(x, y)
|
||||
self.overlay_label.show()
|
||||
|
||||
def update_image_overlay(self, new_image_path):
|
||||
self._load_and_display(new_image_path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user