MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / saveDocks

Method saveDocks

src/settings.cpp:985–1019  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

983}
984
985void GeometrySettings::saveDocks(const QMainWindow* mw)
986{
987 // this attempts to fix https://bugreports.qt.io/browse/QTBUG-46620 where dock
988 // sizes are not restored when the main window is maximized; it is used in
989 // MainWindow::readSettings() and MainWindow::storeSettings()
990 //
991 // there's also https://stackoverflow.com/questions/44005852, which has what
992 // seems to be a popular fix, but it breaks the restored size of the window
993 // by setting it to the desktop's resolution, so that doesn't work
994 //
995 // the only fix I could find is to remember the sizes of the docks and manually
996 // setting them back; saving is straightforward, but restoring is messy
997 //
998 // this also depends on the window being visible before the timer in restore()
999 // is fired and the timer must be processed by application.exec(); therefore,
1000 // the splash screen _must_ be closed before readSettings() is called, because
1001 // it has its own event loop, which seems to interfere with this
1002 //
1003 // all of this should become unnecessary when QTBUG-46620 is fixed
1004 //
1005
1006 // saves the size of each dock
1007 for (const auto* dock : mw->findChildren<QDockWidget*>()) {
1008 int size = 0;
1009
1010 // save the width for horizontal docks, or the height for vertical
1011 if (dockOrientation(mw, dock) == Qt::Horizontal) {
1012 size = dock->size().width();
1013 } else {
1014 size = dock->size().height();
1015 }
1016
1017 set(m_Settings, "Geometry", dockSettingName(dock), size);
1018 }
1019}
1020
1021void GeometrySettings::restoreDocks(QMainWindow* mw) const
1022{

Callers 1

storeSettingsMethod · 0.80

Calls 4

dockOrientationFunction · 0.85
dockSettingNameFunction · 0.85
setFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected