Qt: simplify occasions of restoreState

This commit is contained in:
Megamouse 2018-05-22 11:15:18 +02:00 committed by Ani
parent 31101b4828
commit bff9a06f9f
3 changed files with 5 additions and 31 deletions

View file

@ -243,24 +243,15 @@ trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr<gui_settings> gui_s
if (!restoreGeometry(m_gui_settings->GetValue(gui::tr_geometry).toByteArray()))
resize(QDesktopWidget().availableGeometry().size() * 0.7);
QByteArray splitterstate = m_gui_settings->GetValue(gui::tr_splitterState).toByteArray();
if (splitterstate.isEmpty())
if (!m_splitter->restoreState(m_gui_settings->GetValue(gui::tr_splitterState).toByteArray()))
{
const int width_left = m_splitter->width() * 0.4;
const int width_right = m_splitter->width() - width_left;
m_splitter->setSizes({ width_left, width_right });
}
else
{
m_splitter->restoreState(splitterstate);
}
QByteArray game_table_state = m_gui_settings->GetValue(gui::tr_games_state).toByteArray();
if (!game_table_state.isEmpty())
{
m_game_table->horizontalHeader()->restoreState(game_table_state);
}
else if (m_game_table->rowCount() > 0)
if (!m_game_table->horizontalHeader()->restoreState(game_table_state) && m_game_table->rowCount())
{
// If no settings exist, go to default.
m_game_table->verticalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents);
@ -268,11 +259,7 @@ trophy_manager_dialog::trophy_manager_dialog(std::shared_ptr<gui_settings> gui_s
}
QByteArray trophy_table_state = m_gui_settings->GetValue(gui::tr_trophy_state).toByteArray();
if (!trophy_table_state.isEmpty())
{
m_trophy_table->horizontalHeader()->restoreState(trophy_table_state);
}
else if (m_trophy_table->rowCount() > 0)
if (!m_trophy_table->horizontalHeader()->restoreState(trophy_table_state) && m_trophy_table->rowCount())
{
// If no settings exist, go to default.
m_trophy_table->verticalHeader()->resizeSections(QHeaderView::ResizeMode::ResizeToContents);