From 8ca6814673ee842d4c667a6e67f1d615b6e3fd71 Mon Sep 17 00:00:00 2001 From: spycrab Date: Wed, 12 Jul 2017 18:25:54 +0200 Subject: [PATCH] Qt: Save sorting order --- Source/Core/DolphinQt2/GameList/GameList.cpp | 14 ++++++++++++++ Source/Core/DolphinQt2/GameList/GameList.h | 1 + 2 files changed, 15 insertions(+) diff --git a/Source/Core/DolphinQt2/GameList/GameList.cpp b/Source/Core/DolphinQt2/GameList/GameList.cpp index daadb38f02..a72c4a8934 100644 --- a/Source/Core/DolphinQt2/GameList/GameList.cpp +++ b/Source/Core/DolphinQt2/GameList/GameList.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "Common/FileUtil.h" @@ -86,6 +87,13 @@ void GameList::MakeTableView() m_table->setColumnHidden(GameListModel::COL_RATING, !SConfig::GetInstance().m_showStateColumn); QHeaderView* hor_header = m_table->horizontalHeader(); + + connect(hor_header, &QHeaderView::sortIndicatorChanged, this, &GameList::OnHeaderViewChanged); + connect(hor_header, &QHeaderView::sectionResized, this, &GameList::OnHeaderViewChanged); + connect(hor_header, &QHeaderView::sectionCountChanged, this, &GameList::OnHeaderViewChanged); + + hor_header->restoreState(QSettings().value(QStringLiteral("tableheader/state")).toByteArray()); + hor_header->setSectionResizeMode(GameListModel::COL_PLATFORM, QHeaderView::ResizeToContents); hor_header->setSectionResizeMode(GameListModel::COL_COUNTRY, QHeaderView::ResizeToContents); hor_header->setSectionResizeMode(GameListModel::COL_ID, QHeaderView::ResizeToContents); @@ -445,3 +453,9 @@ static bool CompressCB(const std::string& text, float percent, void* ptr) progress_dialog->setValue(percent * 100); return !progress_dialog->wasCanceled(); } + +void GameList::OnHeaderViewChanged() +{ + QSettings().setValue(QStringLiteral("tableheader/state"), + m_table->horizontalHeader()->saveState()); +} diff --git a/Source/Core/DolphinQt2/GameList/GameList.h b/Source/Core/DolphinQt2/GameList/GameList.h index da0b352358..3f0584b815 100644 --- a/Source/Core/DolphinQt2/GameList/GameList.h +++ b/Source/Core/DolphinQt2/GameList/GameList.h @@ -39,6 +39,7 @@ private slots: void UninstallWAD(); void ExportWiiSave(); void CompressISO(); + void OnHeaderViewChanged(); signals: void GameSelected();