X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2FfrmMain.cpp;h=c32e61dca8975ce2dc1ad5f5437fabe7392a7dc7;hp=4dc43f6d90f1837155cf24e5886edaece88f4da9;hb=7f33f83780a10b4f4083f5950412f1924f3639a6;hpb=25716f74ecdac6cd5879b659ebc8aaa668261880 diff --git a/source/frmMain.cpp b/source/frmMain.cpp index 4dc43f6..c32e61d 100644 --- a/source/frmMain.cpp +++ b/source/frmMain.cpp @@ -65,7 +65,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 +98,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 +428,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 +440,7 @@ void frmMain::QuitApp() delete cfgfile; cfgfile = NULL; - //Everything closed... exit. + // Everything closed... exit. std::exit(0); @@ -477,6 +475,13 @@ void frmMain::ShowAboutWindow( wxCommandEvent& event ) void frmMain::OpenPreferences( wxCommandEvent& event) { + // Close all windows first. + + if (CloseAllWindows() == false) + { + return; + } + // Open the preferences window. ReloadAccounts = FALSE; @@ -492,7 +497,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(); } @@ -517,7 +522,7 @@ void frmMain::OpenNewABDialog( wxCommandEvent& event) // Reload the accounts as a change has been made within // the application. - this->LoadPreferences(); + this->LoadPreferences(true); } @@ -1103,7 +1108,7 @@ void frmMain::ShowContactInfo( wxListEvent& event ) OldSessionID = SessionID; SessionID = wxString::Format(wxT("%i"), rand() % 32768); - LoadContactData(&Person, htmContactData, SessionID, OldSessionID, &MemoryFileList); + LoadContactData(&Person, htmContactData, SessionID, OldSessionID, &MemoryFileList, ContactBackgroundColour); ActiveFilename = ContactsFileIndex[ContactSeekNum]; } @@ -1349,6 +1354,7 @@ void frmMain::OpenContactInfoList( wxListEvent& event ) wxPostEvent(this, addevent); Contact->SetupPointers(&MemoryFileList); + Contact->SetBackgroundColour(ContactBackgroundColour.GetAsString(wxC2S_CSS_SYNTAX)); Contact->SetupContactData(&Person); Contact->SetIcon(contacticon); @@ -1406,6 +1412,7 @@ void frmMain::OpenContactInfo( wxCommandEvent& event ) wxPostEvent(this, addevent); Contact->SetupPointers(&MemoryFileList); + Contact->SetBackgroundColour(ContactBackgroundColour.GetAsString(wxC2S_CSS_SYNTAX)); Contact->SetupContactData(&Person); Contact->SetIcon(contacticon); @@ -1419,11 +1426,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. @@ -1431,17 +1438,35 @@ 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()); } + if (UseBackgroundContactColour == true){ + + ContactBackgroundColour = preferences.GetBackgroundContactColourData(); + + } else { + + ContactBackgroundColour = wxTransparentColour; + + } + treAccounts->DeleteAllItems(); wxTreeItemId RootNode = treAccounts->AddRoot(wxT("Root Item"), AccountNoneID); @@ -1494,7 +1519,7 @@ void frmMain::LoadPreferences(){ for (int i = 0; i < preferences.accounts.GetCount(); i++){ if ((preferences.accounts.GetAccountType(i) == wxT("Local") || - preferences.accounts.GetAccountType(i) == wxT("local")) && HideLocalABs == TRUE){ + preferences.accounts.GetAccountType(i) == wxT("local")) && HideLocalABs == true){ continue; @@ -1634,7 +1659,7 @@ void frmMain::ConflictResolution(wxCommandEvent& event){ vCardConflictObj *vCardConfObj = (vCardConflictObj*)event.GetClientData(); vCard *ClientDataPtr = vCardConfObj->vCardLocalData; vCard *ServerDataPtr = vCardConfObj->vCardServerData; - frameCR->LoadData(ClientDataPtr, ServerDataPtr, &MemoryFileList); + frameCR->LoadData(ClientDataPtr, ServerDataPtr, &MemoryFileList, ContactBackgroundColour.GetAsString(wxC2S_CSS_SYNTAX)); frameCR->ShowModal(); int FinalConflictResult = frameCR->GetResult(); @@ -1744,6 +1769,7 @@ void frmMain::UpdateContactList(wxCommandEvent& event){ vCard UpdatedPerson; UpdatedPerson.LoadFile(ucd->ContactFilename); + frmContactPtr->SetBackgroundColour(ContactBackgroundColour.GetAsString(wxC2S_CSS_SYNTAX)); frmContactPtr->SetupContactData(&UpdatedPerson); } @@ -1768,12 +1794,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. @@ -1817,7 +1837,7 @@ void frmMain::SetupForm(){ ciicon_png.LoadFile(ciextstream, wxBITMAP_TYPE_PNG); wxMemoryFSHandler::AddFile(wxT("ciext.png"), ciicon_png, wxBITMAP_TYPE_PNG); - LoadPreferences(); + LoadPreferences(false); } @@ -1942,8 +1962,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)); } @@ -3162,7 +3182,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; @@ -3182,4 +3205,29 @@ void frmMain::ResetContactInfo(){ htmContactData->SetPage(EmptyPage); AccCtrl->SetValue(""); -} \ No newline at end of file +} + +bool frmMain::CloseAllWindows() +{ + // Attempt to close all windows. + + if (WindowListPointersMenu.size() == 0) + { + return true; + } + + if (wxMessageBox(_("Before preforming the action, all windows that are open will need to close. Do you wish to continue?"), _("Close All Windowss"), wxYES_NO) == wxYES) + { + for(std::map::iterator windowIter = WindowListPointers.begin(); + windowIter != WindowListPointers.end(); windowIter++) + { + wxWindow *windowPointer = static_cast(windowIter->second); + windowPointer->Close(); + } + return true; + } + else + { + return false; + } +}