Skip to content

Commit

Permalink
Issue #1879: add drop down menu to "Apply filter" button, with an opt…
Browse files Browse the repository at this point in the history
…ion to overwrite the current filter based on the different input text
  • Loading branch information
ansgarbecker committed Dec 2, 2023
1 parent bbcebc8 commit d930400
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
8 changes: 7 additions & 1 deletion out/locale/en/LC_MESSAGES/default.po
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2023-11-26 12:25+0100\n"
"PO-Revision-Date: 2023-12-02 14:00+0100\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n"
"Language: en\n"
Expand Down Expand Up @@ -2100,6 +2100,12 @@ msgstr "Set delimiter used in SQL execution"
msgid "Apply filter"
msgstr "Apply filter"

msgid "Always generate filter"
msgstr "Always generate filter"

msgid "Generate filter based on this text, even if the current filter is not empty"
msgstr "Generate filter based on this text, even if the current filter is not empty"

#. MainForm..ActionList1..actRemoveFilter..Caption
#: main.dfm:2362
msgid "Remove filter"
Expand Down
3 changes: 2 additions & 1 deletion source/apphelpers.pas
Expand Up @@ -231,7 +231,7 @@ TWinControlHelper = class helper for TWinControl
asThemePreviewWidth, asThemePreviewHeight, asThemePreviewTop, asThemePreviewLeft,
asCreateDbCollation, asRealTrailingZeros,
asSequalSuggestWindowWidth, asSequalSuggestWindowHeight, asSequalSuggestPrompt, asSequalSuggestRecentPrompts,
asReformatter,
asReformatter, asAlwaysGenerateFilter,
asUnused);
TAppSetting = record
Name: String;
Expand Down Expand Up @@ -3814,6 +3814,7 @@ constructor TAppSettings.Create;
InitSetting(asSequalSuggestPrompt, 'SequalSuggestPrompt', 0, False, '');
InitSetting(asSequalSuggestRecentPrompts, 'SequalSuggestRecentPrompts', 0, False, '');
InitSetting(asReformatter, 'Reformatter', 0);
InitSetting(asAlwaysGenerateFilter, 'AlwaysGenerateFilter', 0, False);

// Default folder for snippets
if FPortableMode then
Expand Down
22 changes: 18 additions & 4 deletions source/main.dfm
Expand Up @@ -1145,16 +1145,18 @@ object MainForm: TMainForm
object btnFilterApply: TButton
Left = 497
Top = 41
Width = 76
Width = 89
Height = 22
Action = actApplyFilter
Anchors = [akTop, akRight]
DropDownMenu = popupApplyFilter
Style = bsSplitButton
TabOrder = 3
end
object btnFilterClear: TButton
Left = 577
Left = 592
Top = 41
Width = 76
Width = 89
Height = 22
Action = actClearFilterEditor
Anchors = [akTop, akRight]
Expand Down Expand Up @@ -1204,7 +1206,7 @@ object MainForm: TMainForm
object editFilterSearch: TEdit
Left = 497
Top = 15
Width = 156
Width = 184
Height = 22
Anchors = [akTop, akRight]
TabOrder = 2
Expand Down Expand Up @@ -25568,4 +25570,16 @@ object MainForm: TMainForm
Left = 761
Top = 195
end
object popupApplyFilter: TPopupMenu
Left = 200
Top = 312
object menuAlwaysGenerateFilter: TMenuItem
AutoCheck = True
Caption = 'Always generate filter'
Hint =
'Generate filter based on this text, even if the current filter i' +
's not empty'
OnClick = menuAlwaysGenerateFilterClick
end
end
end
12 changes: 11 additions & 1 deletion source/main.pas
Expand Up @@ -784,6 +784,8 @@ TMainForm = class(TExtForm)
btnDonate: TToolButton;
actResetPanelDimensions: TAction;
Resetpaneldimensions1: TMenuItem;
popupApplyFilter: TPopupMenu;
menuAlwaysGenerateFilter: TMenuItem;
procedure actCreateDBObjectExecute(Sender: TObject);
procedure menuConnectionsPopup(Sender: TObject);
procedure actExitApplicationExecute(Sender: TObject);
Expand Down Expand Up @@ -1188,6 +1190,7 @@ TMainForm = class(TExtForm)
procedure TimerCloseTabByButtonTimer(Sender: TObject);
procedure menuTabsInMultipleLinesClick(Sender: TObject);
procedure actResetPanelDimensionsExecute(Sender: TObject);
procedure menuAlwaysGenerateFilterClick(Sender: TObject);
private
// Executable file details
FAppVerMajor: Integer;
Expand Down Expand Up @@ -2036,6 +2039,7 @@ procedure TMainForm.FormCreate(Sender: TObject);
actPreferencesLogging.OnExecute := actPreferences.OnExecute;
actPreferencesData.ImageIndex := actPreferences.ImageIndex;
actPreferencesData.OnExecute := actPreferences.OnExecute;
menuAlwaysGenerateFilter.Checked := AppSettings.ReadBool(asAlwaysGenerateFilter);

pnlQueryMemo.Height := AppSettings.ReadInt(asQuerymemoheight);
pnlQueryHelpers.Width := AppSettings.ReadInt(asQueryhelperswidth);
Expand Down Expand Up @@ -5318,7 +5322,7 @@ procedure TMainForm.actApplyFilterExecute(Sender: TObject);
begin
// If filter box is empty but filter generator box has text, most users expect
// the filter to be auto generated on button click
if (SynMemoFilter.GetTextLen = 0)
if ((SynMemoFilter.GetTextLen = 0) or menuAlwaysGenerateFilter.Checked)
and (editFilterSearch.Text <> '')
and (Sender is TAction)
and ((Sender as TAction).ActionComponent = btnFilterApply)
Expand Down Expand Up @@ -10841,6 +10845,12 @@ procedure TMainForm.menuShowSizeColumnClick(Sender: TObject);
end;


procedure TMainForm.menuAlwaysGenerateFilterClick(Sender: TObject);
begin
// Store setting for toggled filter generation
AppSettings.WriteBool(asAlwaysGenerateFilter, menuAlwaysGenerateFilter.Checked);
end;

procedure TMainForm.menuAutoExpandClick(Sender: TObject);
var
Item: TMenuItem;
Expand Down

0 comments on commit d930400

Please sign in to comment.