浏览代码

Bug 1733: Compressed files entries are hard to read in dark theme

https://winscp.net/tracker/1733

Source commit: 83e7cff7149da980f93f1dd5f254898dbf674d5e
Martin Prikryl 6 年之前
父节点
当前提交
9c13b13a4e
共有 3 个文件被更改,包括 16 次插入33 次删除
  1. 4 15
      source/packages/filemng/DirView.pas
  2. 4 16
      source/packages/filemng/DriveView.pas
  3. 8 2
      source/packages/my/PasTools.pas

+ 4 - 15
source/packages/filemng/DirView.pas

@@ -143,7 +143,6 @@ type
     FUseIconUpdateThread: Boolean;
     FIUThreadFinished: Boolean;
     FDriveType: Integer;
-    FCompressedColor: TColor;
     FParentFolder: IShellFolder;
     FDesktopFolder: IShellFolder;
     FDirOK: Boolean;
@@ -208,7 +207,6 @@ type
     procedure SetPath(Value: string); override;
     procedure PathChanged; override;
     procedure SetItemImageIndex(Item: TListItem; Index: Integer); override;
-    procedure SetCompressedColor(Value: TColor);
     procedure ChangeDetected(Sender: TObject; const Directory: string;
       var SubdirsChanged: Boolean);
     procedure ChangeInvalid(Sender: TObject; const Directory: string; const ErrorStr: string);
@@ -352,8 +350,6 @@ type
     property OnGetOverlay;
     property OnGetItemColor;
 
-    property CompressedColor: TColor
-      read FCompressedColor write SetCompressedColor default clBlue;
     {Confirm deleting files}
     property ConfirmDelete: Boolean
       read FConfirmDelete write FConfirmDelete default True;
@@ -805,7 +801,6 @@ begin
   FDriveType := DRIVE_UNKNOWN;
   FUseIconCache := False;
   FConfirmDelete := True;
-  FCompressedColor := clBlue;
   FParentFolder := nil;
   FDesktopFolder := nil;
   SelectNewFiles := False;
@@ -966,15 +961,6 @@ begin
   end;
 end; {SetLoadEnabled}
 
-procedure TDirView.SetCompressedColor(Value: TColor);
-begin
-  if Value <> CompressedColor then
-  begin
-    FCompressedColor := Value;
-    Invalidate;
-  end;
-end; {SetCompressedColor}
-
 function TDirView.GetPathName: string;
 begin
   if IsRoot then Result := IncludeTrailingBackslash(Path)
@@ -2547,7 +2533,10 @@ end;
 function TDirView.ItemColor(Item: TListItem): TColor;
 begin
   if PFileRec(Item.Data).Attr and FILE_ATTRIBUTE_COMPRESSED <> 0 then
-      Result := FCompressedColor
+  begin
+    if SupportsDarkMode and DarkMode then Result := clSkyBlue
+      else Result := clBlue;
+  end
     else
   if DimmHiddenFiles and not Item.Selected and
      (PFileRec(Item.Data).Attr and FILE_ATTRIBUTE_HIDDEN <> 0) then

+ 4 - 16
source/packages/filemng/DriveView.pas

@@ -148,8 +148,6 @@ type
 
     FChangeInterval: Cardinal;
 
-    FCompressedColor: TColor;
-
     {Drag&drop:}
     FLastPathCut: string;
 
@@ -176,7 +174,6 @@ type
     procedure SetWatchDirectory(Value: Boolean);
     procedure SetShowVolLabel(ShowIt: Boolean);
     procedure SetDirView(Value: TDirView);
-    procedure SetCompressedColor(Value: TColor);
     procedure SetDirectory(Value: string); override;
     procedure GetNodeShellAttr(ParentFolder: IShellFolder; NodeData: TNodeData;
       Path: string; ContentMask: Boolean = True);
@@ -307,8 +304,6 @@ type
     property DirView: TDirView read FDirView write SetDirView;
     {Show the volume labels of drives:}
     property ShowVolLabel: Boolean read FShowVolLabel write SetShowVolLabel default True;
-    {How to display the drives volume labels:}
-    property CompressedColor: TColor read FCompressedColor write SetCompressedColor default clBlue;
     {Additional events:}
     property OnDisplayContextMenu: TNotifyEvent read FOnDisplayContextMenu
       write FOnDisplayContextMenu;
@@ -489,7 +484,6 @@ begin
   FFileOperator.ProgressTitle := coFileOperatorTitle;
   FFileOperator.Flags := [foAllowUndo, foNoConfirmMkDir];
 
-  FCompressedColor := clBlue;
   FShowVolLabel := True;
   FChangeFlag := False;
   FLastDir := EmptyStr;
@@ -733,7 +727,10 @@ begin
     begin
       {Colored display of compressed directories:}
       if (Attr and FILE_ATTRIBUTE_COMPRESSED) <> 0 then
-          Result := FCompressedColor
+      begin
+        if SupportsDarkMode and DarkMode then Result := clSkyBlue
+          else Result := clBlue;
+      end
         else
       {Dimmed display, if hidden-atrribut set:}
       if FDimmHiddenDirs and ((Attr and FILE_ATTRIBUTE_HIDDEN) <> 0) then
@@ -2365,15 +2362,6 @@ begin
   RefreshRootNodes(dvdsFloppy);
 end; {SetShowVolLabel}
 
-procedure TDriveView.SetCompressedColor(Value: TColor);
-begin
-  if Value <> FCompressedColor then
-  begin
-    FCompressedColor := Value;
-    Invalidate;
-  end;
-end; {SetCompressedColor}
-
 procedure TDriveView.DisplayContextMenu(Node: TTreeNode; Point: TPoint);
 var
   Verb: string;

+ 8 - 2
source/packages/my/PasTools.pas

@@ -80,6 +80,7 @@ procedure ForceColorChange(Control: TWinControl);
 
 function IsUncPath(Path: string): Boolean;
 
+function SupportsDarkMode: Boolean;
 procedure AllowDarkModeForWindow(Control: TWinControl; Allow: Boolean);
 
 type
@@ -988,7 +989,7 @@ var
   AllowDarkModeForWindowLoaded: Boolean = False;
   AAllowDarkModeForWindow: function(hWnd: HWND; Allow: BOOL): BOOL; stdcall;
 
-procedure AllowDarkModeForWindow(Control: TWinControl; Allow: Boolean);
+function SupportsDarkMode: Boolean;
 var
   OSVersionInfo: TOSVersionInfoEx;
   UxThemeLib: HMODULE;
@@ -1007,8 +1008,13 @@ begin
     AllowDarkModeForWindowLoaded := True;
   end;
 
+  Result := Assigned(AAllowDarkModeForWindow);
+end;
+
+procedure AllowDarkModeForWindow(Control: TWinControl; Allow: Boolean);
+begin
   Assert(Control.HandleAllocated);
-  if Assigned(AAllowDarkModeForWindow) and Control.HandleAllocated then
+  if SupportsDarkMode and Control.HandleAllocated then
   begin
     AAllowDarkModeForWindow(Control.Handle, Allow);
   end;