Preferences.cpp 71 KB

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