mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Improve splitter geometry migration
This commit is contained in:
parent
ca90f71f23
commit
6c03fe6e34
@ -1,13 +1,13 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# License: GPLv3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
from copy import copy
|
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
|
from copy import copy
|
||||||
from dataclasses import asdict, dataclass, fields
|
from dataclasses import asdict, dataclass, fields
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAction, QDialog, QHBoxLayout, QIcon, QKeySequence, QLabel, QPalette, QPointF,
|
QAction, QDialog, QHBoxLayout, QIcon, QKeySequence, QLabel, QMainWindow, QPalette,
|
||||||
QSize, QSizePolicy, QStyle, QStyleOption, QStylePainter, Qt, QToolButton,
|
QPointF, QSize, QSizePolicy, QStyle, QStyleOption, QStylePainter, Qt, QToolButton,
|
||||||
QVBoxLayout, QWidget, pyqtSignal,
|
QVBoxLayout, QWidget, pyqtSignal,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -425,7 +425,16 @@ class CentralContainer(QWidget):
|
|||||||
|
|
||||||
def read_settings(self):
|
def read_settings(self):
|
||||||
before = self.serialized_settings()
|
before = self.serialized_settings()
|
||||||
|
# sadly self.size() doesnt always return sensible values so look at
|
||||||
|
# the size of the main window which works perfectly for width, not so
|
||||||
|
# perfectly for height
|
||||||
sz = self.size()
|
sz = self.size()
|
||||||
|
p = self.parent()
|
||||||
|
while p is not None and not isinstance(p, QMainWindow):
|
||||||
|
p = p.parent()
|
||||||
|
if p is not None:
|
||||||
|
psz = p.size()
|
||||||
|
sz = QSize(max(sz.width(), psz.width()), max(sz.height(), psz.height() - 50))
|
||||||
settings = gprefs.get(self.prefs_name) or migrate_settings(sz.width(), sz.height())
|
settings = gprefs.get(self.prefs_name) or migrate_settings(sz.width(), sz.height())
|
||||||
self.unserialize_settings(settings)
|
self.unserialize_settings(settings)
|
||||||
if self.serialized_settings() != before:
|
if self.serialized_settings() != before:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user