diff --git a/aegisub/dialog_splash.cpp b/aegisub/dialog_splash.cpp index 5122a0b3e..9bd625792 100644 --- a/aegisub/dialog_splash.cpp +++ b/aegisub/dialog_splash.cpp @@ -58,10 +58,15 @@ SplashScreen::SplashScreen(wxWindow *parent) // Center on current display if (wxDisplay::GetCount() < 1) CentreOnParent(); else { + // Get display number int point = wxDisplay::GetFromPoint(parent->GetScreenPosition()); if (point == wxNOT_FOUND) point = 0; + + // Get display size wxDisplay display(point); wxRect dr = display.GetGeometry(); + + // Calculate position and center it there wxRect window = GetScreenRect(); window = window.CenterIn(dr); Move(window.GetLeft(),window.GetTop()); diff --git a/aegisub/spellchecker_hunspell.cpp b/aegisub/spellchecker_hunspell.cpp index e5c0f1864..3a62a19db 100644 --- a/aegisub/spellchecker_hunspell.cpp +++ b/aegisub/spellchecker_hunspell.cpp @@ -158,6 +158,15 @@ wxArrayString HunspellSpellChecker::GetLanguageList() { //////////////// // Set language void HunspellSpellChecker::SetLanguage(wxString language) { + // Unload + delete hunspell; + hunspell = NULL; + delete conv; + conv = NULL; + + // Unloading + if (language.IsEmpty()) return; + // Get dir name wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),AegisubApp::folderName) + _T("/"); @@ -168,12 +177,6 @@ void HunspellSpellChecker::SetLanguage(wxString language) { // Check if language is available if (!wxFileExists(affpath) || !wxFileExists(dicpath)) return; - // Unload - delete hunspell; - hunspell = NULL; - delete conv; - conv = NULL; - // Load hunspell = new Hunspell(affpath.mb_str(wxConvLocal),dicpath.mb_str(wxConvLocal)); conv = NULL; diff --git a/aegisub/subs_edit_ctrl.cpp b/aegisub/subs_edit_ctrl.cpp index 6f35f9866..731a5434e 100644 --- a/aegisub/subs_edit_ctrl.cpp +++ b/aegisub/subs_edit_ctrl.cpp @@ -513,25 +513,31 @@ void SubsTextEditCtrl::ShowPopupMenu(int activePos) { // Language list wxArrayString langs = spellchecker->GetLanguageList(); // This probably should be cached... - if (langs.Count()) { - // Current language - wxString curLang = Options.AsText(_T("Spell checker language")); - // Languages - wxMenu *languageMenu = new wxMenu(); - wxMenuItem *cur; - wxString name; - const wxLanguageInfo *info; - for (unsigned int i=0;iDescription; - else name = langs[i]; - cur = languageMenu->AppendCheckItem(EDIT_MENU_DIC_LANGS+i,name); - if (langs[i] == curLang) cur->Check(); - } - menu.AppendSubMenu(languageMenu,_("Spell checker language")); + // Current language + wxString curLang = Options.AsText(_T("Spell checker language")); + + // Languages + wxMenu *languageMenu = new wxMenu(); + wxMenuItem *cur; + wxString name; + const wxLanguageInfo *info; + + // Insert "Disable" + cur = languageMenu->AppendCheckItem(EDIT_MENU_DIC_LANGS,_("Disable")); + if (curLang.IsEmpty()) cur->Check(); + + // Each language found + for (unsigned int i=0;iDescription; + else name = langs[i]; + cur = languageMenu->AppendCheckItem(EDIT_MENU_DIC_LANGS+i+1,name); + if (langs[i] == curLang) cur->Check(); } - else menu.Append(EDIT_MENU_DIC_LANGUAGE,_("No dictionaries available"))->Enable(false); + + // Append language list + menu.AppendSubMenu(languageMenu,_("Spell checker language")); menu.AppendSeparator(); } @@ -590,27 +596,31 @@ void SubsTextEditCtrl::ShowPopupMenu(int activePos) { // Language list wxArrayString langs = thesaurus->GetLanguageList(); // This probably should be cached... - if (langs.Count()) { - // Current language - wxString curLang = Options.AsText(_T("Thesaurus language")); - // Languages - wxMenu *languageMenu = new wxMenu(); - wxMenuItem *cur; - wxString name; - const wxLanguageInfo *info; - for (unsigned int i=0;iDescription; - else name = langs[i]; - cur = languageMenu->AppendCheckItem(EDIT_MENU_THES_LANGS+i,name); - if (langs[i].Mid(3) == curLang) cur->Check(); - } - menu.AppendSubMenu(languageMenu,_("Thesaurus language")); + // Current language + wxString curLang = Options.AsText(_T("Thesaurus language")); + + // Languages + wxMenu *languageMenu = new wxMenu(); + wxMenuItem *cur; + wxString name; + const wxLanguageInfo *info; + + // Insert "Disable" + cur = languageMenu->AppendCheckItem(EDIT_MENU_THES_LANGS,_("Disable")); + if (curLang.IsEmpty()) cur->Check(); + + // Each language found + for (unsigned int i=0;iDescription; + else name = langs[i]; + cur = languageMenu->AppendCheckItem(EDIT_MENU_THES_LANGS+i+1,name); + if (langs[i] == curLang) cur->Check(); } - else menu.Append(EDIT_MENU_THES_LANGUAGE,_("No thesauruses available"))->Enable(false); - // Separator + // Append language list + menu.AppendSubMenu(languageMenu,_("Thesaurus language")); menu.AppendSeparator(); } @@ -832,9 +842,11 @@ void SubsTextEditCtrl::OnSetDicLanguage(wxCommandEvent &event) { wxArrayString langs = spellchecker->GetLanguageList(); // Set dictionary - int index = event.GetId() - EDIT_MENU_DIC_LANGS; - spellchecker->SetLanguage(langs[index]); - Options.SetText(_T("Spell checker language"),langs[index]); + int index = event.GetId() - EDIT_MENU_DIC_LANGS - 1; + wxString lang; + if (index >= 0) lang = langs[index]; + spellchecker->SetLanguage(lang); + Options.SetText(_T("Spell checker language"),lang); Options.Save(); // Update styling @@ -849,9 +861,11 @@ void SubsTextEditCtrl::OnSetThesLanguage(wxCommandEvent &event) { wxArrayString langs = thesaurus->GetLanguageList(); // Set language - int index = event.GetId() - EDIT_MENU_THES_LANGS; - thesaurus->SetLanguage(langs[index]); - Options.SetText(_T("Thesaurus language"),langs[index]); + int index = event.GetId() - EDIT_MENU_THES_LANGS - 1; + wxString lang; + if (index >= 0) lang = langs[index]; + thesaurus->SetLanguage(lang); + Options.SetText(_T("Thesaurus language"),lang); Options.Save(); // Update styling diff --git a/aegisub/thesaurus_myspell.cpp b/aegisub/thesaurus_myspell.cpp index 53a4fa60a..50a6cbad3 100644 --- a/aegisub/thesaurus_myspell.cpp +++ b/aegisub/thesaurus_myspell.cpp @@ -110,7 +110,9 @@ wxArrayString MySpellThesaurus::GetLanguageList() { // Found match if (curdat == dat[j]) { wxFileName fname(curdat); - list.Add(fname.GetName()); + wxString name = fname.GetName(); + if (name.Left(3) == _T("th_")) name = name.Mid(3); + list.Add(name); break; } } @@ -124,6 +126,15 @@ wxArrayString MySpellThesaurus::GetLanguageList() { //////////////// // Set language void MySpellThesaurus::SetLanguage(wxString language) { + // Unload + delete mythes; + mythes = NULL; + delete conv; + conv = NULL; + + // Unloading + if (language.IsEmpty()) return; + // Get dir name wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),AegisubApp::folderName) + _T("/"); @@ -134,12 +145,6 @@ void MySpellThesaurus::SetLanguage(wxString language) { // Check if language is available if (!wxFileExists(idxpath) || !wxFileExists(datpath)) return; - // Unload - delete mythes; - mythes = NULL; - delete conv; - conv = NULL; - // Load mythes = new MyThes(idxpath.mb_str(wxConvLocal),datpath.mb_str(wxConvLocal)); conv = NULL;