X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;ds=sidebyside;f=source%2FfrmMain.cpp;h=77b34bd683080cae79489631f84019a6ea3d33e8;hb=b49f6c47e7fef42d63c47be38bca12ab0b250df8;hp=aeffdbaa0f2843b96464cea0d59fb7442022da7d;hpb=540e667a9fdae2213756c164185e4d7f78f33e2b;p=xestiaab%2F.git
diff --git a/source/frmMain.cpp b/source/frmMain.cpp
index aeffdba..77b34bd 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
@@ -65,7 +66,6 @@
// Define the event types.
DEFINE_EVENT_TYPE(CE_UPDATECONTACTLIST);
-DEFINE_EVENT_TYPE(CE_UPDATEACCOUNTLIST);
DEFINE_EVENT_TYPE(SE_UPDATECONTACTNOTIF);
DEFINE_EVENT_TYPE(CE_OPENCONTACT);
DEFINE_EVENT_TYPE(CE_OPENCONTACTLIST);
@@ -99,7 +99,6 @@ DEFINE_EVENT_TYPE(INVALIDSSLTRUST);
BEGIN_EVENT_TABLE(frmMain, wxFrame)
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, frmMain::ConflictResolution)
EVT_COMMAND(wxID_ANY, CE_UPDATECONTACTLIST, frmMain::UpdateContactList)
-EVT_COMMAND(wxID_ANY, CE_UPDATEACCOUNTLIST, frmMain::UpdateAccountList)
EVT_COMMAND(wxID_ANY, SE_UPDATECONTACTNOTIF, frmMain::UpdateSearchContactLists)
EVT_COMMAND(wxID_ANY, CE_OPENCONTACT, frmMain::OpenContactInfo)
EVT_COMMAND(wxID_ANY, CE_OPENCONTACTLIST, frmMain::OpenContactInfoList)
@@ -430,7 +429,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());
@@ -442,7 +441,7 @@ void frmMain::QuitApp()
delete cfgfile;
cfgfile = NULL;
- //Everything closed... exit.
+ // Everything closed... exit.
std::exit(0);
@@ -499,7 +498,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();
}
@@ -524,7 +523,7 @@ void frmMain::OpenNewABDialog( wxCommandEvent& event)
// Reload the accounts as a change has been made within
// the application.
- this->LoadPreferences();
+ this->LoadPreferences(true);
}
@@ -739,8 +738,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;
@@ -1110,7 +1107,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];
}
@@ -1428,11 +1425,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.
@@ -1440,13 +1437,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());
@@ -1456,7 +1460,11 @@ void frmMain::LoadPreferences(){
ContactBackgroundColour = preferences.GetBackgroundContactColourData();
- }
+ } else {
+
+ ContactBackgroundColour = wxTransparentColour;
+
+ }
treAccounts->DeleteAllItems();
@@ -1706,19 +1714,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){
@@ -1785,12 +1814,6 @@ void frmMain::UpdateContactList(wxCommandEvent& event){
}
-void frmMain::UpdateAccountList(wxCommandEvent& event){
-
- // Update the account list (currently unimplemented).
-
-}
-
void frmMain::SetupPointers(void *ActMgrPtrInc){
// Setup the pointers for the main window.
@@ -1834,7 +1857,7 @@ void frmMain::SetupForm(){
ciicon_png.LoadFile(ciextstream, wxBITMAP_TYPE_PNG);
wxMemoryFSHandler::AddFile(wxT("ciext.png"), ciicon_png, wxBITMAP_TYPE_PNG);
- LoadPreferences();
+ LoadPreferences(false);
}
@@ -1959,8 +1982,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));
}
@@ -3099,43 +3122,67 @@ 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__)
#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
}
@@ -3179,7 +3226,10 @@ void frmMain::ShowContactMenu( wxMouseEvent& event ){
bool EnableRefresh = FALSE;
- if (!ActiveAccount.IsEmpty() && (ActiveAccountType == "CardDAV" || ActiveAccountType == "carddav")){
+ if (!ActiveAccount.IsEmpty() && (ActiveAccountType == "CardDAV" ||
+ ActiveAccountType == "carddav" ||
+ ActiveAccountType == "Local" ||
+ ActiveAccountType == "local")){
EnableRefresh = TRUE;
@@ -3224,4 +3274,4 @@ bool frmMain::CloseAllWindows()
{
return false;
}
-}
\ No newline at end of file
+}