forked from mia/Aegisub
Pull some global init logic out of FrameMain's constructor
This commit is contained in:
parent
35301df5f7
commit
2ba88537a8
3 changed files with 35 additions and 41 deletions
|
@ -49,7 +49,6 @@
|
||||||
#include "command/command.h"
|
#include "command/command.h"
|
||||||
#include "dialog_detached_video.h"
|
#include "dialog_detached_video.h"
|
||||||
#include "dialog_manager.h"
|
#include "dialog_manager.h"
|
||||||
#include "dialog_version_check.h"
|
|
||||||
#include "help_button.h"
|
#include "help_button.h"
|
||||||
#include "libresrc/libresrc.h"
|
#include "libresrc/libresrc.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
@ -191,15 +190,6 @@ FrameMain::FrameMain()
|
||||||
// However LC_NUMERIC must be "C", otherwise some parsing fails.
|
// However LC_NUMERIC must be "C", otherwise some parsing fails.
|
||||||
setlocale(LC_NUMERIC, "C");
|
setlocale(LC_NUMERIC, "C");
|
||||||
#endif
|
#endif
|
||||||
#ifdef __APPLE__
|
|
||||||
// When run from an app bundle, LC_CTYPE defaults to "C", which breaks on
|
|
||||||
// anything involving unicode and in some cases number formatting.
|
|
||||||
// The right thing to do here would be to query CoreFoundation for the user's
|
|
||||||
// locale and add .UTF-8 to that, but :effort:
|
|
||||||
LOG_D("locale") << setlocale(LC_ALL, nullptr);
|
|
||||||
setlocale(LC_CTYPE, "en_US.UTF-8");
|
|
||||||
LOG_D("locale") << setlocale(LC_ALL, nullptr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
StartupLog("Initializing context controls");
|
StartupLog("Initializing context controls");
|
||||||
context->ass->AddCommitListener(&FrameMain::UpdateTitle, this);
|
context->ass->AddCommitListener(&FrameMain::UpdateTitle, this);
|
||||||
|
@ -213,9 +203,6 @@ FrameMain::FrameMain()
|
||||||
context->parent = this;
|
context->parent = this;
|
||||||
context->frame = this;
|
context->frame = this;
|
||||||
|
|
||||||
StartupLog("Install PNG handler");
|
|
||||||
wxImage::AddHandler(new wxPNGHandler);
|
|
||||||
|
|
||||||
StartupLog("Apply saved Maximized state");
|
StartupLog("Apply saved Maximized state");
|
||||||
if (OPT_GET("App/Maximized")->GetBool()) Maximize(true);
|
if (OPT_GET("App/Maximized")->GetBool()) Maximize(true);
|
||||||
|
|
||||||
|
@ -243,6 +230,9 @@ FrameMain::FrameMain()
|
||||||
|
|
||||||
StartupLog("Set up drag/drop target");
|
StartupLog("Set up drag/drop target");
|
||||||
SetDropTarget(new AegisubFileDropTarget(this));
|
SetDropTarget(new AegisubFileDropTarget(this));
|
||||||
|
Bind(FILE_LIST_DROPPED, [=](wxThreadEvent &evt) {
|
||||||
|
LoadList(evt.GetPayload<wxArrayString>());
|
||||||
|
});
|
||||||
|
|
||||||
StartupLog("Load default file");
|
StartupLog("Load default file");
|
||||||
context->subsController->Close();
|
context->subsController->Close();
|
||||||
|
@ -252,28 +242,6 @@ FrameMain::FrameMain()
|
||||||
Show();
|
Show();
|
||||||
SetDisplayMode(1, 1);
|
SetDisplayMode(1, 1);
|
||||||
|
|
||||||
// Version checker
|
|
||||||
StartupLog("Possibly perform automatic updates check");
|
|
||||||
if (OPT_GET("App/First Start")->GetBool()) {
|
|
||||||
OPT_SET("App/First Start")->SetBool(false);
|
|
||||||
#ifdef WITH_UPDATE_CHECKER
|
|
||||||
int result = wxMessageBox(_("Do you want Aegisub to check for updates whenever it starts? You can still do it manually via the Help menu."),_("Check for updates?"), wxYES_NO | wxCENTER);
|
|
||||||
OPT_SET("App/Auto/Check For Updates")->SetBool(result == wxYES);
|
|
||||||
try {
|
|
||||||
config::opt->Flush();
|
|
||||||
}
|
|
||||||
catch (agi::fs::FileSystemError const& e) {
|
|
||||||
wxMessageBox(to_wx(e.GetMessage()), "Error saving config file", wxOK | wxICON_ERROR | wxCENTER);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WITH_UPDATE_CHECKER
|
|
||||||
PerformVersionCheck(false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Bind(FILE_LIST_DROPPED, &FrameMain::OnFilesDropped, this);
|
|
||||||
|
|
||||||
StartupLog("Leaving FrameMain constructor");
|
StartupLog("Leaving FrameMain constructor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,10 +414,6 @@ void FrameMain::StatusTimeout(wxString text,int ms) {
|
||||||
StatusClear.Start(ms,true);
|
StatusClear.Start(ms,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameMain::OnFilesDropped(wxThreadEvent &evt) {
|
|
||||||
LoadList(evt.GetPayload<wxArrayString>());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FrameMain::LoadList(wxArrayString list) {
|
bool FrameMain::LoadList(wxArrayString list) {
|
||||||
std::string audio, video, subs;
|
std::string audio, video, subs;
|
||||||
get_files_to_load(list, subs, audio, video);
|
get_files_to_load(list, subs, audio, video);
|
||||||
|
|
|
@ -73,7 +73,6 @@ class FrameMain : public wxFrame {
|
||||||
void InitToolbar();
|
void InitToolbar();
|
||||||
void InitContents();
|
void InitContents();
|
||||||
|
|
||||||
void OnFilesDropped(wxThreadEvent &evt);
|
|
||||||
void UpdateTitle();
|
void UpdateTitle();
|
||||||
|
|
||||||
void OnKeyDown(wxKeyEvent &event);
|
void OnKeyDown(wxKeyEvent &event);
|
||||||
|
|
33
src/main.cpp
33
src/main.cpp
|
@ -39,12 +39,12 @@
|
||||||
#include "command/command.h"
|
#include "command/command.h"
|
||||||
#include "include/aegisub/hotkey.h"
|
#include "include/aegisub/hotkey.h"
|
||||||
|
|
||||||
#include "ass_dialogue.h"
|
|
||||||
#include "ass_file.h"
|
#include "ass_file.h"
|
||||||
#include "auto4_base.h"
|
#include "auto4_base.h"
|
||||||
#include "auto4_lua_factory.h"
|
#include "auto4_lua_factory.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "crash_writer.h"
|
#include "crash_writer.h"
|
||||||
|
#include "dialog_version_check.h"
|
||||||
#include "export_fixstyle.h"
|
#include "export_fixstyle.h"
|
||||||
#include "export_framerate.h"
|
#include "export_framerate.h"
|
||||||
#include "frame_main.h"
|
#include "frame_main.h"
|
||||||
|
@ -235,6 +235,14 @@ bool AegisubApp::OnInit() {
|
||||||
}
|
}
|
||||||
locale.Init(lang);
|
locale.Init(lang);
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
// When run from an app bundle, LC_CTYPE defaults to "C", which breaks on
|
||||||
|
// anything involving unicode and in some cases number formatting.
|
||||||
|
// The right thing to do here would be to query CoreFoundation for the user's
|
||||||
|
// locale and add .UTF-8 to that, but :effort:
|
||||||
|
setlocale(LC_CTYPE, "en_US.UTF-8");
|
||||||
|
#endif
|
||||||
|
|
||||||
exception_message = _("Oops, Aegisub has crashed!\n\nAn attempt has been made to save a copy of your file to:\n\n%s\n\nAegisub will now close.");
|
exception_message = _("Oops, Aegisub has crashed!\n\nAn attempt has been made to save a copy of your file to:\n\n%s\n\nAegisub will now close.");
|
||||||
|
|
||||||
// Load plugins
|
// Load plugins
|
||||||
|
@ -250,11 +258,34 @@ bool AegisubApp::OnInit() {
|
||||||
AssExportFilterChain::Register(agi::util::make_unique<AssFixStylesFilter>());
|
AssExportFilterChain::Register(agi::util::make_unique<AssFixStylesFilter>());
|
||||||
AssExportFilterChain::Register(agi::util::make_unique<AssTransformFramerateFilter>());
|
AssExportFilterChain::Register(agi::util::make_unique<AssTransformFramerateFilter>());
|
||||||
|
|
||||||
|
StartupLog("Install PNG handler");
|
||||||
|
wxImage::AddHandler(new wxPNGHandler);
|
||||||
|
|
||||||
// Open main frame
|
// Open main frame
|
||||||
StartupLog("Create main window");
|
StartupLog("Create main window");
|
||||||
frame = new FrameMain;
|
frame = new FrameMain;
|
||||||
SetTopWindow(frame);
|
SetTopWindow(frame);
|
||||||
|
|
||||||
|
// Version checker
|
||||||
|
StartupLog("Possibly perform automatic updates check");
|
||||||
|
if (OPT_GET("App/First Start")->GetBool()) {
|
||||||
|
OPT_SET("App/First Start")->SetBool(false);
|
||||||
|
#ifdef WITH_UPDATE_CHECKER
|
||||||
|
int result = wxMessageBox(_("Do you want Aegisub to check for updates whenever it starts? You can still do it manually via the Help menu."),_("Check for updates?"), wxYES_NO | wxCENTER);
|
||||||
|
OPT_SET("App/Auto/Check For Updates")->SetBool(result == wxYES);
|
||||||
|
try {
|
||||||
|
config::opt->Flush();
|
||||||
|
}
|
||||||
|
catch (agi::fs::FileSystemError const& e) {
|
||||||
|
wxMessageBox(to_wx(e.GetMessage()), "Error saving config file", wxOK | wxICON_ERROR | wxCENTER);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef WITH_UPDATE_CHECKER
|
||||||
|
PerformVersionCheck(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Get parameter subs
|
// Get parameter subs
|
||||||
StartupLog("Parse command line");
|
StartupLog("Parse command line");
|
||||||
wxArrayString subs;
|
wxArrayString subs;
|
||||||
|
|
Loading…
Reference in a new issue