Skip to content

Commit

Permalink
refactor(power_menu): remove hardcoded path from apply_stylesheet m…
Browse files Browse the repository at this point in the history
…ethod, use `get_stylesheet` instead.
  • Loading branch information
amnweb committed Oct 21, 2024
1 parent 822b3f4 commit 4f22992
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/core/widgets/yasb/power_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
from core.utils.win32.blurWindow import Blur
from core.widgets.base import BaseWidget
from core.validation.widgets.yasb.power_menu import VALIDATION_SCHEMA
from core.config import get_stylesheet_path
from core.config import get_stylesheet
from core.utils.win32.power import PowerOperations
import datetime
import psutil

class BaseStyledWidget(QWidget):
def apply_stylesheet(self, path):
with open(path, "r") as f:
stylesheet = f.read()
self.setStyleSheet(stylesheet)
def apply_stylesheet(self):
stylesheet = get_stylesheet()
self.setStyleSheet(stylesheet)

class ClickableLabel(QLabel):
clicked = pyqtSignal()
Expand Down Expand Up @@ -55,7 +54,7 @@ def __init__(self, animation_duration,uptime):
self.setWindowFlags(Qt.WindowType.FramelessWindowHint | Qt.WindowType.WindowStaysOnTopHint | Qt.WindowType.Tool)
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
if uptime:
self.boot_time(get_stylesheet_path())
self.boot_time()


def update_geometry(self, screen_geometry):
Expand All @@ -68,7 +67,7 @@ def paintEvent(self, event):
overlay_color = QtGui.QColor(0, 0, 0, 50)
painter.fillRect(self.rect(), overlay_color)

def boot_time(self, stylesheet_path):
def boot_time(self):
self.label_boot = QLabel(self)
self.label_boot.setProperty("class", "uptime")
self.label_boot.setAlignment(Qt.AlignmentFlag.AlignCenter)
Expand All @@ -79,7 +78,7 @@ def boot_time(self, stylesheet_path):
layout.addWidget(self.label_boot)
self.setLayout(layout)
# Apply the stylesheet here
self.apply_stylesheet(stylesheet_path)
self.apply_stylesheet()
# Start timer for live updates
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.update_uptime_display)
Expand Down Expand Up @@ -205,7 +204,7 @@ def __init__(self, parent_button, uptime,blur, blur_background, animation_durati
main_layout.addLayout(button_layout3)
main_layout.addLayout(button_layout4)
self.setLayout(main_layout)
self.apply_stylesheet(get_stylesheet_path())
self.apply_stylesheet()
self.adjustSize()
self.center_on_screen()

Expand Down

0 comments on commit 4f22992

Please sign in to comment.