Skip to content

Commit 534016f

Browse files
author
Ravbug
committed
use wxConfig to save sort order (#38)
1 parent 332b231 commit 534016f

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

source/interface_derived.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <fstream>
1212
#include <wx/dirdlg.h>
1313
#include <wx/aboutdlg.h>
14+
#include <wx/config.h>
1415

1516
#include <format>
1617

@@ -26,6 +27,10 @@ using namespace std::filesystem;
2627
//the web view unloads after 5 minutes of page hidden
2728
const int TIMER_LENGTH = 5 * 1000 * 60;
2829

30+
constexpr std::string_view config_name = "com.ravbug.unityhubnative.config";
31+
constexpr std::string_view config_sortCol = "sortColIndex";
32+
constexpr std::string_view config_sortAscending = "sortAscending";
33+
2934
//Declare events here
3035
wxBEGIN_EVENT_TABLE(MainFrameDerived, wxFrame)
3136
EVT_MENU(wxID_ABOUT, MainFrameDerived::OnAbout)
@@ -69,6 +74,12 @@ wxEND_EVENT_TABLE()
6974

7075
//call superclass constructor
7176
MainFrameDerived::MainFrameDerived() : MainFrame(NULL){
77+
78+
// load prefs
79+
wxConfig config(config_name.data());
80+
sortColumn = config.ReadLong(config_sortCol.data(), 0);
81+
sortAscending = config.ReadBool(config_sortAscending.data(), false);
82+
7283
//set up project list columns
7384
{
7485
string cols[] = {"Project Name","Unity Version","Last Modified","Path"};
@@ -147,6 +158,11 @@ void MainFrameDerived::OnSelectEditorPath(wxCommandEvent&){
147158
}
148159
}
149160

161+
void MainFrameDerived::OnQuit(wxCommandEvent&)
162+
{
163+
Close();
164+
}
165+
150166
/**
151167
Loads the data in the main view. If anything is currently loaded, it will be cleared and re-loaded
152168
*/
@@ -466,6 +482,13 @@ void MainFrameDerived::OpenProject(const project& p, const editor& e, TargetPlat
466482
launch_process(cmd);
467483
}
468484

485+
MainFrameDerived::~MainFrameDerived()
486+
{
487+
wxConfig config(config_name.data());
488+
config.Write(config_sortCol.data(), sortColumn);
489+
config.Write(config_sortAscending.data(), sortAscending);
490+
}
491+
469492
/** Brings up a folder selection dialog with a prompt
470493
* @param message the prompt for the user
471494
* @return path selected, or an empty string if nothing chosen

source/interface_derived.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class MainFrameDerived : public MainFrame{
3636
public:
3737
//constructor (takes no args)
3838
MainFrameDerived();
39-
39+
virtual ~MainFrameDerived();
4040
static std::string GetPathFromDialog(const std::string& message);
4141

4242
private:
@@ -60,9 +60,7 @@ class MainFrameDerived : public MainFrame{
6060
void OnSelectEditor(wxCommandEvent&);
6161
void OnSelectEditorPath(wxCommandEvent&);
6262

63-
void OnQuit(wxCommandEvent&) {
64-
Close();
65-
}
63+
void OnQuit(wxCommandEvent&);
6664

6765
wxWindow* const projectActionItems[3]{
6866
revealProjBtn,

0 commit comments

Comments
 (0)