/
Flipper
/
Marginal
Обзор
Документация
Войти
/
Flipper
/
Marginal
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
1
CI/CD
Аналитика
Безопасность
master
src/UI/LockedAppDialog.py
95 строк
3 KB
Alex
Marginal v1.0.0 RELEASE
11 янв 2026, 18:02
11 янв 2026, 18:02
5e1eff8
Код
Авторство
О чём код?
from PySide6.QtWidgets import ( QDialog, QVBoxLayout, QHBoxLayout, QLabel, QPushButton ) from PySide6.QtCore import Qt import compiled_resources from PySide6.QtGui import QIcon class LockedAppDialog(QDialog): """ Dialog displayed when another instance of the application is already running. Informs the user that the application is locked and provides a close option. """ def __init__(self, translator): """ Initialize LockedAppDialog with translator for internationalization. Args: translator (AppTranslator): Application translator instance. """ super().__init__() self.translate = translator.translate self.setupUi() def setupUi(self): """ Set up dialog UI components, layout, and styling. Returns: None """ # Window settings self.setWindowTitle("Marginal - locked") self.setFixedSize(450, 200) self.setModal(True) # Blocks interaction with other windows self.setWindowIcon(QIcon(":/resources/sprites/Icon_lock_small.png")) # Create layout hierarchy mainLayout = QVBoxLayout() contentLayout = QVBoxLayout() # For header and message buttonLayout = QHBoxLayout() # For close button # Header label (application already running warning) headerLabel = QLabel(self.translate("App is already running")) headerLabel.setAlignment(Qt.AlignLeft) headerLabel.setStyleSheet( "margin: 10px 0px 5px 15px; " "font-size: 20px; " "font-weight: bold;" ) # Informational message with troubleshooting hint messageText = QLabel( f"{self.translate('It appears that another instance of the application is already running.')}\n" f"{self.translate('If you believe this message is incorrect, please try restarting your system.')}" ) messageText.setWordWrap(True) messageText.setAlignment(Qt.AlignLeft) messageText.setStyleSheet( "margin: 0px 15px 15px 15px; " "line-height: 1.4;" # Improves text readability ) # Close button to dismiss the dialog closeButton = QPushButton(self.translate("Close")) closeButton.setFixedSize(90, 32) closeButton.clicked.connect(self.closeApplication) # Arrange layouts contentLayout.addWidget(headerLabel) contentLayout.addWidget(messageText) contentLayout.addStretch() # Push content to top buttonLayout.addStretch() # Push button to right buttonLayout.addWidget(closeButton) mainLayout.addLayout(contentLayout) mainLayout.addLayout(buttonLayout) mainLayout.setContentsMargins(10, 10, 10, 10) # Window margin self.setLayout(mainLayout) def closeApplication(self): """ Close the dialog window. Returns: None """ self.close()