mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: support theme changed notify caused by Color Options Dialog on macOS
(cherry picked from commit 1f383b0c61)
This commit is contained in:
parent
b27dc1413f
commit
f1cf91cbfe
4 changed files with 26 additions and 29 deletions
|
|
@ -53,6 +53,7 @@ uses
|
|||
{$IFDEF darwin}
|
||||
uAppleMagnifiedModeFix,
|
||||
uMyDarwin,
|
||||
uDarwinApplication,
|
||||
uiCloudDriverConfig,
|
||||
{$ENDIF}
|
||||
{$IFDEF LCLWIN32}
|
||||
|
|
@ -163,7 +164,7 @@ begin
|
|||
|
||||
{$IF DEFINED(darwin)}
|
||||
FixMacFormatSettings;
|
||||
setMacOSAppearance( gAppMode );
|
||||
TDarwinApplicationUtil.setTheme( gAppMode );
|
||||
{$ENDIF}
|
||||
|
||||
// Use only current directory separator
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ uses
|
|||
{$IF not DEFINED(darwin)}
|
||||
, uDarkStyle
|
||||
{$ELSE}
|
||||
, uMyDarwin
|
||||
, uDarwinApplication
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
;
|
||||
|
|
@ -269,7 +269,7 @@ begin
|
|||
if g_darkModeSupported then
|
||||
Result:= [oesfNeedsRestart];
|
||||
{$ELSE}
|
||||
setMacOSAppearance( gAppMode );
|
||||
TDarwinApplicationUtil.setTheme( gAppMode );
|
||||
{$ENDIF}
|
||||
SaveEarlyConfig;
|
||||
except
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ type
|
|||
|
||||
class procedure addThemeObserver( const observer: TDarwinThemeObserver );
|
||||
|
||||
class procedure setTheme( const mode: Integer );
|
||||
class function isDarkTheme: Boolean;
|
||||
end;
|
||||
|
||||
|
|
@ -93,9 +94,7 @@ procedure TDCCocoaApplication.observeValueForKeyPath_ofObject_change_context(
|
|||
keyPath: NSString; object_: id; change: NSDictionary; context_: pointer);
|
||||
begin
|
||||
Inherited observeValueForKeyPath_ofObject_change_context( keyPath, object_, change, context_ );
|
||||
if keyPath.isEqualToString(NSSTR('effectiveAppearance')) then
|
||||
begin
|
||||
NSAppearance.setCurrentAppearance( self.appearance );
|
||||
if keyPath.isEqualToString(NSSTR('effectiveAppearance')) then begin
|
||||
TDarwinApplicationUtil.themeNotify;
|
||||
end;
|
||||
end;
|
||||
|
|
@ -145,6 +144,25 @@ begin
|
|||
_themeObservers.Add( observer );
|
||||
end;
|
||||
|
||||
class procedure TDarwinApplicationUtil.setTheme(const mode: Integer);
|
||||
var
|
||||
appearance: NSAppearance;
|
||||
begin
|
||||
if not NSApp.respondsToSelector( ObjCSelector('appearance') ) then
|
||||
exit;
|
||||
|
||||
case mode of
|
||||
0, 1:
|
||||
appearance:= nil;
|
||||
2:
|
||||
appearance:= NSAppearance.appearanceNamed( NSSTR_DARK_NAME );
|
||||
3:
|
||||
appearance:= NSAppearance.appearanceNamed( NSAppearanceNameAqua );
|
||||
end;
|
||||
NSApp.setAppearance( appearance );
|
||||
TDarwinApplicationUtil.themeNotify;
|
||||
end;
|
||||
|
||||
class function TDarwinApplicationUtil.isDarkTheme: Boolean;
|
||||
var
|
||||
appearanceName: NSString;
|
||||
|
|
@ -153,7 +171,6 @@ begin
|
|||
if not NSApp.respondsToSelector( ObjCSelector('effectiveAppearance') ) then
|
||||
exit;
|
||||
appearanceName:= NSApp.effectiveAppearance.Name;
|
||||
Writeln( appearanceName.UTF8String );
|
||||
Result:= appearanceName.isEqualToString(NSSTR_DARK_NAME) or appearanceName.isEqualToString(NSSTR_DARK_NAME_VIBRANT);
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ uses
|
|||
uFileProperty, uDisplayFile, uFileView, uColumnsFileView,
|
||||
uLng,
|
||||
MacOSAll, CocoaAll, QuickLookUI,
|
||||
CocoaUtils, CocoaInt, CocoaPrivate, CocoaConst, CocoaMenus,
|
||||
CocoaUtils, CocoaInt, CocoaPrivate, CocoaConst, CocoaMenus, Cocoa_Extra,
|
||||
uDarwinApplication, uDarwinFSWatch, uDarwinFinder, uDarwinFinderModel, uDarwinUtil;
|
||||
|
||||
const
|
||||
|
|
@ -46,8 +46,6 @@ const
|
|||
|
||||
procedure onMainMenuCreate( menu: NSMenu );
|
||||
|
||||
procedure setMacOSAppearance( mode:Integer );
|
||||
|
||||
function getMacOSDefaultTerminal(): String;
|
||||
|
||||
procedure FixMacFormatSettings;
|
||||
|
|
@ -235,25 +233,6 @@ begin
|
|||
end;
|
||||
|
||||
|
||||
procedure setMacOSAppearance( mode:Integer );
|
||||
var
|
||||
appearance: NSAppearance;
|
||||
begin
|
||||
if not NSApp.respondsToSelector( ObjCSelector('appearance') ) then
|
||||
exit;
|
||||
|
||||
case mode of
|
||||
0,1:
|
||||
appearance:= nil;
|
||||
2:
|
||||
appearance:= NSAppearance.appearanceNamed( NSSTR_DARK_NAME );
|
||||
3:
|
||||
appearance:= NSAppearance.appearanceNamed( NSAppearanceNameAqua );
|
||||
end;
|
||||
NSApp.setAppearance( appearance );
|
||||
NSAppearance.setCurrentAppearance( appearance );
|
||||
end;
|
||||
|
||||
procedure TMacosServiceMenuHelper.attachSystemMenu(Sender: TObject);
|
||||
begin
|
||||
self.attachServicesMenu( Sender );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue