From 0fb341bb88f3c07899584d43b65dd99561b10d49 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 17 Mar 2019 11:57:09 +0100 Subject: [PATCH] Issue #140: add "Files" tab to preferences dialog, move "Prompt for file save" checkbox there, and introduce two new checkboxes for restoring opened and unsaved query tab contents (both new yet without functionality in their back) --- out/locale/en/LC_MESSAGES/default.po | 8 +- source/apphelpers.pas | 4 +- source/const.inc | 2 + source/options.dfm | 109 +++++++++++++++++---------- source/options.pas | 20 ++++- 5 files changed, 97 insertions(+), 46 deletions(-) diff --git a/out/locale/en/LC_MESSAGES/default.po b/out/locale/en/LC_MESSAGES/default.po index 3359058d..d723e3d1 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: 2019-03-14 21:10+0100\n" +"PO-Revision-Date: 2019-03-17 11:54+0100\n" "Last-Translator: Ansgar Becker \n" "Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n" "MIME-Version: 1.0\n" @@ -2743,6 +2743,12 @@ msgstr "Tabs to spaces" msgid "Prompt to save modified files on tab close" msgstr "Prompt to save modified files on tab close" +msgid "Reopen previously used SQL files in tabs" +msgstr "Reopen previously used SQL files in tabs" + +msgid "Automatically backup and restore unsaved content (up to %s per file)" +msgstr "Automatically backup and restore unsaved content (up to %s per file)" + msgid "Show query warnings dialog" msgstr "Show query warnings dialog" diff --git a/source/apphelpers.pas b/source/apphelpers.pas index 4140123f..e53c9559 100644 --- a/source/apphelpers.pas +++ b/source/apphelpers.pas @@ -168,7 +168,7 @@ type asCopyTableData, asCopyTableRecentFilter, asServerVersion, asServerVersionFull, asLastConnect, asConnectCount, asRefusedCount, asSessionCreated, asDoUsageStatistics, asLastUsageStatisticCall, asWheelZoom, asDisplayBars, asMySQLBinaries, asCustomSnippetsDirectory, - asPromptSaveFileOnTabClose, asWarnUnsafeUpdates, asQueryWarningsMessage, + asPromptSaveFileOnTabClose, asReopenFiles, asBackupRestoreFiles, asWarnUnsafeUpdates, asQueryWarningsMessage, asCompletionProposal, asCompletionProposalWidth, asCompletionProposalNbLinesInWindow, asAutoUppercase, asTabsToSpaces, asFilterPanel, asAllowMultipleInstances, asFindDialogSearchHistory, asGUIFontName, asGUIFontSize, asTheme, asIconPack, @@ -3615,6 +3615,8 @@ begin DefaultSnippetsDirectory := DefaultSnippetsDirectory + 'Snippets\'; InitSetting(asCustomSnippetsDirectory, 'CustomSnippetsDirectory', 0, False, DefaultSnippetsDirectory); InitSetting(asPromptSaveFileOnTabClose, 'PromptSaveFileOnTabClose', 0, True); + InitSetting(asReopenFiles, 'ReopenFiles', 0, True); + InitSetting(asBackupRestoreFiles, 'BackupRestoreFiles', 0, True); InitSetting(asWarnUnsafeUpdates, 'WarnUnsafeUpdates', 0, True); InitSetting(asQueryWarningsMessage, 'QueryWarningsMessage', 0, True); InitSetting(asCompletionProposal, 'CompletionProposal', 0, True); diff --git a/source/const.inc b/source/const.inc index bc146bf8..04d84698 100644 --- a/source/const.inc +++ b/source/const.inc @@ -82,6 +82,8 @@ const // Data grid: How many bytes to fetch from data fields that are potentially large. GRIDMAXDATA: Integer = 256; + BACKUP_MAXFILESIZE: Integer = 10 * SIZE_MB; + VTREE_NOTLOADED = 0; VTREE_NOTLOADED_PURGECACHE = 1; VTREE_LOADED = 2; diff --git a/source/options.dfm b/source/options.dfm index 42739326..154108a2 100644 --- a/source/options.dfm +++ b/source/options.dfm @@ -568,28 +568,28 @@ object optionsform: Toptionsform end object lblSQLColElement: TLabel Left = 8 - Top = 220 + Top = 186 Width = 42 Height = 13 Caption = 'Element:' end object lblSQLColBackground: TLabel Left = 180 - Top = 314 + Top = 280 Width = 60 Height = 13 Caption = 'Background:' end object lblSQLColForeground: TLabel Left = 180 - Top = 267 + Top = 233 Width = 60 Height = 13 Caption = 'Foreground:' end object lblEditorColorsPreset: TLabel Left = 8 - Top = 193 + Top = 159 Width = 68 Height = 13 Caption = 'Colors preset:' @@ -659,18 +659,6 @@ object optionsform: Toptionsform TabOrder = 4 OnClick = updownSQLFontSizeClick end - object chkAskFileSave: TCheckBox - Left = 180 - Top = 111 - Width = 506 - Height = 17 - Anchors = [akLeft, akTop, akRight] - Caption = 'Prompt to save modified files on tab close' - Checked = True - State = cbChecked - TabOrder = 9 - OnClick = Modified - end object editMaxQueryResults: TEdit Left = 180 Top = 61 @@ -693,55 +681,55 @@ object optionsform: Toptionsform end object comboSQLColElement: TComboBox Left = 180 - Top = 217 + Top = 183 Width = 145 Height = 21 Style = csDropDownList - TabOrder = 13 + TabOrder = 12 OnChange = comboSQLColElementChange end object chkSQLBold: TCheckBox Left = 180 - Top = 244 + Top = 210 Width = 61 Height = 17 Caption = 'Bold' - TabOrder = 14 + TabOrder = 13 OnClick = SQLFontChange end object chkSQLItalic: TCheckBox Left = 254 - Top = 244 + Top = 210 Width = 50 Height = 17 Caption = 'Italic' - TabOrder = 15 + TabOrder = 14 OnClick = SQLFontChange end object cboxSQLColForeground: TColorBox Left = 180 - Top = 286 + Top = 252 + Width = 145 + Height = 22 + Style = [cbStandardColors, cbExtendedColors, cbIncludeNone, cbCustomColor, cbPrettyNames, cbCustomColors] + TabOrder = 15 + OnChange = SQLFontChange + end + object cboxSQLColBackground: TColorBox + Left = 180 + Top = 299 Width = 145 Height = 22 Style = [cbStandardColors, cbExtendedColors, cbIncludeNone, cbCustomColor, cbPrettyNames, cbCustomColors] TabOrder = 16 OnChange = SQLFontChange end - object cboxSQLColBackground: TColorBox - Left = 180 - Top = 333 - Width = 145 - Height = 22 - Style = [cbStandardColors, cbExtendedColors, cbIncludeNone, cbCustomColor, cbPrettyNames, cbCustomColors] - TabOrder = 17 - OnChange = SQLFontChange - end object SynMemoSQLSample: TSynMemo AlignWithMargins = True Left = 331 - Top = 190 + Top = 156 Width = 364 - Height = 191 + Height = 229 Cursor = crHandPoint SingleLineMode = False Anchors = [akLeft, akTop, akRight, akBottom] @@ -750,7 +738,7 @@ object optionsform: Toptionsform Font.Height = -13 Font.Name = 'Courier New' Font.Style = [] - TabOrder = 18 + TabOrder = 17 OnClick = SynMemoSQLSampleClick CodeFolding.GutterShapeSize = 11 CodeFolding.CollapsedLineColor = clGrayText @@ -780,32 +768,32 @@ object optionsform: Toptionsform end object chkQueryWarningsMessage: TCheckBox Left = 180 - Top = 134 + Top = 110 Width = 508 Height = 17 Anchors = [akLeft, akTop, akRight] Caption = 'Show query warnings dialog' - TabOrder = 10 + TabOrder = 9 OnClick = Modified end object chkAutoUppercase: TCheckBox Left = 180 - Top = 159 + Top = 133 Width = 508 Height = 17 Anchors = [akLeft, akTop, akRight] Caption = 'Auto uppercase reserved words and functions' - TabOrder = 11 + TabOrder = 10 OnClick = Modified end object comboEditorColorsPreset: TComboBox Left = 180 - Top = 190 + Top = 156 Width = 145 Height = 21 Style = csDropDownList ItemIndex = 0 - TabOrder = 12 + TabOrder = 11 Text = 'Current custom settings' OnChange = comboEditorColorsPresetChange Items.Strings = ( @@ -1250,6 +1238,45 @@ object optionsform: Toptionsform end end end + object tabFiles: TTabSheet + Caption = 'Files' + ImageIndex = 10 + DesignSize = ( + 700 + 388) + object chkReopenFiles: TCheckBox + Left = 190 + Top = 31 + Width = 496 + Height = 17 + Anchors = [akLeft, akTop, akRight] + Caption = 'Reopen previously used SQL files in tabs' + TabOrder = 0 + end + object chkAskFileSave: TCheckBox + Left = 190 + Top = 8 + Width = 496 + Height = 17 + Anchors = [akLeft, akTop, akRight] + Caption = 'Prompt to save modified files on tab close' + Checked = True + State = cbChecked + TabOrder = 1 + OnClick = Modified + end + object chkBackupRestoreFiles: TCheckBox + Left = 190 + Top = 54 + Width = 496 + Height = 17 + Anchors = [akLeft, akTop, akRight] + Caption = + 'Automatically backup and restore unsaved content (up to %s per f' + + 'ile)' + TabOrder = 2 + end + end end object btnCancel: TButton Left = 561 diff --git a/source/options.pas b/source/options.pas index 33c0f2d4..b29d2653 100644 --- a/source/options.pas +++ b/source/options.pas @@ -98,7 +98,6 @@ type editSQLTabWidth: TEdit; updownSQLTabWidth: TUpDown; Label1: TLabel; - chkAskFileSave: TCheckBox; lblMaxQueryResults: TLabel; editMaxQueryResults: TEdit; updownMaxQueryResults: TUpDown; @@ -169,6 +168,10 @@ type comboGridTextColorsPreset: TComboBox; lblIconPack: TLabel; comboIconPack: TComboBox; + tabFiles: TTabSheet; + chkReopenFiles: TCheckBox; + chkAskFileSave: TCheckBox; + chkBackupRestoreFiles: TCheckBox; procedure FormShow(Sender: TObject); procedure Modified(Sender: TObject); procedure Apply(Sender: TObject); @@ -279,7 +282,6 @@ begin AppSettings.WriteBool(asAutoReconnect, chkAutoReconnect.Checked); AppSettings.WriteBool(asAllowMultipleInstances, chkAllowMultiInstances.Checked); AppSettings.WriteBool(asRestoreLastUsedDB, chkRestoreLastDB.Checked); - AppSettings.WriteBool(asPromptSaveFileOnTabClose, chkAskFileSave.Checked); AppSettings.WriteBool(asQueryWarningsMessage, chkQueryWarningsMessage.Checked); AppSettings.WriteString(asFontName, comboSQLFontName.Text); AppSettings.WriteInt(asFontSize, updownSQLFontSize.Position); @@ -398,6 +400,11 @@ begin // Populate SynMemo settings to all instances Mainform.SetupSynEditors; + // Files + AppSettings.WriteBool(asPromptSaveFileOnTabClose, chkAskFileSave.Checked); + AppSettings.WriteBool(asReopenFiles, chkReopenFiles.Checked); + AppSettings.WriteBool(asBackupRestoreFiles, chkBackupRestoreFiles.Checked); + // Set relevant properties in mainform MainForm.ApplyFontToGrids; MainForm.PrepareImageList; @@ -591,6 +598,9 @@ begin FShortcutCategories.Add(_('SQL editing')); TreeShortcutItems.RootNodeCount := FShortcutCategories.Count; comboLineBreakStyle.Items := Explode(',', _('Windows linebreaks')+','+_('UNIX linebreaks')+','+_('Mac OS linebreaks')); + + // Files + chkBackupRestoreFiles.Caption := f_('Automatically backup and restore unsaved content (up to %s per file)', [FormatByteNumber(BACKUP_MAXFILESIZE,0)]); end; @@ -644,7 +654,6 @@ begin comboGUIFont.OnChange(comboGUIFont); comboTheme.ItemIndex := comboTheme.Items.IndexOf(AppSettings.ReadString(asTheme)); comboIconPack.ItemIndex := comboIconPack.Items.IndexOf(AppSettings.ReadString(asIconPack)); - chkAskFileSave.Checked := AppSettings.ReadBool(asPromptSaveFileOnTabClose); chkQueryWarningsMessage.Checked := AppSettings.ReadBool(asQueryWarningsMessage); // Logging @@ -718,6 +727,11 @@ begin TreeShortcutItems.ReinitChildren(nil, True); SelectNode(TreeShortcutItems, nil); + // Files + chkAskFileSave.Checked := AppSettings.ReadBool(asPromptSaveFileOnTabClose); + chkReopenFiles.Checked := AppSettings.ReadBool(asReopenFiles); + chkBackupRestoreFiles.Checked := AppSettings.ReadBool(asBackupRestoreFiles); + FRestartOptionTouched := False; btnApply.Enabled := False; screen.Cursor := crdefault;