Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmMain: Close all windows when opening preferences
[xestiaab/.git] / source / frmMain.cpp
index 4c0e354..aeffdba 100644 (file)
@@ -54,7 +54,6 @@
 #include "common/events.h"
 #include "common/dirs.h"
 #include "vcard/vcard.h"
-#include "carddav/carddav.h"
 #include "contacteditor/frmContactEditor.h"
 #include "import/import.h"
 #include "export/export.h"
@@ -191,7 +190,40 @@ frmMainADT( parent )
     
        wxImage icons_nossl_png(nosslstream, wxBITMAP_TYPE_PNG);
        imgNoSSL = new wxBitmap(icons_nossl_png, -1);
-    
+       // Toolbar icons.
+
+       wxMemoryInputStream addaddressbook(toolbar_addaddressbook_png, sizeof(toolbar_addaddressbook_png));
+       wxMemoryInputStream preferences(toolbar_preferences_png, sizeof(toolbar_preferences_png));
+       wxMemoryInputStream searchcontacts(toolbar_searchcontacts_png, sizeof(toolbar_searchcontacts_png));
+       wxMemoryInputStream addcontact(toolbar_addcontact_png, sizeof(toolbar_addcontact_png));
+       wxMemoryInputStream editcontact(toolbar_editcontact_png, sizeof(toolbar_editcontact_png));
+       wxMemoryInputStream deletecontact(toolbar_deletecontact_png, sizeof(toolbar_deletecontact_png));
+
+       wxImage toolbar_addaddressbook_png(addaddressbook, wxBITMAP_TYPE_PNG);
+       imgAddAddressBook = new wxBitmap (toolbar_addaddressbook_png, -1);
+       tblMain->SetToolNormalBitmap(tbtNewAccount->GetId(), *imgAddAddressBook);
+
+       wxImage toolbar_preferences_png(preferences, wxBITMAP_TYPE_PNG);
+       imgPreferences = new wxBitmap (toolbar_preferences_png, -1);
+       tblMain->SetToolNormalBitmap(tbtPreferences->GetId(), *imgPreferences);
+
+       wxImage toolbar_searchcontacts_png(searchcontacts, wxBITMAP_TYPE_PNG);
+       imgSearchContacts = new wxBitmap (toolbar_searchcontacts_png, -1);
+       tblMain->SetToolNormalBitmap(tbtSearch->GetId(), *imgSearchContacts);
+
+       wxImage toolbar_addcontact_png(addcontact, wxBITMAP_TYPE_PNG);
+       imgAddContact = new wxBitmap (toolbar_addcontact_png, -1);
+       tblMain->SetToolNormalBitmap(tbtAddContact->GetId(), *imgAddContact);
+       
+       wxImage toolbar_editcontact_png(editcontact, wxBITMAP_TYPE_PNG);
+       imgEditContact = new wxBitmap (toolbar_editcontact_png, -1);
+       tblMain->SetToolNormalBitmap(tbtEditContact->GetId(), *imgEditContact);
+       
+       wxImage toolbar_deletecontact_png(deletecontact, wxBITMAP_TYPE_PNG);
+       imgDeleteContact = new wxBitmap (toolbar_deletecontact_png, -1);
+       tblMain->SetToolNormalBitmap(tbtDeleteContact->GetId(), *imgDeleteContact);
+
        // Activity Icon.
     
        wxMemoryInputStream act1(icons_act1_png, sizeof(icons_act1_png));
@@ -358,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.
     
@@ -451,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;
@@ -1077,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];
     
 }
@@ -1323,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);
@@ -1380,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);
@@ -1409,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);
@@ -1468,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;
             
@@ -1608,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();
@@ -1718,6 +1760,7 @@ void frmMain::UpdateContactList(wxCommandEvent& event){
             
                        vCard UpdatedPerson;
                        UpdatedPerson.LoadFile(ucd->ContactFilename);
+                       frmContactPtr->SetBackgroundColour(ContactBackgroundColour.GetAsString(wxC2S_CSS_SYNTAX));
                        frmContactPtr->SetupContactData(&UpdatedPerson);
             
                }
@@ -2653,7 +2696,7 @@ void frmMain::ShowSSLCertificates( wxCommandEvent &event ){
 
 #else
     
-       std::map<int, SSLCertCollection>::iterator SSLColIter;
+       std::map<int, SSLCertCollectionString>::iterator SSLColIter;
         
        for (int i = 0; i < prefaccounts.GetCount(); i++){
         
@@ -2680,11 +2723,11 @@ void frmMain::ShowSSLCertificates( wxCommandEvent &event ){
             
                        SSLColIter = AccountSSLData.find(i);
             
-                       SSLCertCollection SSLCertInfo = SSLColIter->second;
-            
+                       SSLCertCollectionString SSLCertInfo = SSLColIter->second;
+                       
                        frmSSLCertificate *frameSSLCert = new frmSSLCertificate ( this );
                        frameSSLCert->StartCertFrom(0);
-                       frameSSLCert->SetupCerts(SSLCertInfo);
+                       frameSSLCert->SetupCertsString(SSLCertInfo);
                        frameSSLCert->ShowModal();
             
                        delete frameSSLCert;
@@ -2830,7 +2873,7 @@ void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, PCCERT_CONTEX
 
 #else
 
-void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollection SSLCertInc){
+void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollectionString SSLCertInc){
     
        // Delete existing data.
     
@@ -3156,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