mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Early config file
ADD: Feature [0001272] Option to turn off splash screen
This commit is contained in:
parent
3d6a63cb79
commit
e933679fe3
8 changed files with 162 additions and 112 deletions
|
|
@ -36,6 +36,7 @@ uses
|
|||
uQt5Workaround,
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
uEarlyConfig,
|
||||
DCConvertEncoding,
|
||||
{$IF DEFINED(LCLWIN32) and DEFINED(DARKWIN)}
|
||||
uWin32WidgetSetDark,
|
||||
|
|
@ -186,7 +187,7 @@ begin
|
|||
|
||||
ProcessCommandLineParams; // before load paths
|
||||
|
||||
if not CommandLineParams.NoSplash then
|
||||
if (gSplashForm) and (not CommandLineParams.NoSplash) then
|
||||
begin
|
||||
// Let's show the starting slash screen to confirm user application has been started
|
||||
Application.CreateForm(TfrmStartingSplash, frmStartingSplash);
|
||||
|
|
@ -227,7 +228,7 @@ begin
|
|||
// in Application.CreateForm above.
|
||||
uKeyboard.HookKeyboardLayoutChanged;
|
||||
|
||||
if not CommandLineParams.NoSplash then
|
||||
if (gSplashForm) and (not CommandLineParams.NoSplash) then
|
||||
begin
|
||||
// We may now remove the starting splash screen, most of the application has been started now
|
||||
frmStartingSplash.Close;
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ unit fOptionsColors;
|
|||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, ExtCtrls, DCClassesUtf8, fOptionsFrame,
|
||||
fOptionsGroups;
|
||||
Classes, SysUtils, Forms, Controls, ExtCtrls, Dialogs,
|
||||
fOptionsFrame, fOptionsGroups;
|
||||
|
||||
type
|
||||
|
||||
|
|
@ -15,12 +15,10 @@ type
|
|||
TfrmOptionsColors = class(TOptionsColorsGroup)
|
||||
rgDarkMode: TRadioGroup;
|
||||
private
|
||||
FMode: Integer;
|
||||
FConfig: TIniFileEx;
|
||||
FAppMode: Integer;
|
||||
protected
|
||||
procedure Init; override;
|
||||
procedure Load; override;
|
||||
procedure Done; override;
|
||||
function Save: TOptionsEditorSaveFlags; override;
|
||||
public
|
||||
class function IsEmpty: Boolean; override;
|
||||
|
|
@ -34,52 +32,39 @@ implementation
|
|||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
DCStrUtils, uShowMsg, uGlobsPaths, uDarkStyle;
|
||||
DCStrUtils, uEarlyConfig, uDarkStyle;
|
||||
|
||||
{ TfrmOptionsColors }
|
||||
|
||||
procedure TfrmOptionsColors.Init;
|
||||
begin
|
||||
try
|
||||
FConfig:= TIniFileEx.Create(gpCfgDir + 'doublecmd.ini');
|
||||
except
|
||||
on E: Exception do msgError(E.Message);
|
||||
end;
|
||||
FAppMode:= gAppMode;
|
||||
ParseLineToList(rsDarkModeOptions, rgDarkMode.Items);
|
||||
end;
|
||||
|
||||
procedure TfrmOptionsColors.Load;
|
||||
begin
|
||||
FMode:= FConfig.ReadInteger('General', 'DarkMode', 1);
|
||||
case FMode of
|
||||
case FAppMode of
|
||||
1: rgDarkMode.ItemIndex:= 0;
|
||||
2: rgDarkMode.ItemIndex:= 1;
|
||||
3: rgDarkMode.ItemIndex:= 2;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmOptionsColors.Done;
|
||||
begin
|
||||
FConfig.Free;
|
||||
end;
|
||||
|
||||
function TfrmOptionsColors.Save: TOptionsEditorSaveFlags;
|
||||
var
|
||||
AMode: Integer;
|
||||
begin
|
||||
Result:= [];
|
||||
case rgDarkMode.ItemIndex of
|
||||
0: AMode:= 1;
|
||||
1: AMode:= 2;
|
||||
2: AMode:= 3;
|
||||
0: gAppMode:= 1;
|
||||
1: gAppMode:= 2;
|
||||
2: gAppMode:= 3;
|
||||
end;
|
||||
if FMode <> AMode then
|
||||
if gAppMode <> FAppMode then
|
||||
try
|
||||
FConfig.WriteInteger('General', 'DarkMode', AMode);
|
||||
FConfig.UpdateFile;
|
||||
SaveEarlyConfig;
|
||||
Result:= [oesfNeedsRestart];
|
||||
except
|
||||
on E: Exception do msgError(E.Message);
|
||||
on E: Exception do MessageDlg(E.Message, mtError, [mbOK], 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ inherited frmOptionsMisc: TfrmOptionsMisc
|
|||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 184
|
||||
Height = 230
|
||||
Top = 6
|
||||
Width = 707
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
|
|
@ -24,38 +24,48 @@ inherited frmOptionsMisc: TfrmOptionsMisc
|
|||
BorderSpacing.Around = 6
|
||||
ChildSizing.LeftRightSpacing = 12
|
||||
ChildSizing.TopBottomSpacing = 6
|
||||
ClientHeight = 164
|
||||
ClientHeight = 210
|
||||
ClientWidth = 703
|
||||
TabOrder = 0
|
||||
object chkShowWarningMessages: TCheckBox
|
||||
object chkShowSplashForm: TCheckBox
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 6
|
||||
Width = 251
|
||||
Caption = 'Show &warning messages ("OK" button only)'
|
||||
Width = 122
|
||||
Caption = 'Show &splash screen'
|
||||
TabOrder = 0
|
||||
end
|
||||
object chkShowWarningMessages: TCheckBox
|
||||
AnchorSideTop.Control = chkShowSplashForm
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 29
|
||||
Width = 251
|
||||
BorderSpacing.Top = 4
|
||||
Caption = 'Show &warning messages ("OK" button only)'
|
||||
TabOrder = 1
|
||||
end
|
||||
object chkThumbSave: TCheckBox
|
||||
AnchorSideTop.Control = dblThumbnails
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 79
|
||||
Top = 125
|
||||
Width = 154
|
||||
BorderSpacing.Top = 4
|
||||
Caption = '&Save thumbnails in cache'
|
||||
TabOrder = 3
|
||||
TabOrder = 4
|
||||
end
|
||||
object lblThumbSize: TLabel
|
||||
AnchorSideTop.Control = speThumbWidth
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 12
|
||||
Height = 15
|
||||
Top = 108
|
||||
Width = 83
|
||||
Top = 154
|
||||
Width = 82
|
||||
Caption = '&Thumbnail size:'
|
||||
FocusControl = speThumbWidth
|
||||
ParentColor = False
|
||||
end
|
||||
object dblThumbnails: TDividerBevel
|
||||
AnchorSideLeft.Control = gbExtended
|
||||
|
|
@ -65,7 +75,7 @@ inherited frmOptionsMisc: TfrmOptionsMisc
|
|||
AnchorSideRight.Side = asrBottom
|
||||
Left = 12
|
||||
Height = 15
|
||||
Top = 60
|
||||
Top = 106
|
||||
Width = 679
|
||||
Caption = 'Thumbnails'
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
|
|
@ -77,29 +87,29 @@ inherited frmOptionsMisc: TfrmOptionsMisc
|
|||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = chkThumbSave
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 101
|
||||
Left = 100
|
||||
Height = 23
|
||||
Top = 104
|
||||
Top = 150
|
||||
Width = 50
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 6
|
||||
MaxValue = 512
|
||||
MinValue = 16
|
||||
TabOrder = 4
|
||||
TabOrder = 5
|
||||
Value = 16
|
||||
end
|
||||
object speThumbHeight: TSpinEdit
|
||||
AnchorSideLeft.Control = lblThumbSeparator
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = speThumbWidth
|
||||
Left = 170
|
||||
Left = 169
|
||||
Height = 23
|
||||
Top = 104
|
||||
Top = 150
|
||||
Width = 50
|
||||
BorderSpacing.Left = 6
|
||||
MaxValue = 512
|
||||
MinValue = 16
|
||||
TabOrder = 5
|
||||
TabOrder = 6
|
||||
Value = 16
|
||||
end
|
||||
object lblThumbSeparator: TLabel
|
||||
|
|
@ -107,61 +117,59 @@ inherited frmOptionsMisc: TfrmOptionsMisc
|
|||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = speThumbWidth
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 157
|
||||
Left = 156
|
||||
Height = 15
|
||||
Top = 108
|
||||
Top = 154
|
||||
Width = 7
|
||||
BorderSpacing.Left = 6
|
||||
Caption = 'X'
|
||||
ParentColor = False
|
||||
end
|
||||
object lblThumbPixels: TLabel
|
||||
AnchorSideLeft.Control = speThumbHeight
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = speThumbWidth
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 226
|
||||
Left = 225
|
||||
Height = 15
|
||||
Top = 108
|
||||
Width = 29
|
||||
Top = 154
|
||||
Width = 30
|
||||
BorderSpacing.Left = 6
|
||||
Caption = 'pixels'
|
||||
ParentColor = False
|
||||
end
|
||||
object btnThumbCompactCache: TButton
|
||||
AnchorSideTop.Control = speThumbWidth
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 12
|
||||
Height = 25
|
||||
Top = 133
|
||||
Width = 271
|
||||
Top = 179
|
||||
Width = 272
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 6
|
||||
Caption = '&Remove thumbnails for no longer existing files'
|
||||
OnClick = btnThumbCompactCacheClick
|
||||
TabOrder = 6
|
||||
TabOrder = 7
|
||||
end
|
||||
object chkGoToRoot: TCheckBox
|
||||
AnchorSideTop.Control = chkShowWarningMessages
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 29
|
||||
Top = 52
|
||||
Width = 304
|
||||
BorderSpacing.Top = 4
|
||||
Caption = 'Always &go to the root of a drive when changing drives'
|
||||
TabOrder = 1
|
||||
TabOrder = 2
|
||||
end
|
||||
object chkShowCurDirTitleBar: TCheckBox
|
||||
AnchorSideTop.Control = chkGoToRoot
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 12
|
||||
Height = 19
|
||||
Top = 29
|
||||
Width = 304
|
||||
Top = 75
|
||||
Width = 291
|
||||
BorderSpacing.Top = 4
|
||||
Caption = 'Show ¤t directory in the main window title bar'
|
||||
TabOrder = 2
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object gbTCExportImport: TGroupBox[1]
|
||||
|
|
@ -172,7 +180,7 @@ inherited frmOptionsMisc: TfrmOptionsMisc
|
|||
AnchorSideRight.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 164
|
||||
Top = 269
|
||||
Top = 315
|
||||
Width = 707
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
|
|
@ -266,7 +274,6 @@ inherited frmOptionsMisc: TfrmOptionsMisc
|
|||
Width = 76
|
||||
Alignment = taRightJustify
|
||||
Caption = 'TC executable:'
|
||||
ParentColor = False
|
||||
end
|
||||
object fneTCConfigFilename: TFileNameEdit
|
||||
AnchorSideLeft.Control = gbTCExportImport
|
||||
|
|
@ -298,7 +305,6 @@ inherited frmOptionsMisc: TfrmOptionsMisc
|
|||
Width = 96
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Configuration file:'
|
||||
ParentColor = False
|
||||
end
|
||||
object btnRelativeTCConfigFile: TSpeedButton
|
||||
AnchorSideTop.Control = fneTCConfigFilename
|
||||
|
|
@ -412,10 +418,9 @@ inherited frmOptionsMisc: TfrmOptionsMisc
|
|||
Left = 6
|
||||
Height = 15
|
||||
Top = 98
|
||||
Width = 109
|
||||
Width = 108
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Toolbar output path:'
|
||||
ParentColor = False
|
||||
end
|
||||
object btnOutputPathForToolbar: TButton
|
||||
AnchorSideTop.Control = edOutputPathForToolbar
|
||||
|
|
@ -491,7 +496,7 @@ inherited frmOptionsMisc: TfrmOptionsMisc
|
|||
AnchorSideRight.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 55
|
||||
Top = 202
|
||||
Top = 248
|
||||
Width = 707
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
|
|
@ -512,7 +517,6 @@ inherited frmOptionsMisc: TfrmOptionsMisc
|
|||
Width = 94
|
||||
Caption = 'Default encoding:'
|
||||
Layout = tlCenter
|
||||
ParentColor = False
|
||||
end
|
||||
object cmbDescDefaultEncoding: TComboBox
|
||||
Left = 108
|
||||
|
|
@ -553,7 +557,7 @@ inherited frmOptionsMisc: TfrmOptionsMisc
|
|||
end
|
||||
end
|
||||
object pmPathHelper: TPopupMenu[3]
|
||||
left = 656
|
||||
top = 32
|
||||
Left = 656
|
||||
Top = 32
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
{"hash":241754643,"name":"tfrmoptionsmisc.btnthumbcompactcache.caption","sourcebytes":[38,82,101,109,111,118,101,32,116,104,117,109,98,110,97,105,108,115,32,102,111,114,32,110,111,32,108,111,110,103,101,114,32,101,120,105,115,116,105,110,103,32,102,105,108,101,115],"value":"&Remove thumbnails for no longer existing files"},
|
||||
{"hash":158470307,"name":"tfrmoptionsmisc.chkgotoroot.caption","sourcebytes":[65,108,119,97,121,115,32,38,103,111,32,116,111,32,116,104,101,32,114,111,111,116,32,111,102,32,97,32,100,114,105,118,101,32,119,104,101,110,32,99,104,97,110,103,105,110,103,32,100,114,105,118,101,115],"value":"Always &go to the root of a drive when changing drives"},
|
||||
{"hash":3256530,"name":"tfrmoptionsmisc.chkshowcurdirtitlebar.caption","sourcebytes":[83,104,111,119,32,38,99,117,114,114,101,110,116,32,100,105,114,101,99,116,111,114,121,32,105,110,32,116,104,101,32,109,97,105,110,32,119,105,110,100,111,119,32,116,105,116,108,101,32,98,97,114],"value":"Show ¤t directory in the main window title bar"},
|
||||
{"hash":71209118,"name":"tfrmoptionsmisc.chkshowsplashform.caption","sourcebytes":[83,104,111,119,32,38,115,112,108,97,115,104,32,115,99,114,101,101,110],"value":"Show &splash screen"},
|
||||
{"hash":92360730,"name":"tfrmoptionsmisc.gbtcexportimport.caption","sourcebytes":[82,101,103,97,114,100,105,110,103,32,84,67,32,101,120,112,111,114,116,47,105,109,112,111,114,116,58],"value":"Regarding TC export/import:"},
|
||||
{"hash":15252584,"name":"tfrmoptionsmisc.btnrelativetcexecutablefile.hint","sourcebytes":[83,111,109,101,32,102,117,110,99,116,105,111,110,115,32,116,111,32,115,101,108,101,99,116,32,97,112,112,114,111,112,114,105,97,116,101,32,112,97,116,104],"value":"Some functions to select appropriate path"},
|
||||
{"hash":164330666,"name":"tfrmoptionsmisc.lbltcexecutable.caption","sourcebytes":[84,67,32,101,120,101,99,117,116,97,98,108,101,58],"value":"TC executable:"},
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
-------------------------------------------------------------------------
|
||||
Miscellaneous options page
|
||||
|
||||
Copyright (C) 2006-2018 Alexander Koblov (alexx2000@mail.ru)
|
||||
Copyright (C) 2006-2022 Alexander Koblov (alexx2000@mail.ru)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -35,6 +35,7 @@ type
|
|||
|
||||
TfrmOptionsMisc = class(TOptionsEditor)
|
||||
btnThumbCompactCache: TButton;
|
||||
chkShowSplashForm: TCheckBox;
|
||||
chkDescCreateUnicode: TCheckBox;
|
||||
chkGoToRoot: TCheckBox;
|
||||
chkShowCurDirTitleBar: TCheckBox;
|
||||
|
|
@ -71,6 +72,8 @@ type
|
|||
procedure btnOutputPathForToolbarClick(Sender: TObject);
|
||||
procedure btnRelativeOutputPathForToolbarClick(Sender: TObject);
|
||||
procedure chkDescCreateUnicodeChange(Sender: TObject);
|
||||
private
|
||||
FSplashForm: Boolean;
|
||||
protected
|
||||
procedure Init; override;
|
||||
procedure Load; override;
|
||||
|
|
@ -89,7 +92,7 @@ implementation
|
|||
uses
|
||||
fOptions, Forms, Dialogs, fMain, Controls,
|
||||
DCStrUtils, uDCUtils, uSpecialDir, uShowForm, uGlobs, uLng, uThumbnails,
|
||||
uConvEncoding;
|
||||
uConvEncoding, uEarlyConfig;
|
||||
|
||||
{ TfrmOptionsMisc }
|
||||
|
||||
|
|
@ -110,12 +113,14 @@ end;
|
|||
|
||||
procedure TfrmOptionsMisc.Init;
|
||||
begin
|
||||
FSplashForm:= gSplashForm;
|
||||
fneTCExecutableFilename.Filter := ParseLineToFileFilter([rsFilterExecutableFiles, '*.exe', rsFilterAnyFiles, '*.*']);
|
||||
fneTCConfigFilename.Filter := ParseLineToFileFilter([rsFilterIniConfigFiles, '*.ini', rsFilterAnyFiles, '*.*']);
|
||||
end;
|
||||
|
||||
procedure TfrmOptionsMisc.Load;
|
||||
begin
|
||||
chkShowSplashForm.Checked := gSplashForm;
|
||||
chkShowWarningMessages.Checked := gShowWarningMessages;
|
||||
chkThumbSave.Checked := gThumbSave;
|
||||
speThumbWidth.Value := gThumbSize.cx;
|
||||
|
|
@ -154,6 +159,7 @@ end;
|
|||
function TfrmOptionsMisc.Save: TOptionsEditorSaveFlags;
|
||||
begin
|
||||
Result := [];
|
||||
gSplashForm := chkShowSplashForm.Checked;
|
||||
gShowWarningMessages := chkShowWarningMessages.Checked;
|
||||
gThumbSave := chkThumbSave.Checked;
|
||||
gThumbSize.cx := speThumbWidth.Value;
|
||||
|
|
@ -179,6 +185,13 @@ begin
|
|||
end;
|
||||
|
||||
gDescCreateUnicode:= chkDescCreateUnicode.Checked;
|
||||
|
||||
if gSplashForm <> FSplashForm then
|
||||
try
|
||||
SaveEarlyConfig;
|
||||
except
|
||||
on E: Exception do MessageDlg(E.Message, mtError, [mbOK], 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TfrmOptionsMisc.btnRelativeTCExecutableFileClick }
|
||||
|
|
|
|||
72
src/platform/uearlyconfig.pas
Normal file
72
src/platform/uearlyconfig.pas
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
unit uEarlyConfig;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
|
||||
var
|
||||
{$IFDEF DARKWIN}
|
||||
gAppMode: Integer = 1;
|
||||
{$ENDIF}
|
||||
gSplashForm: Boolean = True;
|
||||
|
||||
procedure SaveEarlyConfig;
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
AConfig: String;
|
||||
|
||||
function GetEarlyConfig: String;
|
||||
begin
|
||||
Result:= ExtractFilePath(ParamStr(0));
|
||||
if FileExists(Result + ApplicationName + '.inf') then
|
||||
Result:= Result + ApplicationName + ConfigExtension
|
||||
else begin
|
||||
Result:= GetAppConfigFile(False, False);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Initialize;
|
||||
begin
|
||||
AConfig:= GetEarlyConfig;
|
||||
if FileExists(AConfig) then
|
||||
try
|
||||
with TStringList.Create do
|
||||
try
|
||||
LoadFromFile(AConfig);
|
||||
gSplashForm:= StrToBoolDef(Values['SplashForm'], gSplashForm);
|
||||
{$IFDEF DARKWIN}
|
||||
gAppMode:= StrToIntDef(Values['DarkMode'], gAppMode);
|
||||
{$ENDIF}
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
except
|
||||
// Skip
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure SaveEarlyConfig;
|
||||
begin
|
||||
AConfig:= GetEarlyConfig;
|
||||
ForceDirectories(ExtractFileDir(AConfig));
|
||||
with TStringList.Create do
|
||||
try
|
||||
AddPair('SplashForm', BoolToStr(gSplashForm));
|
||||
{$IFDEF DARKWIN}
|
||||
AddPair('DarkMode', IntToStr(gAppMode));
|
||||
{$ENDIF}
|
||||
SaveToFile(AConfig);
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
Initialize;
|
||||
|
||||
end.
|
||||
|
|
@ -49,7 +49,7 @@ function AllowDarkModeForWindow(hWnd: HWND; allow: bool): bool;
|
|||
implementation
|
||||
|
||||
uses
|
||||
UxTheme, JwaWinUser, FileInfo, IniFiles, ShlObj, LazUTF8
|
||||
UxTheme, JwaWinUser, FileInfo, uEarlyConfig
|
||||
{$IF DEFINED(LCLQT5)}
|
||||
, Qt5
|
||||
{$ENDIF}
|
||||
|
|
@ -57,17 +57,16 @@ uses
|
|||
|
||||
type
|
||||
// Insider 18334
|
||||
PreferredAppMode =
|
||||
TPreferredAppMode =
|
||||
(
|
||||
Default,
|
||||
AllowDark,
|
||||
ForceDark,
|
||||
ForceLight,
|
||||
Max
|
||||
pamDefault,
|
||||
pamAllowDark,
|
||||
pamForceDark,
|
||||
pamForceLight
|
||||
);
|
||||
|
||||
var
|
||||
AppMode: PreferredAppMode;
|
||||
AppMode: TPreferredAppMode;
|
||||
|
||||
var
|
||||
RtlGetNtVersionNumbers: procedure(major, minor, build: LPDWORD); stdcall;
|
||||
|
|
@ -79,7 +78,7 @@ var
|
|||
_RefreshImmersiveColorPolicyState: procedure(); stdcall; // ordinal 104
|
||||
_IsDarkModeAllowedForWindow: function(hWnd: HWND): bool; stdcall; // ordinal 137
|
||||
// Insider 18334
|
||||
_SetPreferredAppMode: function(appMode: PreferredAppMode): PreferredAppMode; stdcall; // ordinal 135, since 18334
|
||||
_SetPreferredAppMode: function(appMode: TPreferredAppMode): TPreferredAppMode; stdcall; // ordinal 135, since 18334
|
||||
|
||||
function AllowDarkModeForWindow(hWnd: HWND; allow: bool): bool;
|
||||
begin
|
||||
|
|
@ -102,7 +101,7 @@ end;
|
|||
|
||||
function ShouldAppsUseDarkMode: Boolean;
|
||||
begin
|
||||
Result:= (_ShouldAppsUseDarkMode() or (AppMode = ForceDark)) and not IsHighContrast();
|
||||
Result:= (_ShouldAppsUseDarkMode() or (AppMode = pamForceDark)) and not IsHighContrast();
|
||||
end;
|
||||
|
||||
procedure RefreshTitleBarThemeColor(hWnd: HWND);
|
||||
|
|
@ -133,7 +132,7 @@ begin
|
|||
if (allow) then
|
||||
_SetPreferredAppMode(AppMode)
|
||||
else
|
||||
_SetPreferredAppMode(Default);
|
||||
_SetPreferredAppMode(pamDefault);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -212,34 +211,6 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
function DarkAppMode: PreferredAppMode;
|
||||
var
|
||||
APath: String;
|
||||
AConfig: TIniFile;
|
||||
wsPath: array[0..MAX_PATH] of WideChar;
|
||||
begin
|
||||
Result:= AllowDark;
|
||||
APath:= ExtractFilePath(ParamStr(0));
|
||||
if FileExists(APath + ApplicationName + '.inf') then
|
||||
APath:= APath + ApplicationName + '.ini'
|
||||
else begin
|
||||
SHGetFolderPathW(0, CSIDL_APPDATA or CSIDL_FLAG_CREATE, 0, SHGFP_TYPE_CURRENT, @wsPath[0]);
|
||||
APath:= IncludeTrailingBackslash(UTF16ToUTF8(wsPath)) + ApplicationName + PathDelim + ApplicationName + '.ini';
|
||||
end;
|
||||
if FileExists(APath) then
|
||||
try
|
||||
AConfig:= TIniFile.Create(APath);
|
||||
try
|
||||
Result:= PreferredAppMode(AConfig.ReadInteger('General', 'DarkMode', 1));
|
||||
finally
|
||||
AConfig.Free;
|
||||
end;
|
||||
except
|
||||
// Skip
|
||||
end;
|
||||
AppMode:= Result;
|
||||
end;
|
||||
|
||||
procedure InitDarkMode();
|
||||
var
|
||||
hUxtheme: HMODULE;
|
||||
|
|
@ -279,11 +250,13 @@ begin
|
|||
Assigned(_IsDarkModeAllowedForWindow) then
|
||||
begin
|
||||
g_darkModeSupported := true;
|
||||
if DarkAppMode <> ForceLight then
|
||||
AppMode := TPreferredAppMode(gAppMode);
|
||||
if AppMode <> pamForceLight then
|
||||
begin
|
||||
AllowDarkModeForApp(true);
|
||||
_RefreshImmersiveColorPolicyState();
|
||||
g_darkModeEnabled := ShouldAppsUseDarkMode;
|
||||
if g_darkModeEnabled then AppMode := pamForceDark;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -743,7 +743,7 @@ implementation
|
|||
|
||||
uses
|
||||
LCLProc, LCLType, Dialogs, Laz2_XMLRead, LazUTF8, uExifWdx, uSynDiffControls,
|
||||
uGlobsPaths, uLng, uShowMsg, uFileProcs, uOSUtils, uFindFiles,
|
||||
uGlobsPaths, uLng, uShowMsg, uFileProcs, uOSUtils, uFindFiles, uEarlyConfig,
|
||||
uDCUtils, fMultiRename, uFile, uDCVersion, uDebug, uFileFunctions,
|
||||
uDefaultPlugins, Lua, uKeyboard, DCOSUtils, DCStrUtils, uPixMapManager
|
||||
{$IF DEFINED(MSWINDOWS)}
|
||||
|
|
@ -2430,6 +2430,7 @@ begin
|
|||
|
||||
if mbFileAccess(gpCfgDir, fmOpenWrite or fmShareDenyNone) then
|
||||
begin
|
||||
SaveWithCheck(@SaveEarlyConfig, 'early config', ErrMsg);
|
||||
SaveWithCheck(@SaveCfgIgnoreList, 'ignore list', ErrMsg);
|
||||
SaveWithCheck(@SaveCfgMainConfig, 'main configuration', ErrMsg);
|
||||
SaveWithCheck(@SaveHistoryConfig, 'various history', ErrMsg);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue