diff --git a/src/sbbs3/ctrl/ServicesCfgDlgUnit.cpp b/src/sbbs3/ctrl/ServicesCfgDlgUnit.cpp index db168051946e172454353e5b3ba752de2c73233b..c389dfe1a1825cd9bff859b0436b09088a3056bc 100644 --- a/src/sbbs3/ctrl/ServicesCfgDlgUnit.cpp +++ b/src/sbbs3/ctrl/ServicesCfgDlgUnit.cpp @@ -6,6 +6,7 @@ #include "MainFormUnit.h" #include "TextFileEditUnit.h" #include "ServicesCfgDlgUnit.h" +#include "CodeInputFormUnit.h" #include <stdio.h> // sprintf() #include <mmsystem.h> // sndPlaySound() //--------------------------------------------------------------------------- @@ -52,7 +53,6 @@ void __fastcall TServicesCfgDlg::FormShow(TObject *Sender) str_list_t services = iniGetSectionList(ini, NULL); CheckListBox->Items->BeginUpdate(); for(unsigned u=0; services!=NULL && services[u]!=NULL; u++) { - OutputDebugString(services[u]); CheckListBox->Items->Append(services[u]); } CheckListBox->Items->EndUpdate(); @@ -63,8 +63,19 @@ void __fastcall TServicesCfgDlg::FormShow(TObject *Sender) iniFreeStringList(section); } iniFreeStringList(services); - if(CheckListBox->Items->Count) + if(CheckListBox->Items->Count) { CheckListBox->ItemIndex=0; + CheckListBoxClick(Sender); + } + + str_list_t keys = iniGetKeyList(ini, ROOT_SECTION); + for(unsigned u=0; keys!=NULL && keys[u]!=NULL; u++) { + if(keys[u][0]) + GlobalValueListEditor->InsertRow(AnsiString(keys[u]) + ,AnsiString(iniGetString(ini,ROOT_SECTION,keys[u],"error",NULL)) + ,/* append: */true); + } + iniFreeStringList(keys); PageControl->ActivePage=GeneralTabSheet; } @@ -184,3 +195,50 @@ void __fastcall TServicesCfgDlg::ValueListEditorValidate(TObject *Sender, } //--------------------------------------------------------------------------- +void __fastcall TServicesCfgDlg::ServiceAddClick(TObject *Sender) +{ + Application->CreateForm(__classid(TCodeInputForm), &CodeInputForm); + CodeInputForm->Label->Caption="New Service Name"; + CodeInputForm->Edit->Visible=true; + if(CodeInputForm->ShowModal()==mrOk + && CodeInputForm->Edit->Text.Length() + && !iniSectionExists(ini,CodeInputForm->Edit->Text.c_str()) + && iniAppendSection(&ini,CodeInputForm->Edit->Text.c_str(),/* style: */NULL)) { + CheckListBox->Items->Append(CodeInputForm->Edit->Text); + CheckListBox->ItemIndex = CheckListBox->Items->Count-1; + CheckListBoxClick(Sender); + } + delete CodeInputForm; +} +//--------------------------------------------------------------------------- + +void __fastcall TServicesCfgDlg::ServiceRemoveClick(TObject *Sender) +{ + if(CheckListBox->ItemIndex >= 0 + && iniRemoveSection(&ini,CheckListBox->Items->Strings[CheckListBox->ItemIndex].c_str())) { + CheckListBox->DeleteSelected(); + CheckListBoxClick(Sender); + } +} +//--------------------------------------------------------------------------- + +void __fastcall TServicesCfgDlg::CheckListBoxKeyDown(TObject *Sender, + WORD &Key, TShiftState Shift) +{ + if(Key==VK_INSERT) + ServiceAddClick(Sender); + else if(Key==VK_DELETE) + ServiceRemoveClick(Sender); +} +//--------------------------------------------------------------------------- + +void __fastcall TServicesCfgDlg::GlobalValueListEditorValidate( + TObject *Sender, int ACol, int ARow, const AnsiString KeyName, + const AnsiString KeyValue) +{ + iniSetString(&ini + ,ROOT_SECTION + ,KeyName.c_str(), KeyValue.c_str(), /* style: */NULL); +} +//--------------------------------------------------------------------------- + diff --git a/src/sbbs3/ctrl/ServicesCfgDlgUnit.dfm b/src/sbbs3/ctrl/ServicesCfgDlgUnit.dfm index 16b0ef7d273a080b69ecd65b768d663b6df15c92..004b6fea899f8618eb9af30776575d26e6d89453 100644 --- a/src/sbbs3/ctrl/ServicesCfgDlgUnit.dfm +++ b/src/sbbs3/ctrl/ServicesCfgDlgUnit.dfm @@ -95,6 +95,22 @@ object ServicesCfgDlg: TServicesCfgDlg ShowHint = True TabOrder = 1 end + object GlobalValueListEditor: TValueListEditor + Left = 8 + Top = 88 + Width = 250 + Height = 75 + Hint = 'Global settings for services' + KeyOptions = [keyEdit, keyAdd, keyDelete, keyUnique] + Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goEditing, goThumbTracking] + ParentShowHint = False + ShowHint = True + TabOrder = 3 + OnValidate = GlobalValueListEditorValidate + ColWidths = ( + 99 + 145) + end end object SoundTabSheet: TTabSheet Caption = 'Sound' @@ -165,9 +181,11 @@ object ServicesCfgDlg: TServicesCfgDlg Hint = 'Services and their enabled/disabled state' ItemHeight = 13 ParentShowHint = False + PopupMenu = ServicesCfgPopupMenu ShowHint = True TabOrder = 0 OnClick = CheckListBoxClick + OnKeyDown = CheckListBoxKeyDown end object ValueListEditor: TValueListEditor Left = 8 @@ -260,4 +278,18 @@ object ServicesCfgDlg: TServicesCfgDlg Left = 104 Top = 64 end + object ServicesCfgPopupMenu: TPopupMenu + Left = 176 + Top = 48 + object ServiceAdd: TMenuItem + Caption = 'Add' + Hint = 'Add a new service' + OnClick = ServiceAddClick + end + object ServiceRemove: TMenuItem + Caption = 'Remove' + Hint = 'Remove the selected service' + OnClick = ServiceRemoveClick + end + end end diff --git a/src/sbbs3/ctrl/ServicesCfgDlgUnit.h b/src/sbbs3/ctrl/ServicesCfgDlgUnit.h index 39e76104424b388f887be6ff3ae04f6808d3c11c..363c8799992865f875d531e3889c2fe596472b45 100644 --- a/src/sbbs3/ctrl/ServicesCfgDlgUnit.h +++ b/src/sbbs3/ctrl/ServicesCfgDlgUnit.h @@ -41,6 +41,10 @@ __published: // IDE-managed Components TTabSheet *EnableTabSheet; TCheckListBox *CheckListBox; TValueListEditor *ValueListEditor; + TPopupMenu *ServicesCfgPopupMenu; + TMenuItem *ServiceAdd; + TMenuItem *ServiceRemove; + TValueListEditor *GlobalValueListEditor; void __fastcall FormShow(TObject *Sender); void __fastcall OKButtonClick(TObject *Sender); void __fastcall AnswerSoundButtonClick(TObject *Sender); @@ -49,6 +53,13 @@ __published: // IDE-managed Components void __fastcall CheckListBoxClick(TObject *Sender); void __fastcall ValueListEditorValidate(TObject *Sender, int ACol, int ARow, const AnsiString KeyName, const AnsiString KeyValue); + void __fastcall ServiceAddClick(TObject *Sender); + void __fastcall ServiceRemoveClick(TObject *Sender); + void __fastcall CheckListBoxKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall GlobalValueListEditorValidate(TObject *Sender, + int ACol, int ARow, const AnsiString KeyName, + const AnsiString KeyValue); private: // User declarations char iniFilename[MAX_PATH+1]; str_list_t ini;