From fdb66f92f5236f61ff5d47dd1eb24285e1cf6a60 Mon Sep 17 00:00:00 2001 From: nxshock Date: Tue, 5 Mar 2024 21:41:51 +0500 Subject: [PATCH] Add export path picker --- kernel.go | 3 ++- ui_main_form.go | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/kernel.go b/kernel.go index 2940ee3..090b796 100644 --- a/kernel.go +++ b/kernel.go @@ -25,6 +25,7 @@ type Job struct { scriptFilePath string exportFileFormat ExportFormat encoding Encoding + exportPath string config Config @@ -72,7 +73,7 @@ func (j *Job) export(inputRows chan Row) error { return err } - fileName := filepath.Base(j.scriptFilePath) + fileName := filepath.Join(j.exportPath, filepath.Base(j.scriptFilePath)) fileName = strings.TrimSuffix(fileName, filepath.Ext(fileName)) outputRows := make(chan []any) diff --git a/ui_main_form.go b/ui_main_form.go index eaebdac..4353a8c 100644 --- a/ui_main_form.go +++ b/ui_main_form.go @@ -33,6 +33,8 @@ type TMainForm struct { ExportFormatComboBox *vcl.TComboBox CharsetLabel *vcl.TLabel CharsetComboBox *vcl.TComboBox + ExportPathLabel *vcl.TLabel + ExportPathPicker *vcl.TDirectoryEdit BottomPanel *vcl.TPanel LaunchButton *vcl.TBitBtn @@ -157,6 +159,24 @@ func (f *TMainForm) OnFormCreate(sender vcl.IObject) { f.CharsetComboBox.SetTop(700) f.CharsetComboBox.SetStyle(types.CsDropDownList) + f.ExportPathLabel = vcl.NewLabel(f) + f.ExportPathLabel.SetParent(f.GroupBox) + f.ExportPathLabel.SetCaption("Путь сохранения результата") + f.ExportPathLabel.SetAlign(types.AlTop) + f.ExportPathLabel.SetTop(800) + f.ExportPathLabel.BorderSpacing().SetTop(8) + f.ExportPathLabel.BorderSpacing().SetLeft(8) + f.ExportPathLabel.BorderSpacing().SetRight(8) + + f.ExportPathPicker = vcl.NewDirectoryEdit(f) + f.ExportPathPicker.SetParent(f.GroupBox) + f.ExportPathPicker.SetAlign(types.AlTop) + f.ExportPathPicker.BorderSpacing().SetTop(2) + f.ExportPathPicker.BorderSpacing().SetLeft(8) + f.ExportPathPicker.BorderSpacing().SetRight(8) + f.ExportPathPicker.SetTop(900) + f.ExportPathPicker.SetFlat(true) + f.BottomPanel = vcl.NewPanel(f) f.BottomPanel.SetParent(f.TabSheet1) f.BottomPanel.SetAlign(types.AlBottom) @@ -258,7 +278,8 @@ func (f *TMainForm) OnLaunchButtonClick(sender vcl.IObject) { configFilePath: filepath.Join(CONFIG_FILES_DIR, f.ConfigComboBox.Text()) + "." + CONFIG_FILE_EXT, scriptFilePath: filepath.Join(SQL_FILES_DIR, f.SqlFileComboBox.Text()) + "." + SQL_FILE_EXT, exportFileFormat: ExportFormat(f.ExportFormatComboBox.Text()), - encoding: Encoding(f.CharsetComboBox.Text())} + encoding: Encoding(f.CharsetComboBox.Text()), + exportPath: f.ExportPathPicker.Directory()} err := job.init() if err != nil {