forked from Boria138/PortProtonQt
system_overlay now borderless thanks to @Vector_null
This commit is contained in:
@ -19,14 +19,16 @@ class SystemOverlay(QDialog):
|
|||||||
self.setModal(True)
|
self.setModal(True)
|
||||||
self.setFixedSize(400, 300)
|
self.setFixedSize(400, 300)
|
||||||
self.theme_manager = ThemeManager()
|
self.theme_manager = ThemeManager()
|
||||||
# self.setWindowFlags(Qt.FramelessWindowHint)
|
self.setStyleSheet(self.theme.OVERLAY_WINDOW_STYLE)
|
||||||
|
|
||||||
|
# Убираем рамку окна
|
||||||
|
self.setWindowFlags(Qt.WindowType.FramelessWindowHint | Qt.WindowType.Dialog)
|
||||||
|
|
||||||
layout = QVBoxLayout(self)
|
layout = QVBoxLayout(self)
|
||||||
layout.setContentsMargins(20, 20, 20, 20)
|
layout.setContentsMargins(20, 20, 20, 20)
|
||||||
layout.setSpacing(10)
|
layout.setSpacing(10)
|
||||||
|
|
||||||
# Reboot button
|
# Reboot button
|
||||||
# reboot_button = QPushButton(_("Reboot"))
|
|
||||||
reboot_button = AutoSizeButton(
|
reboot_button = AutoSizeButton(
|
||||||
_("Reboot"),
|
_("Reboot"),
|
||||||
icon=self.theme_manager.get_icon("reboot")
|
icon=self.theme_manager.get_icon("reboot")
|
||||||
@ -37,7 +39,6 @@ class SystemOverlay(QDialog):
|
|||||||
layout.addWidget(reboot_button)
|
layout.addWidget(reboot_button)
|
||||||
|
|
||||||
# Shutdown button
|
# Shutdown button
|
||||||
# shutdown_button = QPushButton(_("Shutdown"))
|
|
||||||
shutdown_button = AutoSizeButton(
|
shutdown_button = AutoSizeButton(
|
||||||
_("Shutdown"),
|
_("Shutdown"),
|
||||||
icon=self.theme_manager.get_icon("shutdown")
|
icon=self.theme_manager.get_icon("shutdown")
|
||||||
@ -48,7 +49,6 @@ class SystemOverlay(QDialog):
|
|||||||
layout.addWidget(shutdown_button)
|
layout.addWidget(shutdown_button)
|
||||||
|
|
||||||
# Suspend button
|
# Suspend button
|
||||||
# suspend_button = QPushButton(_("Suspend"))
|
|
||||||
suspend_button = AutoSizeButton(
|
suspend_button = AutoSizeButton(
|
||||||
_("Suspend"),
|
_("Suspend"),
|
||||||
icon=self.theme_manager.get_icon("suspend")
|
icon=self.theme_manager.get_icon("suspend")
|
||||||
@ -59,7 +59,6 @@ class SystemOverlay(QDialog):
|
|||||||
layout.addWidget(suspend_button)
|
layout.addWidget(suspend_button)
|
||||||
|
|
||||||
# Exit application button
|
# Exit application button
|
||||||
# exit_button = QPushButton(_("Exit Application"))
|
|
||||||
exit_button = AutoSizeButton(
|
exit_button = AutoSizeButton(
|
||||||
_("Exit Application"),
|
_("Exit Application"),
|
||||||
icon=self.theme_manager.get_icon("exit")
|
icon=self.theme_manager.get_icon("exit")
|
||||||
@ -70,7 +69,6 @@ class SystemOverlay(QDialog):
|
|||||||
layout.addWidget(exit_button)
|
layout.addWidget(exit_button)
|
||||||
|
|
||||||
# Return to Desktop button
|
# Return to Desktop button
|
||||||
# desktop_button = QPushButton(_("Return to Desktop"))
|
|
||||||
desktop_button = AutoSizeButton(
|
desktop_button = AutoSizeButton(
|
||||||
_("Return to Desktop"),
|
_("Return to Desktop"),
|
||||||
icon=self.theme_manager.get_icon("desktop")
|
icon=self.theme_manager.get_icon("desktop")
|
||||||
@ -86,7 +84,6 @@ class SystemOverlay(QDialog):
|
|||||||
layout.addWidget(desktop_button)
|
layout.addWidget(desktop_button)
|
||||||
|
|
||||||
# Cancel button
|
# Cancel button
|
||||||
# cancel_button = QPushButton(_("Cancel"))
|
|
||||||
cancel_button = AutoSizeButton(
|
cancel_button = AutoSizeButton(
|
||||||
_("Cancel"),
|
_("Cancel"),
|
||||||
icon=self.theme_manager.get_icon("cancel")
|
icon=self.theme_manager.get_icon("cancel")
|
||||||
@ -96,8 +93,20 @@ class SystemOverlay(QDialog):
|
|||||||
cancel_button.clicked.connect(self.reject)
|
cancel_button.clicked.connect(self.reject)
|
||||||
layout.addWidget(cancel_button)
|
layout.addWidget(cancel_button)
|
||||||
|
|
||||||
# Set focus to the first button
|
def showEvent(self, event):
|
||||||
reboot_button.setFocus()
|
"""Переопределяем showEvent для центрирования окна и установки фокуса"""
|
||||||
|
super().showEvent(event)
|
||||||
|
|
||||||
|
# Центрируем окно относительно родителя или экрана
|
||||||
|
if self.parent():
|
||||||
|
self.move(self.parent().geometry().center() - self.rect().center())
|
||||||
|
else:
|
||||||
|
screen_geometry = QApplication.primaryScreen().availableGeometry()
|
||||||
|
self.move(screen_geometry.center() - self.rect().center())
|
||||||
|
|
||||||
|
# Устанавливаем фокус на первый элемент
|
||||||
|
self.setFocus()
|
||||||
|
self.findChild(QPushButton).setFocus()
|
||||||
|
|
||||||
def reboot(self):
|
def reboot(self):
|
||||||
try:
|
try:
|
||||||
|
@ -248,7 +248,8 @@ ACTION_BUTTON_STYLE = """
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# СТИЛЬ КНОПОК ОВЕРЛЕЯ
|
# СТИЛЬ ОВЕРЛЕЯ
|
||||||
|
OVERLAY_WINDOW_STYLE = "background: #282a33;"
|
||||||
OVERLAY_BUTTON_STYLE = """
|
OVERLAY_BUTTON_STYLE = """
|
||||||
QPushButton {
|
QPushButton {
|
||||||
background: #3f424d;
|
background: #3f424d;
|
||||||
|
Reference in New Issue
Block a user