Preferences.cpp 72 KB

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