You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AppFlow/FITK_Component/FITKWidget/FITKWorkingDirDialog.cpp

68 lines
2.0 KiB
C++

#include "FITKWorkingDirDialog.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppSettings.h"
#include "ui_FITKWorkingDirDialog.h"
#include <QFileDialog>
#include <QMessageBox>
namespace Comp
{
FITKWorkingDirDialog::FITKWorkingDirDialog(QWidget* parent) :
Core::FITKDialog(parent)
{
_ui = new Ui::FITKWorkingDirDialog;
_ui->setupUi(this);
///获取工作路径
AppFrame::FITKAppSettings* settings = FITKAPP->getAppSettings();
if (settings == nullptr) return;
QString wk = settings->getWorkingDir();
//设置到界面
_ui->workingDirlineEdit->setText(wk);
_ui->currentWorkingDirLabel->setText(wk);
}
FITKWorkingDirDialog::~FITKWorkingDirDialog()
{
if (_ui != nullptr) {
delete _ui;
_ui = nullptr;
}
}
void FITKWorkingDirDialog::on_browseButton_clicked()
{
//获取工作路径
AppFrame::FITKAppSettings* settings = FITKAPP->getAppSettings();
if (settings == nullptr) {
QMessageBox::critical(this, tr("Error"), tr("AppSetting is nullprt!"), QMessageBox::Ok);
return;
}
QString wk = settings->getWorkingDir();
//弹出对话框
QString dir = QFileDialog::getExistingDirectory(this, tr("Working Dir"), wk);
if (dir.isEmpty()) return;
_ui->workingDirlineEdit->setText(dir);
}
void FITKWorkingDirDialog::on_pushButton_OK_clicked()
{
//点击确定
QString d = _ui->workingDirlineEdit->text();
AppFrame::FITKAppSettings* settings = FITKAPP->getAppSettings();
if (settings == nullptr) {
QMessageBox::critical(this, tr("Error"), tr("AppSetting is nullprt!"), QMessageBox::Ok);
return;
}
//存储信息
settings->setWorkingDir(d);
this->accept();
}
void FITKWorkingDirDialog::on_pushButton_Cancel_clicked()
{
this->reject();
}
} // namespace GUI