Permalink
Browse files

Auto-select fitting color presets for SQL and grid text when selectin…

…g a theme. Closes #425.
  • Loading branch information...
ansgarbecker committed Dec 30, 2018
1 parent bd8cc07 commit 8493b7319870bcb0b6b07cf0cb5c5113d2a8ea89
Showing with 42 additions and 8 deletions.
  1. +14 −0 source/apphelpers.pas
  2. +8 −8 source/options.dfm
  3. +20 −0 source/options.pas
@@ -354,6 +354,7 @@ TAppSettings = class(TObject)
procedure LoadPNGFromImageList(AImageList: TCustomImageList; AIndex: Integer; var ADestPNG: TPngImage);
procedure ResizePngImage(aPng: TPNGImage; NewWidth, NewHeight: Integer);
function GetThemeColor(Color: TColor): TColor;
function ThemeIsDark(ThemeName: String): Boolean;

var
AppSettings: TAppSettings;
@@ -3155,6 +3156,19 @@ function GetThemeColor(Color: TColor): TColor;
end;


function ThemeIsDark(ThemeName: String): Boolean;
const
DarkThemes: String = 'Amakrits,Aqua Graphite,Auric,Carbon,Charcoal Dark Slate,Cobalt XEMedia,Glossy,Glow,Golden Graphite,Onyx Blue,Ruby Graphite,TabletDark,Windows10 Dark,Windows10 SlateGray';
var
DarkThemesList: TStringList;
begin
DarkThemesList := Explode(',', DarkThemes);
ShowMessage(DarkThemesList.Text);
Result := DarkThemesList.IndexOf(ThemeName) > -1;
DarkThemesList.Free;
end;




{ Threading stuff }
@@ -289,7 +289,7 @@ object optionsform: Toptionsform
Anchors = [akLeft, akTop, akRight]
Sorted = True
TabOrder = 16
OnChange = Modified
OnSelect = comboThemeSelect
end
end
end
@@ -1346,17 +1346,17 @@ object optionsform: Toptionsform
Options.AutoDetectEnabled = False
Options.AutoDetectLineLimit = 0
Options.Visible = False
CommentAttri.Foreground = clGray
ConditionalCommentAttri.Foreground = clGray
CommentAttri.Foreground = 4144959
ConditionalCommentAttri.Foreground = 4144959
DataTypeAttri.Foreground = 3148901
DelimitedIdentifierAttri.Foreground = 6383516
DelimitedIdentifierAttri.Foreground = 4804214
FunctionAttri.Foreground = 7811334
IdentifierAttri.Foreground = 6383516
IdentifierAttri.Foreground = 3751259
KeyAttri.Foreground = 11684361
NumberAttri.Foreground = 6754886
StringAttri.Foreground = clGreen
SymbolAttri.Foreground = 11684361
TableNameAttri.Foreground = 13378700
StringAttri.Foreground = 21760
SymbolAttri.Foreground = 9255175
TableNameAttri.Foreground = 10689905
VariableAttri.Foreground = clPurple
SQLDialect = sqlMySQL
Left = 120
@@ -208,6 +208,7 @@ Toptionsform = class(TForm)
procedure comboEditorColorsPresetChange(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure comboGridTextColorsPresetSelect(Sender: TObject);
procedure comboThemeSelect(Sender: TObject);
private
{ Private declarations }
FWasModified: Boolean;
@@ -921,6 +922,25 @@ procedure Toptionsform.comboSQLColElementChange(Sender: TObject);
end;


procedure Toptionsform.comboThemeSelect(Sender: TObject);
begin
// Select text colors so they fit to the selected theme
if ThemeIsDark(comboTheme.Text) then begin
comboGridTextColorsPreset.ItemIndex := comboGridTextColorsPreset.Items.IndexOf(_('Dark'));
comboGridTextColorsPresetSelect(comboGridTextColorsPreset);
comboEditorColorsPreset.ItemIndex := comboEditorColorsPreset.Items.IndexOf(_('Dark'));
comboEditorColorsPresetChange(comboEditorColorsPreset);
end else begin
comboGridTextColorsPreset.ItemIndex := comboGridTextColorsPreset.Items.IndexOf(_('Light'));
comboGridTextColorsPresetSelect(comboGridTextColorsPreset);
comboEditorColorsPreset.ItemIndex := comboEditorColorsPreset.Items.IndexOf(_('Light'));
comboEditorColorsPresetChange(comboEditorColorsPreset);
end;

Modified(Sender);
end;


procedure Toptionsform.updownSQLFontSizeClick(Sender: TObject;
Button: TUDBtnType);
begin

0 comments on commit 8493b73

Please sign in to comment.