X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2FfrmPreferences.cpp;h=e8e37540acef2289ae9fe9c3823406749676c381;hp=716fc7a35c687a3fe27ecc9389fbf6c2a9739821;hb=76214fdd5e820c60a468a62fa586749102310f21;hpb=08422295fa6a0695f6cd6d2da90b560342bec79f diff --git a/source/frmPreferences.cpp b/source/frmPreferences.cpp index 716fc7a..e8e3754 100644 --- a/source/frmPreferences.cpp +++ b/source/frmPreferences.cpp @@ -22,7 +22,7 @@ #include "frmMain.h" #include "common/preferences.h" #include "common/dirs.h" -#include "bitmaps.h" +#include "Bitmaps.h" #include "import/import.h" #include "export/export.h" @@ -33,7 +33,6 @@ #include #include - frmPreferences::frmPreferences( wxWindow* parent ) : frmPreferencesADT( parent ) @@ -43,6 +42,18 @@ frmPreferencesADT( parent ) wxMemoryInputStream astream(icons_accinet_png, sizeof(icons_accinet_png)); wxMemoryInputStream bstream(icons_acclocal_png, sizeof(icons_acclocal_png)); + wxMemoryInputStream cstream(icons_accunsupported_png, sizeof(icons_accunsupported_png)); + wxMemoryInputStream windowposstream(icons_windowpos_png, sizeof(icons_windowpos_png)); + wxMemoryInputStream hideaddressbooksstream(icons_hideaddressbooks_png, sizeof(icons_hideaddressbooks_png)); + + wxImage icons_windowpos_png(windowposstream, wxBITMAP_TYPE_PNG); + wxBitmap WindowPosition(icons_windowpos_png, -1); + + wxImage icons_hideaddressbooks_png(hideaddressbooksstream, wxBITMAP_TYPE_PNG); + wxBitmap HideAddressBooks(icons_hideaddressbooks_png, -1); + + bmpWindowPosition->SetBitmap(WindowPosition); + bmpLocalAddressBooks->SetBitmap(HideAddressBooks); wxImage icons_accinet_png(astream, wxBITMAP_TYPE_PNG); wxBitmap AccInet(icons_accinet_png, -1); @@ -53,9 +64,15 @@ frmPreferencesADT( parent ) wxBitmap AccNIcon(icons_acclocal_png, -1); wxIcon wxIAccNIcon; wxIAccNIcon.CopyFromBitmap(AccNIcon); + + wxImage icons_accunsupported_png(cstream, wxBITMAP_TYPE_PNG); + wxBitmap AccUIcon(icons_accunsupported_png, -1); + wxIcon wxIAccUIcon; + wxIAccUIcon.CopyFromBitmap(AccUIcon); AccountID = AccImgList->Add(wxIAccNIcon); AccountNetID = AccImgList->Add(wxIAccInet); + AccountUnsupportedID = AccImgList->Add(wxIAccUIcon); NbtPreferences->RemovePage(1); @@ -125,14 +142,37 @@ void frmPreferences::ModifyABAccount( wxCommandEvent& event ) long lstAccountsIndex = -1; wxString AccFilename = GetAccountsFile(); wxString AccName; + wxString AccType; - wxFileConfig *cfgfile = new wxFileConfig("", "", AccFilename); - - // Get the account name. - + // Check if an account has been selected before continuing. + lstAccountsIndex = lstAccounts->GetNextItem(lstAccountsIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + + if (lstAccountsIndex == -1){ + + // No account has been selected so exit this subroutine. + + return; + + } + + wxFileConfig *cfgfile = new wxFileConfig("", "", AccFilename); + + // Check that the account type is a supported account type. + + AccType = preferences->accounts.GetAccountType((int)lstAccountsIndex); + + if (AccType != "CardDAV" && AccType != "carddav" && + AccType != "Local" && AccType != "local"){ + + wxMessageBox(_("Cannot modify the selected account settings as the account type is unsupported."), _("Unsupported account type"), wxICON_ERROR); + return; + + } + + // Get the account name. AccName = preferences->accounts.GetAccountName((int)lstAccountsIndex); @@ -161,6 +201,14 @@ void frmPreferences::ModifyABAccount( wxCommandEvent& event ) } +void frmPreferences::ModifyABAccount( wxMouseEvent& event ) +{ + + wxCommandEvent NullEvent; + ModifyABAccount(NullEvent); + +} + void frmPreferences::DeleteABAccount( wxCommandEvent& event ) { // Display a confirmation dialog to confirm deletion. @@ -226,6 +274,10 @@ void frmPreferences::DeleteABAccount( wxCommandEvent& event ) AccountDirFull.Append(wxT("carddav")); + } else { + + AccountDirFull.Append(AccountType.Lower()); + } lstAccounts->DeleteItem(lstAccountsIndex); @@ -254,6 +306,9 @@ void frmPreferences::DeleteABAccount( wxCommandEvent& event ) } + btnAccountModify->Enable(FALSE); + btnAccountDelete->Enable(FALSE); + } void frmPreferences::LoadPreferences( wxInitDialogEvent& event ) @@ -270,19 +325,31 @@ 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); + clpContactBackgroundColour->SetColour(preferences->GetBackgroundContactColourData()); + + } else { + + clpContactBackgroundColour->Enable(false); + + } + // Setup the Themes tab. wxListItem themecol0; @@ -329,21 +396,6 @@ void frmPreferences::ReloadAccounts(){ accountscol2.SetWidth(96); lstAccounts->InsertColumn(2,accountscol2); - /*accountscol1.SetId(1); - accountscol1.SetText(_("")); - accountscol1.SetWidth(32); - lstAccounts->InsertColumn(1,accountscol1); - - accountscol2.SetId(2); - accountscol2.SetText(_("Name")); - accountscol2.SetWidth(224); - lstAccounts->InsertColumn(2,accountscol2); - - accountscol3.SetId(3); - accountscol3.SetText(_("Type")); - accountscol3.SetWidth(96); - lstAccounts->InsertColumn(3,accountscol3);*/ - wxString AccType; for (int i = 0; i < preferences->accounts.GetCount() ; i++){ @@ -359,19 +411,16 @@ void frmPreferences::ReloadAccounts(){ col0.SetImage(AccountID); + } else { + + col0.SetImage(AccountUnsupportedID); + } - - //col0.SetText( wxString::Format(wxT("%i"),i) ); - //col0.SetText(preferences.accounts.GetAccountName(i)); long itemindex = lstAccounts->InsertItem( col0 ); - //AccType = preferences.accounts.GetAccountType(i); - //AccType.Trim(); - lstAccounts->SetItem(itemindex, 1, preferences->accounts.GetAccountName(i)); lstAccounts->SetItem(itemindex, 2, preferences->accounts.GetAccountType(i)); - //lstAccounts->SetItem(itemindex, 3, AccType); } @@ -437,6 +486,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; @@ -445,10 +507,20 @@ 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. this->Close(); -} \ No newline at end of file +}