Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmMain: Close all windows when opening preferences
[xestiaab/.git] / source / frmMain.cpp
index 3d54720..aeffdba 100644 (file)
@@ -390,17 +390,11 @@ void frmMain::QuitApp()
 {
 
        // Function to run when quitting.
-    
-       //Go through the windows and close each one (be it search
-       //or contact editor). Abort if user wants to cancel.
-    
-       // Close the contact editor windows.
-    
-       // Close the contact windows.
-    
-       // Close the search windows.
-    
+       
        // Write out the ETag databases.
+       
+       ETagProcTimer.Stop();
+       ETagProcTimer.Notify();
     
        // Save Preferences: Save the window position if that option is enabled.
     
@@ -483,6 +477,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;
@@ -1109,7 +1110,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.GetAsString(wxC2S_CSS_SYNTAX));
        ActiveFilename = ContactsFileIndex[ContactSeekNum];
     
 }
@@ -1355,6 +1356,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);
@@ -1412,6 +1414,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);
@@ -1441,13 +1444,20 @@ void frmMain::LoadPreferences(){
     
        bool SaveWindowPos = preferences.GetBoolData(wxT("SaveWindowPosition"));
        bool HideLocalABs = preferences.GetBoolData(wxT("HideLocalAddressBooks"));
+       bool UseBackgroundContactColour = preferences.GetBoolData(wxT("UseBackgroundContactColour"));
     
-       if (SaveWindowPos == TRUE){
+       if (SaveWindowPos == true){
         
                this->SetSize(preferences.GetMainWindowData());
         
        }
     
+       if (UseBackgroundContactColour == true){
+               
+               ContactBackgroundColour = preferences.GetBackgroundContactColourData();
+               
+       }
+       
        treAccounts->DeleteAllItems();
     
        wxTreeItemId RootNode = treAccounts->AddRoot(wxT("Root Item"), AccountNoneID);
@@ -1500,7 +1510,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;
             
@@ -1640,7 +1650,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();
@@ -1750,6 +1760,7 @@ void frmMain::UpdateContactList(wxCommandEvent& event){
             
                        vCard UpdatedPerson;
                        UpdatedPerson.LoadFile(ucd->ContactFilename);
+                       frmContactPtr->SetBackgroundColour(ContactBackgroundColour.GetAsString(wxC2S_CSS_SYNTAX));
                        frmContactPtr->SetupContactData(&UpdatedPerson);
             
                }
@@ -3188,4 +3199,29 @@ void frmMain::ResetContactInfo(){
        htmContactData->SetPage(EmptyPage);
        AccCtrl->SetValue("");
        
+}
+
+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<int, void*>::iterator windowIter = WindowListPointers.begin();
+                       windowIter != WindowListPointers.end(); windowIter++)
+               {
+                       wxWindow *windowPointer = static_cast<wxWindow*>(windowIter->second);
+                       windowPointer->Close();
+               }
+               return true;
+       }
+       else
+       {
+               return false;
+       }
 }
\ No newline at end of file
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy