#include "CGH_ProjectView.h" #include "ui_CGH_ProjectView.h" #include #include #include #include #pragma execution_character_set("utf-8") CGH_ProjectView::CGH_ProjectView(QWidget *parent) : QDialog(parent) { ui = new Ui::CGH_ProjectView(); ui->setupUi(this); initSlots(); } CGH_ProjectView::~CGH_ProjectView() { delete ui; } void CGH_ProjectView::initSlots() { connect(ui->ButtonViewResource, SIGNAL(clicked()), this, SLOT(ChooseResourcePath())); connect(ui->ButtonViewOk, SIGNAL(clicked()), this, SLOT(OkNewProject())); connect(ui->ButtonViewCancel, SIGNAL(clicked()), this, SLOT(CancelNewProject())); } // 资源路径 void CGH_ProjectView::ChooseResourcePath() { QFileDialog* file_dialog = new QFileDialog(this); file_dialog->setOption(QFileDialog::ShowDirsOnly);//设置显示选项 file_dialog->setFileMode(QFileDialog::Directory);//设置文件模式 file_dialog->setViewMode(QFileDialog::List);//设置显示模式 //点击确定按钮 if (file_dialog->exec() == QFileDialog::Accepted) { //获取新建项目路径 QString path = file_dialog->selectedFiles().at(0); ui->ViewResource->setText(path);//设置路径栏 } //点取消则返回 else { return; } delete file_dialog; file_dialog = NULL; } // 确认 void CGH_ProjectView::OkNewProject() { //判断名字与路径是否为空 if (ui->ViewName->text().isEmpty()) { QMessageBox::information(this, tr("提示"), tr("表格未填写完整,新建项目失败:\n文件名不可为空!"), QMessageBox::Yes); return; } if (ui->ViewLSpacing->text().isEmpty() || ui->ViewCSpacing->text().isEmpty() || ui->ViewLine->text().isEmpty() || ui->ViewColumn->text().isEmpty()) { QMessageBox::information(this, tr("提示"), tr("表格未填写完整,新建项目失败:\n控制设置不可为空!"), QMessageBox::Yes); return; } if (ui->ViewPrefix->text().isEmpty() || ui->ViewExpose->text().isEmpty() || ui->ViewQuiet->text().isEmpty()) { QMessageBox::information(this, tr("提示"), tr("表格未填写完整,新建项目失败:\n曝光设置不可为空!"), QMessageBox::Yes); return; } if (ui->ViewSave->text().isEmpty() || ui->ViewResource->text().isEmpty()) { QMessageBox::information(this, tr("提示"), tr("表格未填写完整,新建项目失败:\n路径设置不可为空!"), QMessageBox::Yes); return; } QDialog::accept(); } // 取消 void CGH_ProjectView::CancelNewProject() { if (QMessageBox::warning(this, tr("提示"), tr("确定取消创建工程?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { QDialog::reject(); } return; } string CGH_ProjectView::getViewName() { return ui->ViewName->text().toStdString(); } string CGH_ProjectView::getViewLSpacing() { return ui->ViewLSpacing->text().toStdString(); } string CGH_ProjectView::getViewCSpacing() { return ui->ViewCSpacing->text().toStdString(); } string CGH_ProjectView::getViewLine() { return ui->ViewLine->text().toStdString(); } string CGH_ProjectView::getViewColumn() { return ui->ViewColumn->text().toStdString(); } string CGH_ProjectView::getViewPrefix() { return ui->ViewPrefix->text().toStdString(); } string CGH_ProjectView::getViewExpose() { return ui->ViewExpose->text().toStdString(); } string CGH_ProjectView::getViewQuiet() { return ui->ViewQuiet->text().toStdString(); } string CGH_ProjectView::getViewResource() { return ui->ViewResource->text().toStdString(); } void CGH_ProjectView::setViewName(const string& str) { ui->ViewName->setText(QString::fromStdString(str)); } void CGH_ProjectView::setViewLSpacing(const string& str) { ui->ViewLSpacing->setText(QString::fromStdString(str)); } void CGH_ProjectView::setViewCSpacing(const string& str) { ui->ViewCSpacing->setText(QString::fromStdString(str)); } void CGH_ProjectView::setViewLine(const string& str) { ui->ViewLine->setText(QString::fromStdString(str)); } void CGH_ProjectView::setViewColumn(const string& str) { ui->ViewColumn->setText(QString::fromStdString(str)); } void CGH_ProjectView::setViewPrefix(const string& str) { ui->ViewPrefix->setText(QString::fromStdString(str)); } void CGH_ProjectView::setViewExpose(const string& str) { ui->ViewExpose->setText(QString::fromStdString(str)); } void CGH_ProjectView::setViewQuiet(const string& str) { ui->ViewQuiet->setText(QString::fromStdString(str)); } void CGH_ProjectView::setViewResource(const string& str) { ui->ViewResource->setText(QString::fromStdString(str)); } void CGH_ProjectView::initWindow() { relproPath = "../Project"; curabsPath = (QCoreApplication::applicationDirPath()).toStdString(); absproPath = curabsPath + "/" + relproPath; ui->ViewSave->setText(QString::fromStdString(absproPath)); }