Preferences.cpp 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116
  1. //---------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <StrUtils.hpp>
  5. #include <Common.h>
  6. #include <math.h>
  7. #include "Preferences.h"
  8. #include <CoreMain.h>
  9. #include <Terminal.h>
  10. #include <Bookmarks.h>
  11. #include "VCLCommon.h"
  12. #include "GUITools.h"
  13. #include "Tools.h"
  14. #include "TextsWin.h"
  15. #include "HelpWin.h"
  16. #include "WinInterface.h"
  17. #include "WinConfiguration.h"
  18. #include "Setup.h"
  19. #include "ProgParams.h"
  20. //---------------------------------------------------------------------
  21. #pragma link "CopyParams"
  22. #pragma link "UpDownEdit"
  23. #pragma link "ComboEdit"
  24. #ifndef NO_RESOURCES
  25. #pragma link "HistoryComboBox"
  26. #pragma resource "*.dfm"
  27. #endif
  28. //---------------------------------------------------------------------
  29. bool __fastcall DoPreferencesDialog(TPreferencesMode APreferencesMode,
  30. TPreferencesDialogData * DialogData)
  31. {
  32. bool Result;
  33. TPreferencesDialog * PreferencesDialog =
  34. new TPreferencesDialog(GetFormOwner(), APreferencesMode);
  35. try
  36. {
  37. Result = PreferencesDialog->Execute(DialogData);
  38. if (Result)
  39. {
  40. Configuration->SaveExplicit();
  41. }
  42. }
  43. __finally
  44. {
  45. delete PreferencesDialog;
  46. }
  47. return Result;
  48. }
  49. //---------------------------------------------------------------------
  50. __fastcall TPreferencesDialog::TPreferencesDialog(
  51. TComponent* AOwner, TPreferencesMode PreferencesMode)
  52. : TForm(AOwner)
  53. {
  54. SetCorrectFormParent(this);
  55. FNoUpdate = 0;
  56. FPreferencesMode = PreferencesMode;
  57. FEditorFont = new TFont();
  58. FEditorFont->Color = clWindowText;
  59. // color tends to reset in object inspector
  60. EditorFontLabel->Color = clWindow;
  61. // currently useless
  62. FAfterFilenameEditDialog = false;
  63. FCustomCommandList = new TCustomCommandList();
  64. FCustomCommandChanging = false;
  65. FListViewDragDest = -1;
  66. FCopyParamList = new TCopyParamList();
  67. FEditorList = new TEditorList();
  68. UseSystemSettings(this);
  69. FCustomCommandsScrollOnDragOver = new TListViewScrollOnDragOver(CustomCommandsView, true);
  70. FCopyParamScrollOnDragOver = new TListViewScrollOnDragOver(CopyParamListView, true);
  71. FEditorScrollOnDragOver = new TListViewScrollOnDragOver(EditorListView3, true);
  72. ComboAutoSwitchInitialize(UpdatesBetaVersionsCombo);
  73. EnableControl(UpdatesBetaVersionsCombo, !WinConfiguration->IsBeta);
  74. EnableControl(UpdatesBetaVersionsLabel, UpdatesBetaVersionsCombo->Enabled);
  75. HintLabel(LogFileNameHintText, LoadStr(LOG_FILE_HINT3));
  76. HintLabel(ActionsLogFileNameHintText, LoadStr(LOG_FILE_HINT3));
  77. HintLabel(ShellIconsText2);
  78. HotTrackLabel(CopyParamLabel);
  79. HintLabel(PuttyPathHintText, LoadStr(PUTTY_PATTERNS_HINT));
  80. EditorEncodingCombo->Items->Add(DefaultEncodingName());
  81. EditorEncodingCombo->Items->Add(LoadStr(UTF8_NAME));
  82. std::unique_ptr<TStrings> Workspaces(StoredSessions->GetWorkspaces());
  83. AutoWorkspaceCombo->Items->AddStrings(Workspaces.get());
  84. AutoSaveWorkspacePasswordsCheck->Caption = LoadStr(SAVE_WORKSPACE_PASSWORDS);
  85. PuttyRegistryStorageKeyEdit->Items->Add(OriginalPuttyRegistryStorageKey);
  86. PuttyRegistryStorageKeyEdit->Items->Add(KittyRegistryStorageKey);
  87. MenuButton(RegisterAsUrlHandlersButton);
  88. }
  89. //---------------------------------------------------------------------------
  90. __fastcall TPreferencesDialog::~TPreferencesDialog()
  91. {
  92. SAFE_DESTROY(FEditorScrollOnDragOver);
  93. SAFE_DESTROY(FCopyParamScrollOnDragOver);
  94. SAFE_DESTROY(FCustomCommandsScrollOnDragOver);
  95. SAFE_DESTROY(FEditorFont);
  96. delete FCustomCommandList;
  97. FCustomCommandList = NULL;
  98. delete FCopyParamList;
  99. FCopyParamList = NULL;
  100. delete FEditorList;
  101. FEditorList = NULL;
  102. }
  103. //---------------------------------------------------------------------
  104. bool __fastcall TPreferencesDialog::Execute(TPreferencesDialogData * DialogData)
  105. {
  106. PuttyPathEdit->Items = CustomWinConfiguration->History[L"PuttyPath"];
  107. FDialogData = DialogData;
  108. LoadConfiguration();
  109. bool Result = (ShowModal() == DefaultResult(this));
  110. if (Result)
  111. {
  112. SaveConfiguration();
  113. CustomWinConfiguration->History[L"PuttyPath"] = PuttyPathEdit->Items;
  114. }
  115. return Result;
  116. }
  117. //---------------------------------------------------------------------------
  118. void __fastcall TPreferencesDialog::LoadLanguages()
  119. {
  120. if (!FLanguagesLoaded)
  121. {
  122. LanguagesView->Items->Clear();
  123. TStrings * Locales = GUIConfiguration->Locales;
  124. for (int Index = 0; Index < Locales->Count; Index++)
  125. {
  126. TListItem * Item = LanguagesView->Items->Add();
  127. Item->Caption = Locales->Strings[Index];
  128. Item->Data = Locales->Objects[Index];
  129. Item->Focused =
  130. (reinterpret_cast<LCID>(Locales->Objects[Index]) == GUIConfiguration->Locale);
  131. Item->Selected = Item->Focused;
  132. }
  133. FLanguagesLoaded = false;
  134. }
  135. }
  136. //---------------------------------------------------------------------------
  137. TTabSheet * __fastcall TPreferencesDialog::FindPageForTreeNode(TTreeNode * Node)
  138. {
  139. for (int pi = 0; pi < PageControl->PageCount; pi++)
  140. {
  141. TTabSheet * Sheet = PageControl->Pages[pi];
  142. if (Sheet->Tag == Node->SelectedIndex)
  143. {
  144. return Sheet;
  145. }
  146. }
  147. FAIL;
  148. return NULL;
  149. }
  150. //---------------------------------------------------------------------------
  151. void __fastcall TPreferencesDialog::PrepareNavigationTree(TTreeView * Tree)
  152. {
  153. Tree->FullExpand();
  154. int i = 0;
  155. while (i < Tree->Items->Count)
  156. {
  157. TTreeNode * Node = Tree->Items->Item[i];
  158. TTabSheet * Sheet = FindPageForTreeNode(Node);
  159. if (NOT_NULL(Sheet))
  160. {
  161. if (Sheet->Enabled)
  162. {
  163. // gets called multiple times occasionally
  164. // (e.g. when called from upload dialog invoked by /upload)
  165. if (!Sheet->Caption.IsEmpty())
  166. {
  167. Node->Text = Sheet->Caption;
  168. Sheet->Caption = L"";
  169. }
  170. }
  171. else
  172. {
  173. Tree->Items->Delete(Node);
  174. i--;
  175. }
  176. }
  177. i++;
  178. }
  179. }
  180. //---------------------------------------------------------------------------
  181. void __fastcall TPreferencesDialog::LoadConfiguration()
  182. {
  183. FNoUpdate++;
  184. try
  185. {
  186. #define BOOLPROP(PROP) PROP ## Check->Checked = WinConfiguration->PROP;
  187. BOOLPROP(DefaultDirIsHome);
  188. BOOLPROP(PreservePanelState);
  189. BOOLPROP(DeleteToRecycleBin);
  190. BOOLPROP(DDTransferConfirmation);
  191. BOOLPROP(DDWarnLackOfTempSpace);
  192. BOOLPROP(ShowHiddenFiles);
  193. BOOLPROP(FormatSizeBytes);
  194. BOOLPROP(RenameWholeName);
  195. BOOLPROP(ShowInaccesibleDirectories);
  196. BOOLPROP(CopyOnDoubleClickConfirmation);
  197. BOOLPROP(ConfirmTransferring);
  198. BOOLPROP(ConfirmOverwriting);
  199. BOOLPROP(ConfirmResume);
  200. BOOLPROP(ConfirmDeleting);
  201. BOOLPROP(ConfirmRecycling);
  202. BOOLPROP(ConfirmClosingSession);
  203. BOOLPROP(ConfirmExitOnCompletion);
  204. BOOLPROP(ConfirmCommandSession);
  205. BOOLPROP(ContinueOnError);
  206. BOOLPROP(DDAllowMoveInit);
  207. BOOLPROP(BeepOnFinish);
  208. BOOLPROP(TemporaryDirectoryAppendSession);
  209. BOOLPROP(TemporaryDirectoryAppendPath);
  210. BOOLPROP(TemporaryDirectoryCleanup);
  211. BOOLPROP(ConfirmTemporaryDirectoryCleanup);
  212. BOOLPROP(FullRowSelect);
  213. if (WinConfiguration->DDTransferConfirmation == asAuto)
  214. {
  215. // allow greayed state only initially,
  216. // once the off state is confirmed, never allow returning
  217. // to the undefined state
  218. DDTransferConfirmationCheck->AllowGrayed = true;
  219. }
  220. CheckBoxAutoSwitchLoad(DDTransferConfirmationCheck, WinConfiguration->DDTransferConfirmation);
  221. BeepOnFinishAfterEdit->AsInteger =
  222. int(static_cast<double>(GUIConfiguration->BeepOnFinishAfter) * SecsPerDay);
  223. BOOLPROP(BalloonNotifications);
  224. DDExtEnabledButton->Checked = WinConfiguration->DDExtEnabled;
  225. DDExtDisabledButton->Checked = !DDExtEnabledButton->Checked;
  226. DDWarnOnMoveCheck->Checked = !WinConfiguration->DDAllowMove;
  227. if (WinConfiguration->DDTemporaryDirectory.IsEmpty())
  228. {
  229. DDSystemTemporaryDirectoryButton->Checked = true;
  230. DDTemporaryDirectoryEdit->Text = SystemTemporaryDirectory();
  231. }
  232. else
  233. {
  234. DDCustomTemporaryDirectoryButton->Checked = true;
  235. DDTemporaryDirectoryEdit->Text = WinConfiguration->DDTemporaryDirectory;
  236. }
  237. // Commander
  238. if (WinConfiguration->ScpCommander.NortonLikeMode == nlOff)
  239. {
  240. NortonLikeModeCombo->ItemIndex = 2;
  241. }
  242. else if (WinConfiguration->ScpCommander.NortonLikeMode == nlKeyboard)
  243. {
  244. NortonLikeModeCombo->ItemIndex = 1;
  245. }
  246. else
  247. {
  248. NortonLikeModeCombo->ItemIndex = 0;
  249. }
  250. SwappedPanelsCheck->Checked =
  251. WinConfiguration->ScpCommander.SwappedPanels;
  252. TreeOnLeftCheck->Checked = WinConfiguration->ScpCommander.TreeOnLeft;
  253. ExplorerKeyboardShortcutsCombo->ItemIndex =
  254. WinConfiguration->ScpCommander.ExplorerKeyboardShortcuts ? 1 : 0;
  255. BOOLPROP(UseLocationProfiles);
  256. CompareByTimeCheck->Checked = WinConfiguration->ScpCommander.CompareByTime;
  257. CompareBySizeCheck->Checked = WinConfiguration->ScpCommander.CompareBySize;
  258. // Local panel
  259. PreserveLocalDirectoryCheck->Checked =
  260. WinConfiguration->ScpCommander.PreserveLocalDirectory;
  261. SystemContextMenuCheck->Checked =
  262. WinConfiguration->ScpCommander.SystemContextMenu;
  263. // Explorer
  264. ShowFullAddressCheck->Checked =
  265. WinConfiguration->ScpExplorer.ShowFullAddress;
  266. // select none when stNul
  267. RegistryStorageButton->Checked = (Configuration->Storage == stRegistry);
  268. IniFileStorageButton2->Checked = (Configuration->Storage == stIniFile);
  269. RandomSeedFileEdit->Text = Configuration->RandomSeedFile;
  270. // editor
  271. EditorWordWrapCheck->Checked = WinConfiguration->Editor.WordWrap;
  272. EditorTabSizeEdit->AsInteger = WinConfiguration->Editor.TabSize;
  273. if (WinConfiguration->Editor.Encoding == CP_UTF8)
  274. {
  275. EditorEncodingCombo->ItemIndex = 1;
  276. }
  277. else
  278. {
  279. EditorEncodingCombo->ItemIndex = 0;
  280. }
  281. FEditorFont->Name = WinConfiguration->Editor.FontName;
  282. FEditorFont->Size = WinConfiguration->Editor.FontSize;
  283. FEditorFont->Charset = (TFontCharset)WinConfiguration->Editor.FontCharset;
  284. FEditorFont->Style = IntToFontStyles(WinConfiguration->Editor.FontStyle);
  285. (*FEditorList) = *WinConfiguration->EditorList;
  286. UpdateEditorListView();
  287. FCopyParams = GUIConfiguration->DefaultCopyParam;
  288. ResumeOnButton->Checked = GUIConfiguration->DefaultCopyParam.ResumeSupport == rsOn;
  289. ResumeSmartButton->Checked = GUIConfiguration->DefaultCopyParam.ResumeSupport == rsSmart;
  290. ResumeOffButton->Checked = GUIConfiguration->DefaultCopyParam.ResumeSupport == rsOff;
  291. ResumeThresholdEdit->Value = GUIConfiguration->DefaultCopyParam.ResumeThreshold / 1024;
  292. SessionReopenAutoCheck->Checked = (Configuration->SessionReopenAuto > 0);
  293. SessionReopenAutoEdit->Value = (Configuration->SessionReopenAuto > 0 ?
  294. (Configuration->SessionReopenAuto / MSecsPerSec) : 5);
  295. SessionReopenAutoIdleCheck->Checked = (GUIConfiguration->SessionReopenAutoIdle > 0);
  296. SessionReopenAutoIdleEdit->Value = (GUIConfiguration->SessionReopenAutoIdle > 0 ?
  297. (GUIConfiguration->SessionReopenAutoIdle / MSecsPerSec) : 5);
  298. SessionReopenAutoStallCheck->Checked = (Configuration->SessionReopenAutoStall > 0);
  299. SessionReopenAutoStallEdit->Value = (Configuration->SessionReopenAutoStall > 0 ?
  300. (Configuration->SessionReopenAutoStall / MSecsPerSec) : SecsPerMin);
  301. SessionReopenTimeoutEdit->Value = (Configuration->SessionReopenTimeout / MSecsPerSec);
  302. GeneralSheet->Enabled = WinConfiguration->ExpertMode;
  303. ExplorerSheet->Enabled = WinConfiguration->ExpertMode;
  304. CommanderSheet->Enabled = WinConfiguration->ExpertMode;
  305. EditorSheet->Enabled = WinConfiguration->ExpertMode && !WinConfiguration->DisableOpenEdit;
  306. StorageGroup->Visible = WinConfiguration->ExpertMode;
  307. RandomSeedFileLabel->Visible = WinConfiguration->ExpertMode;
  308. RandomSeedFileEdit->Visible = WinConfiguration->ExpertMode;
  309. FCustomCommandList->Assign(WinConfiguration->CustomCommandList);
  310. UpdateCustomCommandsView();
  311. PuttyPathEdit->Text = GUIConfiguration->PuttyPath;
  312. PuttyPasswordCheck2->Checked = GUIConfiguration->PuttyPassword;
  313. AutoOpenInPuttyCheck->Checked = WinConfiguration->AutoOpenInPutty;
  314. TelnetForFtpInPuttyCheck->Checked = WinConfiguration->TelnetForFtpInPutty;
  315. SelectPuttyRegistryStorageKey(GUIConfiguration->PuttyRegistryStorageKey);
  316. // Queue
  317. QueueTransferLimitEdit->AsInteger = GUIConfiguration->QueueTransfersLimit;
  318. EnableQueueByDefaultCheck->Checked = WinConfiguration->EnableQueueByDefault;
  319. QueueAutoPopupCheck->Checked = GUIConfiguration->QueueAutoPopup;
  320. QueueCheck->Checked = GUIConfiguration->DefaultCopyParam.Queue;
  321. QueueIndividuallyCheck->Checked = GUIConfiguration->DefaultCopyParam.QueueIndividually;
  322. QueueNoConfirmationCheck->Checked = GUIConfiguration->DefaultCopyParam.QueueNoConfirmation;
  323. if (!GUIConfiguration->QueueKeepDoneItems)
  324. {
  325. QueueKeepDoneItemsForCombo->ItemIndex = 0;
  326. }
  327. else if (GUIConfiguration->QueueKeepDoneItemsFor < 0)
  328. {
  329. QueueKeepDoneItemsForCombo->ItemIndex = 5;
  330. }
  331. else if (GUIConfiguration->QueueKeepDoneItemsFor <= 15)
  332. {
  333. QueueKeepDoneItemsForCombo->ItemIndex = 1;
  334. }
  335. else if (GUIConfiguration->QueueKeepDoneItemsFor <= 60)
  336. {
  337. QueueKeepDoneItemsForCombo->ItemIndex = 2;
  338. }
  339. else if (GUIConfiguration->QueueKeepDoneItemsFor <= 15 * 60)
  340. {
  341. QueueKeepDoneItemsForCombo->ItemIndex = 3;
  342. }
  343. else if (GUIConfiguration->QueueKeepDoneItemsFor <= 60 * 60)
  344. {
  345. QueueKeepDoneItemsForCombo->ItemIndex = 4;
  346. }
  347. if (WinConfiguration->QueueView.Show == qvShow)
  348. {
  349. QueueViewShowButton->Checked = true;
  350. }
  351. else if (WinConfiguration->QueueView.Show == qvHideWhenEmpty)
  352. {
  353. QueueViewHideWhenEmptyButton->Checked = true;
  354. }
  355. else
  356. {
  357. QueueViewHideButton->Checked = true;
  358. }
  359. // window
  360. AutoSaveWorkspaceCheck->Checked = WinConfiguration->AutoSaveWorkspace;
  361. AutoWorkspaceCombo->Text =
  362. DefaultStr(WinConfiguration->AutoWorkspace,
  363. // It will rarely happen that LastWorkspace is set, while AutoWorkspace not.
  364. // It can happen only when user saved workspace before opening the Preferences
  365. // dialog for the first time
  366. DefaultStr(WinConfiguration->LastWorkspace, LoadStr(NEW_WORKSPACE)));
  367. AutoSaveWorkspacePasswordsCheck->Checked = WinConfiguration->AutoSaveWorkspacePasswords;
  368. if (WinConfiguration->PathInCaption == picFull)
  369. {
  370. PathInCaptionFullButton->Checked = true;
  371. }
  372. else if (WinConfiguration->PathInCaption == picShort)
  373. {
  374. PathInCaptionShortButton->Checked = true;
  375. }
  376. else
  377. {
  378. PathInCaptionNoneButton->Checked = true;
  379. }
  380. BOOLPROP(MinimizeToTray);
  381. // panels
  382. DoubleClickActionCombo->ItemIndex = WinConfiguration->DoubleClickAction;
  383. BOOLPROP(AutoReadDirectoryAfterOp);
  384. BOOLPROP(RefreshRemotePanel);
  385. RefreshRemotePanelIntervalEdit->Value =
  386. int(static_cast<double>(WinConfiguration->RefreshRemotePanelInterval) * SecsPerDay);
  387. // updates
  388. TUpdatesConfiguration Updates = WinConfiguration->Updates;
  389. if (int(Updates.Period) <= 0)
  390. {
  391. UpdatesPeriodCombo->ItemIndex = 0;
  392. }
  393. else if (int(Updates.Period) <= 1)
  394. {
  395. UpdatesPeriodCombo->ItemIndex = 1;
  396. }
  397. else if (int(Updates.Period) <= 7)
  398. {
  399. UpdatesPeriodCombo->ItemIndex = 2;
  400. }
  401. else
  402. {
  403. UpdatesPeriodCombo->ItemIndex = 3;
  404. }
  405. CollectUsageCheck->Checked = Configuration->CollectUsage;
  406. ComboAutoSwitchLoad(UpdatesBetaVersionsCombo, Updates.BetaVersions);
  407. switch (Updates.ConnectionType)
  408. {
  409. case ctDirect:
  410. default:
  411. UpdatesDirectCheck->Checked = true;
  412. break;
  413. case ctAuto:
  414. UpdatesAutoCheck->Checked = true;
  415. break;
  416. case ctProxy:
  417. UpdatesProxyCheck->Checked = true;
  418. break;
  419. }
  420. UpdatesProxyHostEdit->Text = Updates.ProxyHost;
  421. UpdatesProxyPortEdit->AsInteger = Updates.ProxyPort;
  422. // presets
  423. (*FCopyParamList) = *WinConfiguration->CopyParamList;
  424. UpdateCopyParamListView();
  425. CopyParamListView->ItemIndex = 0;
  426. BOOLPROP(CopyParamAutoSelectNotice);
  427. // interface
  428. switch (CustomWinConfiguration->Interface)
  429. {
  430. case ifCommander:
  431. CommanderInterfaceButton2->Checked = true;
  432. break;
  433. case ifExplorer:
  434. ExplorerInterfaceButton2->Checked = true;
  435. break;
  436. default:
  437. FAIL;
  438. break;
  439. }
  440. if (WinConfiguration->Theme == L"OfficeXP")
  441. {
  442. ThemeCombo->ItemIndex = 1;
  443. }
  444. else if (WinConfiguration->Theme == L"Office2003")
  445. {
  446. ThemeCombo->ItemIndex = 2;
  447. }
  448. else
  449. {
  450. ThemeCombo->ItemIndex = 0;
  451. }
  452. // security
  453. UseMasterPasswordCheck->Checked = WinConfiguration->UseMasterPassword;
  454. SessionRememberPasswordCheck->Checked = GUIConfiguration->SessionRememberPassword;
  455. // network
  456. RetrieveExternalIpAddressButton->Checked = Configuration->ExternalIpAddress.IsEmpty();
  457. CustomExternalIpAddressButton->Checked = !RetrieveExternalIpAddressButton->Checked;
  458. CustomExternalIpAddressEdit->Text = Configuration->ExternalIpAddress;
  459. TryFtpWhenSshFailsCheck->Checked = Configuration->TryFtpWhenSshFails;
  460. // logging
  461. EnableLoggingCheck->Checked = Configuration->Logging;
  462. LogProtocolCombo->ItemIndex = Configuration->LogProtocol;
  463. LogToFileCheck->Checked = Configuration->LogToFile;
  464. LogFileNameEdit3->Text =
  465. !Configuration->LogFileName.IsEmpty() ? Configuration->LogFileName : Configuration->DefaultLogFileName;
  466. if (Configuration->LogFileAppend)
  467. {
  468. LogFileAppendButton->Checked = true;
  469. }
  470. else
  471. {
  472. LogFileOverwriteButton->Checked = true;
  473. }
  474. LogShowWindowCheck->Checked = (CustomWinConfiguration->LogView == lvWindow);
  475. if (Configuration->LogWindowComplete)
  476. {
  477. LogWindowCompleteButton->Checked = true;
  478. }
  479. else
  480. {
  481. LogWindowLinesButton->Checked = true;
  482. }
  483. if (!Configuration->LogWindowComplete)
  484. {
  485. LogWindowLinesEdit->AsInteger = Configuration->LogWindowLines;
  486. }
  487. else
  488. {
  489. LogWindowLinesEdit->AsInteger = 500;
  490. }
  491. EnableActionsLoggingCheck->Checked = Configuration->LogActions;
  492. ActionsLogFileNameEdit->Text = Configuration->ActionsLogFileName;
  493. #undef BOOLPROP
  494. }
  495. __finally
  496. {
  497. FNoUpdate--;
  498. }
  499. UpdateControls();
  500. }
  501. //---------------------------------------------------------------------------
  502. void __fastcall TPreferencesDialog::SaveConfiguration()
  503. {
  504. Configuration->BeginUpdate();
  505. try
  506. {
  507. TGUICopyParamType CopyParam = GUIConfiguration->DefaultCopyParam;
  508. #define BOOLPROP(PROP) WinConfiguration->PROP = PROP ## Check->Checked
  509. BOOLPROP(DefaultDirIsHome);
  510. BOOLPROP(PreservePanelState);
  511. BOOLPROP(DeleteToRecycleBin);
  512. BOOLPROP(DDWarnLackOfTempSpace);
  513. BOOLPROP(ShowHiddenFiles);
  514. BOOLPROP(FormatSizeBytes);
  515. BOOLPROP(RenameWholeName);
  516. BOOLPROP(ShowInaccesibleDirectories);
  517. BOOLPROP(CopyOnDoubleClickConfirmation);
  518. BOOLPROP(ConfirmTransferring);
  519. BOOLPROP(ConfirmOverwriting);
  520. BOOLPROP(ConfirmResume);
  521. BOOLPROP(ConfirmDeleting);
  522. BOOLPROP(ConfirmRecycling);
  523. BOOLPROP(ConfirmClosingSession);
  524. BOOLPROP(ConfirmExitOnCompletion);
  525. BOOLPROP(ConfirmCommandSession);
  526. BOOLPROP(ContinueOnError);
  527. BOOLPROP(DDAllowMoveInit);
  528. BOOLPROP(BeepOnFinish);
  529. BOOLPROP(TemporaryDirectoryAppendSession);
  530. BOOLPROP(TemporaryDirectoryAppendPath);
  531. BOOLPROP(TemporaryDirectoryCleanup);
  532. BOOLPROP(ConfirmTemporaryDirectoryCleanup);
  533. BOOLPROP(FullRowSelect);
  534. WinConfiguration->DDTransferConfirmation =
  535. CheckBoxAutoSwitchSave(DDTransferConfirmationCheck);
  536. GUIConfiguration->BeepOnFinishAfter =
  537. static_cast<double>(BeepOnFinishAfterEdit->Value / SecsPerDay);
  538. BOOLPROP(BalloonNotifications);
  539. WinConfiguration->DDAllowMove = !DDWarnOnMoveCheck->Checked;
  540. WinConfiguration->DDExtEnabled = DDExtEnabledButton->Checked;
  541. if (DDSystemTemporaryDirectoryButton->Checked)
  542. {
  543. WinConfiguration->DDTemporaryDirectory = L"";
  544. }
  545. else
  546. {
  547. WinConfiguration->DDTemporaryDirectory = DDTemporaryDirectoryEdit->Text;
  548. }
  549. // Commander
  550. TScpCommanderConfiguration ScpCommander = WinConfiguration->ScpCommander;
  551. if (NortonLikeModeCombo->ItemIndex == 2)
  552. {
  553. ScpCommander.NortonLikeMode = nlOff;
  554. }
  555. else if (NortonLikeModeCombo->ItemIndex == 1)
  556. {
  557. ScpCommander.NortonLikeMode = nlKeyboard;
  558. }
  559. else
  560. {
  561. ScpCommander.NortonLikeMode = nlOn;
  562. }
  563. ScpCommander.SwappedPanels = SwappedPanelsCheck->Checked;
  564. ScpCommander.TreeOnLeft = TreeOnLeftCheck->Checked;
  565. ScpCommander.ExplorerKeyboardShortcuts =
  566. (ExplorerKeyboardShortcutsCombo->ItemIndex != 0);
  567. BOOLPROP(UseLocationProfiles);
  568. ScpCommander.CompareByTime = CompareByTimeCheck->Checked;
  569. ScpCommander.CompareBySize = CompareBySizeCheck->Checked;
  570. // Local panel
  571. ScpCommander.PreserveLocalDirectory = PreserveLocalDirectoryCheck->Checked;
  572. ScpCommander.SystemContextMenu = SystemContextMenuCheck->Checked;
  573. WinConfiguration->ScpCommander = ScpCommander;
  574. // Explorer
  575. TScpExplorerConfiguration ScpExplorer = WinConfiguration->ScpExplorer;
  576. ScpExplorer.ShowFullAddress = ShowFullAddressCheck->Checked;
  577. WinConfiguration->ScpExplorer = ScpExplorer;
  578. Configuration->RandomSeedFile = RandomSeedFileEdit->Text;
  579. // editor
  580. WinConfiguration->Editor.WordWrap = EditorWordWrapCheck->Checked;
  581. WinConfiguration->Editor.TabSize = EditorTabSizeEdit->AsInteger;
  582. switch (EditorEncodingCombo->ItemIndex)
  583. {
  584. case 1:
  585. WinConfiguration->Editor.Encoding = CP_UTF8;
  586. break;
  587. default:
  588. WinConfiguration->Editor.Encoding = CP_ACP;
  589. break;
  590. }
  591. WinConfiguration->Editor.FontName = FEditorFont->Name;
  592. WinConfiguration->Editor.FontSize = FEditorFont->Size;
  593. WinConfiguration->Editor.FontCharset = FEditorFont->Charset;
  594. WinConfiguration->Editor.FontStyle = FontStylesToInt(FEditorFont->Style);
  595. WinConfiguration->EditorList = FEditorList;
  596. // overwrites only TCopyParamType fields
  597. CopyParam = FCopyParams;
  598. if (ResumeOnButton->Checked) CopyParam.ResumeSupport = rsOn;
  599. if (ResumeSmartButton->Checked) CopyParam.ResumeSupport = rsSmart;
  600. if (ResumeOffButton->Checked) CopyParam.ResumeSupport = rsOff;
  601. CopyParam.ResumeThreshold = ResumeThresholdEdit->AsInteger * 1024;
  602. Configuration->SessionReopenAuto =
  603. (SessionReopenAutoCheck->Checked ? (SessionReopenAutoEdit->AsInteger * MSecsPerSec) : 0);
  604. GUIConfiguration->SessionReopenAutoIdle =
  605. (SessionReopenAutoIdleCheck->Checked ? (SessionReopenAutoIdleEdit->AsInteger * MSecsPerSec) : 0);
  606. Configuration->SessionReopenAutoStall =
  607. (SessionReopenAutoStallCheck->Checked ? (SessionReopenAutoStallEdit->AsInteger * MSecsPerSec) : 0);
  608. Configuration->SessionReopenTimeout = (SessionReopenTimeoutEdit->AsInteger * MSecsPerSec);
  609. WinConfiguration->CustomCommandList = FCustomCommandList;
  610. GUIConfiguration->PuttyPath = PuttyPathEdit->Text;
  611. GUIConfiguration->PuttyPassword = PuttyPasswordCheck2->Checked;
  612. WinConfiguration->AutoOpenInPutty = AutoOpenInPuttyCheck->Checked;
  613. WinConfiguration->TelnetForFtpInPutty = TelnetForFtpInPuttyCheck->Checked;
  614. // do not overwrite custom keys
  615. if (PuttyRegistryStorageKeyEdit->ItemIndex >= 0)
  616. {
  617. GUIConfiguration->PuttyRegistryStorageKey = PuttyRegistryStorageKeyEdit->Text;
  618. }
  619. // Queue
  620. GUIConfiguration->QueueTransfersLimit = QueueTransferLimitEdit->AsInteger;
  621. WinConfiguration->EnableQueueByDefault = EnableQueueByDefaultCheck->Checked;
  622. GUIConfiguration->QueueAutoPopup = QueueAutoPopupCheck->Checked;
  623. CopyParam.Queue = QueueCheck->Checked;
  624. CopyParam.QueueIndividually = QueueIndividuallyCheck->Checked;
  625. CopyParam.QueueNoConfirmation = QueueNoConfirmationCheck->Checked;
  626. GUIConfiguration->QueueKeepDoneItems = (QueueKeepDoneItemsForCombo->ItemIndex != 0);
  627. switch (QueueKeepDoneItemsForCombo->ItemIndex)
  628. {
  629. case 0:
  630. GUIConfiguration->QueueKeepDoneItemsFor = 0;
  631. break;
  632. case 1:
  633. GUIConfiguration->QueueKeepDoneItemsFor = 15;
  634. break;
  635. case 2:
  636. GUIConfiguration->QueueKeepDoneItemsFor = 60;
  637. break;
  638. case 3:
  639. GUIConfiguration->QueueKeepDoneItemsFor = 15 * 60;
  640. break;
  641. case 4:
  642. GUIConfiguration->QueueKeepDoneItemsFor = 60 * 60;
  643. break;
  644. default:
  645. GUIConfiguration->QueueKeepDoneItemsFor = -1;
  646. break;
  647. }
  648. if (QueueViewShowButton->Checked)
  649. {
  650. WinConfiguration->QueueView.Show = qvShow;
  651. }
  652. else if (QueueViewHideWhenEmptyButton->Checked)
  653. {
  654. WinConfiguration->QueueView.Show = qvHideWhenEmpty;
  655. }
  656. else
  657. {
  658. WinConfiguration->QueueView.Show = qvHide;
  659. }
  660. GUIConfiguration->DefaultCopyParam = CopyParam;
  661. // window
  662. WinConfiguration->AutoSaveWorkspace =
  663. !AutoWorkspaceCombo->Text.IsEmpty() &&
  664. AutoSaveWorkspaceCheck->Checked;
  665. if (!AutoWorkspaceCombo->Text.IsEmpty())
  666. {
  667. WinConfiguration->AutoWorkspace = AutoWorkspaceCombo->Text;
  668. }
  669. WinConfiguration->AutoSaveWorkspacePasswords = AutoSaveWorkspacePasswordsCheck->Checked;
  670. if (PathInCaptionFullButton->Checked)
  671. {
  672. WinConfiguration->PathInCaption = picFull;
  673. }
  674. else if (PathInCaptionShortButton->Checked)
  675. {
  676. WinConfiguration->PathInCaption = picShort;
  677. }
  678. else
  679. {
  680. WinConfiguration->PathInCaption = picNone;
  681. }
  682. BOOLPROP(MinimizeToTray);
  683. // panels
  684. WinConfiguration->DoubleClickAction = (TDoubleClickAction)DoubleClickActionCombo->ItemIndex;
  685. BOOLPROP(AutoReadDirectoryAfterOp);
  686. BOOLPROP(RefreshRemotePanel);
  687. WinConfiguration->RefreshRemotePanelInterval =
  688. static_cast<double>(RefreshRemotePanelIntervalEdit->Value / SecsPerDay);
  689. // updates
  690. TUpdatesConfiguration Updates = WinConfiguration->Updates;
  691. if (UpdatesPeriodCombo->ItemIndex == 0)
  692. {
  693. Updates.Period = 0;
  694. }
  695. else if (UpdatesPeriodCombo->ItemIndex == 1)
  696. {
  697. Updates.Period = 1;
  698. }
  699. else if (UpdatesPeriodCombo->ItemIndex == 2)
  700. {
  701. Updates.Period = 7;
  702. }
  703. else
  704. {
  705. Updates.Period = 30;
  706. }
  707. Configuration->CollectUsage = CollectUsageCheck->Checked;
  708. Updates.BetaVersions = ComboAutoSwitchSave(UpdatesBetaVersionsCombo);
  709. if (UpdatesDirectCheck->Checked)
  710. {
  711. Updates.ConnectionType = ctDirect;
  712. }
  713. else if (UpdatesAutoCheck->Checked)
  714. {
  715. Updates.ConnectionType = ctAuto;
  716. }
  717. else if (UpdatesProxyCheck->Checked)
  718. {
  719. if (!UpdatesProxyHostEdit->Text.IsEmpty())
  720. {
  721. Updates.ConnectionType = ctProxy;
  722. }
  723. else
  724. {
  725. Updates.ConnectionType = ctDirect;
  726. }
  727. }
  728. Updates.ProxyHost = UpdatesProxyHostEdit->Text;
  729. Updates.ProxyPort = UpdatesProxyPortEdit->AsInteger;
  730. WinConfiguration->Updates = Updates;
  731. // presets
  732. WinConfiguration->CopyParamList = FCopyParamList;
  733. BOOLPROP(CopyParamAutoSelectNotice);
  734. // interface
  735. if (GetInterface() != CustomWinConfiguration->Interface)
  736. {
  737. Configuration->Usage->Inc(L"InterfaceChanges");
  738. }
  739. CustomWinConfiguration->Interface = GetInterface();
  740. if (ThemeCombo->ItemIndex == 1)
  741. {
  742. WinConfiguration->Theme = L"OfficeXP";
  743. }
  744. else if (ThemeCombo->ItemIndex == 2)
  745. {
  746. WinConfiguration->Theme = L"Office2003";
  747. }
  748. else
  749. {
  750. WinConfiguration->Theme = L"Default";
  751. }
  752. // network
  753. Configuration->ExternalIpAddress =
  754. (CustomExternalIpAddressButton->Checked ? CustomExternalIpAddressEdit->Text : UnicodeString());
  755. Configuration->TryFtpWhenSshFails = TryFtpWhenSshFailsCheck->Checked;
  756. // security
  757. GUIConfiguration->SessionRememberPassword = SessionRememberPasswordCheck->Checked;
  758. // logging
  759. Configuration->Logging = EnableLoggingCheck->Checked;
  760. Configuration->LogProtocol = LogProtocolCombo->ItemIndex;
  761. Configuration->LogFileName = LogToFileCheck->Checked ? LogFileNameEdit3->Text : UnicodeString();
  762. Configuration->LogFileAppend = LogFileAppendButton->Checked;
  763. CustomWinConfiguration->LogView = LogShowWindowCheck->Checked ? lvWindow : lvNone;
  764. Configuration->LogWindowComplete = LogWindowCompleteButton->Checked;
  765. if (!LogWindowCompleteButton->Checked)
  766. {
  767. Configuration->LogWindowLines = LogWindowLinesEdit->AsInteger;
  768. }
  769. Configuration->LogActions = EnableActionsLoggingCheck->Checked;
  770. Configuration->ActionsLogFileName = ActionsLogFileNameEdit->Text;
  771. // languages
  772. // As this dialog does not explicitly support run-time locale changing,
  773. // make this last, otherwise we lose some settings (or even worse
  774. // we end-up saving default text box values=control names as our configuration)
  775. if (LanguagesView->ItemFocused != NULL)
  776. {
  777. GUIConfiguration->Locale =
  778. reinterpret_cast<LCID>(LanguagesView->ItemFocused->Data);
  779. }
  780. // This possibly fails, make it last, so that the other settings are preserved.
  781. // Do nothing when no option is selected (i.e. storage is stNul).
  782. if (RegistryStorageButton->Checked)
  783. {
  784. Configuration->Storage = stRegistry;
  785. }
  786. else if (IniFileStorageButton2->Checked)
  787. {
  788. Configuration->Storage = stIniFile;
  789. }
  790. #undef BOOLPROP
  791. }
  792. __finally
  793. {
  794. Configuration->EndUpdate();
  795. }
  796. }
  797. //---------------------------------------------------------------------------
  798. TInterface __fastcall TPreferencesDialog::GetInterface()
  799. {
  800. return CommanderInterfaceButton2->Checked ? ifCommander : ifExplorer;
  801. }
  802. //---------------------------------------------------------------------------
  803. void __fastcall TPreferencesDialog::FormShow(TObject * /*Sender*/)
  804. {
  805. InstallPathWordBreakProc(RandomSeedFileEdit);
  806. InstallPathWordBreakProc(DDTemporaryDirectoryEdit);
  807. InstallPathWordBreakProc(PuttyPathEdit);
  808. InstallPathWordBreakProc(LogFileNameEdit3);
  809. InstallPathWordBreakProc(ActionsLogFileNameEdit);
  810. PrepareNavigationTree(NavigationTree);
  811. switch (FPreferencesMode) {
  812. case pmEditor: PageControl->ActivePage = EditorSheet; break;
  813. case pmCustomCommands: PageControl->ActivePage = CustomCommandsSheet; break;
  814. case pmQueue: PageControl->ActivePage = QueueSheet; break;
  815. case pmLogging: PageControl->ActivePage = LogSheet; break;
  816. case pmUpdates: PageControl->ActivePage = UpdatesSheet; break;
  817. case pmPresets: PageControl->ActivePage = CopyParamListSheet; break;
  818. case pmEditors: PageControl->ActivePage = EditorSheet; break;
  819. default: PageControl->ActivePage = PreferencesSheet; break;
  820. }
  821. PageControlChange(NULL);
  822. }
  823. //---------------------------------------------------------------------------
  824. void __fastcall TPreferencesDialog::ControlChange(TObject * /*Sender*/)
  825. {
  826. UpdateControls();
  827. }
  828. //---------------------------------------------------------------------------
  829. UnicodeString __fastcall TPreferencesDialog::TabSample(UnicodeString Values)
  830. {
  831. UnicodeString Result;
  832. for (int Index = 1; Index <= Values.Length(); Index++)
  833. {
  834. if (Index > 1)
  835. {
  836. Result += L' ';
  837. if (EditorTabSizeEdit->AsInteger > 2)
  838. {
  839. Result += UnicodeString::StringOfChar(L' ', EditorTabSizeEdit->AsInteger - 2);
  840. }
  841. }
  842. Result += Values[Index];
  843. }
  844. return Result;
  845. }
  846. //---------------------------------------------------------------------------
  847. void __fastcall TPreferencesDialog::UpdateControls()
  848. {
  849. if (FNoUpdate == 0)
  850. {
  851. EnableControl(BeepOnFinishAfterEdit, BeepOnFinishCheck->Checked);
  852. EnableControl(BeepOnFinishAfterText, BeepOnFinishCheck->Checked);
  853. EnableControl(ResumeThresholdEdit, ResumeSmartButton->Checked);
  854. EnableControl(ResumeThresholdUnitLabel, ResumeThresholdEdit->Enabled);
  855. EnableControl(SessionReopenAutoEdit, SessionReopenAutoCheck->Checked);
  856. EnableControl(SessionReopenAutoLabel, SessionReopenAutoEdit->Enabled);
  857. EnableControl(SessionReopenAutoSecLabel, SessionReopenAutoEdit->Enabled);
  858. EnableControl(SessionReopenAutoIdleEdit, SessionReopenAutoIdleCheck->Checked);
  859. EnableControl(SessionReopenAutoIdleLabel, SessionReopenAutoIdleEdit->Enabled);
  860. EnableControl(SessionReopenAutoIdleSecLabel, SessionReopenAutoIdleEdit->Enabled);
  861. EnableControl(SessionReopenAutoStallEdit, SessionReopenAutoStallCheck->Checked);
  862. EnableControl(SessionReopenAutoStallLabel, SessionReopenAutoStallEdit->Enabled);
  863. EnableControl(SessionReopenAutoStallSecLabel, SessionReopenAutoStallEdit->Enabled);
  864. EnableControl(SessionReopenTimeoutEdit,
  865. SessionReopenAutoEdit->Enabled || SessionReopenAutoStallCheck->Checked);
  866. EnableControl(SessionReopenTimeoutLabel, SessionReopenTimeoutEdit->Enabled);
  867. EnableControl(SessionReopenTimeoutSecLabel,SessionReopenTimeoutEdit->Enabled);
  868. EnableControl(CopyOnDoubleClickConfirmationCheck,
  869. (DoubleClickActionCombo->ItemIndex == 1) && ConfirmTransferringCheck->Checked);
  870. EnableControl(RefreshRemotePanelIntervalEdit, RefreshRemotePanelCheck->Checked);
  871. EnableControl(RefreshRemoteDirectoryUnitLabel, RefreshRemotePanelCheck->Checked);
  872. UnicodeString EditorFontLabelText;
  873. EditorFontLabelText = FMTLOAD(EDITOR_FONT_FMT,
  874. (FEditorFont->Name, FEditorFont->Size)) + L"\n\n";
  875. EditorFontLabelText += TabSample(L"ABCD") + L"\n";
  876. EditorFontLabelText += TabSample(L"1234");
  877. EditorFontLabel->Caption = EditorFontLabelText;
  878. EditorFontLabel->Font = FEditorFont;
  879. bool CommandSelected = (CustomCommandsView->Selected != NULL);
  880. EnableControl(EditCommandButton, CommandSelected);
  881. EnableControl(RemoveCommandButton, CommandSelected);
  882. EnableControl(UpCommandButton, CommandSelected &&
  883. CustomCommandsView->ItemIndex > 0);
  884. EnableControl(DownCommandButton, CommandSelected &&
  885. (CustomCommandsView->ItemIndex < CustomCommandsView->Items->Count - 1));
  886. bool CopyParamSelected = (CopyParamListView->Selected != NULL);
  887. EnableControl(EditCopyParamButton, CopyParamSelected);
  888. EnableControl(DuplicateCopyParamButton, CopyParamSelected);
  889. EnableControl(RemoveCopyParamButton,
  890. CopyParamSelected && (CopyParamListView->ItemIndex >= 1));
  891. EnableControl(UpCopyParamButton,
  892. CopyParamSelected && (CopyParamListView->ItemIndex > 1));
  893. EnableControl(DownCopyParamButton,
  894. CopyParamSelected &&
  895. (CopyParamListView->ItemIndex >= 1) &&
  896. (CopyParamListView->ItemIndex < CopyParamListView->Items->Count - 1));
  897. EnableControl(CopyParamAutoSelectNoticeCheck, FCopyParamList->AnyRule);
  898. UnicodeString InfoStr;
  899. if (CopyParamSelected)
  900. {
  901. const TCopyParamType * SelectedCopyParam = GetCopyParam(CopyParamListView->ItemIndex);
  902. InfoStr = SelectedCopyParam->GetInfoStr(L"; ", 0);
  903. if (CopyParamListView->ItemIndex >= 1)
  904. {
  905. const TCopyParamRule * Rule = FCopyParamList->Rules[CopyParamListView->ItemIndex - 1];
  906. if (Rule != NULL)
  907. {
  908. InfoStr += L"\n" + FORMAT(ReplaceStr(LoadStr(COPY_PARAM_RULE), L"\n", L" "), (Rule->GetInfoStr(L"; ")));
  909. }
  910. }
  911. }
  912. CopyParamLabel->Caption = InfoStr;
  913. CopyParamLabel->Hint = InfoStr;
  914. CopyParamLabel->ShowHint =
  915. (CopyParamLabel->Canvas->TextWidth(InfoStr) > (CopyParamLabel->Width * 3 / 2));
  916. EnableControl(DDExtEnabledButton, WinConfiguration->DDExtInstalled);
  917. EnableControl(DDExtEnabledLabel, WinConfiguration->DDExtInstalled);
  918. EnableControl(DDExtDisabledPanel, DDExtDisabledButton->Checked);
  919. EnableControl(DDTemporaryDirectoryEdit, DDCustomTemporaryDirectoryButton->Enabled &&
  920. DDCustomTemporaryDirectoryButton->Checked);
  921. EnableControl(DDWarnOnMoveCheck, DDExtDisabledButton->Checked &&
  922. DDAllowMoveInitCheck->Checked);
  923. EnableControl(ConfirmTemporaryDirectoryCleanupCheck,
  924. TemporaryDirectoryCleanupCheck->Checked);
  925. // allow only when some of the known storages is selected,
  926. // and particularly do not allow switching storage, when we start with stNul,
  927. // as that would destroy the stored configuration
  928. EnableControl(StorageGroup, RegistryStorageButton->Checked || IniFileStorageButton2->Checked);
  929. IniFileStorageButton2->Caption =
  930. AnsiReplaceStr(IniFileStorageButton2->Caption, L"winscp.ini",
  931. ExpandEnvironmentVariables(Configuration->IniFileStorageName));
  932. EditorFontLabel->WordWrap = EditorWordWrapCheck->Checked;
  933. bool EditorSelected = (EditorListView3->Selected != NULL);
  934. EnableControl(EditEditorButton, EditorSelected);
  935. EnableControl(RemoveEditorButton, EditorSelected);
  936. EnableControl(UpEditorButton, EditorSelected &&
  937. (EditorListView3->ItemIndex > 0));
  938. EnableControl(DownEditorButton, EditorSelected &&
  939. (EditorListView3->ItemIndex < EditorListView3->Items->Count - 1));
  940. EnableControl(UsageViewButton, CollectUsageCheck->Checked);
  941. EnableControl(UpdatesProxyHostEdit, UpdatesProxyCheck->Checked);
  942. EnableControl(UpdatesProxyHostLabel, UpdatesProxyHostEdit->Enabled);
  943. EnableControl(UpdatesProxyPortEdit, UpdatesProxyCheck->Checked);
  944. EnableControl(UpdatesProxyPortLabel, UpdatesProxyPortEdit->Enabled);
  945. bool IsSiteCommand = false;
  946. try
  947. {
  948. TRemoteCustomCommand RemoteCustomCommand;
  949. TInteractiveCustomCommand InteractiveCustomCommand(&RemoteCustomCommand);
  950. UnicodeString PuttyPath = PuttyPathEdit->Text;
  951. PuttyPath = InteractiveCustomCommand.Complete(PuttyPath, false);
  952. IsSiteCommand = RemoteCustomCommand.IsSiteCommand(PuttyPath);
  953. }
  954. catch (...)
  955. {
  956. // noop
  957. }
  958. EnableControl(PuttyPasswordCheck2, !PuttyPathEdit->Text.IsEmpty());
  959. EnableControl(AutoOpenInPuttyCheck, PuttyPasswordCheck2->Enabled);
  960. EnableControl(TelnetForFtpInPuttyCheck,
  961. PuttyPasswordCheck2->Enabled && !IsSiteCommand);
  962. EnableControl(PuttyRegistryStorageKeyEdit,
  963. PuttyPasswordCheck2->Enabled && !IsSiteCommand);
  964. EnableControl(PuttyRegistryStorageKeyLabel, PuttyRegistryStorageKeyEdit->Enabled);
  965. EnableControl(SetMasterPasswordButton, WinConfiguration->UseMasterPassword);
  966. // network
  967. EnableControl(CustomExternalIpAddressEdit, CustomExternalIpAddressButton->Checked);
  968. // window
  969. EnableControl(AutoWorkspaceCombo, AutoSaveWorkspaceCheck->Checked);
  970. EnableControl(AutoWorkspaceLabel, AutoWorkspaceCombo->Enabled);
  971. EnableControl(AutoSaveWorkspacePasswordsCheck,
  972. !Configuration->DisablePasswordStoring &&
  973. AutoWorkspaceCombo->Enabled);
  974. // integration
  975. // There's no quick launch in Windows 7
  976. EnableControl(QuickLaunchIconButton, !::IsWin7());
  977. MakeDefaultHandlerItem->Visible = IsWinVista();
  978. // languages
  979. LanguageChangeLabel->Visible =
  980. !GUIConfiguration->CanApplyLocaleImmediately &&
  981. (LanguagesView->ItemFocused != NULL) &&
  982. (reinterpret_cast<LCID>(LanguagesView->ItemFocused->Data) != GUIConfiguration->AppliedLocale);
  983. // logging
  984. EnableControl(LogProtocolCombo, EnableLoggingCheck->Checked);
  985. EnableControl(LogToFileCheck, LogProtocolCombo->Enabled);
  986. EnableControl(LogFileNameEdit3, LogToFileCheck->Enabled && LogToFileCheck->Checked);
  987. EnableControl(LogFileNameHintText, LogFileNameEdit3->Enabled);
  988. EnableControl(LogFileAppendButton, LogFileNameEdit3->Enabled);
  989. EnableControl(LogFileOverwriteButton, LogFileNameEdit3->Enabled);
  990. EnableControl(LogShowWindowCheck, LogProtocolCombo->Enabled);
  991. EnableControl(LogWindowCompleteButton, LogShowWindowCheck->Enabled && LogShowWindowCheck->Checked);
  992. EnableControl(LogWindowLinesButton, LogWindowCompleteButton->Enabled);
  993. EnableControl(LogWindowLinesEdit, LogWindowLinesButton->Enabled && LogWindowLinesButton->Checked);
  994. EnableControl(LogWindowLinesText, LogWindowLinesEdit->Enabled);
  995. EnableControl(ActionsLogFileNameEdit, EnableActionsLoggingCheck->Checked);
  996. EnableControl(ActionsLogFileNameHintText, ActionsLogFileNameEdit->Enabled);
  997. // interface
  998. InterfaceChangeLabel->Visible =
  999. !CustomWinConfiguration->CanApplyInterfaceImmediately &&
  1000. (GetInterface() != CustomWinConfiguration->AppliedInterface);
  1001. }
  1002. }
  1003. //---------------------------------------------------------------------------
  1004. void __fastcall TPreferencesDialog::EditorFontButtonClick(TObject * /*Sender*/)
  1005. {
  1006. if (FontDialog(FEditorFont))
  1007. {
  1008. UpdateControls();
  1009. }
  1010. }
  1011. //---------------------------------------------------------------------------
  1012. void __fastcall TPreferencesDialog::FormCloseQuery(TObject * /*Sender*/,
  1013. bool & /*CanClose*/)
  1014. {
  1015. if (ModalResult == DefaultResult(this))
  1016. {
  1017. ExitActiveControl(this);
  1018. }
  1019. }
  1020. //---------------------------------------------------------------------------
  1021. void __fastcall TPreferencesDialog::IconButtonClick(TObject *Sender)
  1022. {
  1023. UnicodeString IconName, Params;
  1024. int SpecialFolder;
  1025. if (Sender == DesktopIconButton)
  1026. {
  1027. IconName = AppName;
  1028. int Result =
  1029. MessageDialog(LoadStr(CREATE_DESKTOP_ICON2), qtConfirmation,
  1030. qaYes | qaNo | qaCancel, HELP_CREATE_ICON);
  1031. switch (Result)
  1032. {
  1033. case qaYes:
  1034. SpecialFolder = CSIDL_COMMON_DESKTOPDIRECTORY;
  1035. break;
  1036. case qaNo:
  1037. SpecialFolder = CSIDL_DESKTOPDIRECTORY;
  1038. break;
  1039. default:
  1040. Abort();
  1041. break;
  1042. }
  1043. }
  1044. else
  1045. {
  1046. if (MessageDialog(MainInstructions(LoadStr(CONFIRM_CREATE_ICON)),
  1047. qtConfirmation, qaYes | qaNo, HELP_CREATE_ICON) == qaYes)
  1048. {
  1049. if (Sender == SendToHookButton)
  1050. {
  1051. IconName = FMTLOAD(SENDTO_HOOK_NAME, (AppName));
  1052. SpecialFolder = CSIDL_SENDTO;
  1053. Params = TProgramParams::FormatSwitch(UPLOAD_SWITCH);
  1054. }
  1055. else if (Sender == QuickLaunchIconButton)
  1056. {
  1057. IconName = L"Microsoft\\Internet Explorer\\Quick Launch\\" +
  1058. AppName;
  1059. SpecialFolder = CSIDL_APPDATA;
  1060. }
  1061. }
  1062. else
  1063. {
  1064. Abort();
  1065. }
  1066. }
  1067. TInstantOperationVisualizer Visualizer;
  1068. CreateDesktopShortCut(IconName,
  1069. Application->ExeName, Params, L"", SpecialFolder);
  1070. }
  1071. //---------------------------------------------------------------------------
  1072. void __fastcall TPreferencesDialog::CustomCommandsViewData(TObject * /*Sender*/,
  1073. TListItem * Item)
  1074. {
  1075. // WORKAROUND We get here on Wine after destructor is called
  1076. if (FCustomCommandList != NULL)
  1077. {
  1078. int Index = Item->Index;
  1079. assert(Index >= 0 && Index <= FCustomCommandList->Count);
  1080. const TCustomCommandType * Command = FCustomCommandList->Commands[Index];
  1081. UnicodeString Caption = StripHotkey(Command->Name);
  1082. if (Command->ShortCut != 0)
  1083. {
  1084. Caption = FORMAT(L"%s (%s)", (Caption, ShortCutToText(Command->ShortCut)));
  1085. }
  1086. Item->Caption = Caption;
  1087. assert(!Item->SubItems->Count);
  1088. Item->SubItems->Add(Command->Command);
  1089. int Params = Command->Params;
  1090. Item->SubItems->Add(LoadStr(
  1091. FLAGSET(Params, ccLocal) ? CUSTOM_COMMAND_LOCAL : CUSTOM_COMMAND_REMOTE));
  1092. UnicodeString ParamsStr;
  1093. #define ADDPARAM(PARAM, STR) \
  1094. if (FLAGSET(Params, PARAM)) \
  1095. ParamsStr += (ParamsStr.IsEmpty() ? L"" : L"/") + LoadStr(STR);
  1096. ADDPARAM(ccApplyToDirectories, CUSTOM_COMMAND_DIRECTORIES);
  1097. ADDPARAM(ccRecursive, CUSTOM_COMMAND_RECURSE);
  1098. #undef ADDPARAM
  1099. Item->SubItems->Add(ParamsStr);
  1100. }
  1101. }
  1102. //---------------------------------------------------------------------------
  1103. void __fastcall TPreferencesDialog::ListViewSelectItem(
  1104. TObject * /*Sender*/, TListItem * /*Item*/, bool /*Selected*/)
  1105. {
  1106. UpdateControls();
  1107. }
  1108. //---------------------------------------------------------------------------
  1109. void __fastcall TPreferencesDialog::UpdateCustomCommandsView()
  1110. {
  1111. CustomCommandsView->Items->Count = FCustomCommandList->Count;
  1112. AdjustListColumnsWidth(CustomCommandsView);
  1113. CustomCommandsView->Invalidate();
  1114. }
  1115. //---------------------------------------------------------------------------
  1116. void __fastcall TPreferencesDialog::CustomCommandsViewKeyDown(
  1117. TObject * /*Sender*/, WORD & Key, TShiftState /*Shift*/)
  1118. {
  1119. if (RemoveCommandButton->Enabled && (Key == VK_DELETE))
  1120. {
  1121. RemoveCommandButtonClick(NULL);
  1122. }
  1123. if (AddCommandButton->Enabled && (Key == VK_INSERT))
  1124. {
  1125. AddEditCommandButtonClick(AddCommandButton);
  1126. }
  1127. }
  1128. //---------------------------------------------------------------------------
  1129. void __fastcall TPreferencesDialog::CustomCommandsViewDblClick(
  1130. TObject * /*Sender*/)
  1131. {
  1132. if (EditCommandButton->Enabled)
  1133. {
  1134. AddEditCommandButtonClick(EditCommandButton);
  1135. }
  1136. }
  1137. //---------------------------------------------------------------------------
  1138. void __fastcall TPreferencesDialog::AddEditCommandButtonClick(TObject * Sender)
  1139. {
  1140. bool Edit = (Sender == EditCommandButton);
  1141. TCustomCommandType Command;
  1142. if (Edit)
  1143. {
  1144. int Index = CustomCommandsView->ItemIndex;
  1145. assert(Index >= 0 && Index <= FCustomCommandList->Count);
  1146. Command = *FCustomCommandList->Commands[Index];
  1147. }
  1148. TShortCuts ShortCuts;
  1149. if (WinConfiguration->SharedBookmarks != NULL)
  1150. {
  1151. WinConfiguration->SharedBookmarks->ShortCuts(ShortCuts);
  1152. }
  1153. FCustomCommandList->ShortCuts(ShortCuts);
  1154. if (DoCustomCommandDialog(Command, FCustomCommandList,
  1155. (Edit ? ccmEdit : ccmAdd), 0, NULL, &ShortCuts))
  1156. {
  1157. int Index = CustomCommandsView->ItemIndex;
  1158. TCustomCommandType * ACommand = new TCustomCommandType(Command);
  1159. if (Edit)
  1160. {
  1161. FCustomCommandList->Change(Index, ACommand);
  1162. }
  1163. else
  1164. {
  1165. if (Index >= 0)
  1166. {
  1167. FCustomCommandList->Insert(Index, ACommand);
  1168. }
  1169. else
  1170. {
  1171. FCustomCommandList->Add(ACommand);
  1172. Index = FCustomCommandList->Count - 1;
  1173. }
  1174. }
  1175. UpdateCustomCommandsView();
  1176. CustomCommandsView->ItemIndex = Index;
  1177. UpdateControls();
  1178. }
  1179. }
  1180. //---------------------------------------------------------------------------
  1181. void __fastcall TPreferencesDialog::RemoveCommandButtonClick(
  1182. TObject * /*Sender*/)
  1183. {
  1184. assert(CustomCommandsView->ItemIndex >= 0 &&
  1185. CustomCommandsView->ItemIndex < FCustomCommandList->Count);
  1186. FCustomCommandList->Delete(CustomCommandsView->ItemIndex);
  1187. UpdateCustomCommandsView();
  1188. UpdateControls();
  1189. }
  1190. //---------------------------------------------------------------------------
  1191. void __fastcall TPreferencesDialog::CustomCommandMove(int Source, int Dest)
  1192. {
  1193. if (Source >= 0 && Source < FCustomCommandList->Count &&
  1194. Dest >= 0 && Dest < FCustomCommandList->Count)
  1195. {
  1196. FCustomCommandList->Move(Source, Dest);
  1197. // workaround for bug in VCL
  1198. CustomCommandsView->ItemIndex = -1;
  1199. CustomCommandsView->ItemFocused = CustomCommandsView->Selected;
  1200. CustomCommandsView->ItemIndex = Dest;
  1201. UpdateCustomCommandsView();
  1202. UpdateControls();
  1203. }
  1204. }
  1205. //---------------------------------------------------------------------------
  1206. void __fastcall TPreferencesDialog::UpDownCommandButtonClick(TObject * Sender)
  1207. {
  1208. CustomCommandMove(CustomCommandsView->ItemIndex,
  1209. CustomCommandsView->ItemIndex + (Sender == UpCommandButton ? -1 : 1));
  1210. }
  1211. //---------------------------------------------------------------------------
  1212. TListViewScrollOnDragOver * __fastcall TPreferencesDialog::ScrollOnDragOver(TObject * ListView)
  1213. {
  1214. if (ListView == CopyParamListView)
  1215. {
  1216. return FCopyParamScrollOnDragOver;
  1217. }
  1218. else if (ListView == CustomCommandsView)
  1219. {
  1220. return FCustomCommandsScrollOnDragOver;
  1221. }
  1222. else if (ListView == EditorListView3)
  1223. {
  1224. return FEditorScrollOnDragOver;
  1225. }
  1226. else
  1227. {
  1228. assert(false);
  1229. return NULL;
  1230. }
  1231. }
  1232. //---------------------------------------------------------------------------
  1233. void __fastcall TPreferencesDialog::ListViewStartDrag(
  1234. TObject * Sender, TDragObject *& /*DragObject*/)
  1235. {
  1236. FListViewDragSource = dynamic_cast<TListView*>(Sender)->ItemIndex;
  1237. FListViewDragDest = -1;
  1238. ScrollOnDragOver(Sender)->StartDrag();
  1239. }
  1240. //---------------------------------------------------------------------------
  1241. bool __fastcall TPreferencesDialog::AllowListViewDrag(TObject * Sender, int X, int Y)
  1242. {
  1243. TListItem * Item = dynamic_cast<TListView*>(Sender)->GetItemAt(X, Y);
  1244. FListViewDragDest = Item ? Item->Index : -1;
  1245. return (FListViewDragDest >= 0) && (FListViewDragDest != FListViewDragSource);
  1246. }
  1247. //---------------------------------------------------------------------------
  1248. void __fastcall TPreferencesDialog::CustomCommandsViewDragDrop(
  1249. TObject * Sender, TObject * Source, int X, int Y)
  1250. {
  1251. if (Source == CustomCommandsView)
  1252. {
  1253. if (AllowListViewDrag(Sender, X, Y))
  1254. {
  1255. CustomCommandMove(FListViewDragSource, FListViewDragDest);
  1256. }
  1257. }
  1258. }
  1259. //---------------------------------------------------------------------------
  1260. void __fastcall TPreferencesDialog::ListViewDragOver(
  1261. TObject * Sender, TObject * Source, int X, int Y,
  1262. TDragState /*State*/, bool & Accept)
  1263. {
  1264. if (Source == Sender)
  1265. {
  1266. // cannot use AllowListViewDrag(X, Y) because of bug in VCL
  1267. // (when dropped on item itself, when it was dragged over another item before,
  1268. // that another item remains highlighted forever)
  1269. Accept = true;
  1270. ScrollOnDragOver(Source)->DragOver(TPoint(X, Y));
  1271. }
  1272. }
  1273. //---------------------------------------------------------------------------
  1274. const TCopyParamType * TPreferencesDialog::GetCopyParam(int Index)
  1275. {
  1276. if (Index == 0)
  1277. {
  1278. return &FCopyParams;
  1279. }
  1280. else
  1281. {
  1282. return FCopyParamList->CopyParams[Index - 1];
  1283. }
  1284. }
  1285. //---------------------------------------------------------------------------
  1286. void __fastcall TPreferencesDialog::CopyParamMove(int Source, int Dest)
  1287. {
  1288. if (Source >= 1 && Source < (1 + FCopyParamList->Count) &&
  1289. Dest >= 0 && Dest < (1 + FCopyParamList->Count))
  1290. {
  1291. if (Dest == 0)
  1292. {
  1293. Dest = 1;
  1294. }
  1295. FCopyParamList->Move(Source - 1, Dest - 1);
  1296. // workaround for bug in VCL
  1297. CopyParamListView->ItemIndex = -1;
  1298. CopyParamListView->ItemFocused = CopyParamListView->Selected;
  1299. CopyParamListView->ItemIndex = Dest;
  1300. UpdateCopyParamListView();
  1301. UpdateControls();
  1302. }
  1303. }
  1304. //---------------------------------------------------------------------------
  1305. void __fastcall TPreferencesDialog::CopyParamListViewDragDrop(
  1306. TObject * Sender, TObject * Source, int X, int Y)
  1307. {
  1308. if (Source == CopyParamListView)
  1309. {
  1310. if (AllowListViewDrag(Sender, X, Y))
  1311. {
  1312. CopyParamMove(FListViewDragSource, FListViewDragDest);
  1313. }
  1314. }
  1315. }
  1316. //---------------------------------------------------------------------------
  1317. void __fastcall TPreferencesDialog::UpDownCopyParamButtonClick(TObject * Sender)
  1318. {
  1319. CopyParamMove(CopyParamListView->ItemIndex,
  1320. CopyParamListView->ItemIndex + (Sender == UpCopyParamButton ? -1 : 1));
  1321. }
  1322. //---------------------------------------------------------------------------
  1323. void __fastcall TPreferencesDialog::RemoveCopyParamButtonClick(
  1324. TObject * /*Sender*/)
  1325. {
  1326. assert(CopyParamListView->ItemIndex >= 1 &&
  1327. CopyParamListView->ItemIndex < (1 + FCopyParamList->Count));
  1328. FCopyParamList->Delete(CopyParamListView->ItemIndex - 1);
  1329. UpdateCopyParamListView();
  1330. UpdateControls();
  1331. }
  1332. //---------------------------------------------------------------------------
  1333. void __fastcall TPreferencesDialog::AddEditCopyParam(TCopyParamPresetMode Mode)
  1334. {
  1335. int Index = CopyParamListView->ItemIndex;
  1336. bool Result;
  1337. if ((Index == 0) && (Mode == cpmEdit))
  1338. {
  1339. Result = DoCopyParamCustomDialog(FCopyParams, 0);
  1340. }
  1341. else
  1342. {
  1343. TCopyParamRuleData * CopyParamRuleData =
  1344. (FDialogData != NULL ? FDialogData->CopyParamRuleData : NULL);
  1345. // negative (when default is selected) means add to the end
  1346. Index--;
  1347. Result = DoCopyParamPresetDialog(FCopyParamList, Index, Mode, CopyParamRuleData, FCopyParams);
  1348. if (Result)
  1349. {
  1350. UpdateCopyParamListView();
  1351. CopyParamListView->ItemIndex = Index + 1;
  1352. // when using duplicate button, focus remains on original item
  1353. CopyParamListView->ItemFocused = CopyParamListView->Selected;
  1354. }
  1355. }
  1356. if (Result)
  1357. {
  1358. UpdateControls();
  1359. }
  1360. }
  1361. //---------------------------------------------------------------------------
  1362. void __fastcall TPreferencesDialog::AddCopyParamButtonClick(TObject * /*Sender*/)
  1363. {
  1364. AddEditCopyParam(cpmAdd);
  1365. }
  1366. //---------------------------------------------------------------------------
  1367. void __fastcall TPreferencesDialog::EditCopyParamButtonClick(TObject * /*Sender*/)
  1368. {
  1369. AddEditCopyParam(cpmEdit);
  1370. }
  1371. //---------------------------------------------------------------------------
  1372. void __fastcall TPreferencesDialog::DuplicateCopyParamButtonClick(TObject * /*Sender*/)
  1373. {
  1374. AddEditCopyParam(cpmDuplicate);
  1375. }
  1376. //---------------------------------------------------------------------------
  1377. void __fastcall TPreferencesDialog::CopyParamListViewDblClick(
  1378. TObject * /*Sender*/)
  1379. {
  1380. if (EditCopyParamButton->Enabled)
  1381. {
  1382. AddEditCopyParam(cpmEdit);
  1383. }
  1384. }
  1385. //---------------------------------------------------------------------------
  1386. void __fastcall TPreferencesDialog::CopyParamListViewKeyDown(
  1387. TObject * /*Sender*/, WORD & Key, TShiftState /*Shift*/)
  1388. {
  1389. if (RemoveCopyParamButton->Enabled && (Key == VK_DELETE))
  1390. {
  1391. RemoveCopyParamButtonClick(NULL);
  1392. }
  1393. if (AddCopyParamButton->Enabled && (Key == VK_INSERT))
  1394. {
  1395. AddEditCopyParam(cpmAdd);
  1396. }
  1397. }
  1398. //---------------------------------------------------------------------------
  1399. void __fastcall TPreferencesDialog::EditorMove(int Source, int Dest)
  1400. {
  1401. if (Source >= 0 && Source < FEditorList->Count &&
  1402. Dest >= 0 && Dest < FEditorList->Count)
  1403. {
  1404. FEditorList->Move(Source, Dest);
  1405. // workaround for bug in VCL
  1406. EditorListView3->ItemIndex = -1;
  1407. EditorListView3->ItemFocused = EditorListView3->Selected;
  1408. EditorListView3->ItemIndex = Dest;
  1409. UpdateEditorListView();
  1410. UpdateControls();
  1411. }
  1412. }
  1413. //---------------------------------------------------------------------------
  1414. void __fastcall TPreferencesDialog::EditorListView3DragDrop(TObject * Sender,
  1415. TObject * Source, int X, int Y)
  1416. {
  1417. if (Source == EditorListView3)
  1418. {
  1419. if (AllowListViewDrag(Sender, X, Y))
  1420. {
  1421. EditorMove(FListViewDragSource, FListViewDragDest);
  1422. }
  1423. }
  1424. }
  1425. //---------------------------------------------------------------------------
  1426. void __fastcall TPreferencesDialog::UpDownEditorButtonClick(TObject *Sender)
  1427. {
  1428. EditorMove(EditorListView3->ItemIndex,
  1429. EditorListView3->ItemIndex + (Sender == UpEditorButton ? -1 : 1));
  1430. }
  1431. //---------------------------------------------------------------------------
  1432. void __fastcall TPreferencesDialog::RemoveEditorButtonClick(
  1433. TObject * /*Sender*/)
  1434. {
  1435. assert(EditorListView3->ItemIndex >= 0 &&
  1436. EditorListView3->ItemIndex < FEditorList->Count);
  1437. FEditorList->Delete(EditorListView3->ItemIndex);
  1438. UpdateEditorListView();
  1439. UpdateControls();
  1440. }
  1441. //---------------------------------------------------------------------------
  1442. void __fastcall TPreferencesDialog::AddEditEditorButtonClick(TObject * Sender)
  1443. {
  1444. TEditorPreferencesMode Mode = (Sender == EditEditorButton ? epmEdit : epmAdd);
  1445. int Index = EditorListView3->ItemIndex;
  1446. TEditorPreferences * Editor;
  1447. if (Mode == epmEdit)
  1448. {
  1449. Editor = new TEditorPreferences(*FEditorList->Editors[Index]);
  1450. }
  1451. else
  1452. {
  1453. Editor = new TEditorPreferences();
  1454. }
  1455. try
  1456. {
  1457. bool DummyRemember = false;
  1458. if (DoEditorPreferencesDialog(Editor->GetData(), DummyRemember, Mode, true))
  1459. {
  1460. if (Mode == epmEdit)
  1461. {
  1462. FEditorList->Change(Index, Editor);
  1463. }
  1464. else
  1465. {
  1466. if (Index < 0)
  1467. {
  1468. Index = FEditorList->Count;
  1469. FEditorList->Add(Editor);
  1470. }
  1471. else
  1472. {
  1473. FEditorList->Insert(Index, Editor);
  1474. }
  1475. }
  1476. // ownership of the object lost
  1477. Editor = NULL;
  1478. UpdateEditorListView();
  1479. EditorListView3->ItemIndex = Index;
  1480. UpdateControls();
  1481. }
  1482. }
  1483. __finally
  1484. {
  1485. delete Editor;
  1486. }
  1487. }
  1488. //---------------------------------------------------------------------------
  1489. void __fastcall TPreferencesDialog::EditorListView3DblClick(TObject * /*Sender*/)
  1490. {
  1491. if (EditEditorButton->Enabled)
  1492. {
  1493. AddEditEditorButtonClick(EditEditorButton);
  1494. }
  1495. }
  1496. //---------------------------------------------------------------------------
  1497. void __fastcall TPreferencesDialog::EditorListView3KeyDown(TObject * /*Sender*/,
  1498. WORD & Key, TShiftState /*Shift*/)
  1499. {
  1500. if (RemoveEditorButton->Enabled && (Key == VK_DELETE))
  1501. {
  1502. RemoveEditorButtonClick(NULL);
  1503. }
  1504. if (AddEditorButton->Enabled && (Key == VK_INSERT))
  1505. {
  1506. AddEditEditorButtonClick(AddEditorButton);
  1507. }
  1508. }
  1509. //---------------------------------------------------------------------------
  1510. void __fastcall TPreferencesDialog::UpdateEditorListView()
  1511. {
  1512. EditorListView3->Items->Count = FEditorList->Count;
  1513. AdjustListColumnsWidth(EditorListView3);
  1514. EditorListView3->Invalidate();
  1515. }
  1516. //---------------------------------------------------------------------------
  1517. void __fastcall TPreferencesDialog::EditorListView3Data(TObject * /*Sender*/,
  1518. TListItem * Item)
  1519. {
  1520. // WORKAROUND We get here on Wine after destructor is called
  1521. if (FEditorList != NULL)
  1522. {
  1523. int Index = Item->Index;
  1524. assert(Index >= 0 && Index <= FEditorList->Count);
  1525. const TEditorPreferences * Editor = FEditorList->Editors[Index];
  1526. Item->Caption = Editor->Name;
  1527. Item->SubItems->Add(Editor->Data->FileMask.Masks);
  1528. if (Editor->Data->Editor == edExternal)
  1529. {
  1530. Item->SubItems->Add(BooleanToStr(Editor->Data->ExternalEditorText));
  1531. }
  1532. }
  1533. }
  1534. //---------------------------------------------------------------------------
  1535. void __fastcall TPreferencesDialog::NavigationTreeChange(TObject * /*Sender*/,
  1536. TTreeNode * Node)
  1537. {
  1538. if (ALWAYS_TRUE(Node->SelectedIndex > 0))
  1539. {
  1540. PageControl->ActivePage = NOT_NULL(FindPageForTreeNode(Node));
  1541. // reshow the accelerators, etc
  1542. ResetSystemSettings(this);
  1543. // This is particularly here to enable EditCopyParamButton,
  1544. // as to some reason CopyParamListView->Selected is NULL until
  1545. // its page is shown for the first time
  1546. UpdateControls();
  1547. }
  1548. }
  1549. //---------------------------------------------------------------------------
  1550. void __fastcall TPreferencesDialog::PageControlChange(TObject * /*Sender*/)
  1551. {
  1552. // this is probably only ever called from FormShow (explicitly)
  1553. bool Found = false;
  1554. if (ALWAYS_TRUE(PageControl->ActivePage->Tag > 0))
  1555. {
  1556. for (int Index = 0; Index < NavigationTree->Items->Count; Index++)
  1557. {
  1558. if (NavigationTree->Items->Item[Index]->SelectedIndex ==
  1559. PageControl->ActivePage->Tag)
  1560. {
  1561. NavigationTree->Items->Item[Index]->Selected = true;
  1562. Found = true;
  1563. }
  1564. }
  1565. }
  1566. if (ALWAYS_TRUE(Found))
  1567. {
  1568. UpdateControls();
  1569. }
  1570. }
  1571. //---------------------------------------------------------------------------
  1572. void __fastcall TPreferencesDialog::CMDialogKey(TWMKeyDown & Message)
  1573. {
  1574. if (Message.CharCode == VK_TAB)
  1575. {
  1576. TShiftState Shift = KeyDataToShiftState(Message.KeyData);
  1577. if (Shift.Contains(ssCtrl))
  1578. {
  1579. TTreeNode * Node = NavigationTree->Selected;
  1580. if (!Shift.Contains(ssShift))
  1581. {
  1582. Node = Node->GetNext();
  1583. if (!Node) Node = NavigationTree->Items->GetFirstNode();
  1584. }
  1585. else
  1586. {
  1587. if (Node->GetPrev()) Node = Node->GetPrev();
  1588. else
  1589. while (Node->GetNext()) Node = Node->GetNext();
  1590. }
  1591. Node->Selected = True;
  1592. Message.Result = 1;
  1593. return;
  1594. }
  1595. }
  1596. TForm::Dispatch(&Message);
  1597. }
  1598. //---------------------------------------------------------------------------
  1599. void __fastcall TPreferencesDialog::WMHelp(TWMHelp & Message)
  1600. {
  1601. assert(Message.HelpInfo != NULL);
  1602. if (Message.HelpInfo->iContextType == HELPINFO_WINDOW)
  1603. {
  1604. // invoke help for active page (not for whole form), regardless of focus
  1605. // (e.g. even if focus is on control outside pagecontrol)
  1606. Message.HelpInfo->hItemHandle = PageControl->ActivePage->Handle;
  1607. }
  1608. TForm::Dispatch(&Message);
  1609. }
  1610. //---------------------------------------------------------------------------
  1611. void __fastcall TPreferencesDialog::Dispatch(void *Message)
  1612. {
  1613. TMessage * M = reinterpret_cast<TMessage*>(Message);
  1614. assert(M);
  1615. if (M->Msg == CM_DIALOGKEY)
  1616. {
  1617. CMDialogKey(*((TWMKeyDown *)Message));
  1618. }
  1619. else if (M->Msg == WM_HELP)
  1620. {
  1621. WMHelp(*((TWMHelp *)Message));
  1622. }
  1623. else
  1624. {
  1625. TForm::Dispatch(Message);
  1626. }
  1627. }
  1628. //---------------------------------------------------------------------------
  1629. void __fastcall TPreferencesDialog::RegisterAsUrlHandlersButtonClick(
  1630. TObject * /*Sender*/)
  1631. {
  1632. MenuPopup(RegisterAsUrlHandlerMenu, RegisterAsUrlHandlersButton);
  1633. }
  1634. //---------------------------------------------------------------------------
  1635. void __fastcall TPreferencesDialog::RegisterAsUrlHandlerItemClick(TObject * /*Sender*/)
  1636. {
  1637. unsigned int Result =
  1638. MessageDialog(MainInstructions(LoadStr(CONFIRM_REGISTER_URL2)),
  1639. qtConfirmation, qaYes | qaNo, HELP_REGISTER_URL);
  1640. if (Result == qaYes)
  1641. {
  1642. TInstantOperationVisualizer Visualizer;
  1643. RegisterForDefaultProtocols();
  1644. }
  1645. }
  1646. //---------------------------------------------------------------------------
  1647. void __fastcall TPreferencesDialog::UnregisterForDefaultProtocolsItemClick(TObject * /*Sender*/)
  1648. {
  1649. unsigned int Result =
  1650. MessageDialog(MainInstructions(LoadStr(CONFIRM_UNREGISTER_URL)),
  1651. qtConfirmation, qaYes | qaNo, HELP_REGISTER_URL);
  1652. if (Result == qaYes)
  1653. {
  1654. TInstantOperationVisualizer Visualizer;
  1655. UnregisterForProtocols();
  1656. }
  1657. }
  1658. //---------------------------------------------------------------------------
  1659. void __fastcall TPreferencesDialog::MakeDefaultHandlerItemClick(TObject * /*Sender*/)
  1660. {
  1661. TOperationVisualizer Visualizer;
  1662. LaunchAdvancedAssociationUI();
  1663. }
  1664. //---------------------------------------------------------------------------
  1665. void __fastcall TPreferencesDialog::DDExtLabelClick(TObject * Sender)
  1666. {
  1667. ((Sender == DDExtEnabledLabel) ? DDExtEnabledButton : DDExtDisabledButton)->
  1668. SetFocus();
  1669. }
  1670. //---------------------------------------------------------------------------
  1671. void __fastcall TPreferencesDialog::AddSearchPathButtonClick(
  1672. TObject * /*Sender*/)
  1673. {
  1674. UnicodeString AppPath = ExtractFilePath(Application->ExeName);
  1675. if (MessageDialog(MainInstructions(FMTLOAD(CONFIRM_ADD_SEARCH_PATH, (AppPath))),
  1676. qtConfirmation, qaYes | qaNo, HELP_ADD_SEARCH_PATH) == qaYes)
  1677. {
  1678. TInstantOperationVisualizer Visualizer;
  1679. AddSearchPath(AppPath);
  1680. }
  1681. }
  1682. //---------------------------------------------------------------------------
  1683. void __fastcall TPreferencesDialog::EditorFontLabelDblClick(
  1684. TObject * Sender)
  1685. {
  1686. EditorFontButtonClick(Sender);
  1687. }
  1688. //---------------------------------------------------------------------------
  1689. void __fastcall TPreferencesDialog::UpdateCopyParamListView()
  1690. {
  1691. CopyParamListView->Items->Count = 1 + FCopyParamList->Count;
  1692. AdjustListColumnsWidth(CopyParamListView);
  1693. CopyParamListView->Invalidate();
  1694. }
  1695. //---------------------------------------------------------------------------
  1696. void __fastcall TPreferencesDialog::CopyParamListViewData(TObject * /*Sender*/,
  1697. TListItem * Item)
  1698. {
  1699. // WORKAROUND We get here on Wine after destructor is called
  1700. if (FCopyParamList != NULL)
  1701. {
  1702. UnicodeString Name;
  1703. UnicodeString Rule;
  1704. int Index = Item->Index;
  1705. if (Index == 0)
  1706. {
  1707. Name = StripHotkey(LoadStr(COPY_PARAM_DEFAULT));
  1708. }
  1709. else
  1710. {
  1711. assert(Index >= 1 && Index <= 1 + FCopyParamList->Count);
  1712. Name = StripHotkey(FCopyParamList->Names[Index - 1]);
  1713. Rule = BooleanToStr(FCopyParamList->Rules[Index - 1] != NULL);
  1714. }
  1715. Item->Caption = Name;
  1716. Item->SubItems->Add(Rule);
  1717. }
  1718. }
  1719. //---------------------------------------------------------------------------
  1720. void __fastcall TPreferencesDialog::HelpButtonClick(TObject * /*Sender*/)
  1721. {
  1722. FormHelp(this);
  1723. }
  1724. //---------------------------------------------------------------------------
  1725. void __fastcall TPreferencesDialog::PuttyPathBrowseButtonClick(
  1726. TObject * /*Sender*/)
  1727. {
  1728. UnicodeString Executables = FORMAT("%s;%s", (OriginalPuttyExecutable, KittyExecutable));
  1729. BrowseForExecutable(PuttyPathEdit, LoadStr(PREFERENCES_SELECT_PUTTY2),
  1730. FMTLOAD(PREFERENCES_PUTTY_FILTER2, (Executables)), false, false);
  1731. }
  1732. //---------------------------------------------------------------------------
  1733. void __fastcall TPreferencesDialog::PathEditBeforeDialog(
  1734. TObject * /*Sender*/, UnicodeString & Name, bool & /*Action*/)
  1735. {
  1736. FBeforeDialogPath = Name;
  1737. Name = ExpandEnvironmentVariables(Name);
  1738. }
  1739. //---------------------------------------------------------------------------
  1740. void __fastcall TPreferencesDialog::PathEditAfterDialog(
  1741. TObject * /*Sender*/, UnicodeString & Name, bool & /*Action*/)
  1742. {
  1743. if (CompareFileName(Name, ExpandEnvironmentVariables(FBeforeDialogPath)))
  1744. {
  1745. Name = FBeforeDialogPath;
  1746. }
  1747. }
  1748. //---------------------------------------------------------------------------
  1749. void __fastcall TPreferencesDialog::NavigationTreeCollapsing(
  1750. TObject * /*Sender*/, TTreeNode * /*Node*/, bool & AllowCollapse)
  1751. {
  1752. AllowCollapse = false;
  1753. }
  1754. //---------------------------------------------------------------------------
  1755. void __fastcall TPreferencesDialog::ListViewEndDrag(
  1756. TObject * Sender, TObject * /*Target*/, int /*X*/, int /*Y*/)
  1757. {
  1758. ScrollOnDragOver(Sender)->EndDrag();
  1759. }
  1760. //---------------------------------------------------------------------------
  1761. void __fastcall TPreferencesDialog::PathEditCreateEditDialog(
  1762. TObject * Sender, TFileDialogKind DialogKind, TOpenDialog *& Dialog)
  1763. {
  1764. USEDPARAM(DialogKind);
  1765. assert(DialogKind == dkOpen);
  1766. Dialog = new TOpenDialog(dynamic_cast<TComponent *>(Sender));
  1767. }
  1768. //---------------------------------------------------------------------------
  1769. void __fastcall TPreferencesDialog::SessionReopenTimeoutEditSetValue(
  1770. TObject * /*Sender*/, Extended Value, UnicodeString & Text, bool & Handled)
  1771. {
  1772. if (Value == 0)
  1773. {
  1774. Text = LoadStr(PREFERENCES_RECONNECT_TIMEOUT_UNLIMITED);
  1775. Handled = true;
  1776. }
  1777. }
  1778. //---------------------------------------------------------------------------
  1779. void __fastcall TPreferencesDialog::SessionReopenTimeoutEditGetValue(
  1780. TObject * /*Sender*/, UnicodeString Text, Extended & Value, bool & Handled)
  1781. {
  1782. if (AnsiSameText(Text, LoadStr(PREFERENCES_RECONNECT_TIMEOUT_UNLIMITED)))
  1783. {
  1784. Value = 0;
  1785. Handled = true;
  1786. }
  1787. }
  1788. //---------------------------------------------------------------------------
  1789. bool __fastcall TPreferencesDialog::CanSetMasterPassword()
  1790. {
  1791. bool Result;
  1792. bool Retry;
  1793. do
  1794. {
  1795. Retry = false;
  1796. Result = !AnyOtherInstanceOfSelf();
  1797. if (!Result)
  1798. {
  1799. unsigned int Answer =
  1800. MessageDialog(
  1801. LoadStr(MASTER_PASSWORD_OTHER_INSTANCE),
  1802. qtConfirmation, qaRetry | qaIgnore | qaCancel,
  1803. HELP_MASTER_PASSWORD);
  1804. switch (Answer)
  1805. {
  1806. case qaRetry:
  1807. Retry = true;
  1808. break;
  1809. case qaIgnore:
  1810. Result = true;
  1811. break;
  1812. case qaCancel:
  1813. default:
  1814. // noop
  1815. break;
  1816. }
  1817. }
  1818. }
  1819. while (Retry && !Result);
  1820. return Result;
  1821. }
  1822. //---------------------------------------------------------------------------
  1823. void __fastcall TPreferencesDialog::MasterPasswordChanged(
  1824. UnicodeString Message, TStrings * RecryptPasswordErrors)
  1825. {
  1826. // Save master password.
  1827. // This is unlikely to fail, as storage is written explicitly already
  1828. // when writting the recrypted passwords
  1829. Configuration->SaveExplicit();
  1830. TQueryType QueryType = qtInformation;
  1831. if (RecryptPasswordErrors->Count > 0)
  1832. {
  1833. Message = FMTLOAD(MASTER_PASSWORD_RECRYPT_ERRORS, (Message));
  1834. QueryType = qtWarning;
  1835. }
  1836. MoreMessageDialog(
  1837. Message, RecryptPasswordErrors, QueryType, qaOK, HELP_MASTER_PASSWORD);
  1838. }
  1839. //---------------------------------------------------------------------------
  1840. void __fastcall TPreferencesDialog::ChangeMasterPassword(UnicodeString Message)
  1841. {
  1842. UnicodeString NewPassword;
  1843. if (DoChangeMasterPasswordDialog(NewPassword))
  1844. {
  1845. std::unique_ptr<TStrings> RecryptPasswordErrors(new TStringList());
  1846. WinConfiguration->ChangeMasterPassword(NewPassword, RecryptPasswordErrors.get());
  1847. MasterPasswordChanged(Message, RecryptPasswordErrors.get());
  1848. }
  1849. }
  1850. //---------------------------------------------------------------------------
  1851. void __fastcall TPreferencesDialog::UseMasterPasswordCheckClick(
  1852. TObject * /*Sender*/)
  1853. {
  1854. if (UseMasterPasswordCheck->Checked != WinConfiguration->UseMasterPassword)
  1855. {
  1856. try
  1857. {
  1858. if (CanSetMasterPassword())
  1859. {
  1860. if (UseMasterPasswordCheck->Checked)
  1861. {
  1862. ChangeMasterPassword(LoadStr(MASTER_PASSWORD_SET2));
  1863. }
  1864. else
  1865. {
  1866. if (DoMasterPasswordDialog())
  1867. {
  1868. std::unique_ptr<TStrings> RecryptPasswordErrors(new TStringList());
  1869. WinConfiguration->ClearMasterPassword(RecryptPasswordErrors.get());
  1870. MasterPasswordChanged(LoadStr(MASTER_PASSWORD_CLEARED2), RecryptPasswordErrors.get());
  1871. }
  1872. }
  1873. }
  1874. }
  1875. __finally
  1876. {
  1877. UseMasterPasswordCheck->Checked = WinConfiguration->UseMasterPassword;
  1878. UpdateControls();
  1879. }
  1880. }
  1881. }
  1882. //---------------------------------------------------------------------------
  1883. void __fastcall TPreferencesDialog::SetMasterPasswordButtonClick(
  1884. TObject * /*Sender*/)
  1885. {
  1886. if (CanSetMasterPassword())
  1887. {
  1888. ChangeMasterPassword(MainInstructions(LoadStr(MASTER_PASSWORD_CHANGED)));
  1889. }
  1890. }
  1891. //---------------------------------------------------------------------------
  1892. void __fastcall TPreferencesDialog::UsageViewButtonClick(TObject * /*Sender*/)
  1893. {
  1894. TStrings * Data = new TStringList();
  1895. try
  1896. {
  1897. Data->Text = GetUsageData();
  1898. UnicodeString Message =
  1899. Data->Text.IsEmpty() ? MainInstructions(LoadStr(USAGE_DATA_NONE)) : LoadStr(USAGE_DATA2);
  1900. MoreMessageDialog(Message, Data, qtInformation, qaOK, HELP_USAGE);
  1901. }
  1902. __finally
  1903. {
  1904. delete Data;
  1905. }
  1906. }
  1907. //---------------------------------------------------------------------------
  1908. void __fastcall TPreferencesDialog::CopyParamLabelClick(TObject * /*Sender*/)
  1909. {
  1910. if (EditCopyParamButton->Enabled)
  1911. {
  1912. AddEditCopyParam(cpmEdit);
  1913. }
  1914. }
  1915. //---------------------------------------------------------------------------
  1916. void __fastcall TPreferencesDialog::CopyParamListViewCustomDrawItem(
  1917. TCustomListView * Sender, TListItem * Item,
  1918. TCustomDrawState /*State*/, bool & /*DefaultDraw*/)
  1919. {
  1920. if (Item->Index == 0)
  1921. {
  1922. Sender->Canvas->Font->Style = Sender->Canvas->Font->Style << fsBold;
  1923. }
  1924. }
  1925. //---------------------------------------------------------------------------
  1926. void __fastcall TPreferencesDialog::SelectPuttyRegistryStorageKey(const UnicodeString & Key)
  1927. {
  1928. PuttyRegistryStorageKeyEdit->ItemIndex =
  1929. PuttyRegistryStorageKeyEdit->Items->IndexOf(Key);
  1930. }
  1931. //---------------------------------------------------------------------------
  1932. void __fastcall TPreferencesDialog::PuttyPathEditChange(TObject * /*Sender*/)
  1933. {
  1934. UnicodeString PuttyPath = PuttyPathEdit->Text;
  1935. if (ContainsText(PuttyPath, OriginalPuttyExecutable))
  1936. {
  1937. SelectPuttyRegistryStorageKey(OriginalPuttyRegistryStorageKey);
  1938. }
  1939. else if (ContainsText(PuttyPath, KittyExecutable))
  1940. {
  1941. SelectPuttyRegistryStorageKey(KittyRegistryStorageKey);
  1942. }
  1943. UpdateControls();
  1944. }
  1945. //---------------------------------------------------------------------------
  1946. void __fastcall TPreferencesDialog::NavigationTreeChanging(TObject * /*Sender*/,
  1947. TTreeNode * Node, bool & /*AllowChange*/)
  1948. {
  1949. TTabSheet * Sheet = FindPageForTreeNode(Node);
  1950. // delay load as this can be time consuming
  1951. if (Sheet == LanguagesSheet)
  1952. {
  1953. LoadLanguages();
  1954. }
  1955. }
  1956. //---------------------------------------------------------------------------
  1957. void __fastcall TPreferencesDialog::LanguagesGetMoreButtonClick(TObject * /*Sender*/)
  1958. {
  1959. OpenBrowser(LoadStr(LOCALES_URL));
  1960. }
  1961. //---------------------------------------------------------------------------
  1962. void __fastcall TPreferencesDialog::CommanderClick(TObject * /*Sender*/)
  1963. {
  1964. CommanderInterfaceButton2->SetFocus();
  1965. }
  1966. //---------------------------------------------------------------------------
  1967. void __fastcall TPreferencesDialog::ExplorerClick(TObject * /*Sender*/)
  1968. {
  1969. ExplorerInterfaceButton2->SetFocus();
  1970. }
  1971. //---------------------------------------------------------------------------