mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Auto-select fitting color presets for SQL and grid text when selecting a theme. Closes #425.
This commit is contained in:
@@ -354,6 +354,7 @@ type
|
||||
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 @@ begin
|
||||
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 @@ type
|
||||
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 @@ begin
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user