X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2FfrmMain.cpp;h=f07a5ca1f736bc6aff7c6ef2fefae2b9f3b2dbce;hp=e9ce30477bc121d14b98ef591b3f4684a882de40;hb=76214fdd5e820c60a468a62fa586749102310f21;hpb=974a0d586c5480559439d4756c3ce5fb3876da0c diff --git a/source/frmMain.cpp b/source/frmMain.cpp index e9ce304..f07a5ca 100644 --- a/source/frmMain.cpp +++ b/source/frmMain.cpp @@ -16,6 +16,7 @@ // You should have received a copy of the GNU General Public License along // with Xestia Address Book. If not, see +#include #include #include #include @@ -47,7 +48,7 @@ #include "frmSSLCertificate.h" #include "frmUpdate.h" #include "import/frmImportResults.h" -#include "bitmaps.h" +#include "Bitmaps.h" #include "common/preferences.h" #include "common/getcontactinfo.h" @@ -406,6 +407,10 @@ void frmMain::QuitApp() SetFilename.Append(wxT("settings")); +#elif defined(__APPLE__) + + TerminateHelpBrowserProcess(); + #else // *nix OSes @@ -428,7 +433,7 @@ void frmMain::QuitApp() if (SaveWindowPos == TRUE){ - wxRect frmMainPos = this->GetRect(); + wxRect frmMainPos = GetRect(); cfgfile->Write(wxT("WindowPositionX"), frmMainPos.GetX()); cfgfile->Write(wxT("WindowPositionY"), frmMainPos.GetY()); @@ -440,7 +445,7 @@ void frmMain::QuitApp() delete cfgfile; cfgfile = NULL; - //Everything closed... exit. + // Everything closed... exit. std::exit(0); @@ -497,7 +502,7 @@ void frmMain::OpenPreferences( wxCommandEvent& event) // Reload the accounts as a change has been made within // the application and clear the current contact information. - this->LoadPreferences(); + this->LoadPreferences(true); this->ResetContactInfo(); } @@ -522,7 +527,7 @@ void frmMain::OpenNewABDialog( wxCommandEvent& event) // Reload the accounts as a change has been made within // the application. - this->LoadPreferences(); + this->LoadPreferences(true); } @@ -737,8 +742,6 @@ void frmMain::LoadContactList( wxTreeEvent& event ) // Split the name into sections. - vCardDataString = Person.Get(wxT("N")); - vCardName NameData = Person.GetName(); vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname; @@ -1108,7 +1111,7 @@ void frmMain::ShowContactInfo( wxListEvent& event ) OldSessionID = SessionID; SessionID = wxString::Format(wxT("%i"), rand() % 32768); - LoadContactData(&Person, htmContactData, SessionID, OldSessionID, &MemoryFileList, ContactBackgroundColour.GetAsString(wxC2S_CSS_SYNTAX)); + LoadContactData(&Person, htmContactData, SessionID, OldSessionID, &MemoryFileList, ContactBackgroundColour); ActiveFilename = ContactsFileIndex[ContactSeekNum]; } @@ -1426,11 +1429,11 @@ void frmMain::LoadPreferences( wxActivateEvent& event) // Load the preferences. - this->LoadPreferences(); + this->LoadPreferences(true); } -void frmMain::LoadPreferences(){ +void frmMain::LoadPreferences(bool skipWindowSizeReload){ // Load the preferences. @@ -1438,13 +1441,20 @@ void frmMain::LoadPreferences(){ XABPreferences preferences(preffilename); + // Clear the active account/filename information and account list. + + ActiveAccount = ""; + ActiveAccountType = ""; + ActiveFilename = ""; + lstContacts->DeleteAllItems(); + // Setup the main window position (if needed). bool SaveWindowPos = preferences.GetBoolData(wxT("SaveWindowPosition")); bool HideLocalABs = preferences.GetBoolData(wxT("HideLocalAddressBooks")); bool UseBackgroundContactColour = preferences.GetBoolData(wxT("UseBackgroundContactColour")); - if (SaveWindowPos == true){ + if (SaveWindowPos == true && skipWindowSizeReload == false){ this->SetSize(preferences.GetMainWindowData()); @@ -1708,19 +1718,40 @@ void frmMain::UpdateContactList(wxCommandEvent& event){ // First Name, Last Name. - lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Forename + wxT(" ") + ucd->ContactNameArray.Surname); + if (ucd->ContactNameArray.Forename == wxT("") && ucd->ContactNameArray.Surname == wxT("")) + { + lstContacts->SetItem(longSelected, 0, ucd->ContactName); + } + else + { + lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Forename + wxT(" ") + ucd->ContactNameArray.Surname); + } } else if (SortMode == 2){ // Last Name, First Name. - - lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Surname + wxT(", ") + ucd->ContactNameArray.Forename); + + if (ucd->ContactNameArray.Forename == wxT("") && ucd->ContactNameArray.Surname == wxT("")) + { + lstContacts->SetItem(longSelected, 0, wxT(", ") + ucd->ContactName); + } + else + { + lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Surname + wxT(", ") + ucd->ContactNameArray.Forename); + } } else if (SortMode == 3){ // Nickname. - lstContacts->SetItem(longSelected, 0, ucd->ContactNickname); + if (ucd->ContactNickname == wxT("")) + { + lstContacts->SetItem(longSelected, 0, _("(no nickname)")); + } + else + { + lstContacts->SetItem(longSelected, 0, ucd->ContactNickname); + } } else if (SortMode == 4){ @@ -1830,7 +1861,7 @@ void frmMain::SetupForm(){ ciicon_png.LoadFile(ciextstream, wxBITMAP_TYPE_PNG); wxMemoryFSHandler::AddFile(wxT("ciext.png"), ciicon_png, wxBITMAP_TYPE_PNG); - LoadPreferences(); + LoadPreferences(false); } @@ -1955,8 +1986,8 @@ void frmMain::RevealContact(wxCommandEvent& event){ if (uc->ContactAccount == AccountAccDirList[i]){ - treAccounts->SelectItem(nextChild, TRUE); - AccCtrl->SetText(treAccounts->GetItemText(nextChild)); + treAccounts->SelectItem(nextChild, TRUE); + AccCtrl->SetText(treAccounts->GetItemText(nextChild)); } @@ -3095,43 +3126,70 @@ void frmMain::ShowHelp( wxCommandEvent& event ){ // Based on the operating system, work out where // the documentation should be. - -//#ifdef __APPLE__ + #if defined(__HAIKU__) - -#elif defined(__WIN32__) - - - + +#elif defined(__WIN32__) + +#elif defined(__APPLE__) + DisplayHelpBrowser(); + return; #else - if (wxFileExists("/usr/share/doc/xestiaab/index.html")){ - - wxLaunchDefaultBrowser(wxT("file:///usr/share/doc/xestiaab/index.html")); + // Get the LANG environment variable + + char *languageEnvironmentVariableChar = getenv("LANG"); + std::string languageEnvironmentVariable(languageEnvironmentVariableChar); + + int executeResult = 0; + + wxString documentPath = wxString::Format("/usr/local/share/doc/xestiaab/%s.fodt", + wxString(languageEnvironmentVariable).BeforeFirst('.', nullptr)); + std::string commandToExecute = "odthelpbrowser -d " + documentPath.ToStdString(); + + if (wxFileExists(documentPath)) + executeResult = system(commandToExecute.c_str()); + + if (executeResult == 0) return; #if XSDAB_RELEASE == 0 + documentPath = wxString::Format("/usr/share/doc/xestiaab/%s.fodt", + wxString(languageEnvironmentVariable).BeforeFirst('.', nullptr)); + commandToExecute = "odthelpbrowser -d " + documentPath.ToStdString(); + + if (wxFileExists(documentPath)) + executeResult = system(commandToExecute.c_str()); - } else if (wxFileExists("/usr/local/share/doc/xestiaab/index.html")){ - - wxLaunchDefaultBrowser(wxT("file:///usr/local/share/doc/xestiaab/index.html")); + if (executeResult == 0) return; - #endif - + + // Attempt to launch using the "default" language. + + if (wxFileExists("/usr/share/doc/xestiaab/en_GB.fodt") && executeResult > 0) + { + commandToExecute = "odthelpbrowser -d " + documentPath.ToStdString(); + executeResult = system(commandToExecute.c_str()); + } + else if (wxFileExists("/usr/local/share/doc/xestiaab/en_GB.fodt") && executeResult > 0) + { + commandToExecute = "odthelpbrowser -d " + documentPath.ToStdString(); + executeResult = system(commandToExecute.c_str()); } -#endif + if (executeResult == 0) + return; +#endif + #if XSDAB_RELEASE == 0 - wxMessageBox(_("The help documentation is not available.\n\nYou can view the documentation that came with your source package."), _("Help documentation missing!")); - + return; #else - - wxMessageBox(_("The help documentation is not available in the usual locations on the system. Please visit http://documentation.xestia.co.uk/xestiaab/ for documentation"), _("Help documentation missing!")); - + wxMessageBox(_("The help documentation is not available in the usual locations on the system. Please visit https://xestia.co.uk/addressbook for documentation"), _("Help documentation missing!")); + return; #endif }