Skip to content

Commit

Permalink
qt: Save sizes of the splitters
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonKagstrom committed Jul 6, 2024
1 parent 2ee9a8c commit 161a4fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
22 changes: 21 additions & 1 deletion qt/emilpro/mainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -727,13 +727,26 @@ MainWindow::RestoreSettings()
QSettings settings("ska", "emilpro");

settings.beginGroup("MainWindow");

if (const auto geometry = settings.value("geometry", QByteArray()).toByteArray();
!geometry.isEmpty())
{
restoreGeometry(geometry);
}
settings.endGroup();

settings.beginGroup("Splitters");
if (const auto state =
settings.value("symbol_instruction_splitter_size", QByteArray()).toByteArray();
!state.isEmpty())
{
m_ui->symbolInstructionSplitter->restoreState(state);
}
if (const auto state =
settings.value("instruction_source_splitter_size", QByteArray()).toByteArray();
!state.isEmpty())
{
m_ui->instructionSourceSplitter->restoreState(state);
}
settings.endGroup();
}

Expand All @@ -745,6 +758,13 @@ MainWindow::SaveSettings()
settings.beginGroup("MainWindow");
settings.setValue("geometry", saveGeometry());
settings.endGroup();

settings.beginGroup("Splitters");
settings.setValue("symbol_instruction_splitter_size",
m_ui->symbolInstructionSplitter->saveState());
settings.setValue("instruction_source_splitter_size",
m_ui->instructionSourceSplitter->saveState());
settings.endGroup();
}

void
Expand Down
4 changes: 2 additions & 2 deletions qt/emilpro/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QSplitter" name="splitter">
<widget class="QSplitter" name="symbolInstructionSplitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -401,7 +401,7 @@
</layout>
</widget>
</widget>
<widget class="QSplitter" name="splitter_2">
<widget class="QSplitter" name="instructionSourceSplitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand Down

0 comments on commit 161a4fa

Please sign in to comment.