fix: properly load table header state

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2022-10-01 23:44:32 +02:00
parent 5189d29810
commit e91564d424
No known key found for this signature in database
GPG Key ID: C10411294912A422

View File

@ -77,7 +77,6 @@ void InstanceView::createTable()
m_table->verticalHeader()->hide();
QHeaderView* header = m_table->horizontalHeader();
header->restoreState(QByteArray::fromBase64(APPLICATION->settings()->get("InstanceViewTableHeaderState").toByteArray()));
header->setSectionsMovable(true);
header->setSectionResizeMode(InstanceList::NameColumn, QHeaderView::Stretch);
@ -86,12 +85,14 @@ void InstanceView::createTable()
header->setSectionResizeMode(InstanceList::LastPlayedColumn, QHeaderView::Interactive);
m_table->verticalHeader()->setDefaultSectionSize(m_rowHeight + 1 + 1); // padding top and bottom
m_table->setColumnWidth(InstanceList::GameVersionColumn, 96 + 3 + 3);
m_table->setColumnWidth(InstanceList::PlayTimeColumn, 96 + 3 + 3);
m_table->setColumnWidth(InstanceList::LastPlayedColumn, 128 + 3 + 3);
if (!APPLICATION->settings()->contains("InstanceViewTableHeaderState"))
if (!APPLICATION->settings()->contains("InstanceViewTableHeaderState")) {
m_table->setColumnWidth(InstanceList::GameVersionColumn, 96 + 3 + 3);
m_table->setColumnWidth(InstanceList::PlayTimeColumn, 96 + 3 + 3);
m_table->setColumnWidth(InstanceList::LastPlayedColumn, 128 + 3 + 3);
m_table->sortByColumn(InstanceList::LastPlayedColumn, Qt::DescendingOrder);
} else {
header->restoreState(QByteArray::fromBase64(APPLICATION->settings()->get("InstanceViewTableHeaderState").toByteArray()));
}
connect(m_table, &QAbstractItemView::doubleClicked, this, &InstanceView::activateInstance);
connect(m_table->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &InstanceView::currentRowChanged);