mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Add preference option and logic for alternating grid row background colors. Fixes issue #2820.
This commit is contained in:
@@ -170,7 +170,7 @@ type
|
||||
asLogUserSQL, asLogSQL, asLogInfos, asLogDebug, asFieldColorNumeric,
|
||||
asFieldColorReal, asFieldColorText, asFieldColorBinary, asFieldColorDatetime, asFieldColorSpatial,
|
||||
asFieldColorOther, asFieldEditorBinary, asFieldEditorDatetime, asFieldEditorDatetimePrefill, asFieldEditorEnum,
|
||||
asFieldEditorSet, asFieldNullBackground, asGroupTreeObjects, asDisplayObjectSizeColumn, asSQLfile,
|
||||
asFieldEditorSet, asFieldNullBackground, asRowBackgroundEven, asRowBackgroundOdd, asGroupTreeObjects, asDisplayObjectSizeColumn, asSQLfile,
|
||||
asActionShortcut1, asActionShortcut2, asHighlighterForeground, asHighlighterBackground, asHighlighterStyle,
|
||||
asListColWidths, asListColsVisible, asListColPositions, asListColSort, asSessionFolder,
|
||||
asRecentFilter, asTimestampColumns, asDateTimeEditorCursorPos, asAppLanguage, asAutoExpand, asForeignDropDown, asQueryHistoryEnabled,
|
||||
@@ -3315,6 +3315,8 @@ begin
|
||||
InitSetting(asFieldEditorEnum, 'FieldEditor_Enum', 0, True);
|
||||
InitSetting(asFieldEditorSet, 'FieldEditor_Set', 0, True);
|
||||
InitSetting(asFieldNullBackground, 'Field_NullBackground', $00FF00FF);
|
||||
InitSetting(asRowBackgroundEven, 'RowBackgroundEven', clNone);
|
||||
InitSetting(asRowBackgroundOdd, 'RowBackgroundOdd', clNone);
|
||||
InitSetting(asGroupTreeObjects, 'GroupTreeObjects', 0, False);
|
||||
InitSetting(asDisplayObjectSizeColumn, 'DisplayObjectSizeColumn', 0, True);
|
||||
InitSetting(asActionShortcut1, 'Shortcut1_%s', 0);
|
||||
|
||||
@@ -8321,21 +8321,35 @@ procedure TMainForm.AnyGridBeforeCellPaint(Sender: TBaseVirtualTree;
|
||||
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
|
||||
var
|
||||
r: TDBQuery;
|
||||
cl: TColor;
|
||||
cl, clNull, clEven, clOdd: TColor;
|
||||
RowNumber: PCardinal;
|
||||
isEven: Boolean;
|
||||
begin
|
||||
if Column = -1 then
|
||||
Exit;
|
||||
r := GridResult(Sender);
|
||||
RowNumber := Sender.GetNodeData(Node);
|
||||
r.RecNo := RowNumber^;
|
||||
cl := clNone;
|
||||
|
||||
clEven := AppSettings.ReadInt(asRowBackgroundEven);
|
||||
clOdd := AppSettings.ReadInt(asRowBackgroundOdd);
|
||||
isEven := Node.Index mod 2 = 0;
|
||||
if IsEven and (clEven <> clNone) then
|
||||
cl := AppSettings.ReadInt(asRowBackgroundEven)
|
||||
else if (not IsEven) and (clOdd <> clNone) then
|
||||
cl := AppSettings.ReadInt(asRowBackgroundOdd)
|
||||
else
|
||||
cl := clNone;
|
||||
|
||||
if (vsSelected in Node.States) and (Node = Sender.FocusedNode) and (Column = Sender.FocusedColumn) then
|
||||
cl := clHighlight
|
||||
else if vsSelected in Node.States then
|
||||
cl := $00DDDDDD
|
||||
else if r.IsNull(Column) then
|
||||
cl := AppSettings.ReadInt(asFieldNullBackground);
|
||||
else if r.IsNull(Column) then begin
|
||||
clNull := AppSettings.ReadInt(asFieldNullBackground);
|
||||
if clNull <> clNone then
|
||||
cl := clNull;
|
||||
end;
|
||||
if cl <> clNone then begin
|
||||
TargetCanvas.Brush.Color := cl;
|
||||
TargetCanvas.FillRect(CellRect);
|
||||
|
||||
@@ -653,11 +653,18 @@ object optionsform: Toptionsform
|
||||
end
|
||||
object lblNullBackground: TLabel
|
||||
Left = 8
|
||||
Top = 137
|
||||
Top = 140
|
||||
Width = 226
|
||||
Height = 13
|
||||
Caption = 'NULL background color (use "None" to disable):'
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 8
|
||||
Top = 168
|
||||
Width = 137
|
||||
Height = 13
|
||||
Caption = 'Alternating row background:'
|
||||
end
|
||||
object editMaxColWidth: TEdit
|
||||
Left = 309
|
||||
Top = 8
|
||||
@@ -787,69 +794,86 @@ object optionsform: Toptionsform
|
||||
end
|
||||
object chkEditorBinary: TCheckBox
|
||||
Left = 8
|
||||
Top = 164
|
||||
Top = 188
|
||||
Width = 433
|
||||
Height = 17
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
Caption = 'Enable popup BLOB/HEX editor'
|
||||
TabOrder = 12
|
||||
TabOrder = 14
|
||||
OnClick = Modified
|
||||
end
|
||||
object chkEditorDatetime: TCheckBox
|
||||
Left = 8
|
||||
Top = 187
|
||||
Top = 211
|
||||
Width = 433
|
||||
Height = 17
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
Caption = 'Enable inplace date/time editor'
|
||||
TabOrder = 13
|
||||
TabOrder = 15
|
||||
OnClick = Modified
|
||||
end
|
||||
object chkEditorEnum: TCheckBox
|
||||
Left = 8
|
||||
Top = 233
|
||||
Top = 257
|
||||
Width = 433
|
||||
Height = 17
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
Caption = 'Enable ENUM pulldown editor'
|
||||
TabOrder = 15
|
||||
TabOrder = 17
|
||||
OnClick = Modified
|
||||
end
|
||||
object chkEditorSet: TCheckBox
|
||||
Left = 8
|
||||
Top = 256
|
||||
Top = 280
|
||||
Width = 433
|
||||
Height = 17
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
Caption = 'Enable SET checkbox editor'
|
||||
TabOrder = 16
|
||||
TabOrder = 18
|
||||
OnClick = Modified
|
||||
end
|
||||
object chkPrefillDateTime: TCheckBox
|
||||
Left = 24
|
||||
Top = 210
|
||||
Top = 234
|
||||
Width = 417
|
||||
Height = 17
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
Caption = 'Prefill empty date/time fields with current date/time'
|
||||
TabOrder = 14
|
||||
TabOrder = 16
|
||||
OnClick = Modified
|
||||
end
|
||||
object chkRememberFilters: TCheckBox
|
||||
Left = 8
|
||||
Top = 279
|
||||
Top = 303
|
||||
Width = 433
|
||||
Height = 17
|
||||
Caption = 'Remember filters, sorting and column selection across sessions'
|
||||
TabOrder = 17
|
||||
TabOrder = 19
|
||||
end
|
||||
object chkForeignDropDown: TCheckBox
|
||||
Left = 8
|
||||
Top = 302
|
||||
Top = 326
|
||||
Width = 433
|
||||
Height = 17
|
||||
Caption = 'Drop down values from foreign table in InnoDB rows'
|
||||
TabOrder = 18
|
||||
TabOrder = 20
|
||||
end
|
||||
object cboxRowBackgroundOdd: TColorBox
|
||||
Left = 309
|
||||
Top = 165
|
||||
Width = 132
|
||||
Height = 22
|
||||
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
TabOrder = 13
|
||||
end
|
||||
object cboxRowBackgroundEven: TColorBox
|
||||
Left = 171
|
||||
Top = 165
|
||||
Width = 132
|
||||
Height = 22
|
||||
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbCustomColor, cbPrettyNames]
|
||||
TabOrder = 12
|
||||
end
|
||||
end
|
||||
object tabShortcuts: TTabSheet
|
||||
@@ -977,7 +1001,7 @@ object optionsform: Toptionsform
|
||||
end
|
||||
object SynSQLSynSQLSample: TSynSQLSyn
|
||||
SQLDialect = sqlMySQL
|
||||
Left = 112
|
||||
Top = 360
|
||||
Left = 432
|
||||
Top = 352
|
||||
end
|
||||
end
|
||||
|
||||
@@ -121,6 +121,9 @@ type
|
||||
comboAppLanguage: TComboBox;
|
||||
chkForeignDropDown: TCheckBox;
|
||||
chkQueryHistory: TCheckBox;
|
||||
cboxRowBackgroundOdd: TColorBox;
|
||||
cboxRowBackgroundEven: TColorBox;
|
||||
Label2: TLabel;
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure Modified(Sender: TObject);
|
||||
procedure Apply(Sender: TObject);
|
||||
@@ -272,6 +275,8 @@ begin
|
||||
AppSettings.WriteInt(asFieldColorSpatial, FGridTextColors[dtcSpatial]);
|
||||
AppSettings.WriteInt(asFieldColorOther, FGridTextColors[dtcOther]);
|
||||
AppSettings.WriteInt(asFieldNullBackground, cboxNullBackground.Selected);
|
||||
AppSettings.WriteInt(asRowBackgroundEven, cboxRowBackgroundEven.Selected);
|
||||
AppSettings.WriteInt(asRowBackgroundOdd, cboxRowBackgroundOdd.Selected);
|
||||
// Editor enablings
|
||||
AppSettings.WriteBool(asFieldEditorBinary, chkEditorBinary.Checked);
|
||||
AppSettings.WriteBool(asFieldEditorDatetime, chkEditorDatetime.Checked);
|
||||
@@ -476,6 +481,8 @@ begin
|
||||
comboGridTextColors.ItemIndex := 0;
|
||||
comboGridTextColors.OnSelect(comboGridTextColors);
|
||||
cboxNullBackground.Selected := AppSettings.ReadInt(asFieldNullBackground);
|
||||
cboxRowBackgroundEven.Selected := AppSettings.ReadInt(asRowBackgroundEven);
|
||||
cboxRowBackgroundOdd.Selected := AppSettings.ReadInt(asRowBackgroundOdd);
|
||||
// Editor enablings
|
||||
chkEditorBinary.Checked := AppSettings.ReadBool(asFieldEditorBinary);
|
||||
chkEditorDatetime.Checked := AppSettings.ReadBool(asFieldEditorDatetime);
|
||||
|
||||
Reference in New Issue
Block a user