mirror of https://github.com/odrling/Aegisub
Added option to let user disable spellchecker and thesaurus from right click menu, and a possible fix to splash screen.
Originally committed to SVN as r676.
This commit is contained in:
parent
af78223810
commit
9d1a3466dd
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;i<langs.Count();i++) {
|
||||
info = wxLocale::FindLanguageInfo(langs[i]);
|
||||
if (info) name = info->Description;
|
||||
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;i<langs.Count();i++) {
|
||||
info = wxLocale::FindLanguageInfo(langs[i]);
|
||||
if (info) name = info->Description;
|
||||
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;i<langs.Count();i++) {
|
||||
info = wxLocale::FindLanguageInfo(langs[i].Mid(3));
|
||||
if (info) name = info->Description;
|
||||
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;i<langs.Count();i++) {
|
||||
info = wxLocale::FindLanguageInfo(langs[i]);
|
||||
if (info) name = info->Description;
|
||||
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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue