fix: restore the main window geometry across sessions
Core regression / Python core, intervention UI and release configuration (push) Successful in 5m28s
Core regression / JavaScript syntax (push) Successful in 6s
Core regression / Python core, intervention UI and release configuration (pull_request) Successful in 5m27s
Core regression / JavaScript syntax (pull_request) Successful in 9s
Core regression / Python core, intervention UI and release configuration (push) Successful in 5m28s
Core regression / JavaScript syntax (push) Successful in 6s
Core regression / Python core, intervention UI and release configuration (pull_request) Successful in 5m27s
Core regression / JavaScript syntax (pull_request) Successful in 9s
This commit is contained in:
1 parent
46deb9cec8
commit
650dfd5491
3 files changed
+142
-1
No files matched your search
@@ -4,7 +4,7 @@ from threading import Event
|
||||
from ..stop_control import StopControl
|
||||
from shiboken6 import isValid
|
||||
import time
|
||||
from PySide6.QtCore import QElapsedTimer, QSettings, QSignalBlocker, QThreadPool, QTimer, Qt
|
||||
from PySide6.QtCore import QByteArray, QElapsedTimer, QRect, QSettings, QSignalBlocker, QThreadPool, QTimer, Qt
|
||||
from PySide6.QtGui import QAction, QActionGroup
|
||||
from PySide6.QtWidgets import (QApplication, QCheckBox, QDialog, QFileDialog, QHBoxLayout, QMessageBox,
|
||||
QPushButton, QLabel, QSizePolicy, QSplitter, QStackedWidget, QTabWidget, QToolButton, QVBoxLayout, QWidget)
|
||||
@@ -184,6 +184,7 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
self.archive_on_close_check.setToolTip('默认关闭。仅归档安全任务,保留计划、日志和文件;待核验或资源未释放的任务保留在当前列表。')
|
||||
self._build_layout()
|
||||
self._layout_settings = QSettings(str(service.layout_settings_path), QSettings.Format.IniFormat)
|
||||
self._restore_window_geometry()
|
||||
self.auto_intervention_check.setChecked(self._layout_settings.value(
|
||||
'dsh/auto_intervention', True, type=bool))
|
||||
self.auto_intervention_check.toggled.connect(self._set_auto_intervention)
|
||||
@@ -319,6 +320,34 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
return {'workspace': self.workspace_splitter, 'detail': self.detail_splitter,
|
||||
'rules': self.mapping_table.horizontalHeader(), 'targets': self.plan_panel.table.horizontalHeader()}
|
||||
|
||||
def _restore_window_geometry(self):
|
||||
saved = self._layout_settings.value('main_window/geometry')
|
||||
if saved is None:
|
||||
return
|
||||
default = self.geometry()
|
||||
restored = isinstance(saved, QByteArray) and self.restoreGeometry(saved)
|
||||
normal = self.normalGeometry() if restored else default
|
||||
screen = QApplication.screenAt(normal.center()) if restored else None
|
||||
screen = screen or QApplication.primaryScreen()
|
||||
if screen is None:
|
||||
return
|
||||
available = screen.availableGeometry()
|
||||
if restored and available.contains(normal) and normal.size().expandedTo(self.minimumSize()) == normal.size():
|
||||
return
|
||||
|
||||
# Qt may reject a saved geometry after a DPI change. Keep the normal
|
||||
# window reachable on the current display, even when its minimum exceeds it.
|
||||
available = available.adjusted(8, 36, -8, -8)
|
||||
state = self.windowState()
|
||||
self.setWindowState(Qt.WindowState.WindowNoState)
|
||||
size = normal.size().boundedTo(available.size()).expandedTo(self.minimumSize())
|
||||
fallback = QRect(available.topLeft(), size)
|
||||
fallback.moveCenter(available.center())
|
||||
fallback.moveLeft(max(fallback.left(), available.left()))
|
||||
fallback.moveTop(max(fallback.top(), available.top()))
|
||||
self.setGeometry(fallback)
|
||||
self.setWindowState(state)
|
||||
|
||||
def _reset_layout(self):
|
||||
self.workspace_splitter.setSizes((240, 1040))
|
||||
self.detail_splitter.setSizes((650, 110))
|
||||
@@ -416,9 +445,11 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
QTimer.singleShot(100, self.close)
|
||||
return
|
||||
self._cancel_dsh_diagnosis()
|
||||
self._layout_settings.setValue('main_window/geometry', self.saveGeometry())
|
||||
for name, widget in self._layout_widgets().items():
|
||||
self._layout_settings.setValue(f'single_project/{name}', widget.saveState())
|
||||
self._layout_settings.setValue('tasks/sort', self.task_list.sort.currentData())
|
||||
self._layout_settings.sync()
|
||||
self._closed = True
|
||||
self._dsh_status.close()
|
||||
self._dsh_stall_timer.stop()
|
||||
|
||||
Reference in new issue
Block a user