Permalink
Browse files

Add presets dropdown for quick selection of grid text colors, with li…

…ght, dark, black and white presets.
  • Loading branch information...
ansgarbecker committed Dec 30, 2018
1 parent 0d62609 commit bd8cc07bc82b4d277f6db18f7857f4ece51fb789
Showing with 117 additions and 25 deletions.
  1. +13 −1 out/locale/en/LC_MESSAGES/default.po
  2. +1 −1 source/mysql_structures.pas
  3. +28 −19 source/options.dfm
  4. +75 −4 source/options.pas
@@ -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:"

@@ -315,7 +315,7 @@ TServerVariable = record
MySQLErrorCodes: TStringList;

// MySQL data type categories
DatatypeCategories: array[dtcInteger..dtcOther] of TDBDatatypeCategory = (
DatatypeCategories: array[TDBDatatypeCategoryIndex] of TDBDatatypeCategory = (
(
Index: dtcInteger;
Name: 'Integer'
@@ -876,22 +876,22 @@ object optionsform: Toptionsform
end
object lblNullBackground: TLabel
Left = 8
Top = 146
Top = 173
Width = 87
Height = 13
Hint = 'Use "None" to disable'
Caption = 'NULL background:'
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
Top = 170
Width = 133
Height = 22
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
Anchors = [akTop, akRight]
TabOrder = 11
TabOrder = 12
OnChange = Modified
OnSelect = Modified
end
object cboxRowBackgroundOdd: TColorBox
Left = 330
Top = 171
Top = 198
Width = 132
Height = 22
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
Anchors = [akTop, akRight]
TabOrder = 13
TabOrder = 14
OnChange = Modified
end
object cboxRowBackgroundEven: TColorBox
Left = 191
Top = 171
Top = 198
Width = 133
Height = 22
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
Anchors = [akTop, akRight]
TabOrder = 12
TabOrder = 13
OnChange = Modified
end
object chkLocalNumberFormat: TCheckBox
Left = 191
Top = 227
Top = 254
Width = 510
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Local number format'
TabOrder = 15
TabOrder = 16
OnClick = Modified
end
object chkHintsOnResultTabs: TCheckBox
Left = 191
Top = 250
Top = 277
Width = 510
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Pop up SQL text over result tabs'
TabOrder = 16
TabOrder = 17
OnClick = Modified
end
object cboxRowHighlightSameText: TColorBox
Left = 191
Top = 199
Top = 226
Width = 133
Height = 22
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
Anchors = [akTop, akRight]
TabOrder = 14
TabOrder = 15
end
object comboGridTextColorsPreset: TComboBox
Left = 191
Top = 116
Width = 133
Height = 21
Style = csDropDownList
TabOrder = 9
OnSelect = comboGridTextColorsPresetSelect
end
end
end
@@ -12,7 +12,7 @@ interface
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 @@ TShortcutItemData = record
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 @@ Toptionsform = class(TForm)
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 @@ Toptionsform = class(TForm)
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 @@ procedure Toptionsform.FormClose(Sender: TObject; var Action: TCloseAction);


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 @@ procedure Toptionsform.FormCreate(Sender: TObject);
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 @@ procedure Toptionsform.FormShow(Sender: TObject);
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 @@ procedure Toptionsform.FormShow(Sender: TObject);
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 @@ procedure Toptionsform.comboEditorColorsPresetChange(Sender: TObject);
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

0 comments on commit bd8cc07

Please sign in to comment.