fix: resolve Pyright type errors in SystemOverlay class
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
This commit is contained in:
@ -1,6 +1,5 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
from PySide6.QtWidgets import QDialog, QVBoxLayout, QPushButton, QMessageBox
|
from PySide6.QtWidgets import QDialog, QVBoxLayout, QPushButton, QMessageBox, QApplication, QWidget
|
||||||
from PySide6.QtWidgets import QApplication
|
|
||||||
from PySide6.QtCore import Qt
|
from PySide6.QtCore import Qt
|
||||||
from portprotonqt.logger import get_logger
|
from portprotonqt.logger import get_logger
|
||||||
import os
|
import os
|
||||||
@ -94,19 +93,21 @@ class SystemOverlay(QDialog):
|
|||||||
layout.addWidget(cancel_button)
|
layout.addWidget(cancel_button)
|
||||||
|
|
||||||
def showEvent(self, event):
|
def showEvent(self, event):
|
||||||
"""Переопределяем showEvent для центрирования окна и установки фокуса"""
|
"""Override showEvent to center window and set focus."""
|
||||||
super().showEvent(event)
|
super().showEvent(event)
|
||||||
|
|
||||||
# Центрируем окно относительно родителя или экрана
|
# Center window relative to parent or screen
|
||||||
if self.parent():
|
parent = self.parent()
|
||||||
self.move(self.parent().geometry().center() - self.rect().center())
|
if isinstance(parent, QWidget) and parent.isVisible():
|
||||||
|
self.move(parent.geometry().center() - self.rect().center())
|
||||||
else:
|
else:
|
||||||
screen_geometry = QApplication.primaryScreen().availableGeometry()
|
screen_geometry = QApplication.primaryScreen().availableGeometry()
|
||||||
self.move(screen_geometry.center() - self.rect().center())
|
self.move(screen_geometry.center() - self.rect().center())
|
||||||
|
|
||||||
# Устанавливаем фокус на первый элемент
|
# Set focus on first button
|
||||||
self.setFocus()
|
button = self.findChild(QPushButton)
|
||||||
self.findChild(QPushButton).setFocus()
|
if button is not None:
|
||||||
|
button.setFocus()
|
||||||
|
|
||||||
def reboot(self):
|
def reboot(self):
|
||||||
try:
|
try:
|
||||||
|
Reference in New Issue
Block a user