Add presets dropdown for quick selection of grid text colors, with light, dark, black and white presets.

This commit is contained in:
Ansgar Becker
2018-12-30 14:46:59 +01:00
parent 0d626096b3
commit bd8cc07bc8
4 changed files with 151 additions and 59 deletions

View File

@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2018-12-28 20:11+0100\n"
"PO-Revision-Date: 2018-12-30 14:43+0100\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n"
"MIME-Version: 1.0\n"
@@ -6303,6 +6303,18 @@ msgstr "Scaling font size from %d to %d."
msgid "Current custom settings"
msgstr "Current custom settings"
msgid "Light"
msgstr "Light"
msgid "Dark"
msgstr "Dark"
msgid "Black"
msgstr "Black"
msgid "White"
msgstr "White"
msgid "current value:"
msgstr "current value:"

View File

@@ -315,7 +315,7 @@ var
MySQLErrorCodes: TStringList;
// MySQL data type categories
DatatypeCategories: array[dtcInteger..dtcOther] of TDBDatatypeCategory = (
DatatypeCategories: array[TDBDatatypeCategoryIndex] of TDBDatatypeCategory = (
(
Index: dtcInteger;
Name: 'Integer'

View File

@@ -876,7 +876,7 @@ object optionsform: Toptionsform
end
object lblNullBackground: TLabel
Left = 8
Top = 146
Top = 173
Width = 87
Height = 13
Hint = 'Use "None" to disable'
@@ -884,14 +884,14 @@ object optionsform: Toptionsform
end
object Label2: TLabel
Left = 8
Top = 174
Top = 201
Width = 137
Height = 13
Caption = 'Alternating row background:'
end
object Label3: TLabel
Left = 8
Top = 202
Top = 229
Width = 112
Height = 13
Caption = 'Same text background:'
@@ -995,83 +995,92 @@ object optionsform: Toptionsform
end
object comboGridTextColors: TComboBox
Left = 191
Top = 116
Top = 143
Width = 133
Height = 21
Style = csDropDownList
Anchors = [akTop, akRight]
TabOrder = 9
TabOrder = 10
OnSelect = comboGridTextColorsSelect
end
object colorBoxGridTextColors: TColorBox
Left = 330
Top = 116
Top = 143
Width = 132
Height = 22
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbCustomColor, cbPrettyNames]
Anchors = [akTop, akRight]
TabOrder = 10
TabOrder = 11
OnSelect = colorBoxGridTextColorsSelect
end
object cboxNullBackground: TColorBox
Left = 191
Top = 143
Width = 133
Height = 22
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
Anchors = [akTop, akRight]
TabOrder = 11
OnChange = Modified
OnSelect = Modified
end
object cboxRowBackgroundOdd: TColorBox
Left = 330
Top = 171
Width = 132
Height = 22
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
Anchors = [akTop, akRight]
TabOrder = 13
OnChange = Modified
end
object cboxRowBackgroundEven: TColorBox
Left = 191
Top = 171
Top = 170
Width = 133
Height = 22
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
Anchors = [akTop, akRight]
TabOrder = 12
OnChange = Modified
OnSelect = Modified
end
object chkLocalNumberFormat: TCheckBox
Left = 191
Top = 227
Width = 510
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Local number format'
TabOrder = 15
OnClick = Modified
end
object chkHintsOnResultTabs: TCheckBox
Left = 191
Top = 250
Width = 510
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Pop up SQL text over result tabs'
TabOrder = 16
OnClick = Modified
end
object cboxRowHighlightSameText: TColorBox
Left = 191
Top = 199
Width = 133
object cboxRowBackgroundOdd: TColorBox
Left = 330
Top = 198
Width = 132
Height = 22
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
Anchors = [akTop, akRight]
TabOrder = 14
OnChange = Modified
end
object cboxRowBackgroundEven: TColorBox
Left = 191
Top = 198
Width = 133
Height = 22
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
Anchors = [akTop, akRight]
TabOrder = 13
OnChange = Modified
end
object chkLocalNumberFormat: TCheckBox
Left = 191
Top = 254
Width = 510
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Local number format'
TabOrder = 16
OnClick = Modified
end
object chkHintsOnResultTabs: TCheckBox
Left = 191
Top = 277
Width = 510
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Pop up SQL text over result tabs'
TabOrder = 17
OnClick = Modified
end
object cboxRowHighlightSameText: TColorBox
Left = 191
Top = 226
Width = 133
Height = 22
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
Anchors = [akTop, akRight]
TabOrder = 15
end
object comboGridTextColorsPreset: TComboBox
Left = 191
Top = 116
Width = 133
Height = 21
Style = csDropDownList
TabOrder = 9
OnSelect = comboGridTextColorsPresetSelect
end
end
end

View File

@@ -12,7 +12,7 @@ uses
Windows, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, ExtCtrls, SynEditHighlighter, SynHighlighterSQL,
SynEdit, SynMemo, VirtualTrees, SynEditKeyCmds, ActnList, SynEditMiscClasses, StdActns, Menus,
mysql_structures, gnugettext, Vcl.Themes, Vcl.Styles, SynRegExpr;
mysql_structures, gnugettext, Vcl.Themes, Vcl.Styles, SynRegExpr, Generics.Collections;
type
TShortcutItemData = record
@@ -22,6 +22,14 @@ type
end;
PShortcutItemData = ^TShortcutItemData;
// Color set for grid text, and preset class with a name
TGridTextColors = Array[TDBDatatypeCategoryIndex] of TColor;
TGridColorsPreset = class
TextColors: TGridTextColors;
Name: String;
end;
TGridColorsPresetList = TObjectList<TGridColorsPreset>;
Toptionsform = class(TForm)
pagecontrolMain: TPageControl;
tabMisc: TTabSheet;
@@ -158,6 +166,7 @@ type
SynSQLSyn_Light: TSynSQLSyn;
SynSQLSyn_Black: TSynSQLSyn;
SynSQLSyn_White: TSynSQLSyn;
comboGridTextColorsPreset: TComboBox;
procedure FormShow(Sender: TObject);
procedure Modified(Sender: TObject);
procedure Apply(Sender: TObject);
@@ -198,11 +207,13 @@ type
procedure chkQueryHistoryClick(Sender: TObject);
procedure comboEditorColorsPresetChange(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure comboGridTextColorsPresetSelect(Sender: TObject);
private
{ Private declarations }
FWasModified: Boolean;
FShortcutCategories: TStringList;
FGridTextColors: Array[dtcInteger..dtcOther] of TColor;
FGridTextColors: TGridTextColors;
FGridColorsPresets: TGridColorsPresetList;
FLanguages: TStringList;
FRestartOptionTouched: Boolean;
FRestartOptionApplied: Boolean;
@@ -439,12 +450,19 @@ end;
procedure Toptionsform.FormCreate(Sender: TObject);
const
// Define grid colors as constants, for easy assignment
GridColorsLight: TGridTextColors = ($00FF0000, $00FF0048, $00008000, $00800080, $00000080, $00808000, $00008080);
GridColorsDark: TGridTextColors = ($00FF9785, $00D07D7D, $0073D573, $00C9767F, $007373C9, $00CECE73, $0073C1C1);
GridColorsBlack: TGridTextColors = ($00000000, $00000000, $00000000, $00000000, $00000000, $00000000, $00000000);
GridColorsWhite: TGridTextColors = ($00FFFFFF, $00FFFFFF, $00FFFFFF, $00FFFFFF, $00FFFFFF, $00FFFFFF, $00FFFFFF);
var
i: Integer;
dtc: TDBDatatypeCategoryIndex;
Styles: TArray<String>;
Highlighter: TSynSQLSyn;
Name: String;
GridColorsPreset: TGridColorsPreset;
begin
TranslateComponent(Self);
@@ -495,11 +513,46 @@ begin
Name := Highlighter.Name;
Name := RegExprGetMatch('_([^_]+)$', Name, 1, False);
if Name <> '' then begin
comboEditorColorsPreset.Items.Add(Name);
comboEditorColorsPreset.Items.Add(_(Name));
end;
end;
end;
// Grid formatting
FGridColorsPresets := TGridColorsPresetList.Create;
// Current colors - assign from global DatatypeCategories array
GridColorsPreset := TGridColorsPreset.Create;
GridColorsPreset.Name := _('Current custom settings');
for dtc:=Low(TDBDatatypeCategoryIndex) to High(TDBDatatypeCategoryIndex) do begin
GridColorsPreset.TextColors[dtc] := DatatypeCategories[dtc].Color;
end;
FGridColorsPresets.Add(GridColorsPreset);
// Light - default values
GridColorsPreset := TGridColorsPreset.Create;
GridColorsPreset.Name := _('Light');
GridColorsPreset.TextColors := GridColorsLight;
FGridColorsPresets.Add(GridColorsPreset);
// Dark
GridColorsPreset := TGridColorsPreset.Create;
GridColorsPreset.Name := _('Dark');
GridColorsPreset.TextColors := GridColorsDark;
FGridColorsPresets.Add(GridColorsPreset);
// Black
GridColorsPreset := TGridColorsPreset.Create;
GridColorsPreset.Name := _('Black');
GridColorsPreset.TextColors := GridColorsBlack;
FGridColorsPresets.Add(GridColorsPreset);
// White
GridColorsPreset := TGridColorsPreset.Create;
GridColorsPreset.Name := _('White');
GridColorsPreset.TextColors := GridColorsWhite;
FGridColorsPresets.Add(GridColorsPreset);
// Add all to combo box
comboGridTextColorsPreset.Clear;
for GridColorsPreset in FGridColorsPresets do begin
comboGridTextColorsPreset.Items.Add(GridColorsPreset.Name);
end;
// Shortcuts
FShortcutCategories := TStringList.Create;
for i:=0 to Mainform.ActionList1.ActionCount-1 do begin
@@ -580,7 +633,7 @@ begin
chkTabsToSpaces.Checked := AppSettings.ReadBool(asTabsToSpaces);
comboSQLColElementChange(Sender);
// Data-Appearance:
// Grid formatting:
comboDataFontName.Items := Screen.Fonts;
comboDataFontName.ItemIndex := comboDataFontName.Items.IndexOf(AppSettings.ReadString(asDataFontName));
updownDataFontSize.Position := AppSettings.ReadInt(asDataFontSize);
@@ -593,6 +646,7 @@ begin
FGridTextColors[dtcTemporal] := AppSettings.ReadInt(asFieldColorDatetime);
FGridTextColors[dtcSpatial] := AppSettings.ReadInt(asFieldColorSpatial);
FGridTextColors[dtcOther] := AppSettings.ReadInt(asFieldColorOther);
comboGridTextColorsPreset.ItemIndex := 0;
comboGridTextColors.ItemIndex := 0;
comboGridTextColors.OnSelect(comboGridTextColors);
cboxNullBackground.Selected := AppSettings.ReadInt(asFieldNullBackground);
@@ -787,6 +841,23 @@ begin
Modified(Sender);
end;
procedure Toptionsform.comboGridTextColorsPresetSelect(Sender: TObject);
var
Preset: TGridColorsPreset;
dtc: TDBDatatypeCategoryIndex;
begin
// Grid colors preset selected
Preset := FGridColorsPresets[comboGridTextColorsPreset.ItemIndex];
for dtc:=Low(Preset.TextColors) to High(Preset.TextColors) do begin
FGridTextColors[dtc] := Preset.TextColors[dtc];
end;
comboGridTextColors.OnSelect(comboGridTextColors);
if comboGridTextColorsPreset.ItemIndex > 0 then
Modified(Sender);
end;
procedure Toptionsform.comboGridTextColorsSelect(Sender: TObject);
begin
// Data type category selected