-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
45 lines (38 loc) · 1.42 KB
/
Copy pathmain.cpp
File metadata and controls
45 lines (38 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <wx/wx.h>
#include "MainFrame.h"
#include "LanguageManager.h"
#include "Languages.h"
#include <wx/intl.h>
#include <wx/config.h>
class MyApp : public wxApp {
public:
bool OnInit() override {
// Set app/vendor identity so every wxConfig::Get() call shares one
// backing store (registry key on Windows, plist on macOS).
SetVendorName("L2Reborn");
SetAppName("EasyLoginManager");
// Follow the system light/dark theme on Windows (wxWidgets 3.3+).
#if defined(__WXMSW__) && wxCHECK_VERSION(3, 3, 0)
MSWEnableDarkMode();
#endif
wxConfigBase* config = wxConfig::Get();
wxString langCode = config->Read("/Language", "");
if (langCode.IsEmpty()) {
// Fall back to the system language if we ship a matching translation.
const wxLanguageInfo* sysInfo = wxLocale::GetLanguageInfo(wxLocale::GetSystemLanguage());
if (sysInfo) {
wxString sysCode = sysInfo->CanonicalName.BeforeFirst('_');
for (const auto& lang : AvailableLanguages()) {
if (sysCode == lang.code) { langCode = lang.code; break; }
}
}
if (langCode.IsEmpty()) langCode = "en";
}
LanguageManager::Get().LoadLanguage(langCode);
auto* frame = new MainFrame();
frame->Show(true);
frame->Raise();
return true;
}
};
wxIMPLEMENT_APP(MyApp);