uconfig.pas 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887
  1. // SPDX-License-Identifier: GPL-3.0-only
  2. unit UConfig;
  3. {$mode objfpc}{$H+}
  4. interface
  5. uses
  6. Classes, SysUtils, IniFiles, BGRABitmapTypes, Graphics, LCLType, uscripting,
  7. Forms, LCVectorRectShapes;
  8. type
  9. TLazPaintConfig = class;
  10. IConfigProvider = interface
  11. function GetConfig: TLazPaintConfig;
  12. end;
  13. { TLazPaintConfig }
  14. TLazPaintConfig = class
  15. private
  16. iniOptions: TIniFile;
  17. recentFiles, recentDirs: TStringList;
  18. tempFont: TFont;
  19. colorizePresets: TList;
  20. FVersion: string;
  21. FDarkTheme,FDarkThemeEvaluated: boolean;
  22. FWorkspaceColor: TColor;
  23. FWorkspaceColorEvaluated: boolean;
  24. function GetBrushCount: integer;
  25. function GetBrushInfo(Index: integer): string;
  26. function GetColorizePreset(Index: Integer): TVariableSet;
  27. function GetColorizePresetCount: integer;
  28. function GetRecentDirectoriesCount: integer;
  29. function GetRecentDirectory(Index: Integer): string;
  30. function GetRecentFile(Index: Integer): string;
  31. function GetRecentFilesCount: integer;
  32. public
  33. Languages: TStringList;
  34. constructor Create(ini: TIniFile; AVersion: string);
  35. destructor Destroy; override;
  36. procedure InitRecentFiles;
  37. procedure AddRecentFile(filename: string);
  38. procedure AddRecentDirectory(dirname: string);
  39. procedure FinalizeRecentFiles;
  40. function DefaultRememberStartupTargetDirectory: boolean;
  41. procedure SetRememberStartupTargetDirectory(AValue: boolean);
  42. function DefaultRememberStartupExportDirectory: boolean;
  43. procedure SetRememberStartupExportDirectory(AValue: boolean);
  44. function DefaultRememberStartupSourceDirectory: boolean;
  45. procedure SetRememberStartupSourceDirectory(AValue: boolean);
  46. function DefaultStartupSourceDirectory: string;
  47. procedure SetStartupSourceDirectory(AValue: string);
  48. function DefaultStartupTargetDirectory: string;
  49. procedure SetStartupTargetDirectory(AValue: string);
  50. function DefaultStartupExportDirectory: string;
  51. procedure SetStartupExportDirectory(AValue: string);
  52. function DefaultRememberSaveFormat: boolean;
  53. procedure SetRememberSaveFormat(AValue: boolean);
  54. function DefaultSaveExtensions: string;
  55. procedure SetSaveExtensions(AValue: string);
  56. procedure SetBrushes(ABrushes: TStringList);
  57. function DefaultJpegQuality: integer;
  58. procedure SetDefaultJpegQuality(value: integer);
  59. function DefaultWebPLossless: boolean;
  60. procedure SetDefaultWebPLossless(value: boolean);
  61. function DefaultSaveOptionDialogMaximized: boolean;
  62. procedure SetDefaultSaveOptionDialogMaximized(value: boolean);
  63. procedure InitColorizePresets;
  64. function AddColorizePreset(AName: string; AHue, ASaturation: double; ACorrection: Boolean): integer;
  65. function AddColorizePreset(AParams: TVariableSet): integer;
  66. procedure RemoveColorizePreset(AIndex: integer);
  67. function IndexOfColorizePreset(AName: string): integer;
  68. procedure FinalizeColorizePresets;
  69. function DefaultLangage: string;
  70. class function ClassGetDefaultLangage(AIni: TIniFile): string; static;
  71. procedure SetDefaultLangage(value: string);
  72. function GetLastUpdateCheck: TDateTime;
  73. procedure SetLastUpdateCheck(value: TDateTime);
  74. function LatestVersion: string;
  75. procedure SetLatestVersion(value: string);
  76. procedure GetUpdatedLanguages(AList: TStringList);
  77. procedure SetUpdatedLanguages(AList: TStringList);
  78. class procedure ClassGetUpdatedLanguages(AList: TStringList; AIni: TIniFile; AVersion: string); static;
  79. class procedure ClassSetUpdatedLanguages(AList: TStringList; AIni: TIniFile; AVersion: string); static;
  80. procedure AddUpdatedLanguage(ALang: string);
  81. function Default3dObjectDirectory: string;
  82. procedure SetDefault3dObjectDirectory(value: string);
  83. function DefaultTextureDirectory: string;
  84. procedure SetDefaultTextureDirectory(value: string);
  85. function DefaultBrushDirectory: string;
  86. procedure SetDefaultBrushDirectory(value: string);
  87. function DefaultPaletteDirectory: string;
  88. procedure SetDefaultPaletteDirectory(value: string);
  89. function DefaultScriptDirectory: string;
  90. procedure SetDefaultScriptDirectory(value: string);
  91. function DefaultIconSize(defaultValue: integer): integer;
  92. procedure SetDefaultIconSize(value: integer);
  93. function GetDarkTheme: boolean;
  94. procedure SetDarkTheme(AValue: boolean);
  95. //new image config
  96. function DefaultImageWidth: integer;
  97. function DefaultImageHeight: integer;
  98. function DefaultImageBackgroundColor: TBGRAPixel;
  99. procedure SetDefaultImageWidth(value: integer);
  100. procedure SetDefaultImageHeight(value: integer);
  101. procedure SetDefaultImageBackgroundColor(value: TBGRAPixel);
  102. function DefaultIconImageWidth: integer;
  103. function DefaultIconImageHeight: integer;
  104. function DefaultIconImageBitDepth: integer;
  105. function DefaultIconImageBackgroundColor: TBGRAPixel;
  106. procedure SetDefaultIconImageWidth(value: integer);
  107. procedure SetDefaultIconImageHeight(value: integer);
  108. procedure SetDefaultIconImageBitDepth(value: integer);
  109. procedure SetDefaultIconImageBackgroundColor(value: TBGRAPixel);
  110. //resample config
  111. function DefaultResampleKeepAspectRatio: boolean;
  112. function DefaultResampleQuality: integer;
  113. procedure SetDefaultResampleKeepAspectRatio(value: boolean);
  114. procedure SetDefaultResampleQuality(value: integer);
  115. //window
  116. function DefaultScreenSize: TRect;
  117. function DefaultDockLayersAndColors: boolean;
  118. procedure SetDefaultDockLayersAndColors(value: boolean);
  119. function ScreenSizeChanged: boolean;
  120. procedure SetDefaultScreenSize(value: TRect);
  121. function DefaultMainWindowMaximized: boolean;
  122. procedure SetDefaultMainWindowMaximized(value: boolean);
  123. function DefaultMainWindowPosition: TRect;
  124. procedure SetDefaultMainWindowPosition(value: TRect);
  125. function DefaultColorWindowPosition: TRect;
  126. procedure SetDefaultColorWindowPosition(value: TRect);
  127. function DefaultLayerWindowPosition: TRect;
  128. procedure SetDefaultLayerWindowPosition(value: TRect);
  129. function DefaultLayerStackZoom: single;
  130. procedure SetDefaultLayerStackZoom(value: single);
  131. function DefaultToolboxWindowPosition: TRect;
  132. procedure SetDefaultToolboxWindowPosition(value: TRect);
  133. function DefaultToolboxDocking: string;
  134. procedure SetDefaultToolboxDocking(value: string);
  135. function DefaultImageListPosition: TRect;
  136. procedure SetDefaultImagelistWindowPosition(value: TRect);
  137. function DefaultBrowseWindowMaximized: boolean;
  138. procedure SetDefaultBrowseWindowMaximized(value: boolean);
  139. function DefaultBrowseWindowPosition: TRect;
  140. procedure SetDefaultBrowseWindowPosition(value: TRect);
  141. function DefaultPreviewDialogMaximized: boolean;
  142. procedure SetDefaultPreviewDialogMaximized(value: boolean);
  143. function DefaultPreviewDialogPosition: TRect;
  144. procedure SetDefaultPreviewDialogPosition(value: TRect);
  145. function DefaultPaletteToolbarVisible: boolean;
  146. procedure SetDefaultPaletteToolbarVisible(value: boolean);
  147. function DefaultColorWindowVisible: boolean;
  148. procedure SetDefaultColorWindowVisible(value: boolean);
  149. function DefaultLayerWindowVisible: boolean;
  150. procedure SetDefaultLayerWindowVisible(value: boolean);
  151. function DefaultToolboxWindowVisible: boolean;
  152. procedure SetDefaultToolboxWindowVisible(value: boolean);
  153. function DefaultImagelistWindowVisible: boolean;
  154. procedure SetDefaultImagelistWindowVisible(value: boolean);
  155. function DefaultGridVisible: boolean;
  156. procedure SetDefaultGridVisible(value: boolean);
  157. function DefaultZoomToolbarVisible: boolean;
  158. procedure SetDefaultZoomToolbarVisible(value: boolean);
  159. function DefaultFileToolbarVisible: boolean;
  160. procedure SetDefaultFileToolbarVisible(value: boolean);
  161. function DefaultUndoRedoToolbarVisible: boolean;
  162. procedure SetDefaultUndoRedoToolbarVisible(value: boolean);
  163. function DefaultCopyPasteToolbarVisible: boolean;
  164. procedure SetDefaultCopyPasteToolbarVisible(value: boolean);
  165. function DefaultCoordinatesToolbarVisible: boolean;
  166. procedure SetDefaultCoordinatesToolbarVisible(value: boolean);
  167. function GetStatusBarVisible: boolean;
  168. procedure SetStatusBarVisible(value: boolean);
  169. function GetWorkspaceColor: TColor;
  170. procedure SetWorkspaceColor(value: TColor);
  171. function DefaultUseImageBrowser: boolean;
  172. procedure SetDefaultUseImageBrowser(value: boolean);
  173. //tools
  174. function DefaultToolForeColor: TBGRAPixel;
  175. function DefaultToolBackColor: TBGRAPixel;
  176. function DefaultToolOutlineColor: TBGRAPixel;
  177. procedure SetDefaultToolForeColor(value: TBGRAPixel);
  178. procedure SetDefaultToolBackColor(value: TBGRAPixel);
  179. procedure SetDefaultToolOutlineColor(value: TBGRAPixel);
  180. function DefaultToolForeGradient: string;
  181. function DefaultToolBackGradient: string;
  182. function DefaultToolOutlineGradient: string;
  183. procedure SetDefaultToolForeGradient(value: string);
  184. procedure SetDefaultToolBackGradient(value: string);
  185. procedure SetDefaultToolOutlineGradient(value: string);
  186. function DefaultToolPenWidth: single;
  187. procedure SetDefaultToolPenWidth(value: single);
  188. function DefaultToolEraserWidth: single;
  189. procedure SetDefaultToolEraserWidth(value: single);
  190. function DefaultToolOptionDrawShape: boolean;
  191. procedure SetDefaultToolOptionDrawShape(value: boolean);
  192. function DefaultToolOptionFillShape: boolean;
  193. procedure SetDefaultToolOptionFillShape(value: boolean);
  194. function DefaultToolOptionCloseShape: boolean;
  195. procedure SetDefaultToolOptionCloseShape(value: boolean);
  196. function DefaultToolTolerance: integer;
  197. procedure SetDefaultToolTolerance(value: integer);
  198. function DefaultToolTextOutline: boolean;
  199. procedure SetDefaultToolTextOutline(value: boolean);
  200. function DefaultToolTextOutlineWidth: single;
  201. procedure SetDefaultToolTextOutlineWidth(value: single);
  202. function DefaultToolTextShadow: boolean;
  203. procedure SetDefaultToolTextShadow(value: boolean);
  204. function DefaultToolTextFont: TFont;
  205. procedure SetDefaultToolTextFont(AName: string; ASize: single; AStyle: TFontStyles);
  206. function DefaultToolTextBlur: single;
  207. procedure SetDefaultToolTextBlur(value: single);
  208. function DefaultToolTextShadowOffsetX: integer;
  209. procedure SetDefaultToolTextShadowOffsetX(value: integer);
  210. function DefaultToolTextShadowOffsetY: integer;
  211. procedure SetDefaultToolTextShadowOffsetY(value: integer);
  212. procedure SetDefaultToolTextShadowOffset(value: TPoint);
  213. function DefaultToolTextShadowOffset: TPoint;
  214. function DefaultToolTextPhong: boolean;
  215. procedure SetDefaultToolTextPhong(value: boolean);
  216. function ToolPopupMessageShownCount(index: integer): integer;
  217. procedure SetToolPopupMessageShownCount(index: integer; AValue: integer);
  218. function DefaultToolLightPositionX: single;
  219. procedure SetDefaultToolLightPositionX(value: single);
  220. function DefaultToolLightPositionY: single;
  221. procedure SetDefaultToolLightPositionY(value: single);
  222. procedure SetDefaultToolLightPosition(const value: TPointF);
  223. function DefaultToolLightPosition: TPointF;
  224. function DefaultToolLightAltitude: integer;
  225. procedure SetDefaultToolLightAltitude(value: integer);
  226. function DefaultToolShapeAltitude: integer;
  227. procedure SetDefaultToolShapeAltitude(value: integer);
  228. function DefaultToolShapeBorderSize: integer;
  229. procedure SetDefaultToolShapeBorderSize(value: integer);
  230. function DefaultToolShapeType: TPhongShapeKind;
  231. procedure SetDefaultToolShapeType(value: TPhongShapeKind);
  232. function DefaultRetrieveSelectionAnswer: TModalResult;
  233. procedure SetDefaultRetrieveSelectionAnswer(value: TModalResult);
  234. function DefaultTransformSelectionAnswer: TModalResult;
  235. procedure SetDefaultTransformSelectionAnswer(value: TModalResult);
  236. //radial blur config
  237. function DefaultBlurRadius: single;
  238. procedure SetDefaultBlurRadius(value: single);
  239. function DefaultPixelateSize: integer;
  240. procedure SetDefaultPixelateSize(value: integer);
  241. function DefaultPixelateQuality: string;
  242. procedure SetDefaultPixelateQuality(value: string);
  243. function DefaultSharpenAmount: single;
  244. procedure SetDefaultSharpenAmount(value: single);
  245. //motion blur config
  246. function DefaultBlurMotionAngle: double;
  247. function DefaultBlurMotionDistance: single;
  248. function DefaultBlurMotionOriented: boolean;
  249. procedure SetDefaultBlurMotionAngle(value: double);
  250. procedure SetDefaultBlurMotionDistance(value: single);
  251. procedure SetDefaultBlurMotionOriented(value: boolean);
  252. //custom blur config
  253. function DefaultCustomBlurMaskUTF8: string;
  254. procedure SetDefaultCustomBlurMaskUTF8(value: string);
  255. //emboss config
  256. function DefaultEmbossAngle: double;
  257. procedure SetDefaultEmbossAngle(value: double);
  258. //rain config
  259. function DefaultRainWind: double;
  260. procedure SetDefaultRainWind(value: double);
  261. function DefaultRainQuantity: double;
  262. procedure SetDefaultRainQuantity(value: double);
  263. //twirl config
  264. function DefaultTwirlRadius: double;
  265. procedure SetDefaultTwirlRadius(value: double);
  266. function DefaultTwirlTurn: double;
  267. procedure SetDefaultTwirlTurn(value: double);
  268. //wave displacement config
  269. function DefaultWaveDisplacementWavelength: double;
  270. procedure SetDefaultWaveDisplacementWavelength(value: double);
  271. function DefaultWaveDisplacementAmount: double;
  272. procedure SetDefaultWaveDisplacementAmount(value: double);
  273. function DefaultWaveDisplacementPhase: double;
  274. procedure SetDefaultWaveDisplacementPhase(value: double);
  275. //phong filter
  276. function DefaultPhongFilterAltitude: integer;
  277. procedure SetDefaultPhongFilterAltitude(value: integer);
  278. //color config
  279. function DefaultPosterizeLevels: integer;
  280. procedure SetDefaultPosterizeLevels(value: integer);
  281. function DefaultPosterizeByLightness: boolean;
  282. procedure SetDefaultPosterizeByLightness(value: boolean);
  283. function DefaultUseGSBA: boolean;
  284. procedure SetDefaultUseGSBA(value: boolean);
  285. property RecentFilesCount : integer read GetRecentFilesCount;
  286. property RecentFile[Index: Integer]: string read GetRecentFile;
  287. property RecentDirectoriesCount : integer read GetRecentDirectoriesCount;
  288. property RecentDirectory[Index: Integer]: string read GetRecentDirectory;
  289. property ColorizePresetCount: integer read GetColorizePresetCount;
  290. property ColorizePreset[Index: Integer]: TVariableSet read GetColorizePreset;
  291. property BrushCount: integer read GetBrushCount;
  292. property BrushInfo[Index: integer]: string read GetBrushInfo;
  293. //ImageList
  294. function ImageListLastFolder: string;
  295. procedure SetImageListLastFolder(value: string);
  296. function ImageListAutoZoom: Boolean;
  297. procedure SetImageListAutoZoom(value: Boolean);
  298. function ImageListAutoUncheck: Boolean;
  299. procedure SetImageListAutoUncheck(value: Boolean);
  300. function ImageListAutoUncheckMode: Integer;
  301. procedure SetImageListAutoUncheckMode(value: integer);
  302. end;
  303. function GetActualConfig: TIniFile;
  304. function DefaultPicturesDirectory: string;
  305. var
  306. ActualConfigDirUTF8 : string;
  307. MenuDefinitionKeys,MenuDefinitionValues: TStringList;
  308. implementation
  309. uses uparse, LCLProc, BGRAUTF8, LazFileUtils, UFileSystem;
  310. const maxRecentFiles = 10;
  311. maxRecentDirectories = 10;
  312. //returns the config file to use
  313. function GetActualConfig: TIniFile;
  314. var
  315. PortableConfig: TIniFile;
  316. AppDirSys: string;
  317. PortableConfigFilenameSys: string;
  318. ActualConfigFilenameSys: string;
  319. {$IFDEF DARWIN}
  320. ConfigPath: string;
  321. {$ENDIF}
  322. i: integer;
  323. begin
  324. ActualConfigFilenameSys := '';
  325. //check if a config file path is defined
  326. AppDirSys := ExtractFilePath(Application.ExeName);
  327. PortableConfigFilenameSys := AppDirSys+'lazpaint.ini';
  328. If FileExists(PortableConfigFilenameSys) then
  329. begin
  330. PortableConfig := TIniFile.Create(PortableConfigFilenameSys);
  331. ActualConfigFilenameSys:= PortableConfig.ReadString('General','ConfigFile','');
  332. if ActualConfigFilenameSys <> '' then
  333. ActualConfigFilenameSys:= ExpandFileName(AppDirSys+ActualConfigFilenameSys);
  334. MenuDefinitionKeys.Clear;
  335. MenuDefinitionValues.Clear;
  336. PortableConfig.ReadSection('Menu',MenuDefinitionKeys);
  337. for i := 0 to MenuDefinitionKeys.Count-1 do
  338. MenuDefinitionValues.Add(PortableConfig.ReadString('Menu',MenuDefinitionKeys[i],''));
  339. PortableConfig.Free;
  340. end;
  341. //otherwise, use default path
  342. if ActualConfigFilenameSys = '' then
  343. begin
  344. CreateDir(GetAppConfigDir(False));
  345. ActualConfigFilenameSys := GetAppConfigFile(False,False);
  346. end;
  347. {$IFDEF DARWIN}
  348. ConfigPath := ExtractFilePath(ActualConfigFilenameSys);
  349. CreateDir(ConfigPath);
  350. {$ENDIF}
  351. result := TIniFile.Create(ActualConfigFilenameSys,True);
  352. ActualConfigDirUTF8 := SysToUTF8(ExtractFilePath(ActualConfigFilenameSys));
  353. end;
  354. function DefaultPicturesDirectory: string;
  355. begin
  356. DefaultPicturesDirectory := SysToUTF8(GetUserDir);
  357. if DirectoryExistsUTF8(AppendPathDelim(DefaultPicturesDirectory)+'Pictures') then
  358. DefaultPicturesDirectory := AppendPathDelim(DefaultPicturesDirectory)+'Pictures';
  359. end;
  360. { TLazPaintConfig }
  361. function TLazPaintConfig.DefaultImageWidth: integer;
  362. begin
  363. result := iniOptions.ReadInteger('General','DefaultImageWidth',640);
  364. end;
  365. function TLazPaintConfig.DefaultImageHeight: integer;
  366. begin
  367. result := iniOptions.ReadInteger('General','DefaultImageHeight',480);
  368. end;
  369. procedure TLazPaintConfig.SetDefaultImageWidth(value: integer);
  370. begin
  371. iniOptions.WriteInteger('General','DefaultImageWidth',value);
  372. end;
  373. procedure TLazPaintConfig.SetDefaultImageHeight(value: integer);
  374. begin
  375. iniOptions.WriteInteger('General','DefaultImageHeight',value);
  376. end;
  377. procedure TLazPaintConfig.SetDefaultImageBackgroundColor(value: TBGRAPixel);
  378. begin
  379. iniOptions.WriteString('General','DefaultImageBackColor',BGRAToStr(value));
  380. end;
  381. function TLazPaintConfig.DefaultImageBackgroundColor: TBGRAPixel;
  382. begin
  383. result := StrToBGRA(iniOptions.ReadString('General','DefaultImageBackColor','00000000'));
  384. end;
  385. function TLazPaintConfig.DefaultIconImageWidth: integer;
  386. begin
  387. result := iniOptions.ReadInteger('General','DefaultIconImageWidth',128);
  388. end;
  389. function TLazPaintConfig.DefaultIconImageHeight: integer;
  390. begin
  391. result := iniOptions.ReadInteger('General','DefaultIconImageHeight',128);
  392. end;
  393. function TLazPaintConfig.DefaultIconImageBitDepth: integer;
  394. begin
  395. result := iniOptions.ReadInteger('General','DefaultIconImageBitDepth',32);
  396. end;
  397. procedure TLazPaintConfig.SetDefaultIconImageWidth(value: integer);
  398. begin
  399. iniOptions.WriteInteger('General','DefaultIconImageWidth',value);
  400. end;
  401. procedure TLazPaintConfig.SetDefaultIconImageHeight(value: integer);
  402. begin
  403. iniOptions.WriteInteger('General','DefaultIconImageHeight',value);
  404. end;
  405. procedure TLazPaintConfig.SetDefaultIconImageBitDepth(value: integer);
  406. begin
  407. iniOptions.WriteInteger('General','DefaultIconImageBitDepth',value);
  408. end;
  409. procedure TLazPaintConfig.SetDefaultIconImageBackgroundColor(value: TBGRAPixel);
  410. begin
  411. iniOptions.WriteString('General','DefaultIconImageBackColor',BGRAToStr(value));
  412. end;
  413. function TLazPaintConfig.DefaultIconImageBackgroundColor: TBGRAPixel;
  414. begin
  415. result := StrToBGRA(iniOptions.ReadString('General','DefaultIconImageBackColor','00000000'));
  416. end;
  417. function TLazPaintConfig.DefaultResampleKeepAspectRatio: boolean;
  418. begin
  419. result := iniOptions.ReadBool('General','ResampleKeepAspectRatio',true);
  420. end;
  421. function TLazPaintConfig.DefaultResampleQuality: integer;
  422. begin
  423. result := iniOptions.ReadInteger('General','ResampleQuality',2);
  424. end;
  425. procedure TLazPaintConfig.SetDefaultResampleKeepAspectRatio(value: boolean);
  426. begin
  427. iniOptions.WriteBool('General','ResampleKeepAspectRatio',value);
  428. end;
  429. procedure TLazPaintConfig.SetDefaultResampleQuality(value: integer);
  430. begin
  431. iniOptions.WriteInteger('General','ResampleQuality',value);
  432. end;
  433. function TLazPaintConfig.DefaultScreenSize: TRect;
  434. begin
  435. result := StrToRect(iniOptions.ReadString('Window','ScreenSize',''));
  436. end;
  437. function TLazPaintConfig.DefaultDockLayersAndColors: boolean;
  438. begin
  439. result := iniOptions.ReadBool('Window','DockLayersAndColors',false);
  440. end;
  441. procedure TLazPaintConfig.SetDefaultDockLayersAndColors(value: boolean);
  442. begin
  443. iniOptions.WriteBool('Window','DockLayersAndColors',value);
  444. end;
  445. procedure TLazPaintConfig.SetDefaultScreenSize(value: TRect);
  446. begin
  447. iniOptions.WriteString('Window','ScreenSize',RectToStr(value));
  448. end;
  449. function TLazPaintConfig.DefaultMainWindowMaximized: boolean;
  450. begin
  451. result := iniOptions.ReadBool('Window','MainWindowMaximized',false);
  452. end;
  453. procedure TLazPaintConfig.SetDefaultMainWindowMaximized(value: boolean);
  454. begin
  455. iniOptions.WriteBool('Window','MainWindowMaximized',value);
  456. end;
  457. function TLazPaintConfig.DefaultMainWindowPosition: TRect;
  458. begin
  459. result := StrToRect(iniOptions.ReadString('Window','MainWindowPosition',''));
  460. end;
  461. procedure TLazPaintConfig.SetDefaultMainWindowPosition(value: TRect);
  462. begin
  463. iniOptions.WriteString('Window','MainWindowPosition',RectToStr(value));
  464. SetDefaultMainWindowMaximized(False);
  465. end;
  466. function TLazPaintConfig.DefaultColorWindowPosition: TRect;
  467. begin
  468. result := StrToRect(iniOptions.ReadString('Window','ColorWindowPosition',''));
  469. end;
  470. procedure TLazPaintConfig.SetDefaultColorWindowPosition(value: TRect);
  471. begin
  472. iniOptions.WriteString('Window','ColorWindowPosition',RectToStr(value));
  473. end;
  474. function TLazPaintConfig.DefaultLayerWindowPosition: TRect;
  475. begin
  476. result := StrToRect(iniOptions.ReadString('Window','LayerWindowPosition',''));
  477. end;
  478. procedure TLazPaintConfig.SetDefaultLayerWindowPosition(value: TRect);
  479. begin
  480. iniOptions.WriteString('Window','LayerWindowPosition',RectToStr(value));
  481. end;
  482. function TLazPaintConfig.DefaultLayerStackZoom: single;
  483. begin
  484. result := iniOptions.ReadFloat('Window', 'LayerStackZoom', EmptySingle);
  485. end;
  486. procedure TLazPaintConfig.SetDefaultLayerStackZoom(value: single);
  487. begin
  488. iniOptions.WriteFloat('Window', 'LayerStackZoom', value);
  489. end;
  490. function TLazPaintConfig.DefaultToolboxWindowPosition: TRect;
  491. begin
  492. result := StrToRect(iniOptions.ReadString('Window','ToolboxWindowPosition',''));
  493. end;
  494. procedure TLazPaintConfig.SetDefaultToolboxWindowPosition(value: TRect);
  495. begin
  496. iniOptions.WriteString('Window','ToolboxWindowPosition',RectToStr(value));
  497. end;
  498. function TLazPaintConfig.DefaultToolboxDocking: string;
  499. begin
  500. result := iniOptions.ReadString('Window','ToolBoxDocking','Left');
  501. end;
  502. procedure TLazPaintConfig.SetDefaultToolboxDocking(value: string);
  503. begin
  504. iniOptions.WriteString('Window','ToolBoxDocking',value);
  505. end;
  506. function TLazPaintConfig.DefaultImageListPosition: TRect;
  507. begin
  508. result := StrToRect(iniOptions.ReadString('Window','ImagelistWindowPosition',''));
  509. end;
  510. procedure TLazPaintConfig.SetDefaultImagelistWindowPosition(value: TRect);
  511. begin
  512. iniOptions.WriteString('Window','ImagelistWindowPosition',RectToStr(value));
  513. end;
  514. function TLazPaintConfig.DefaultBrowseWindowMaximized: boolean;
  515. begin
  516. result := iniOptions.ReadBool('Window','BrowseWindowMaximized',false);
  517. end;
  518. procedure TLazPaintConfig.SetDefaultBrowseWindowMaximized(value: boolean);
  519. begin
  520. iniOptions.WriteBool('Window','BrowseWindowMaximized',value);
  521. end;
  522. function TLazPaintConfig.DefaultBrowseWindowPosition: TRect;
  523. begin
  524. result := StrToRect(iniOptions.ReadString('Window','BrowseWindowPosition',''));
  525. end;
  526. procedure TLazPaintConfig.SetDefaultBrowseWindowPosition(value: TRect);
  527. begin
  528. iniOptions.WriteString('Window','BrowseWindowPosition',RectToStr(value));
  529. end;
  530. function TLazPaintConfig.DefaultPreviewDialogMaximized: boolean;
  531. begin
  532. result := iniOptions.ReadBool('Window','PreviewDialogMaximized',false);
  533. end;
  534. procedure TLazPaintConfig.SetDefaultPreviewDialogMaximized(value: boolean);
  535. begin
  536. iniOptions.WriteBool('Window','PreviewDialogMaximized',value);
  537. end;
  538. function TLazPaintConfig.DefaultPreviewDialogPosition: TRect;
  539. begin
  540. result := StrToRect(iniOptions.ReadString('Window','PreviewDialogPosition',''));
  541. end;
  542. procedure TLazPaintConfig.SetDefaultPreviewDialogPosition(value: TRect);
  543. begin
  544. iniOptions.WriteString('Window','PreviewDialogPosition',RectToStr(value));
  545. end;
  546. function TLazPaintConfig.DefaultPaletteToolbarVisible: boolean;
  547. begin
  548. result := iniOptions.ReadBool('Toolbar','PaletteToolbar',true);
  549. end;
  550. procedure TLazPaintConfig.SetDefaultPaletteToolbarVisible(value: boolean);
  551. begin
  552. iniOptions.WriteBool('Toolbar','PaletteToolbar',value);
  553. end;
  554. function TLazPaintConfig.DefaultColorWindowVisible: boolean;
  555. begin
  556. result := iniOptions.ReadBool('Window','ColorWindowVisible',true);
  557. end;
  558. procedure TLazPaintConfig.SetDefaultColorWindowVisible(value: boolean);
  559. begin
  560. iniOptions.WriteBool('Window','ColorWindowVisible',value);
  561. end;
  562. function TLazPaintConfig.DefaultLayerWindowVisible: boolean;
  563. begin
  564. result := iniOptions.ReadBool('Window','LayerWindowVisible',true);
  565. end;
  566. procedure TLazPaintConfig.SetDefaultLayerWindowVisible(value: boolean);
  567. begin
  568. iniOptions.WriteBool('Window','LayerWindowVisible',value);
  569. end;
  570. function TLazPaintConfig.DefaultToolboxWindowVisible: boolean;
  571. begin
  572. result := iniOptions.ReadBool('Window','ToolboxWindowVisible',true);
  573. end;
  574. function TLazPaintConfig.DefaultImagelistWindowVisible: boolean;
  575. begin
  576. result := iniOptions.ReadBool('Window','ImagelistWindowVisible',false);
  577. end;
  578. procedure TLazPaintConfig.SetDefaultToolboxWindowVisible(value: boolean);
  579. begin
  580. iniOptions.WriteBool('Window','ToolboxWindowVisible',value);
  581. end;
  582. procedure TLazPaintConfig.SetDefaultImagelistWindowVisible(value: boolean);
  583. begin
  584. iniOptions.WriteBool('Window','ImagelistWindowVisible',value);
  585. end;
  586. function TLazPaintConfig.DefaultGridVisible: boolean;
  587. begin
  588. result := iniOptions.ReadBool('General','GridVisible',true);
  589. end;
  590. procedure TLazPaintConfig.SetDefaultGridVisible(value: boolean);
  591. begin
  592. iniOptions.WriteBool('General','GridVisible',value);
  593. end;
  594. function TLazPaintConfig.DefaultZoomToolbarVisible: boolean;
  595. begin
  596. result := iniOptions.ReadBool('Toolbar','ZoomToolbar',true);
  597. end;
  598. procedure TLazPaintConfig.SetDefaultZoomToolbarVisible(value: boolean);
  599. begin
  600. iniOptions.WriteBool('Toolbar','ZoomToolbar',value);
  601. end;
  602. function TLazPaintConfig.DefaultFileToolbarVisible: boolean;
  603. begin
  604. result := iniOptions.ReadBool('Toolbar','FileToolbar',true);
  605. end;
  606. procedure TLazPaintConfig.SetDefaultFileToolbarVisible(value: boolean);
  607. begin
  608. iniOptions.WriteBool('Toolbar','FileToolbar',value);
  609. end;
  610. function TLazPaintConfig.DefaultUndoRedoToolbarVisible: boolean;
  611. begin
  612. result := iniOptions.ReadBool('Toolbar','UndoRedoToolbar',true);
  613. end;
  614. procedure TLazPaintConfig.SetDefaultUndoRedoToolbarVisible(value: boolean);
  615. begin
  616. iniOptions.WriteBool('Toolbar','UndoRedoToolbar',value);
  617. end;
  618. function TLazPaintConfig.DefaultCopyPasteToolbarVisible: boolean;
  619. begin
  620. result := iniOptions.ReadBool('Toolbar','CopyPasteToolbar',false);
  621. end;
  622. procedure TLazPaintConfig.SetDefaultCopyPasteToolbarVisible(value: boolean);
  623. begin
  624. iniOptions.WriteBool('Toolbar','CopyPasteToolbar',value);
  625. end;
  626. function TLazPaintConfig.DefaultCoordinatesToolbarVisible: boolean;
  627. begin
  628. result := iniOptions.ReadBool('Toolbar','CoordinatesToolbar',true);
  629. end;
  630. procedure TLazPaintConfig.SetDefaultCoordinatesToolbarVisible(value: boolean);
  631. begin
  632. iniOptions.WriteBool('Toolbar','CoordinatesToolbar',value);
  633. end;
  634. function TLazPaintConfig.GetStatusBarVisible: boolean;
  635. begin
  636. result := iniOptions.ReadBool('Toolbar','StatusBar',true);
  637. end;
  638. procedure TLazPaintConfig.SetStatusBarVisible(value: boolean);
  639. begin
  640. iniOptions.WriteBool('Toolbar','StatusBar',value);
  641. end;
  642. function TLazPaintConfig.GetWorkspaceColor: TColor;
  643. begin
  644. if not FWorkspaceColorEvaluated then
  645. begin
  646. if GetDarkTheme then
  647. FWorkspaceColor := StrToBGRA(iniOptions.ReadString('General','DarkWorkspaceColor', '#2D3B49'), clAppWorkspace)
  648. else
  649. FWorkspaceColor := StrToBGRA(iniOptions.ReadString('General','WorkspaceColor', '#BBD1E8'), clAppWorkspace);
  650. FWorkspaceColorEvaluated := true;
  651. end;
  652. result := FWorkspaceColor;
  653. end;
  654. procedure TLazPaintConfig.SetWorkspaceColor(value: TColor);
  655. begin
  656. if GetDarkTheme then
  657. iniOptions.WriteString('General','DarkWorkspaceColor', BGRAToStr(value))
  658. else
  659. iniOptions.WriteString('General','WorkspaceColor', BGRAToStr(value));
  660. FWorkspaceColor:= value;
  661. FWorkspaceColorEvaluated:= true;
  662. end;
  663. function TLazPaintConfig.DefaultUseImageBrowser: boolean;
  664. begin
  665. result := iniOptions.ReadBool('General','UseImageBrowser',{$IFDEF DARWIN}false{$ELSE}true{$ENDIF});
  666. end;
  667. procedure TLazPaintConfig.SetDefaultUseImageBrowser(value: boolean);
  668. begin
  669. iniOptions.WriteBool('General','UseImageBrowser',value);
  670. end;
  671. function TLazPaintConfig.DefaultToolForeColor: TBGRAPixel;
  672. begin
  673. result := StrToBGRA(iniOptions.ReadString('Tool','ForeColor','00000080'));
  674. end;
  675. function TLazPaintConfig.DefaultToolBackColor: TBGRAPixel;
  676. begin
  677. result := StrToBGRA(iniOptions.ReadString('Tool','BackColor','0080FFC0'));
  678. end;
  679. function TLazPaintConfig.DefaultToolOutlineColor: TBGRAPixel;
  680. begin
  681. result := StrToBGRA(iniOptions.ReadString('Tool','OutlineColor','FF0000C0'));
  682. end;
  683. procedure TLazPaintConfig.SetDefaultToolForeColor(value: TBGRAPixel);
  684. begin
  685. iniOptions.WriteString('Tool','ForeColor',BGRAToStr(value));
  686. end;
  687. procedure TLazPaintConfig.SetDefaultToolBackColor(value: TBGRAPixel);
  688. begin
  689. iniOptions.WriteString('Tool','BackColor',BGRAToStr(value));
  690. end;
  691. procedure TLazPaintConfig.SetDefaultToolOutlineColor(value: TBGRAPixel);
  692. begin
  693. iniOptions.WriteString('Tool','OutlineColor',BGRAToStr(value));
  694. end;
  695. function TLazPaintConfig.DefaultToolForeGradient: string;
  696. begin
  697. result := iniOptions.ReadString('Tool','ForeGradient','');
  698. end;
  699. function TLazPaintConfig.DefaultToolBackGradient: string;
  700. begin
  701. result := iniOptions.ReadString('Tool','BackGradient','');
  702. end;
  703. function TLazPaintConfig.DefaultToolOutlineGradient: string;
  704. begin
  705. result := iniOptions.ReadString('Tool','OutlineGradient','');
  706. end;
  707. procedure TLazPaintConfig.SetDefaultToolForeGradient(value: string);
  708. begin
  709. iniOptions.WriteString('Tool','ForeGradient',value);
  710. end;
  711. procedure TLazPaintConfig.SetDefaultToolBackGradient(value: string);
  712. begin
  713. iniOptions.WriteString('Tool','BackGradient',value);
  714. end;
  715. procedure TLazPaintConfig.SetDefaultToolOutlineGradient(value: string);
  716. begin
  717. iniOptions.WriteString('Tool','OutlineGradient',value);
  718. end;
  719. function TLazPaintConfig.DefaultToolPenWidth: single;
  720. begin
  721. result := iniOptions.ReadFloat('Tool','PenWidth',5);
  722. end;
  723. procedure TLazPaintConfig.SetDefaultToolPenWidth(value: single);
  724. begin
  725. iniOptions.WriteFloat('Tool','PenWidth',value);
  726. end;
  727. function TLazPaintConfig.DefaultToolEraserWidth: single;
  728. begin
  729. result := iniOptions.ReadFloat('Tool','EraserWidth',10);
  730. end;
  731. procedure TLazPaintConfig.SetDefaultToolEraserWidth(value: single);
  732. begin
  733. iniOptions.WriteFloat('Tool','EraserWidth',value);
  734. end;
  735. function TLazPaintConfig.DefaultToolOptionDrawShape: boolean;
  736. begin
  737. result := iniOptions.ReadBool('Tool','DrawShape',true);
  738. end;
  739. procedure TLazPaintConfig.SetDefaultToolOptionDrawShape(value: boolean);
  740. begin
  741. iniOptions.WriteBool('Tool','DrawShape',value);
  742. end;
  743. function TLazPaintConfig.DefaultToolOptionFillShape: boolean;
  744. begin
  745. result := iniOptions.ReadBool('Tool','FillShape',true);
  746. end;
  747. procedure TLazPaintConfig.SetDefaultToolOptionFillShape(value: boolean);
  748. begin
  749. iniOptions.WriteBool('Tool','FillShape',value);
  750. end;
  751. function TLazPaintConfig.DefaultToolOptionCloseShape: boolean;
  752. begin
  753. result := iniOptions.ReadBool('Tool','CloseShape',true);
  754. end;
  755. procedure TLazPaintConfig.SetDefaultToolOptionCloseShape(value: boolean);
  756. begin
  757. iniOptions.WriteBool('Tool','CloseShape',value);
  758. end;
  759. function TLazPaintConfig.DefaultToolTolerance: integer;
  760. begin
  761. result := iniOptions.ReadInteger('Tool','Tolerance',64);
  762. end;
  763. procedure TLazPaintConfig.SetDefaultToolTolerance(value: integer);
  764. begin
  765. iniOptions.WriteInteger('Tool','Tolerance',value);
  766. end;
  767. function TLazPaintConfig.DefaultToolTextOutline: boolean;
  768. begin
  769. result := iniOptions.ReadBool('Tool','TextOutline',false);
  770. end;
  771. procedure TLazPaintConfig.SetDefaultToolTextOutline(value: boolean);
  772. begin
  773. iniOptions.WriteBool('Tool','TextOutline',value);
  774. end;
  775. function TLazPaintConfig.DefaultToolTextOutlineWidth: single;
  776. begin
  777. result := iniOptions.ReadFloat('Tool','TextOutlineWidth',2);
  778. end;
  779. procedure TLazPaintConfig.SetDefaultToolTextOutlineWidth(value: single);
  780. begin
  781. iniOptions.WriteFloat('Tool','TextOutlineWidth',value);
  782. end;
  783. function TLazPaintConfig.DefaultToolTextShadow: boolean;
  784. begin
  785. result := iniOptions.ReadBool('Tool','TextShadow',false);
  786. end;
  787. procedure TLazPaintConfig.SetDefaultToolTextShadow(value: boolean);
  788. begin
  789. iniOptions.WriteBool('Tool','TextShadow',value);
  790. end;
  791. function TLazPaintConfig.DefaultToolTextFont: TFont;
  792. var fontStyle: TFontStyles;
  793. begin
  794. tempFont.Name := iniOptions.ReadString('Tool','TextFontName','');
  795. tempFont.Size := iniOptions.ReadInteger('Tool','TextFontSize',10);
  796. fontStyle := [];
  797. if iniOptions.ReadBool('Tool','TextFontBold',False) then fontStyle += [fsBold];
  798. if iniOptions.ReadBool('Tool','TextFontItalic',False) then fontStyle += [fsItalic];
  799. if iniOptions.ReadBool('Tool','TextFontStrikeOut',False) then fontStyle += [fsStrikeOut];
  800. if iniOptions.ReadBool('Tool','TextFontUnderline',False) then fontStyle += [fsUnderline];
  801. tempFont.Style := fontStyle;
  802. result := tempFont;
  803. end;
  804. procedure TLazPaintConfig.SetDefaultToolTextFont(AName: string; ASize: single;
  805. AStyle: TFontStyles);
  806. begin
  807. iniOptions.WriteString('Tool','TextFontName',AName);
  808. iniOptions.WriteInteger('Tool','TextFontSize',round(ASize));
  809. iniOptions.DeleteKey('Tool','TextFontHeight');
  810. iniOptions.WriteBool('Tool','TextFontBold',fsBold in AStyle);
  811. iniOptions.WriteBool('Tool','TextFontItalic',fsItalic in AStyle);
  812. iniOptions.WriteBool('Tool','TextFontStrikeOut',fsStrikeOut in AStyle);
  813. iniOptions.WriteBool('Tool','TextFontUnderline',fsUnderline in AStyle);
  814. end;
  815. function TLazPaintConfig.DefaultToolTextBlur: single;
  816. begin
  817. result := iniOptions.ReadFloat('Tool','TextBlur',4);
  818. end;
  819. procedure TLazPaintConfig.SetDefaultToolTextBlur(value: single);
  820. begin
  821. iniOptions.WriteFloat('Tool','TextBlur',value);
  822. end;
  823. function TLazPaintConfig.DefaultToolTextShadowOffsetX: integer;
  824. begin
  825. result := iniOptions.ReadInteger('Tool','TextShadowX',5);
  826. end;
  827. procedure TLazPaintConfig.SetDefaultToolTextShadowOffsetX(value: integer);
  828. begin
  829. iniOptions.WriteInteger('Tool','TextShadowX',value);
  830. end;
  831. function TLazPaintConfig.DefaultToolTextShadowOffsetY: integer;
  832. begin
  833. result := iniOptions.ReadInteger('Tool','TextShadowY',5);
  834. end;
  835. procedure TLazPaintConfig.SetDefaultToolTextShadowOffsetY(value: integer);
  836. begin
  837. iniOptions.WriteInteger('Tool','TextShadowY',value);
  838. end;
  839. procedure TLazPaintConfig.SetDefaultToolTextShadowOffset(value: TPoint);
  840. begin
  841. SetDefaultToolTextShadowOffsetX(value.X);
  842. SetDefaultToolTextShadowOffsetY(value.Y);
  843. end;
  844. function TLazPaintConfig.DefaultToolTextShadowOffset: TPoint;
  845. begin
  846. result := Point(DefaultToolTextShadowOffsetX,DefaultToolTextShadowOffsetY);
  847. end;
  848. function TLazPaintConfig.DefaultToolTextPhong: boolean;
  849. begin
  850. result := iniOptions.ReadBool('Tool','TextPhong',false);
  851. end;
  852. procedure TLazPaintConfig.SetDefaultToolTextPhong(value: boolean);
  853. begin
  854. iniOptions.WriteBool('Tool','TextPhong',value);
  855. end;
  856. function TLazPaintConfig.ToolPopupMessageShownCount(index: integer): integer;
  857. begin
  858. result := iniOptions.ReadInteger('Popup','ToolPopupMessage' + inttostr(index),0);
  859. end;
  860. procedure TLazPaintConfig.SetToolPopupMessageShownCount(index: integer;
  861. AValue: integer);
  862. begin
  863. iniOptions.WriteInteger('Popup','ToolPopupMessage' + inttostr(index), avalue);
  864. end;
  865. function TLazPaintConfig.DefaultToolLightPositionX: single;
  866. begin
  867. result := iniOptions.ReadFloat('Tool','LightPositionX',0);
  868. end;
  869. procedure TLazPaintConfig.SetDefaultToolLightPositionX(value: single);
  870. begin
  871. iniOptions.WriteFloat('Tool','LightPositionX',value);
  872. end;
  873. function TLazPaintConfig.DefaultToolLightPositionY: single;
  874. begin
  875. result := iniOptions.ReadFloat('Tool','LightPositionY',0);
  876. end;
  877. procedure TLazPaintConfig.SetDefaultToolLightPositionY(value: single);
  878. begin
  879. iniOptions.WriteFloat('Tool','LightPositionY',value);
  880. end;
  881. procedure TLazPaintConfig.SetDefaultToolLightPosition(const value: TPointF);
  882. begin
  883. SetDefaultToolLightPositionX(value.X);
  884. SetDefaultToolLightPositionY(value.Y);
  885. end;
  886. function TLazPaintConfig.DefaultToolLightPosition: TPointF;
  887. begin
  888. result := PointF(DefaultToolLightPositionX,DefaultToolLightPositionY);
  889. end;
  890. function TLazPaintConfig.DefaultToolLightAltitude: integer;
  891. begin
  892. result := iniOptions.ReadInteger('Filter','LightPositionZ',100);
  893. end;
  894. procedure TLazPaintConfig.SetDefaultToolLightAltitude(value: integer);
  895. begin
  896. iniOptions.WriteInteger('Filter','LightPositionZ',value);
  897. end;
  898. function TLazPaintConfig.DefaultToolShapeAltitude: integer;
  899. begin
  900. result := iniOptions.ReadInteger('Filter','ShapeAltitude',50);
  901. end;
  902. procedure TLazPaintConfig.SetDefaultToolShapeAltitude(value: integer);
  903. begin
  904. iniOptions.WriteInteger('Filter','ShapeAltitude',value);
  905. end;
  906. function TLazPaintConfig.DefaultToolShapeBorderSize: integer;
  907. begin
  908. result := iniOptions.ReadInteger('Filter','ShapeBorderSize',20);
  909. end;
  910. procedure TLazPaintConfig.SetDefaultToolShapeBorderSize(value: integer);
  911. begin
  912. iniOptions.WriteInteger('Filter','ShapeBorderSize',value);
  913. end;
  914. function TLazPaintConfig.DefaultToolShapeType: TPhongShapeKind;
  915. var
  916. str: String;
  917. begin
  918. str := iniOptions.ReadString('Filter','ShapeType','Rectangle');
  919. if str = 'RoundRectangle' then result := pskRoundRectangle else
  920. if str = 'Sphere' then result := pskHalfSphere else
  921. if str = 'Cone' then result := pskConeTop else
  922. if str = 'VerticalCone' then result := pskConeSide else
  923. if str = 'VerticalCylinder' then result := pskVertCylinder else
  924. if str = 'HorizontalCylinder' then result := pskHorizCylinder
  925. else result := pskRectangle;
  926. end;
  927. procedure TLazPaintConfig.SetDefaultToolShapeType(value: TPhongShapeKind);
  928. var
  929. str: String;
  930. begin
  931. case value of
  932. pskRoundRectangle: str := 'RoundRectangle';
  933. pskHalfSphere: str := 'Sphere';
  934. pskConeTop: str := 'Cone';
  935. pskConeSide: str := 'VerticalCone';
  936. pskVertCylinder: str := 'VerticalCylinder';
  937. pskHorizCylinder: str := 'HorizontalCylinder';
  938. else str:= 'Rectangle'
  939. end;
  940. iniOptions.WriteString('Filter','ShapeType',str);
  941. end;
  942. function TLazPaintConfig.DefaultRetrieveSelectionAnswer: TModalResult;
  943. begin
  944. result := iniOptions.ReadInteger('Tool','RetrieveSelectionAnswer', 0);
  945. end;
  946. procedure TLazPaintConfig.SetDefaultRetrieveSelectionAnswer(value: TModalResult);
  947. begin
  948. iniOptions.WriteInteger('Tool','RetrieveSelectionAnswer', value);
  949. end;
  950. function TLazPaintConfig.DefaultTransformSelectionAnswer: TModalResult;
  951. begin
  952. result := iniOptions.ReadInteger('Tool','TransformSelectionAnswer', 0);
  953. end;
  954. procedure TLazPaintConfig.SetDefaultTransformSelectionAnswer(value: TModalResult);
  955. begin
  956. iniOptions.WriteInteger('Tool','TransformSelectionAnswer', value);
  957. end;
  958. function TLazPaintConfig.DefaultBlurRadius: single;
  959. begin
  960. result := iniOptions.ReadFloat('Filter','BlurRadius',5);
  961. end;
  962. procedure TLazPaintConfig.SetDefaultBlurRadius(value: single);
  963. begin
  964. iniOptions.WriteFloat('Filter','BlurRadius',value);
  965. end;
  966. function TLazPaintConfig.DefaultPixelateSize: integer;
  967. begin
  968. result := iniOptions.ReadInteger('Filter','PixelateSize',5);
  969. end;
  970. procedure TLazPaintConfig.SetDefaultPixelateSize(value: integer);
  971. begin
  972. iniOptions.WriteInteger('Filter','PixelateSize',value);
  973. end;
  974. function TLazPaintConfig.DefaultPixelateQuality: string;
  975. begin
  976. result := iniOptions.ReadString('Filter','PixelateQuality','Linear');
  977. end;
  978. procedure TLazPaintConfig.SetDefaultPixelateQuality(value: string);
  979. begin
  980. iniOptions.WriteString('Filter','PixelateQuality',value);
  981. end;
  982. function TLazPaintConfig.DefaultSharpenAmount: single;
  983. begin
  984. result := iniOptions.ReadFloat('Filter','SharpenAmount',1);
  985. end;
  986. procedure TLazPaintConfig.SetDefaultSharpenAmount(value: single);
  987. begin
  988. iniOptions.WriteFloat('Filter','SharpenAmount',value);
  989. end;
  990. function TLazPaintConfig.DefaultBlurMotionAngle: double;
  991. begin
  992. result := iniOptions.ReadFloat('Filter','MotionBlurAngle',0);
  993. end;
  994. function TLazPaintConfig.DefaultBlurMotionDistance: single;
  995. begin
  996. result := iniOptions.ReadFloat('Filter','MotionBlurDistance',5);
  997. end;
  998. function TLazPaintConfig.DefaultBlurMotionOriented: boolean;
  999. begin
  1000. result := iniOptions.ReadBool('Filter','MotionBlurOriented',true);
  1001. end;
  1002. procedure TLazPaintConfig.SetDefaultBlurMotionAngle(value: double);
  1003. begin
  1004. iniOptions.WriteFloat('Filter','MotionBlurAngle',value);
  1005. end;
  1006. procedure TLazPaintConfig.SetDefaultBlurMotionDistance(value: single);
  1007. begin
  1008. iniOptions.WriteFloat('Filter','MotionBlurDistance',value);
  1009. end;
  1010. procedure TLazPaintConfig.SetDefaultBlurMotionOriented(value: boolean);
  1011. begin
  1012. iniOptions.WriteBool('Filter','MotionBlurOriented',value);
  1013. end;
  1014. function TLazPaintConfig.DefaultCustomBlurMaskUTF8: string;
  1015. begin
  1016. result := iniOptions.ReadString('Filter','CustomBlurMask','');
  1017. end;
  1018. procedure TLazPaintConfig.SetDefaultCustomBlurMaskUTF8(value: string);
  1019. begin
  1020. iniOptions.WriteString('Filter','CustomBlurMask',value);
  1021. end;
  1022. function TLazPaintConfig.DefaultEmbossAngle: double;
  1023. begin
  1024. result := iniOptions.ReadFloat('Filter','EmbossAngle',45);
  1025. end;
  1026. procedure TLazPaintConfig.SetDefaultEmbossAngle(value: double);
  1027. begin
  1028. iniOptions.WriteFloat('Filter','EmbossAngle',value);
  1029. end;
  1030. function TLazPaintConfig.DefaultRainWind: double;
  1031. begin
  1032. result := iniOptions.ReadFloat('Filter','RainWind',-0.5);
  1033. end;
  1034. procedure TLazPaintConfig.SetDefaultRainWind(value: double);
  1035. begin
  1036. iniOptions.WriteFloat('Filter','RainWind',value);
  1037. end;
  1038. function TLazPaintConfig.DefaultRainQuantity: double;
  1039. begin
  1040. result := iniOptions.ReadFloat('Filter','RainQuantity',0.5);
  1041. end;
  1042. procedure TLazPaintConfig.SetDefaultRainQuantity(value: double);
  1043. begin
  1044. iniOptions.WriteFloat('Filter','RainQuantity',value);
  1045. end;
  1046. function TLazPaintConfig.DefaultTwirlRadius: double;
  1047. begin
  1048. result := iniOptions.ReadFloat('Filter','TwirlRadius',100);
  1049. end;
  1050. procedure TLazPaintConfig.SetDefaultTwirlRadius(value: double);
  1051. begin
  1052. iniOptions.WriteFloat('Filter','TwirlRadius',value);
  1053. end;
  1054. function TLazPaintConfig.DefaultTwirlTurn: double;
  1055. begin
  1056. result := iniOptions.ReadFloat('Filter','TwirlTurn',1);
  1057. end;
  1058. procedure TLazPaintConfig.SetDefaultTwirlTurn(value: double);
  1059. begin
  1060. iniOptions.WriteFloat('Filter','TwirlTurn',value);
  1061. end;
  1062. function TLazPaintConfig.DefaultWaveDisplacementWavelength: double;
  1063. begin
  1064. result := iniOptions.ReadFloat('Filter','WaveDisplacementWavelength',100);
  1065. end;
  1066. procedure TLazPaintConfig.SetDefaultWaveDisplacementWavelength(value: double);
  1067. begin
  1068. iniOptions.WriteFloat('Filter','WaveDisplacementWavelength',value);
  1069. end;
  1070. function TLazPaintConfig.DefaultWaveDisplacementAmount: double;
  1071. begin
  1072. result := iniOptions.ReadFloat('Filter','WaveDisplacementAmount',50);
  1073. end;
  1074. procedure TLazPaintConfig.SetDefaultWaveDisplacementAmount(value: double);
  1075. begin
  1076. iniOptions.WriteFloat('Filter','WaveDisplacementAmount',value);
  1077. end;
  1078. function TLazPaintConfig.DefaultWaveDisplacementPhase: double;
  1079. begin
  1080. result := iniOptions.ReadFloat('Filter','WaveDisplacementPhase',0);
  1081. end;
  1082. procedure TLazPaintConfig.SetDefaultWaveDisplacementPhase(value: double);
  1083. begin
  1084. iniOptions.WriteFloat('Filter','WaveDisplacementPhase',value);
  1085. end;
  1086. function TLazPaintConfig.DefaultPhongFilterAltitude: integer;
  1087. begin
  1088. result := iniOptions.ReadInteger('Filter','MapAltitude',10);
  1089. end;
  1090. procedure TLazPaintConfig.SetDefaultPhongFilterAltitude(value: integer);
  1091. begin
  1092. iniOptions.WriteInteger('Filter','MapAltitude',value);
  1093. end;
  1094. function TLazPaintConfig.DefaultPosterizeLevels: integer;
  1095. begin
  1096. result := iniOptions.ReadInteger('Filter','PosterizeLevels',4);
  1097. end;
  1098. procedure TLazPaintConfig.SetDefaultPosterizeLevels(value: integer);
  1099. begin
  1100. iniOptions.WriteInteger('Filter','PosterizeLevels',value);
  1101. end;
  1102. function TLazPaintConfig.DefaultPosterizeByLightness: boolean;
  1103. begin
  1104. result := iniOptions.ReadBool('Filter','PosterizeByLightness',True);
  1105. end;
  1106. procedure TLazPaintConfig.SetDefaultPosterizeByLightness(value: boolean);
  1107. begin
  1108. iniOptions.WriteBool('Filter','PosterizeByLightness',value);
  1109. end;
  1110. function TLazPaintConfig.DefaultUseGSBA: boolean;
  1111. begin
  1112. result := iniOptions.ReadBool('Filter','UseGSBA',True);
  1113. end;
  1114. procedure TLazPaintConfig.SetDefaultUseGSBA(value: boolean);
  1115. begin
  1116. iniOptions.WriteBool('Filter','UseGSBA',value);
  1117. end;
  1118. procedure TLazPaintConfig.InitRecentFiles;
  1119. var i: integer;
  1120. begin
  1121. recentFiles := TStringList.Create;
  1122. iniOptions.ReadSection('RecentFiles',recentFiles);
  1123. for i := 0 to recentFiles.Count-1 do
  1124. recentFiles[i] := iniOptions.ReadString('RecentFiles',recentFiles[i],'');
  1125. for i := recentFiles.Count-1 downto 0 do
  1126. if not FileManager.FileExists(recentFiles[i]) then recentFiles.Delete(i);
  1127. recentDirs := TStringList.Create;
  1128. iniOptions.ReadSection('RecentDirectories',recentDirs);
  1129. for i := 0 to recentDirs.Count-1 do
  1130. recentDirs[i] := iniOptions.ReadString('RecentDirectories',recentDirs[i],'');
  1131. for i := recentDirs.Count-1 downto 0 do
  1132. if not FileManager.IsDirectory(recentDirs[i]) then recentDirs.Delete(i);
  1133. end;
  1134. procedure TLazPaintConfig.FinalizeRecentFiles;
  1135. var i: integer;
  1136. begin
  1137. iniOptions.EraseSection('RecentFiles');
  1138. for i := 0 to recentFiles.Count-1 do
  1139. iniOptions.WriteString('RecentFiles','File'+inttostr(I+1),recentFiles[i]);
  1140. recentFiles.Free;
  1141. iniOptions.EraseSection('RecentDirectories');
  1142. for i := 0 to recentDirs.Count-1 do
  1143. iniOptions.WriteString('RecentDirectories','Dir'+inttostr(I+1),recentDirs[i]);
  1144. recentDirs.Free;
  1145. end;
  1146. function TLazPaintConfig.DefaultRememberStartupTargetDirectory: boolean;
  1147. begin
  1148. result := iniOptions.ReadBool('Startup', 'RememberTargetDirectory', false);
  1149. end;
  1150. procedure TLazPaintConfig.SetRememberStartupTargetDirectory(AValue: boolean);
  1151. begin
  1152. iniOptions.WriteBool('Startup', 'RememberTargetDirectory', AValue);
  1153. end;
  1154. function TLazPaintConfig.DefaultRememberStartupExportDirectory: boolean;
  1155. begin
  1156. result := iniOptions.ReadBool('Startup', 'RememberExportDirectory', false);
  1157. end;
  1158. procedure TLazPaintConfig.SetRememberStartupExportDirectory(AValue: boolean);
  1159. begin
  1160. iniOptions.WriteBool('Startup', 'RememberExportDirectory', AValue);
  1161. end;
  1162. function TLazPaintConfig.DefaultRememberStartupSourceDirectory: boolean;
  1163. begin
  1164. result := iniOptions.ReadBool('Startup', 'RememberSourceDirectory', false);
  1165. end;
  1166. procedure TLazPaintConfig.SetRememberStartupSourceDirectory(AValue: boolean);
  1167. begin
  1168. iniOptions.WriteBool('Startup', 'RememberSourceDirectory', AValue);
  1169. end;
  1170. function TLazPaintConfig.DefaultStartupSourceDirectory: string;
  1171. begin
  1172. result := iniOptions.ReadString('Startup', 'SourceDirectory', '');
  1173. end;
  1174. procedure TLazPaintConfig.SetStartupSourceDirectory(AValue: string);
  1175. begin
  1176. iniOptions.WriteString('Startup', 'SourceDirectory', AValue);
  1177. end;
  1178. function TLazPaintConfig.DefaultStartupTargetDirectory: string;
  1179. begin
  1180. result := iniOptions.ReadString('Startup', 'TargetDirectory', '');
  1181. end;
  1182. procedure TLazPaintConfig.SetStartupTargetDirectory(AValue: string);
  1183. begin
  1184. iniOptions.WriteString('Startup', 'TargetDirectory', AValue);
  1185. end;
  1186. function TLazPaintConfig.DefaultStartupExportDirectory: string;
  1187. begin
  1188. result := iniOptions.ReadString('Startup', 'ExportDirectory', '');
  1189. end;
  1190. procedure TLazPaintConfig.SetStartupExportDirectory(AValue: string);
  1191. begin
  1192. iniOptions.WriteString('Startup', 'ExportDirectory', AValue);
  1193. end;
  1194. function TLazPaintConfig.DefaultRememberSaveFormat: boolean;
  1195. begin
  1196. result := iniOptions.ReadBool('Startup', 'RememberSaveFormat', false);
  1197. end;
  1198. procedure TLazPaintConfig.SetRememberSaveFormat(AValue: boolean);
  1199. begin
  1200. iniOptions.WriteBool('Startup', 'RememberSaveFormat', AValue);
  1201. end;
  1202. function TLazPaintConfig.DefaultSaveExtensions: string;
  1203. begin
  1204. result := iniOptions.ReadString('Startup', 'SaveExtensions', '');
  1205. end;
  1206. procedure TLazPaintConfig.SetSaveExtensions(AValue: string);
  1207. begin
  1208. iniOptions.WriteString('Startup', 'SaveExtensions', AValue);
  1209. end;
  1210. procedure TLazPaintConfig.SetBrushes(ABrushes: TStringList);
  1211. var
  1212. i: Integer;
  1213. begin
  1214. iniOptions.EraseSection('Brushes');
  1215. iniOptions.WriteInteger('Brushes','Count',ABrushes.Count);
  1216. for i := 0 to ABrushes.Count-1 do
  1217. iniOptions.WriteString('Brushes','Brush'+inttostr(I+1),ABrushes[i]);
  1218. end;
  1219. function TLazPaintConfig.DefaultJpegQuality: integer;
  1220. begin
  1221. result := iniOptions.ReadInteger('General','JpegQuality',100);
  1222. end;
  1223. procedure TLazPaintConfig.SetDefaultJpegQuality(value: integer);
  1224. begin
  1225. iniOptions.WriteInteger('General','JpegQuality',value);
  1226. end;
  1227. function TLazPaintConfig.DefaultWebPLossless: boolean;
  1228. begin
  1229. result := iniOptions.ReadBool('General','WebPLossless',true);
  1230. end;
  1231. procedure TLazPaintConfig.SetDefaultWebPLossless(value: boolean);
  1232. begin
  1233. iniOptions.WriteBool('General','WebPLossless',value);
  1234. end;
  1235. function TLazPaintConfig.DefaultSaveOptionDialogMaximized: boolean;
  1236. begin
  1237. result := iniOptions.ReadBool('Window','SaveOptionDialogMaximized',false);
  1238. end;
  1239. procedure TLazPaintConfig.SetDefaultSaveOptionDialogMaximized(value: boolean);
  1240. begin
  1241. iniOptions.WriteBool('Window','SaveOptionDialogMaximized',value);
  1242. end;
  1243. procedure TLazPaintConfig.InitColorizePresets;
  1244. var presetsStr: TStringList;
  1245. i: integer;
  1246. begin
  1247. presetsStr := TStringList.Create;
  1248. iniOptions.ReadSection('Colorize',presetsStr);
  1249. colorizePresets := TList.Create;
  1250. for i := 0 to presetsStr.Count-1 do
  1251. begin
  1252. AddColorizePreset(TVariableSet.Create('ColorColorize',iniOptions.ReadString('Colorize',presetsStr[i],'')));
  1253. end;
  1254. presetsStr.free;
  1255. if ColorizePresetCount = 0 then
  1256. begin
  1257. AddColorizePreset('Antartic',211,0.660,True);
  1258. AddColorizePreset('Mars',16.5,0.902,True);
  1259. AddColorizePreset('Purple',291,0.634,False);
  1260. AddColorizePreset('Sepia',31.0,0.119,False);
  1261. end;
  1262. end;
  1263. function TLazPaintConfig.AddColorizePreset(AName: string; AHue,
  1264. ASaturation: double; ACorrection: Boolean): integer;
  1265. var
  1266. params: TVariableSet;
  1267. begin
  1268. params := TVariableSet.Create('ColorColorize');
  1269. params.AddString('Name',AName);
  1270. params.AddFloat('Hue', AHue);
  1271. params.AddFloat('Saturation',ASaturation);
  1272. params.AddBoolean('Correction',ACorrection);
  1273. result := AddColorizePreset(params);
  1274. end;
  1275. function TLazPaintConfig.AddColorizePreset(AParams: TVariableSet): integer;
  1276. var i: integer;
  1277. s: string;
  1278. begin
  1279. s := AParams.Strings['Name'];
  1280. for i := ColorizePresetCount-1 downto 0 do
  1281. if CompareText(colorizePreset[i].Strings['Name'],s) = 0 then
  1282. RemoveColorizePreset(i);
  1283. result := colorizePresets.Add(AParams);
  1284. end;
  1285. procedure TLazPaintConfig.RemoveColorizePreset(AIndex: integer);
  1286. begin
  1287. if (AIndex >= 0) and (AIndex < ColorizePresetCount) then
  1288. begin
  1289. ColorizePreset[AIndex].Free;
  1290. colorizePresets.Delete(AIndex);
  1291. end;
  1292. end;
  1293. function TLazPaintConfig.IndexOfColorizePreset(AName: string): integer;
  1294. var i: integer;
  1295. begin
  1296. for i := ColorizePresetCount-1 downto 0 do
  1297. if CompareText(colorizePreset[i].Strings['Name'],AName) = 0 then
  1298. begin
  1299. result := i;
  1300. exit;
  1301. end;
  1302. result := -1;
  1303. end;
  1304. procedure TLazPaintConfig.FinalizeColorizePresets;
  1305. var i: integer;
  1306. begin
  1307. iniOptions.EraseSection('Colorize');
  1308. for i := 0 to ColorizePresetCount-1 do
  1309. iniOptions.WriteString('Colorize','Preset'+inttostr(I+1),ColorizePreset[i].VariablesAsString);
  1310. for i := 0 to ColorizePresetCount-1 do
  1311. ColorizePreset[i].Free;
  1312. colorizePresets.Free;
  1313. end;
  1314. function TLazPaintConfig.DefaultLangage: string;
  1315. begin
  1316. result := ClassGetDefaultLangage(iniOptions);
  1317. end;
  1318. class function TLazPaintConfig.ClassGetDefaultLangage(AIni: TIniFile): string;
  1319. begin
  1320. result := AIni.ReadString('General','Language','');
  1321. if result = '' then result := 'auto';
  1322. end;
  1323. procedure TLazPaintConfig.SetDefaultLangage(value: string);
  1324. begin
  1325. if value = 'auto' then value := '';
  1326. iniOptions.WriteString('General','Language',value);
  1327. end;
  1328. function TLazPaintConfig.GetLastUpdateCheck: TDateTime;
  1329. begin
  1330. result := iniOptions.ReadInt64('General','LastUpdateCheck',0);
  1331. end;
  1332. procedure TLazPaintConfig.SetLastUpdateCheck(value: TDateTime);
  1333. begin
  1334. iniOptions.WriteInt64('General','LastUpdateCheck',round(value));
  1335. end;
  1336. function TLazPaintConfig.LatestVersion: string;
  1337. begin
  1338. result := iniOptions.ReadString('General','LatestOnlineVersion','');
  1339. end;
  1340. procedure TLazPaintConfig.SetLatestVersion(value: string);
  1341. begin
  1342. iniOptions.WriteString('General','LatestOnlineVersion',value);
  1343. end;
  1344. procedure TLazPaintConfig.GetUpdatedLanguages(AList: TStringList);
  1345. begin
  1346. ClassGetUpdatedLanguages(AList,iniOptions,FVersion);
  1347. end;
  1348. procedure TLazPaintConfig.SetUpdatedLanguages(AList: TStringList);
  1349. begin
  1350. ClassSetUpdatedLanguages(AList,iniOptions,FVersion);
  1351. end;
  1352. class procedure TLazPaintConfig.ClassGetUpdatedLanguages(AList: TStringList;
  1353. AIni: TIniFile; AVersion: string);
  1354. begin
  1355. AList.CommaText := AIni.ReadString('General','UpdatedLanguages'+AVersion,'');
  1356. end;
  1357. class procedure TLazPaintConfig.ClassSetUpdatedLanguages(AList: TStringList;
  1358. AIni: TIniFile; AVersion: string);
  1359. begin
  1360. AIni.WriteString('General','UpdatedLanguages'+AVersion,AList.CommaText)
  1361. end;
  1362. procedure TLazPaintConfig.AddUpdatedLanguage(ALang: string);
  1363. var list: TStringList;
  1364. begin
  1365. list := TStringList.Create;
  1366. GetUpdatedLanguages(list);
  1367. if list.IndexOf(ALang)=-1 then
  1368. begin
  1369. list.Add(ALang);
  1370. SetUpdatedLanguages(list);
  1371. end;
  1372. list.Free;
  1373. end;
  1374. function TLazPaintConfig.Default3dObjectDirectory: string;
  1375. begin
  1376. result := iniOptions.ReadString('General','3dObjectDirectory','');
  1377. end;
  1378. procedure TLazPaintConfig.SetDefault3dObjectDirectory(value: string);
  1379. begin
  1380. iniOptions.WriteString('General','3dObjectDirectory',ChompPathDelim(value))
  1381. end;
  1382. function TLazPaintConfig.DefaultTextureDirectory: string;
  1383. begin
  1384. result := iniOptions.ReadString('General','TextureDirectory',DefaultPicturesDirectory);
  1385. end;
  1386. procedure TLazPaintConfig.SetDefaultTextureDirectory(value: string);
  1387. begin
  1388. iniOptions.WriteString('General','TextureDirectory',ChompPathDelim(value))
  1389. end;
  1390. function TLazPaintConfig.DefaultBrushDirectory: string;
  1391. begin
  1392. result := iniOptions.ReadString('General','BrushDirectory',DefaultPicturesDirectory);
  1393. end;
  1394. procedure TLazPaintConfig.SetDefaultBrushDirectory(value: string);
  1395. begin
  1396. iniOptions.WriteString('General','BrushDirectory',ChompPathDelim(value))
  1397. end;
  1398. function TLazPaintConfig.DefaultPaletteDirectory: string;
  1399. begin
  1400. result := iniOptions.ReadString('General','PaletteDirectory','');
  1401. end;
  1402. procedure TLazPaintConfig.SetDefaultPaletteDirectory(value: string);
  1403. begin
  1404. iniOptions.WriteString('General','PaletteDirectory',ChompPathDelim(value))
  1405. end;
  1406. function TLazPaintConfig.DefaultScriptDirectory: string;
  1407. begin
  1408. result := iniOptions.ReadString('General','ScriptDirectory','');
  1409. end;
  1410. procedure TLazPaintConfig.SetDefaultScriptDirectory(value: string);
  1411. begin
  1412. iniOptions.WriteString('General','ScriptDirectory',ChompPathDelim(value))
  1413. end;
  1414. function TLazPaintConfig.DefaultIconSize(defaultValue: integer): integer;
  1415. begin
  1416. result := iniOptions.ReadInteger('General','DefaultIconSize',0);
  1417. if result > 48 then result := 48;
  1418. if result = 0 then result := defaultValue;
  1419. end;
  1420. procedure TLazPaintConfig.SetDefaultIconSize(value: integer);
  1421. begin
  1422. iniOptions.WriteInteger('General','DefaultIconSize',value);
  1423. end;
  1424. function TLazPaintConfig.GetDarkTheme: boolean;
  1425. begin
  1426. if not FDarkThemeEvaluated then
  1427. begin
  1428. FDarkTheme := iniOptions.ReadBool('General','DarkTheme', false);
  1429. FDarkThemeEvaluated:= true;
  1430. end;
  1431. result := FDarkTheme;
  1432. end;
  1433. procedure TLazPaintConfig.SetDarkTheme(AValue: boolean);
  1434. begin
  1435. if FDarkThemeEvaluated and (AValue = FDarkTheme) then exit;
  1436. iniOptions.WriteBool('General','DarkTheme', AValue);
  1437. FDarkTheme:= AValue;
  1438. FDarkThemeEvaluated:= true;
  1439. FWorkspaceColorEvaluated:= false;
  1440. end;
  1441. function TLazPaintConfig.ScreenSizeChanged: boolean;
  1442. var currentScreenSize,previousScreenSize: TRect;
  1443. begin
  1444. currentScreenSize := rect(0,0,screen.Width,screen.Height);
  1445. previousScreenSize := DefaultScreenSize;
  1446. if not CompareRect(@previousScreenSize,@currentScreenSize.left) then
  1447. begin
  1448. SetDefaultScreenSize(currentScreenSize);
  1449. result := true;
  1450. end else
  1451. result := false;
  1452. end;
  1453. procedure TLazPaintConfig.AddRecentFile(filename: string);
  1454. var idx : integer;
  1455. begin
  1456. idx := recentFiles.IndexOf(filename);
  1457. if idx <> -1 then
  1458. recentFiles.Delete(idx);
  1459. recentFiles.Insert(0,filename);
  1460. while recentFiles.count > maxRecentFiles do
  1461. recentFiles.Delete(recentFiles.count-1);
  1462. end;
  1463. procedure TLazPaintConfig.AddRecentDirectory(dirname: string);
  1464. var idx : integer;
  1465. begin
  1466. dirname := ChompPathDelim(dirname);
  1467. idx := recentDirs.IndexOf(dirname);
  1468. if idx <> -1 then
  1469. recentDirs.Delete(idx);
  1470. recentDirs.Insert(0,dirname);
  1471. while recentDirs.count > maxRecentDirectories do
  1472. recentDirs.Delete(recentDirs.count-1);
  1473. end;
  1474. function TLazPaintConfig.GetRecentFilesCount: integer;
  1475. begin
  1476. result := recentFiles.Count;
  1477. end;
  1478. function TLazPaintConfig.GetColorizePreset(Index: Integer): TVariableSet;
  1479. begin
  1480. result := TVariableSet(colorizePresets[Index]);
  1481. end;
  1482. function TLazPaintConfig.GetBrushCount: integer;
  1483. begin
  1484. result := iniOptions.ReadInteger('Brushes','Count',0);
  1485. end;
  1486. function TLazPaintConfig.GetBrushInfo(Index: integer): string;
  1487. begin
  1488. result := iniOptions.ReadString('Brushes','Brush'+IntToStr(index+1),'');
  1489. end;
  1490. function TLazPaintConfig.GetColorizePresetCount: integer;
  1491. begin
  1492. result := colorizePresets.Count;
  1493. end;
  1494. function TLazPaintConfig.GetRecentDirectoriesCount: integer;
  1495. begin
  1496. result := recentDirs.Count;
  1497. end;
  1498. function TLazPaintConfig.GetRecentDirectory(Index: Integer): string;
  1499. begin
  1500. result := recentDirs[Index];
  1501. end;
  1502. function TLazPaintConfig.GetRecentFile(Index: Integer): string;
  1503. begin
  1504. result := recentFiles[Index];
  1505. end;
  1506. function TLazPaintConfig.ImageListLastFolder: string;
  1507. begin
  1508. result := iniOptions.ReadString('ImageList','LastFolder','');
  1509. end;
  1510. procedure TLazPaintConfig.SetImageListLastFolder(value: string);
  1511. begin
  1512. iniOptions.WriteString('ImageList','LastFolder',ChompPathDelim(value));
  1513. end;
  1514. function TLazPaintConfig.ImageListAutoZoom: Boolean;
  1515. begin
  1516. result := iniOptions.ReadBool('ImageList','AutoZoom',True);
  1517. end;
  1518. procedure TLazPaintConfig.SetImageListAutoZoom(value: Boolean);
  1519. begin
  1520. iniOptions.WriteBool('ImageList','AutoZoom',Value);
  1521. end;
  1522. function TLazPaintConfig.ImageListAutoUncheck: Boolean;
  1523. begin
  1524. result := iniOptions.ReadBool('ImageList','AutoUncheck',True);
  1525. end;
  1526. procedure TLazPaintConfig.SetImageListAutoUncheck(value: Boolean);
  1527. begin
  1528. iniOptions.WriteBool('ImageList','AutoUncheck',Value);
  1529. end;
  1530. function TLazPaintConfig.ImageListAutoUncheckMode: Integer;
  1531. begin
  1532. result := iniOptions.ReadInteger('ImageList','AutoUncheckMode',0);
  1533. end;
  1534. procedure TLazPaintConfig.SetImageListAutoUncheckMode(value: integer);
  1535. begin
  1536. iniOptions.WriteInteger('ImageList','AutoUncheckMode',value);
  1537. end;
  1538. constructor TLazPaintConfig.Create(ini: TIniFile; AVersion: string);
  1539. begin
  1540. FVersion:= AVersion;
  1541. iniOptions := ini;
  1542. InitRecentFiles;
  1543. if ScreenSizeChanged then
  1544. begin
  1545. SetDefaultMainWindowPosition(EmptyRect);
  1546. SetDefaultColorWindowPosition(EmptyRect);
  1547. SetDefaultToolboxWindowPosition(EmptyRect);
  1548. SetDefaultLayerWindowPosition(EmptyRect);
  1549. SetDefaultImagelistWindowPosition(EmptyRect);
  1550. SetDefaultBrowseWindowPosition(EmptyRect);
  1551. end;
  1552. tempFont := TFont.Create;
  1553. Languages := TStringList.Create;
  1554. InitColorizePresets;
  1555. end;
  1556. destructor TLazPaintConfig.Destroy;
  1557. begin
  1558. FinalizeRecentFiles;
  1559. FinalizeColorizePresets;
  1560. iniOptions.Free;
  1561. tempFont.Free;
  1562. Languages.Free;
  1563. end;
  1564. initialization
  1565. MenuDefinitionKeys := TStringList.Create;
  1566. MenuDefinitionValues := TStringList.Create;
  1567. finalization
  1568. MenuDefinitionKeys.Free;
  1569. MenuDefinitionValues.Free;
  1570. end.