Add export config directory specification feature (#15235)

This commit is contained in:
wasd845
2024-12-14 00:44:30 +08:00
committed by GitHub
parent 871a040911
commit 85eaa2d373
6 changed files with 41 additions and 10 deletions

View File

@@ -32,6 +32,7 @@
#include "DlgCreateNewPreferencePackImp.h"
#include "ui_DlgCreateNewPreferencePack.h"
#include "FileDialog.h"
using namespace Gui::Dialog;
@@ -54,6 +55,7 @@ DlgCreateNewPreferencePackImp::DlgCreateNewPreferencePackImp(QWidget* parent)
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &DlgCreateNewPreferencePackImp::onItemChanged);
connect(ui->lineEdit, &QLineEdit::textEdited, this, &DlgCreateNewPreferencePackImp::onLineEditTextEdited);
connect(ui->pushButton, &QPushButton::clicked, this, &DlgCreateNewPreferencePackImp::onBrowseButtonClicked);
}
@@ -114,6 +116,11 @@ std::string DlgCreateNewPreferencePackImp::preferencePackName() const
return ui->lineEdit->text().toStdString();
}
std::string Gui::Dialog::DlgCreateNewPreferencePackImp::preferencePackDirectory() const
{
return _cfgFileDirectory.toStdString();
}
void DlgCreateNewPreferencePackImp::onItemChanged(QTreeWidgetItem* item, int column)
{
Q_UNUSED(column);
@@ -151,6 +158,11 @@ void DlgCreateNewPreferencePackImp::onLineEditTextEdited(const QString& text)
ui->buttonBox->button(QDialogButtonBox::Ok)->setDisabled(text.isEmpty());
}
void DlgCreateNewPreferencePackImp::onBrowseButtonClicked()
{
_cfgFileDirectory = FileDialog::getExistingDirectory(this, tr("Export Config"), _cfgFileDirectory);
}
void Gui::Dialog::DlgCreateNewPreferencePackImp::accept()
{
// Ensure that the chosen name is either unique, or that the user actually wants to overwrite the old one