Reorder components in grid export dialog, and convert format radio buttons to combobox. Makes the dialog more wide than high, creating space for wider labels and more format options.

This commit is contained in:
Ansgar Becker
2024-04-20 10:50:14 +02:00
parent e0f8abad06
commit a8405070db
2 changed files with 144 additions and 151 deletions

View File

@ -3,11 +3,11 @@ object frmExportGrid: TfrmExportGrid
Top = 0 Top = 0
BorderIcons = [biSystemMenu] BorderIcons = [biSystemMenu]
Caption = 'Export grid rows' Caption = 'Export grid rows'
ClientHeight = 445 ClientHeight = 412
ClientWidth = 373 ClientWidth = 574
Color = clBtnFace Color = clBtnFace
Constraints.MinHeight = 480 Constraints.MinHeight = 450
Constraints.MinWidth = 350 Constraints.MinWidth = 530
Font.Charset = DEFAULT_CHARSET Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText Font.Color = clWindowText
Font.Height = -12 Font.Height = -12
@ -16,91 +16,69 @@ object frmExportGrid: TfrmExportGrid
Position = poMainFormCenter Position = poMainFormCenter
OnClose = FormClose OnClose = FormClose
OnCreate = FormCreate OnCreate = FormCreate
OnResize = FormResize
OnShow = FormShow OnShow = FormShow
DesignSize = ( DesignSize = (
373 574
445) 412)
TextHeight = 14 TextHeight = 14
object btnOK: TButton object btnOK: TButton
Left = 209 Left = 410
Top = 412 Top = 379
Width = 75 Width = 75
Height = 25 Height = 25
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
Caption = 'OK' Caption = 'OK'
Default = True Default = True
ModalResult = 1 ModalResult = 1
TabOrder = 0 TabOrder = 5
OnClick = btnOKClick OnClick = btnOKClick
end end
object btnCancel: TButton object btnCancel: TButton
Left = 290 Left = 491
Top = 412 Top = 379
Width = 75 Width = 75
Height = 25 Height = 25
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
Cancel = True Cancel = True
Caption = 'Cancel' Caption = 'Cancel'
ModalResult = 2 ModalResult = 2
TabOrder = 1 TabOrder = 6
end
object grpFormat: TRadioGroup
Left = 8
Top = 112
Width = 137
Height = 294
Anchors = [akLeft, akTop, akBottom]
Caption = 'Output format'
ItemIndex = 0
Items.Strings = (
'Excel compatible'
'Delimited text'
'HTML table'
'XML'
'SQL INSERTs'
'SQL REPLACEs'
'LaTeX'
'Wiki markup'
'PHP Array')
TabOrder = 2
OnClick = grpFormatClick
end end
object grpSelection: TRadioGroup object grpSelection: TRadioGroup
Left = 151 Left = 8
Top = 112 Top = 168
Width = 214 Width = 558
Height = 66 Height = 66
Anchors = [akTop, akRight] Anchors = [akLeft, akTop, akRight]
Caption = 'Row selection' Caption = 'Row selection'
ItemIndex = 1 ItemIndex = 1
Items.Strings = ( Items.Strings = (
'Selected rows' 'Selected rows'
'All loaded rows') 'All loaded rows')
TabOrder = 3 TabOrder = 2
end end
object grpOutput: TGroupBox object grpOutput: TGroupBox
Left = 8 Left = 8
Top = 8 Top = 8
Width = 357 Width = 558
Height = 98 Height = 98
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Caption = 'Output target' Caption = 'Output target'
TabOrder = 4 TabOrder = 0
DesignSize = ( DesignSize = (
357 558
98) 98)
object lblEncoding: TLabel object lblEncoding: TLabel
Left = 8 Left = 8
Top = 72 Top = 72
Width = 47 Width = 54
Height = 13 Height = 14
Caption = 'Encoding:' Caption = 'Encoding:'
end end
object radioOutputCopyToClipboard: TRadioButton object radioOutputCopyToClipboard: TRadioButton
Left = 8 Left = 8
Top = 18 Top = 18
Width = 335 Width = 540
Height = 17 Height = 17
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Caption = 'Copy to clipboard' Caption = 'Copy to clipboard'
@ -121,8 +99,8 @@ object frmExportGrid: TfrmExportGrid
object editFilename: TButtonedEdit object editFilename: TButtonedEdit
Left = 79 Left = 79
Top = 42 Top = 42
Width = 264 Width = 469
Height = 21 Height = 22
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Images = MainForm.VirtualImageListMain Images = MainForm.VirtualImageListMain
LeftButton.DropDownMenu = popupRecentFiles LeftButton.DropDownMenu = popupRecentFiles
@ -139,152 +117,148 @@ object frmExportGrid: TfrmExportGrid
object comboEncoding: TComboBox object comboEncoding: TComboBox
Left = 79 Left = 79
Top = 69 Top = 69
Width = 264 Width = 469
Height = 21 Height = 22
Style = csDropDownList Style = csDropDownList
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
TabOrder = 3 TabOrder = 3
end end
end end
object grpOptions: TGroupBox object grpOptions: TGroupBox
Left = 151 Left = 8
Top = 184 Top = 240
Width = 214 Width = 558
Height = 222 Height = 133
Anchors = [akTop, akRight, akBottom] Anchors = [akLeft, akTop, akRight, akBottom]
Caption = 'Options' Caption = 'Options'
TabOrder = 5 TabOrder = 3
DesignSize = ( DesignSize = (
214 558
222) 133)
object lblSeparator: TLabel object lblSeparator: TLabel
Left = 6 Left = 279
Top = 116 Top = 18
Width = 76 Width = 83
Height = 13 Height = 14
Caption = 'Field separator:' Caption = 'Field separator:'
end end
object lblEncloser: TLabel object lblEncloser: TLabel
Left = 6 Left = 279
Top = 141 Top = 44
Width = 44 Width = 49
Height = 13 Height = 14
Caption = 'Encloser:' Caption = 'Encloser:'
end end
object lblTerminator: TLabel object lblTerminator: TLabel
Left = 6 Left = 279
Top = 167 Top = 71
Width = 76 Width = 87
Height = 13 Height = 14
Caption = 'Line terminator:' Caption = 'Line terminator:'
end end
object lblNull: TLabel object lblNull: TLabel
Left = 6 Left = 279
Top = 194 Top = 97
Width = 57 Width = 64
Height = 13 Height = 14
Caption = 'NULL value:' Caption = 'NULL value:'
end end
object chkIncludeColumnNames: TCheckBox object chkIncludeColumnNames: TCheckBox
Left = 6 Left = 8
Top = 18 Top = 18
Width = 191 Width = 257
Height = 17 Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Include column names' Caption = 'Include column names'
Checked = True Checked = True
State = cbChecked State = cbChecked
TabOrder = 0 TabOrder = 0
end end
object editSeparator: TButtonedEdit object editSeparator: TButtonedEdit
Left = 106 Left = 400
Top = 112 Top = 15
Width = 93 Width = 148
Height = 21 Height = 22
Anchors = [akLeft, akTop, akRight]
Images = MainForm.VirtualImageListMain
RightButton.DisabledImageIndex = 107
RightButton.ImageIndex = 108
RightButton.Visible = True
TabOrder = 3
Text = ';'
OnChange = editCSVChange
OnRightButtonClick = editCSVRightButtonClick
end
object editEncloser: TButtonedEdit
Left = 106
Top = 138
Width = 93
Height = 21
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Images = MainForm.VirtualImageListMain Images = MainForm.VirtualImageListMain
RightButton.DisabledImageIndex = 107 RightButton.DisabledImageIndex = 107
RightButton.ImageIndex = 108 RightButton.ImageIndex = 108
RightButton.Visible = True RightButton.Visible = True
TabOrder = 4 TabOrder = 4
Text = ';'
OnChange = editCSVChange OnChange = editCSVChange
OnRightButtonClick = editCSVRightButtonClick OnRightButtonClick = editCSVRightButtonClick
end end
object editTerminator: TButtonedEdit object editEncloser: TButtonedEdit
Left = 106 Left = 400
Top = 164 Top = 41
Width = 93 Width = 148
Height = 21 Height = 22
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Images = MainForm.VirtualImageListMain Images = MainForm.VirtualImageListMain
RightButton.DisabledImageIndex = 107 RightButton.DisabledImageIndex = 107
RightButton.ImageIndex = 108 RightButton.ImageIndex = 108
RightButton.Visible = True RightButton.Visible = True
TabOrder = 5 TabOrder = 5
Text = '\r\n'
OnChange = editCSVChange OnChange = editCSVChange
OnRightButtonClick = editCSVRightButtonClick OnRightButtonClick = editCSVRightButtonClick
end end
object chkIncludeAutoIncrement: TCheckBox object editTerminator: TButtonedEdit
Left = 6 Left = 400
Top = 41 Top = 68
Width = 191 Width = 148
Height = 17 Height = 22
Anchors = [akLeft, akTop, akRight]
Caption = 'Include auto increment column'
TabOrder = 1
end
object chkIncludeQuery: TCheckBox
Left = 6
Top = 64
Width = 191
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Include SQL query'
TabOrder = 2
end
object editNull: TButtonedEdit
Left = 106
Top = 191
Width = 93
Height = 21
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Images = MainForm.VirtualImageListMain Images = MainForm.VirtualImageListMain
RightButton.DisabledImageIndex = 107 RightButton.DisabledImageIndex = 107
RightButton.ImageIndex = 108 RightButton.ImageIndex = 108
RightButton.Visible = True RightButton.Visible = True
TabOrder = 6 TabOrder = 6
Text = '\r\n'
OnChange = editCSVChange
OnRightButtonClick = editCSVRightButtonClick
end
object chkIncludeAutoIncrement: TCheckBox
Left = 8
Top = 41
Width = 257
Height = 17
Caption = 'Include auto increment column'
TabOrder = 1
end
object chkIncludeQuery: TCheckBox
Left = 8
Top = 64
Width = 257
Height = 17
Caption = 'Include SQL query'
TabOrder = 2
end
object editNull: TButtonedEdit
Left = 400
Top = 94
Width = 148
Height = 22
Anchors = [akLeft, akTop, akRight]
Images = MainForm.VirtualImageListMain
RightButton.DisabledImageIndex = 107
RightButton.ImageIndex = 108
RightButton.Visible = True
TabOrder = 7
OnChange = editCSVChange OnChange = editCSVChange
OnRightButtonClick = editCSVRightButtonClick OnRightButtonClick = editCSVRightButtonClick
end end
object chkRemoveLinebreaks: TCheckBox object chkRemoveLinebreaks: TCheckBox
Left = 6 Left = 8
Top = 87 Top = 87
Width = 191 Width = 257
Height = 17 Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Remove linebreaks from contents' Caption = 'Remove linebreaks from contents'
TabOrder = 7 TabOrder = 3
end end
end end
object btnSetClipboardDefaults: TButton object btnSetClipboardDefaults: TButton
Left = 8 Left = 8
Top = 412 Top = 379
Width = 153 Width = 153
Height = 25 Height = 25
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
@ -292,12 +266,40 @@ object frmExportGrid: TfrmExportGrid
ImageIndex = 4 ImageIndex = 4
ImageName = 'icons8-paste-100' ImageName = 'icons8-paste-100'
Images = MainForm.VirtualImageListMain Images = MainForm.VirtualImageListMain
TabOrder = 6 TabOrder = 4
OnClick = btnSetClipboardDefaultsClick OnClick = btnSetClipboardDefaultsClick
end end
object grpFormat: TGroupBox
Left = 8
Top = 112
Width = 558
Height = 50
Anchors = [akLeft, akTop, akRight]
Caption = 'Output format'
TabOrder = 1
DesignSize = (
558
50)
object comboFormat: TComboBox
Left = 8
Top = 18
Width = 540
Height = 22
Style = csDropDownList
Anchors = [akLeft, akTop, akRight]
DropDownCount = 20
ItemIndex = 0
TabOrder = 0
Text = 'Excel CSV'
Items.Strings = (
'Excel CSV'
'Delimited Text'
'...')
end
end
object popupCSVchar: TPopupMenu object popupCSVchar: TPopupMenu
AutoHotkeys = maManual AutoHotkeys = maManual
Left = 224 Left = 160
Top = 6 Top = 6
object menuCSVtab: TMenuItem object menuCSVtab: TMenuItem
Caption = 'Tab' Caption = 'Tab'
@ -367,7 +369,7 @@ object frmExportGrid: TfrmExportGrid
object popupRecentFiles: TPopupMenu object popupRecentFiles: TPopupMenu
AutoHotkeys = maManual AutoHotkeys = maManual
OnPopup = popupRecentFilesPopup OnPopup = popupRecentFilesPopup
Left = 312 Left = 248
Top = 6 Top = 6
end end
end end

View File

@ -29,7 +29,6 @@ type
TfrmExportGrid = class(TExtForm) TfrmExportGrid = class(TExtForm)
btnOK: TButton; btnOK: TButton;
btnCancel: TButton; btnCancel: TButton;
grpFormat: TRadioGroup;
grpSelection: TRadioGroup; grpSelection: TRadioGroup;
grpOutput: TGroupBox; grpOutput: TGroupBox;
radioOutputCopyToClipboard: TRadioButton; radioOutputCopyToClipboard: TRadioButton;
@ -67,6 +66,8 @@ type
editNull: TButtonedEdit; editNull: TButtonedEdit;
btnSetClipboardDefaults: TButton; btnSetClipboardDefaults: TButton;
chkRemoveLinebreaks: TCheckBox; chkRemoveLinebreaks: TCheckBox;
grpFormat: TGroupBox;
comboFormat: TComboBox;
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure CalcSize(Sender: TObject); procedure CalcSize(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormClose(Sender: TObject; var Action: TCloseAction);
@ -81,7 +82,6 @@ type
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure grpFormatClick(Sender: TObject); procedure grpFormatClick(Sender: TObject);
procedure btnSetClipboardDefaultsClick(Sender: TObject); procedure btnSetClipboardDefaultsClick(Sender: TObject);
procedure FormResize(Sender: TObject);
private private
{ Private declarations } { Private declarations }
FCSVEditor: TButtonedEdit; FCSVEditor: TButtonedEdit;
@ -179,15 +179,15 @@ begin
comboEncoding.Items.Assign(MainForm.FileEncodings); comboEncoding.Items.Assign(MainForm.FileEncodings);
comboEncoding.Items.Delete(0); // Remove "Auto detect" comboEncoding.Items.Delete(0); // Remove "Auto detect"
comboEncoding.ItemIndex := AppSettings.ReadInt(asGridExportEncoding); comboEncoding.ItemIndex := AppSettings.ReadInt(asGridExportEncoding);
grpFormat.Items.Clear; comboFormat.Items.Clear;
for FormatDesc in FormatToDescription do for FormatDesc in FormatToDescription do
grpFormat.Items.Add(FormatDesc); comboFormat.Items.Add(FormatDesc);
SenderName := Owner.Name; SenderName := Owner.Name;
FHiddenCopyMode := SenderName.StartsWith(CopyAsActionPrefix); FHiddenCopyMode := SenderName.StartsWith(CopyAsActionPrefix);
if FHiddenCopyMode then begin if FHiddenCopyMode then begin
radioOutputCopyToClipboard.Checked := True; radioOutputCopyToClipboard.Checked := True;
grpFormat.ItemIndex := Owner.Tag; comboFormat.ItemIndex := Owner.Tag;
grpSelection.ItemIndex := 0; // Always use selected cells in copy mode grpSelection.ItemIndex := 0; // Always use selected cells in copy mode
chkIncludeColumnNames.Checked := AppSettings.ReadBool(asGridExportClpColumnNames); chkIncludeColumnNames.Checked := AppSettings.ReadBool(asGridExportClpColumnNames);
chkIncludeAutoIncrement.Checked := AppSettings.ReadBool(asGridExportClpIncludeAutoInc); chkIncludeAutoIncrement.Checked := AppSettings.ReadBool(asGridExportClpIncludeAutoInc);
@ -200,7 +200,7 @@ begin
end else begin end else begin
radioOutputCopyToClipboard.Checked := AppSettings.ReadBool(asGridExportOutputCopy); radioOutputCopyToClipboard.Checked := AppSettings.ReadBool(asGridExportOutputCopy);
radioOutputFile.Checked := AppSettings.ReadBool(asGridExportOutputFile); radioOutputFile.Checked := AppSettings.ReadBool(asGridExportOutputFile);
grpFormat.ItemIndex := AppSettings.ReadInt(asGridExportFormat); comboFormat.ItemIndex := AppSettings.ReadInt(asGridExportFormat);
grpSelection.ItemIndex := AppSettings.ReadInt(asGridExportSelection); grpSelection.ItemIndex := AppSettings.ReadInt(asGridExportSelection);
chkIncludeColumnNames.Checked := AppSettings.ReadBool(asGridExportColumnNames); chkIncludeColumnNames.Checked := AppSettings.ReadBool(asGridExportColumnNames);
chkIncludeAutoIncrement.Checked := AppSettings.ReadBool(asGridExportIncludeAutoInc); chkIncludeAutoIncrement.Checked := AppSettings.ReadBool(asGridExportIncludeAutoInc);
@ -215,15 +215,6 @@ begin
end; end;
procedure TfrmExportGrid.FormResize(Sender: TObject);
begin
grpFormat.Width := Width div 3;
grpSelection.Left := grpFormat.Left + grpFormat.Width + 8;
grpSelection.Width := Width - grpSelection.Left - 24;
grpOptions.Left := grpSelection.Left;
grpOptions.Width := grpSelection.Width;
end;
procedure TfrmExportGrid.FormShow(Sender: TObject); procedure TfrmExportGrid.FormShow(Sender: TObject);
begin begin
// Show dialog. Expect "Grid" property to be set now by the caller. // Show dialog. Expect "Grid" property to be set now by the caller.
@ -245,7 +236,7 @@ begin
AppSettings.WriteString(asGridExportFilename, editFilename.Text); AppSettings.WriteString(asGridExportFilename, editFilename.Text);
AppSettings.WriteString(asGridExportRecentFiles, Implode(DELIM, FRecentFiles)); AppSettings.WriteString(asGridExportRecentFiles, Implode(DELIM, FRecentFiles));
AppSettings.WriteInt(asGridExportEncoding, comboEncoding.ItemIndex); AppSettings.WriteInt(asGridExportEncoding, comboEncoding.ItemIndex);
AppSettings.WriteInt(asGridExportFormat, grpFormat.ItemIndex); AppSettings.WriteInt(asGridExportFormat, comboFormat.ItemIndex);
AppSettings.WriteInt(asGridExportSelection, grpSelection.ItemIndex); AppSettings.WriteInt(asGridExportSelection, grpSelection.ItemIndex);
AppSettings.WriteBool(asGridExportColumnNames, chkIncludeColumnNames.Checked); AppSettings.WriteBool(asGridExportColumnNames, chkIncludeColumnNames.Checked);
AppSettings.WriteBool(asGridExportIncludeAutoInc, chkIncludeAutoIncrement.Checked); AppSettings.WriteBool(asGridExportIncludeAutoInc, chkIncludeAutoIncrement.Checked);
@ -320,13 +311,13 @@ end;
function TfrmExportGrid.GetExportFormat: TGridExportFormat; function TfrmExportGrid.GetExportFormat: TGridExportFormat;
begin begin
Result := TGridExportFormat(grpFormat.ItemIndex); Result := TGridExportFormat(comboFormat.ItemIndex);
end; end;
procedure TfrmExportGrid.SetExportFormat(Value: TGridExportFormat); procedure TfrmExportGrid.SetExportFormat(Value: TGridExportFormat);
begin begin
grpFormat.ItemIndex := Integer(Value); comboFormat.ItemIndex := Integer(Value);
end; end;
@ -387,7 +378,7 @@ begin
Dialog.Filter := Dialog.Filter + FormatToDescription[ef] + ' (*.'+FormatToFileExtension[ef]+')|*.'+FormatToFileExtension[ef]+'|'; Dialog.Filter := Dialog.Filter + FormatToDescription[ef] + ' (*.'+FormatToFileExtension[ef]+')|*.'+FormatToFileExtension[ef]+'|';
Dialog.Filter := Dialog.Filter + _('All files')+' (*.*)|*.*'; Dialog.Filter := Dialog.Filter + _('All files')+' (*.*)|*.*';
Dialog.OnTypeChange := SaveDialogTypeChange; Dialog.OnTypeChange := SaveDialogTypeChange;
Dialog.FilterIndex := grpFormat.ItemIndex+1; Dialog.FilterIndex := comboFormat.ItemIndex+1;
Dialog.OnTypeChange(Dialog); Dialog.OnTypeChange(Dialog);
if Dialog.Execute then begin if Dialog.Execute then begin
editFilename.Text := Dialog.FileName; editFilename.Text := Dialog.FileName;