From: Steve Brokenshire Date: Wed, 14 Jun 2017 22:08:06 +0000 (+0100) Subject: Preferences: Option to select background colour for contacts X-Git-Tag: release-0.19~2 X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=commitdiff_plain;h=d1663f3d3931bb05c791ef2c86926a22932c6014 Preferences: Option to select background colour for contacts --- diff --git a/source/AppXestiaAddrBk.cpp b/source/AppXestiaAddrBk.cpp index 8ffcff5..3e55af5 100644 --- a/source/AppXestiaAddrBk.cpp +++ b/source/AppXestiaAddrBk.cpp @@ -575,7 +575,7 @@ frmPreferencesADT::frmPreferencesADT( wxWindow* parent, wxWindowID id, const wxS tabGeneral->SetSizer( szrGeneral ); tabGeneral->Layout(); szrGeneral->Fit( tabGeneral ); - NbtPreferences->AddPage( tabGeneral, wxT("General"), false ); + NbtPreferences->AddPage( tabGeneral, wxT("General"), true ); tabTheme = new wxPanel( NbtPreferences, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); tabTheme->Hide(); @@ -651,7 +651,25 @@ frmPreferencesADT::frmPreferencesADT( wxWindow* parent, wxWindowID id, const wxS tabAccounts->SetSizer( szrAccounts ); tabAccounts->Layout(); szrAccounts->Fit( tabAccounts ); - NbtPreferences->AddPage( tabAccounts, wxT("Accounts"), true ); + NbtPreferences->AddPage( tabAccounts, wxT("Accounts"), false ); + tabContacts = new wxPanel( NbtPreferences, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxFlexGridSizer* szrContacts; + szrContacts = new wxFlexGridSizer( 1, 2, 0, 0 ); + szrContacts->AddGrowableCol( 0 ); + szrContacts->SetFlexibleDirection( wxBOTH ); + szrContacts->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + chkUseBackgroundColour = new wxCheckBox( tabContacts, wxID_ANY, wxT("Use different background colour"), wxDefaultPosition, wxDefaultSize, 0 ); + szrContacts->Add( chkUseBackgroundColour, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + clpContactBackgroundColour = new wxColourPickerCtrl( tabContacts, wxID_ANY, wxColour( 255, 255, 255 ), wxDefaultPosition, wxDefaultSize, wxCLRP_DEFAULT_STYLE ); + szrContacts->Add( clpContactBackgroundColour, 0, wxALL, 5 ); + + + tabContacts->SetSizer( szrContacts ); + tabContacts->Layout(); + szrContacts->Fit( tabContacts ); + NbtPreferences->AddPage( tabContacts, wxT("Contacts"), false ); szrTabs->Add( NbtPreferences, 1, wxALL|wxEXPAND, 5 ); @@ -699,6 +717,7 @@ frmPreferencesADT::frmPreferencesADT( wxWindow* parent, wxWindowID id, const wxS btnAccountAdd->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmPreferencesADT::AddABAccount ), NULL, this ); btnAccountModify->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmPreferencesADT::ModifyABAccount ), NULL, this ); btnAccountDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmPreferencesADT::DeleteABAccount ), NULL, this ); + chkUseBackgroundColour->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( frmPreferencesADT::EnableBackgroundColourPicker ), NULL, this ); btnSave->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmPreferencesADT::SavePreferences ), NULL, this ); btnCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmPreferencesADT::CloseWindow ), NULL, this ); } @@ -718,6 +737,7 @@ frmPreferencesADT::~frmPreferencesADT() btnAccountAdd->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmPreferencesADT::AddABAccount ), NULL, this ); btnAccountModify->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmPreferencesADT::ModifyABAccount ), NULL, this ); btnAccountDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmPreferencesADT::DeleteABAccount ), NULL, this ); + chkUseBackgroundColour->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( frmPreferencesADT::EnableBackgroundColourPicker ), NULL, this ); btnSave->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmPreferencesADT::SavePreferences ), NULL, this ); btnCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( frmPreferencesADT::CloseWindow ), NULL, this ); diff --git a/source/AppXestiaAddrBk.h b/source/AppXestiaAddrBk.h index 753f748..2d8c1e1 100644 --- a/source/AppXestiaAddrBk.h +++ b/source/AppXestiaAddrBk.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -268,6 +269,9 @@ class frmPreferencesADT : public wxDialog wxButton* btnAccountAdd; wxButton* btnAccountModify; wxButton* btnAccountDelete; + wxPanel* tabContacts; + wxCheckBox* chkUseBackgroundColour; + wxColourPickerCtrl* clpContactBackgroundColour; wxButton* btnSave; wxButton* btnCancel; @@ -279,6 +283,7 @@ class frmPreferencesADT : public wxDialog virtual void ModifyABAccount( wxCommandEvent& event ) { event.Skip(); } virtual void DeleteABAccount( wxCommandEvent& event ) { event.Skip(); } virtual void ModifyABAccount( wxMouseEvent& event ) { event.Skip(); } + virtual void EnableBackgroundColourPicker( wxCommandEvent& event ) { event.Skip(); } virtual void SavePreferences( wxCommandEvent& event ) { event.Skip(); } virtual void CloseWindow( wxCommandEvent& event ) { event.Skip(); } diff --git a/source/common/defaults.cpp b/source/common/defaults.cpp index 2e47a27..924c550 100644 --- a/source/common/defaults.cpp +++ b/source/common/defaults.cpp @@ -130,7 +130,7 @@ void SetupDefaultSettings(){ PrefsFile.Open(PrefsFilename, wxT("w")); #endif - PrefsFile.Write(wxT("HideLocalAddressBooks=false\nSaveWindowPosition=true\n")); + PrefsFile.Write(wxT("HideLocalAddressBooks=false\nSaveWindowPosition=true\nUseBackgroundContactColour=false\n")); } diff --git a/source/common/getcontactinfo.cpp b/source/common/getcontactinfo.cpp index b997279..1b4a5e6 100644 --- a/source/common/getcontactinfo.cpp +++ b/source/common/getcontactinfo.cpp @@ -32,13 +32,14 @@ #include "../vcard/vcard34conv.h" void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, - wxString OldSID, std::map *MemoryFSList){ + wxString OldSID, std::map *MemoryFSList, wxString backgroundColour){ // Load the vCard contact data into the wxHTMLWindow given. // Show message to user that the contact information is loading. HTMLObj->SetBorders(0); + HTMLObj->SetBackgroundColour(wxColour(160,160,160,0)); wxString PageData; @@ -467,6 +468,8 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, } + // TODO: Setup the second table. + // Process Birthday ContactData = vCardObj->GetByPartial(wxT("BDAY")); @@ -551,7 +554,13 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, } - PageData.append("
"); + if (!backgroundColour.IsEmpty()){ + PageData.append("
"); + } else { + PageData.append("
"); + } if (DataDisplay == TRUE){ diff --git a/source/common/getcontactinfo.h b/source/common/getcontactinfo.h index 416f7f9..d71e6f3 100644 --- a/source/common/getcontactinfo.h +++ b/source/common/getcontactinfo.h @@ -27,7 +27,7 @@ #define GETCONTACTINFO_H void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, - wxString OldSID, std::map *MemoryFSList); + wxString OldSID, std::map *MemoryFSList, wxString backgroundColour); void ProcessIMPPType(wxString *PageData, wxString *IMPPType, bool PreferredContact); void SplitPropertyData(wxString *PropertyLine, std::map *SplitPoints, std::map *SplitLength, int intSize, std::map *SplitData); diff --git a/source/common/preferences.cpp b/source/common/preferences.cpp index 009afea..e965f48 100644 --- a/source/common/preferences.cpp +++ b/source/common/preferences.cpp @@ -72,7 +72,7 @@ XABPreferences::XABPreferences(wxString PreferencesFilename){ if (ValueInc == wxT("true")){ - SaveWindowPos = TRUE; + SaveWindowPos = true; wxRect WindowPosition; long PosX, PosY, PosH, PosW = 0; @@ -107,7 +107,18 @@ XABPreferences::XABPreferences(wxString PreferencesFilename){ settingfile->Read(wxT("HideLocalAddressBooks"), &ValueInc); if (ValueInc == wxT("true")){ - HideLocalABs = TRUE; + HideLocalABs = true; + } + + settingfile->Read(wxT("UseBackgroundContactColour"), &ValueInc); + + if (ValueInc == wxT("true")){ + UseBackgroundContactColour = true; + wxString BackgroundContactColourRead; + settingfile->Read(wxT("BackgroundContactColour"), &BackgroundContactColourRead); + if (BackgroundContactColourRead.Mid(0, 1) == "#"){ + BackgroundContactColour.Set(BackgroundContactColourRead); + } } delete settingfile; @@ -271,8 +282,9 @@ bool XABPreferences::GetBoolData(wxString SettingName){ if (SettingName == wxT("SaveWindowPosition")) { return SaveWindowPos; } else if (SettingName == wxT("HideLocalAddressBooks")) { return HideLocalABs; } + else if (SettingName == wxT("UseBackgroundContactColour")) { return UseBackgroundContactColour; } - return FALSE; + return false; } @@ -292,6 +304,18 @@ void XABPreferences::SetMainWindowData(wxRect WindowData){ } +wxColour XABPreferences::GetBackgroundContactColourData(){ + + return BackgroundContactColour; + +} + +void XABPreferences::SetBackgroundContactColourData(wxColour ColourData){ + + BackgroundContactColour = ColourData; + +} + // XABPrefAccounts XABPrefAccounts::XABPrefAccounts(){ diff --git a/source/common/preferences.h b/source/common/preferences.h index 6b31ef4..0edf6df 100644 --- a/source/common/preferences.h +++ b/source/common/preferences.h @@ -84,15 +84,19 @@ class XABPreferences private: // General Tab - bool SaveWindowPos = FALSE; + bool SaveWindowPos = false; wxRect MainWindowData; - bool HideLocalABs = FALSE; + bool HideLocalABs = false; // Themes tab - bool EnableThemes = FALSE; + bool EnableThemes = false; // Accounts tab + // Contacts tab + bool UseBackgroundContactColour = false; + wxColour BackgroundContactColour; + // General things. wxString Filename; @@ -110,6 +114,8 @@ public: bool SetBoolData(wxString SettingName, bool SettingValue); wxRect GetMainWindowData(); void SetMainWindowData(wxRect WindowData); + wxColour GetBackgroundContactColourData(); + void SetBackgroundContactColourData(wxColour ColourData); //int AddAccount(wxString Name); diff --git a/source/frmConflictResolution.cpp b/source/frmConflictResolution.cpp index d5c0a3f..1779161 100644 --- a/source/frmConflictResolution.cpp +++ b/source/frmConflictResolution.cpp @@ -64,7 +64,7 @@ int frmConflictResolution::GetResult(){ } -void frmConflictResolution::LoadData(vCard *LocalData, vCard *ServerData, std::map *MemoryFSList){ +void frmConflictResolution::LoadData(vCard *LocalData, vCard *ServerData, std::map *MemoryFSList, wxString backgroundColour){ // Load the local data. @@ -72,11 +72,11 @@ void frmConflictResolution::LoadData(vCard *LocalData, vCard *ServerData, std::m wxString ServerSID = wxString::Format(wxT("%i"), rand() % 32768); LoadContactData(LocalData, htmClient, ClientSID, - wxT(""), MemoryFSList); + wxT(""), MemoryFSList, backgroundColour); // Load the server data. LoadContactData(ServerData, htmServer, ServerSID, - wxT(""), MemoryFSList); + wxT(""), MemoryFSList, backgroundColour); } \ No newline at end of file diff --git a/source/frmConflictResolution.h b/source/frmConflictResolution.h index a4c4877..09e90ea 100644 --- a/source/frmConflictResolution.h +++ b/source/frmConflictResolution.h @@ -50,7 +50,7 @@ class frmConflictResolution : public frmConflictResolutionADT /** Constructor */ frmConflictResolution( wxWindow* parent ); int GetResult(); - void LoadData(vCard *LocalObj, vCard *ServerObj, std::map *MemoryFSList); + void LoadData(vCard *LocalObj, vCard *ServerObj, std::map *MemoryFSList, wxString backgroundColour); //// end generated class members }; diff --git a/source/frmContact.cpp b/source/frmContact.cpp index 5df8728..d02be95 100644 --- a/source/frmContact.cpp +++ b/source/frmContact.cpp @@ -121,7 +121,7 @@ bool frmContact::SetupContactData(vCard *vCardObj){ OldSessionID = SessionID; SessionID = wxString::Format(wxT("%i"), rand() % 32768); - LoadContactData(vCardObj, htmContactData, SessionID, OldSessionID, MemoryFSListPtr); + LoadContactData(vCardObj, htmContactData, SessionID, OldSessionID, MemoryFSListPtr, backgroundColour); ArrayvCardOutData FNList; FNList = vCardObj->GetByPartial(wxT("FN")); @@ -179,4 +179,12 @@ wxString frmContact::GetFilename(){ return vCardFilename; +} + +void frmContact::SetBackgroundColour(wxString backgroundColour){ + + // Set the background colour. + + this->backgroundColour = backgroundColour; + } \ No newline at end of file diff --git a/source/frmContact.h b/source/frmContact.h index a3a7b3c..2154f1a 100644 --- a/source/frmContact.h +++ b/source/frmContact.h @@ -40,6 +40,7 @@ class frmContact : public frmContactADT wxString OldSessionID; int ContactUID; wxString vCardFilename; + wxString backgroundColour; bool StartupMode; void CloseWindowProcessing(); @@ -53,6 +54,7 @@ class frmContact : public frmContactADT void SetupPointers(std::map *MemoryFSListIncPtr); void SetUID(int UID); void SetMode(bool StartupModeIn); + void SetBackgroundColour(wxString backgroundColour); wxString GetFilename(); DECLARE_EVENT_TABLE(); //// end generated class members diff --git a/source/frmMain.cpp b/source/frmMain.cpp index 4dc43f6..63f0015 100644 --- a/source/frmMain.cpp +++ b/source/frmMain.cpp @@ -1103,7 +1103,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]; } @@ -1349,6 +1349,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 +1407,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); @@ -1435,13 +1437,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); @@ -1494,7 +1503,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 +1643,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 +1753,7 @@ void frmMain::UpdateContactList(wxCommandEvent& event){ vCard UpdatedPerson; UpdatedPerson.LoadFile(ucd->ContactFilename); + frmContactPtr->SetBackgroundColour(ContactBackgroundColour.GetAsString(wxC2S_CSS_SYNTAX)); frmContactPtr->SetupContactData(&UpdatedPerson); } diff --git a/source/frmMain.h b/source/frmMain.h index 24f4032..ae5c3d0 100644 --- a/source/frmMain.h +++ b/source/frmMain.h @@ -152,7 +152,6 @@ class frmMain : public frmMainADT std::map WindowListPointersMenu; std::map WindowListPointers; std::map WindowListType; - //std::map WindowListType; wxMenuItem *mnuContactWindows; wxMenuItem *mnuContactEditorWindows; wxMenuItem *mnuSearchWindows; @@ -160,15 +159,11 @@ class frmMain : public frmMainADT bool RevealWait = FALSE; wxString SessionID; wxString OldSessionID; + wxColour ContactBackgroundColour; wxIcon IconEmp; - //wxIcon Emp; - //wxComboCtrl* AccControl = new wxGenericComboCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize); - //wxComboCtrl* AccControl = new wxComboCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCB_READONLY|wxEXPAND|wxCC_STD_BUTTON); - //wxStaticBitmap* AccIcon = new wxStaticBitmap(this, wxID_ANY, IconEmp, wxDefaultPosition, wxSize(16,16), wxALL|wxEXPAND, wxStaticBitmapNameStr); XABAccountView* treAccounts = new XABAccountView(); wxImageList *AccImgList = new wxImageList(16,16,true); wxImageList *ActMgrImgList = new wxImageList(16,16,true); - //wxIcon wxIAccInet; int AccountID; int AccountNetID; int AccountGrpID; diff --git a/source/frmPreferences.cpp b/source/frmPreferences.cpp index b8757ba..f2a156a 100644 --- a/source/frmPreferences.cpp +++ b/source/frmPreferences.cpp @@ -325,19 +325,32 @@ void frmPreferences::LoadPreferences( wxInitDialogEvent& event ) bool SaveWindowPos = preferences->GetBoolData(wxT("SaveWindowPosition")); bool HideLocalABs = preferences->GetBoolData(wxT("HideLocalAddressBooks")); + bool UseBackgroundContactColour = preferences->GetBoolData(wxT("UseBackgroundContactColour")); - if (SaveWindowPos == TRUE){ + if (SaveWindowPos == true){ - chkSaveWindowPosition->SetValue(TRUE); + chkSaveWindowPosition->SetValue(true); } - if (HideLocalABs == TRUE){ + if (HideLocalABs == true){ - chkHideLocal->SetValue(TRUE); + chkHideLocal->SetValue(true); } + if (UseBackgroundContactColour == true){ + + chkUseBackgroundColour->SetValue(true); + std::cout << preferences->GetBackgroundContactColourData().GetAsString().ToStdString() << std::endl; + clpContactBackgroundColour->SetColour(preferences->GetBackgroundContactColourData()); + + } else { + + clpContactBackgroundColour->Enable(false); + + } + // Setup the Themes tab. wxListItem themecol0; @@ -474,6 +487,19 @@ void frmPreferences::SavePreferences(wxCommandEvent &event){ *ReloadAccountConfig = TRUE; } + + if (chkUseBackgroundColour->GetValue() == TRUE){ + + cfgfile->Write(wxT("UseBackgroundContactColour"), wxT("true")); + cfgfile->Write(wxT("BackgroundContactColour"), clpContactBackgroundColour->GetColour().GetAsString(wxC2S_HTML_SYNTAX)); + *ReloadAccountConfig = TRUE; + + } else { + + cfgfile->Write(wxT("UseBackgroundContactColour"), wxT("false")); + *ReloadAccountConfig = TRUE; + + } delete cfgfile; cfgfile = NULL; @@ -482,6 +508,16 @@ void frmPreferences::SavePreferences(wxCommandEvent &event){ } +void frmPreferences::EnableBackgroundColourPicker(wxCommandEvent &event){ + + if (chkUseBackgroundColour->GetValue() == true){ + clpContactBackgroundColour->Enable(true); + } else { + clpContactBackgroundColour->Enable(false); + } + +} + void frmPreferences::CloseWindow(wxCommandEvent &event){ // Close the preferences window. diff --git a/source/frmPreferences.h b/source/frmPreferences.h index 154a946..179d7a7 100644 --- a/source/frmPreferences.h +++ b/source/frmPreferences.h @@ -41,6 +41,7 @@ class frmPreferences : public frmPreferencesADT void ModifyABAccount( wxMouseEvent& event ); void SavePreferences( wxCommandEvent &event ); void AddABAccount( wxCommandEvent &event ); + void EnableBackgroundColourPicker( wxCommandEvent &event ); void CloseWindow( wxCommandEvent &event ); private: void ReloadAccounts();