From 0444ebbdb7b6fba24a09ea4fe88f99b795db0885 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Thu, 12 Oct 2023 07:27:00 +0200 Subject: [PATCH] Issue #861: support hiding row id column through new preference checkbox --- out/locale/en/LC_MESSAGES/default.po | 5 +- source/apphelpers.pas | 2 + source/column_selection.dfm | 13 +++- source/column_selection.pas | 3 + source/main.pas | 4 ++ source/preferences.dfm | 88 ++++++++++++++++------------ source/preferences.pas | 7 ++- 7 files changed, 78 insertions(+), 44 deletions(-) diff --git a/out/locale/en/LC_MESSAGES/default.po b/out/locale/en/LC_MESSAGES/default.po index 61e2575c..bc6f57a1 100644 --- a/out/locale/en/LC_MESSAGES/default.po +++ b/out/locale/en/LC_MESSAGES/default.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: HeidiSQL\n" "POT-Creation-Date: 2012-11-05 21:40\n" -"PO-Revision-Date: 2023-10-02 18:16+0200\n" +"PO-Revision-Date: 2023-10-12 07:21+0200\n" "Last-Translator: Ansgar Becker \n" "Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n" "Language: en\n" @@ -6623,3 +6623,6 @@ msgstr "Query exact row count" msgid "Code reformatted in %s, using formatter %s" msgstr "Code reformatted in %s, using formatter %s" + +msgid "Show static row id column" +msgstr "Show static row id column" diff --git a/source/apphelpers.pas b/source/apphelpers.pas index 9ccd8151..df69efdc 100644 --- a/source/apphelpers.pas +++ b/source/apphelpers.pas @@ -169,6 +169,7 @@ type TAppSettingIndex = (asHiddenColumns, asFilter, asSort, asDisplayedColumnsSorted, asLastSessions, asLastActiveSession, asAutoReconnect, asRestoreLastUsedDB, asLastUsedDB, asTreeBackground, asIgnoreDatabasePattern, asLogFileDdl, asLogFileDml, asLogFilePath, asFontName, asFontSize, asTabWidth, asDataFontName, asDataFontSize, asDataLocalNumberFormat, asLowercaseHex, asHintsOnResultTabs, asHightlightSameTextBackground, + asShowRowId, asLogsqlnum, asLogsqlwidth, asSessionLogsDirectory, asLogHorizontalScrollbar, asSQLColActiveLine, asSQLColMatchingBraceForeground, asSQLColMatchingBraceBackground, asMaxColWidth, asDatagridMaximumRows, asDatagridRowsPerStep, asGridRowLineCount, asColumnHeaderClick, asReuseEditorConfiguration, @@ -3653,6 +3654,7 @@ begin InitSetting(asDataLocalNumberFormat, 'DataLocalNumberFormat', 0, True); InitSetting(asLowercaseHex, 'LowercaseHex', 0, True); InitSetting(asHintsOnResultTabs, 'HintsOnResultTabs', 0, True); + InitSetting(asShowRowId, 'ShowRowId', 0, True); InitSetting(asHightlightSameTextBackground, 'HightlightSameTextBackground', GetThemeColor(clInfoBk)); InitSetting(asLogsqlnum, 'logsqlnum', 300); InitSetting(asLogsqlwidth, 'logsqlwidth', 2000); diff --git a/source/column_selection.dfm b/source/column_selection.dfm index 327a44b2..732c16e0 100644 --- a/source/column_selection.dfm +++ b/source/column_selection.dfm @@ -46,7 +46,7 @@ object frmColumnSelection: TfrmColumnSelection end object chkSort: TCheckBox Left = 8 - Top = 187 + Top = 167 Width = 168 Height = 17 Anchors = [akLeft, akRight, akBottom] @@ -68,7 +68,7 @@ object frmColumnSelection: TfrmColumnSelection Left = 8 Top = 31 Width = 168 - Height = 150 + Height = 130 Anchors = [akLeft, akTop, akRight, akBottom] ItemHeight = 13 TabOrder = 4 @@ -89,4 +89,13 @@ object frmColumnSelection: TfrmColumnSelection OnChange = PopulateList OnLeftButtonClick = editFilterLeftButtonClick end + object chkShowRowId: TCheckBox + Left = 8 + Top = 190 + Width = 168 + Height = 17 + Anchors = [akLeft, akRight, akBottom] + Caption = 'Show static row id column' + TabOrder = 6 + end end diff --git a/source/column_selection.pas b/source/column_selection.pas index a287936a..087e7bb4 100644 --- a/source/column_selection.pas +++ b/source/column_selection.pas @@ -14,6 +14,7 @@ type chklistColumns: TCheckListBox; chkSort: TCheckBox; editFilter: TButtonedEdit; + chkShowRowId: TCheckBox; procedure btnCancelClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure chklistColumnsClickCheck(Sender: TObject); @@ -76,6 +77,7 @@ begin // Restore last used sorting state from registry chkSort.Checked := AppSettings.ReadBool(asDisplayedColumnsSorted); + chkShowRowId.Checked := AppSettings.ReadBool(asShowRowId); end; @@ -87,6 +89,7 @@ var i: Integer; Col: String; begin + AppSettings.WriteBool(asShowRowId, chkShowRowId.Checked); // Prepare string for storing in registry. // Use quote-character as separator to ensure columnnames can // be extracted safely later diff --git a/source/main.pas b/source/main.pas index 869a9553..520f8dd6 100644 --- a/source/main.pas +++ b/source/main.pas @@ -3360,6 +3360,8 @@ begin col.CaptionAlignment := taRightJustify; col.Alignment := taRightJustify; col.Options := col.Options + [coFixed]- [coAllowClick, coAllowFocus, coEditable, coResizable]; + if not AppSettings.ReadBool(asShowRowId) then + col.Options := col.Options - [coVisible]; col.Text := '#'; for i:=0 to NewTab.Results.ColumnCount-1 do begin col := NewTab.Grid.Header.Columns.Add; @@ -6031,6 +6033,8 @@ begin Col.CaptionAlignment := taRightJustify; Col.Alignment := taRightJustify; Col.Options := col.Options + [coFixed]- [coAllowClick, coAllowFocus, coEditable, coResizable]; + if not AppSettings.ReadBool(asShowRowId) then + Col.Options := col.Options - [coVisible]; Col.Text := '#'; for i:=0 to WantedColumns.Count-1 do begin InitColumn(i, WantedColumns[i]); diff --git a/source/preferences.dfm b/source/preferences.dfm index 07ab8ce4..3a577912 100644 --- a/source/preferences.dfm +++ b/source/preferences.dfm @@ -3,7 +3,7 @@ object frmPreferences: TfrmPreferences Top = 163 BorderIcons = [biSystemMenu] Caption = 'Preferences' - ClientHeight = 442 + ClientHeight = 482 ClientWidth = 708 Color = clBtnFace Constraints.MinHeight = 480 @@ -19,13 +19,13 @@ object frmPreferences: TfrmPreferences OnShow = FormShow DesignSize = ( 708 - 442) + 482) TextHeight = 14 object pagecontrolMain: TPageControl Left = 8 Top = 8 Width = 692 - Height = 395 + Height = 435 ActivePage = tabMisc Anchors = [akLeft, akTop, akRight, akBottom] Images = MainForm.VirtualImageListMain @@ -38,7 +38,7 @@ object frmPreferences: TfrmPreferences ImageName = 'icons8-settings' DesignSize = ( 684 - 366) + 406) object lblMySQLBinaries: TLabel Left = 8 Top = 177 @@ -343,7 +343,7 @@ object frmPreferences: TfrmPreferences ImageName = 'icons8-index' DesignSize = ( 684 - 366) + 406) object Label4: TLabel Left = 8 Top = 11 @@ -565,7 +565,7 @@ object frmPreferences: TfrmPreferences ImageName = 'icons8-play' DesignSize = ( 684 - 366) + 406) object lblFont: TLabel Left = 8 Top = 11 @@ -773,7 +773,7 @@ object frmPreferences: TfrmPreferences Left = 371 Top = 156 Width = 308 - Height = 183 + Height = 223 Cursor = crHandPoint SingleLineMode = False Anchors = [akLeft, akTop, akRight, akBottom] @@ -881,7 +881,7 @@ object frmPreferences: TfrmPreferences ImageName = 'icons8-data-grid' DesignSize = ( 684 - 366) + 406) object lblMaxColWidth: TLabel Left = 8 Top = 11 @@ -949,7 +949,7 @@ object frmPreferences: TfrmPreferences end object lblLongSortRowNum: TLabel Left = 8 - Top = 354 + Top = 285 Width = 146 Height = 14 Caption = 'Sort warning on grid rows:' @@ -1104,22 +1104,22 @@ object frmPreferences: TfrmPreferences end object chkLocalNumberFormat: TCheckBox Left = 220 - Top = 281 + Top = 310 Width = 459 Height = 17 Anchors = [akLeft, akTop, akRight] Caption = 'Local number format' - TabOrder = 18 + TabOrder = 20 OnClick = Modified end object chkHintsOnResultTabs: TCheckBox Left = 220 - Top = 327 + Top = 356 Width = 459 Height = 17 Anchors = [akLeft, akTop, akRight] Caption = 'Pop up SQL text over result tabs' - TabOrder = 20 + TabOrder = 22 OnClick = Modified end object cboxRowHighlightSameText: TColorBox @@ -1142,30 +1142,30 @@ object frmPreferences: TfrmPreferences end object editLongSortRowNum: TEdit Left = 220 - Top = 351 + Top = 282 Width = 145 Height = 22 - TabOrder = 21 + TabOrder = 18 Text = '0' end object updownLongSortRowNum: TUpDown Left = 365 - Top = 351 + Top = 282 Width = 16 Height = 22 Associate = editLongSortRowNum Max = 2147483647 - TabOrder = 22 + TabOrder = 19 OnChanging = anyUpDownLimitChanging end object chkLowercaseHex: TCheckBox Left = 220 - Top = 304 + Top = 333 Width = 459 Height = 17 Anchors = [akLeft, akTop, akRight] Caption = 'Lowercase hexadecimal' - TabOrder = 19 + TabOrder = 21 end object editRealTrailingZeros: TEdit Left = 220 @@ -1184,6 +1184,16 @@ object frmPreferences: TfrmPreferences Min = -1 TabOrder = 17 end + object chkShowRowId: TCheckBox + Left = 220 + Top = 379 + Width = 461 + Height = 17 + Anchors = [akLeft, akTop, akRight] + Caption = 'Show static row id column' + TabOrder = 23 + OnClick = Modified + end end object tabDataEditors: TTabSheet Caption = 'Data editors' @@ -1191,7 +1201,7 @@ object frmPreferences: TfrmPreferences ImageName = 'icons8-compose' DesignSize = ( 684 - 366) + 406) object lblLineBreakStyle: TLabel Left = 3 Top = 235 @@ -1303,7 +1313,7 @@ object frmPreferences: TfrmPreferences ImageName = 'icons8-lightning-bolt-100' DesignSize = ( 684 - 366) + 406) object lblShortcut1: TLabel Left = 306 Top = 64 @@ -1332,7 +1342,7 @@ object frmPreferences: TfrmPreferences Left = 0 Top = 0 Width = 300 - Height = 366 + Height = 406 Align = alLeft Header.AutoSizeIndex = 0 Header.MainColumn = -1 @@ -1355,7 +1365,7 @@ object frmPreferences: TfrmPreferences ImageName = 'icons8-save-button-100' DesignSize = ( 684 - 366) + 406) object chkAskFileSave: TCheckBox Left = 220 Top = 8 @@ -1390,7 +1400,7 @@ object frmPreferences: TfrmPreferences end object btnCancel: TButton Left = 545 - Top = 409 + Top = 449 Width = 75 Height = 25 Anchors = [akRight, akBottom] @@ -1401,7 +1411,7 @@ object frmPreferences: TfrmPreferences end object btnOK: TButton Left = 465 - Top = 409 + Top = 449 Width = 75 Height = 25 Anchors = [akRight, akBottom] @@ -1413,7 +1423,7 @@ object frmPreferences: TfrmPreferences end object btnApply: TButton Left = 625 - Top = 409 + Top = 449 Width = 75 Height = 25 Anchors = [akRight, akBottom] @@ -1424,7 +1434,7 @@ object frmPreferences: TfrmPreferences end object btnRestoreDefaults: TButton Left = 8 - Top = 409 + Top = 449 Width = 177 Height = 25 Anchors = [akLeft, akBottom] @@ -1437,8 +1447,8 @@ object frmPreferences: TfrmPreferences Options.AutoDetectLineLimit = 0 Options.Visible = False SQLDialect = sqlMySQL - Left = 432 - Top = 352 + Left = 584 + Top = 392 end object SynSQLSyn_Dark: TSynSQLSyn Options.AutoDetectEnabled = False @@ -1457,8 +1467,8 @@ object frmPreferences: TfrmPreferences TableNameAttri.Foreground = 16755327 VariableAttri.Foreground = clPurple SQLDialect = sqlMySQL - Left = 200 - Top = 352 + Left = 592 + Top = 168 end object SynSQLSyn_Light: TSynSQLSyn Options.AutoDetectEnabled = False @@ -1477,8 +1487,8 @@ object frmPreferences: TfrmPreferences TableNameAttri.Foreground = clFuchsia VariableAttri.Foreground = clPurple SQLDialect = sqlMySQL - Left = 120 - Top = 352 + Left = 592 + Top = 112 end object SynSQLSyn_Black: TSynSQLSyn Options.AutoDetectEnabled = False @@ -1497,8 +1507,8 @@ object frmPreferences: TfrmPreferences TableNameAttri.Foreground = clBlack VariableAttri.Foreground = clBlack SQLDialect = sqlMySQL - Left = 196 - Top = 404 + Left = 588 + Top = 228 end object SynSQLSyn_White: TSynSQLSyn Options.AutoDetectEnabled = False @@ -1517,8 +1527,8 @@ object frmPreferences: TfrmPreferences TableNameAttri.Foreground = clWhite VariableAttri.Foreground = clWhite SQLDialect = sqlMySQL - Left = 284 - Top = 404 + Left = 588 + Top = 284 end object SynSQLSyn_Material: TSynSQLSyn Options.AutoDetectEnabled = False @@ -1537,7 +1547,7 @@ object frmPreferences: TfrmPreferences TableNameAttri.Foreground = 6911735 VariableAttri.Foreground = 7064575 SQLDialect = sqlMySQL - Left = 320 - Top = 404 + Left = 584 + Top = 340 end end diff --git a/source/preferences.pas b/source/preferences.pas index c2d101b9..6696fcbe 100644 --- a/source/preferences.pas +++ b/source/preferences.pas @@ -184,6 +184,7 @@ type lblCompletionProposalIntervalUnit: TLabel; chkColumnHeaderClick: TCheckBox; chkIncrementalSearch: TCheckBox; + chkShowRowId: TCheckBox; procedure FormShow(Sender: TObject); procedure Modified(Sender: TObject); procedure Apply(Sender: TObject); @@ -379,10 +380,11 @@ begin AppSettings.WriteInt(asRowBackgroundOdd, cboxRowBackgroundOdd.Selected); AppSettings.WriteInt(asHightlightSameTextBackground, cboxRowHighlightSameText.Selected); AppSettings.WriteInt(asRealTrailingZeros, updownRealTrailingZeros.Position); + AppSettings.WriteInt(asQueryGridLongSortRowNum, updownLongSortRowNum.Position); AppSettings.WriteBool(asDataLocalNumberFormat, chkLocalNumberFormat.Checked); AppSettings.WriteBool(asLowercaseHex, chkLowercaseHex.Checked); AppSettings.WriteBool(asHintsOnResultTabs, chkHintsOnResultTabs.Checked); - AppSettings.WriteInt(asQueryGridLongSortRowNum, updownLongSortRowNum.Position); + AppSettings.WriteBool(asShowRowId, chkShowRowId.Checked); // Editor Configuration AppSettings.WriteBool(asFieldEditorBinary, chkEditorBinary.Checked); @@ -768,10 +770,11 @@ begin cboxRowBackgroundOdd.Selected := AppSettings.ReadInt(asRowBackgroundOdd); cboxRowHighlightSameText.Selected := AppSettings.ReadInt(asHightlightSameTextBackground); updownRealTrailingZeros.Position := AppSettings.ReadInt(asRealTrailingZeros); + updownLongSortRowNum.Position := AppSettings.ReadInt(asQueryGridLongSortRowNum); chkLocalNumberFormat.Checked := AppSettings.ReadBool(asDataLocalNumberFormat); chkLowercaseHex.Checked := AppSettings.ReadBool(asLowercaseHex); chkHintsOnResultTabs.Checked := AppSettings.ReadBool(asHintsOnResultTabs); - updownLongSortRowNum.Position := AppSettings.ReadInt(asQueryGridLongSortRowNum); + chkShowRowId.Checked := AppSettings.ReadBool(asShowRowId); // Editor Configuration chkEditorBinary.Checked := AppSettings.ReadBool(asFieldEditorBinary);