mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-03 01:04:13 +02:00
Fix dock widget size/position not being restored on Qt6
This commit is contained in:
@@ -132,8 +132,9 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
||||
connect(&m_workspace, &QMdiArea::subWindowActivated, this, &QETDiagramEditor::subWindowActivated);
|
||||
connect(QApplication::clipboard(), &QClipboard::dataChanged, this, &QETDiagramEditor::slot_updatePasteAction);
|
||||
|
||||
readSettings();
|
||||
readSettings(); // restoreGeometry before show()
|
||||
show();
|
||||
readSettingsState(); // restoreState() must be called after show() in Qt6
|
||||
|
||||
//If valid file path is given as arguments
|
||||
uint opened_projects = 0;
|
||||
@@ -2202,10 +2203,6 @@ void QETDiagramEditor::readSettings()
|
||||
QVariant geometry = settings.value("diagrameditor/geometry");
|
||||
if (geometry.isValid()) restoreGeometry(geometry.toByteArray());
|
||||
|
||||
// etat de la fenetre (barres d'outils, docks...)
|
||||
QVariant state = settings.value("diagrameditor/state");
|
||||
if (state.isValid()) restoreState(state.toByteArray());
|
||||
|
||||
// gestion des projets (onglets ou fenetres)
|
||||
bool tabbed = settings.value("diagrameditor/viewmode", "tabbed") == "tabbed";
|
||||
if (tabbed) {
|
||||
@@ -2215,6 +2212,28 @@ void QETDiagramEditor::readSettings()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETDiagramEditor::readSettingsState
|
||||
Restore the window state (docks, toolbars).
|
||||
Must be called AFTER show() in Qt6 for restoreState() to work correctly.
|
||||
*/
|
||||
void QETDiagramEditor::readSettingsState()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
// etat de la fenetre (barres d'outils, docks...)
|
||||
QVariant state = settings.value("diagrameditor/state");
|
||||
if (state.isValid()) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (!restoreState(state.toByteArray())) {
|
||||
settings.remove("diagrameditor/state");
|
||||
}
|
||||
#else
|
||||
restoreState(state.toByteArray());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETDiagramEditor::writeSettings
|
||||
Write the settings
|
||||
|
||||
Reference in New Issue
Block a user