CreateDirectory.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //---------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <CoreMain.h>
  5. #include <Configuration.h>
  6. #include <RemoteFiles.h>
  7. #include <VCLCommon.h>
  8. #include <TextsWin.h>
  9. #include <Common.h>
  10. #include <WinInterface.h>
  11. #include <Tools.h>
  12. #include "CreateDirectory.h"
  13. #include "WinConfiguration.h"
  14. //---------------------------------------------------------------------
  15. #pragma link "MoreButton"
  16. #pragma link "RightsExt"
  17. #pragma link "Rights"
  18. #pragma resource "*.dfm"
  19. //---------------------------------------------------------------------
  20. bool __fastcall DoCreateDirectoryDialog(AnsiString & Directory,
  21. TRemoteProperties * Properties, bool & SaveSettings)
  22. {
  23. bool Result;
  24. TCreateDirectoryDialog * Dialog = new TCreateDirectoryDialog(Application);
  25. try
  26. {
  27. Result = Dialog->Execute(Directory, Properties, SaveSettings);
  28. }
  29. __finally
  30. {
  31. delete Dialog;
  32. }
  33. return Result;
  34. }
  35. //---------------------------------------------------------------------
  36. __fastcall TCreateDirectoryDialog::TCreateDirectoryDialog(TComponent * AOwner):
  37. TForm(AOwner)
  38. {
  39. UseSystemSettings(this);
  40. InstallPathWordBreakProc(DirectoryEdit);
  41. RightsFrame->AllowAddXToDirectories = false;
  42. }
  43. //---------------------------------------------------------------------
  44. __fastcall TCreateDirectoryDialog::~TCreateDirectoryDialog()
  45. {
  46. }
  47. //---------------------------------------------------------------------------
  48. void __fastcall TCreateDirectoryDialog::ControlChange(TObject * /*Sender*/)
  49. {
  50. UpdateControls();
  51. }
  52. //---------------------------------------------------------------------------
  53. void __fastcall TCreateDirectoryDialog::UpdateControls()
  54. {
  55. EnableControl(OKBtn, !DirectoryEdit->Text.Trim().IsEmpty());
  56. EnableControl(RightsFrame, SetRightsCheck->Checked);
  57. }
  58. //---------------------------------------------------------------------------
  59. bool __fastcall TCreateDirectoryDialog::Execute(AnsiString & Directory,
  60. TRemoteProperties * Properties, bool & SaveSettings)
  61. {
  62. DirectoryEdit->Text = Directory;
  63. SaveSettingsCheck->Checked = SaveSettings;
  64. if (Properties != NULL)
  65. {
  66. bool SetRights = Properties->Valid.Contains(vpRights);
  67. SetRightsCheck->Checked = SetRights;
  68. // expect sensible value even if rights are not set valid
  69. RightsFrame->Rights = Properties->Rights;
  70. MoreButton->Expanded = GUIConfiguration->CopyParamDialogExpanded;
  71. }
  72. else
  73. {
  74. MoreButton->Expanded = false;
  75. MoreButton->Visible = false;
  76. }
  77. bool Result = (ShowModal() != mrCancel);
  78. if (Result)
  79. {
  80. Directory = DirectoryEdit->Text;
  81. SaveSettings = SaveSettingsCheck->Checked;
  82. if (Properties != NULL)
  83. {
  84. if (SetRightsCheck->Checked)
  85. {
  86. Properties->Valid = Properties->Valid << vpRights;
  87. Properties->Rights = RightsFrame->Rights;
  88. }
  89. else
  90. {
  91. Properties->Valid = Properties->Valid >> vpRights;
  92. }
  93. GUIConfiguration->CopyParamDialogExpanded = MoreButton->Expanded;
  94. }
  95. }
  96. return Result;
  97. }
  98. //---------------------------------------------------------------------------
  99. void __fastcall TCreateDirectoryDialog::DirectoryEditChange(TObject * /*Sender*/)
  100. {
  101. UpdateControls();
  102. }
  103. //---------------------------------------------------------------------------
  104. void __fastcall TCreateDirectoryDialog::FormShow(TObject * /*Sender*/)
  105. {
  106. UpdateControls();
  107. }
  108. //---------------------------------------------------------------------------
  109. void __fastcall TCreateDirectoryDialog::HelpButtonClick(TObject * /*Sender*/)
  110. {
  111. FormHelp(this);
  112. }
  113. //---------------------------------------------------------------------------
  114. void __fastcall TCreateDirectoryDialog::FormCloseQuery(TObject * /*Sender*/,
  115. bool & /*CanClose*/)
  116. {
  117. if (ModalResult != mrCancel)
  118. {
  119. ExitActiveControl(this);
  120. }
  121. }
  122. //---------------------------------------------------------------------------