From bcb5b9e7249d7b1295c0948810709bde79f7870f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=89=91=E5=8F=A4=E6=95=9B=E9=94=8B?= <3045316072@qq.com> Date: Tue, 23 Jul 2024 10:33:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AF=E4=BB=B6=E6=80=BB=E4=BD=93=E5=8F=82?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=85=B3=E4=BA=8E?= =?UTF-8?q?FEKO=E8=BD=AF=E4=BB=B6=E7=9B=B8=E5=85=B3=E7=9A=84=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Settings/DialogGraphOption.cpp | 79 ++++++++++++++++++++++++++++++ src/Settings/DialogGraphOption.h | 3 ++ 2 files changed, 82 insertions(+) diff --git a/src/Settings/DialogGraphOption.cpp b/src/Settings/DialogGraphOption.cpp index bd6425f..3bd2ddc 100644 --- a/src/Settings/DialogGraphOption.cpp +++ b/src/Settings/DialogGraphOption.cpp @@ -20,10 +20,17 @@ * DISCLAIMED. * ================================================================================== */ +#include #include "DialogGraphOption.h" #include "GraphOption.h" #include "ui_DialogGraphOption.h" #include "MainWindow/MainWindow.h" +#include "BusAPI.h" +#include +#include +#include +#include +#include namespace Setting { @@ -32,6 +39,7 @@ namespace Setting { _ui->setupUi(this); connect(this, SIGNAL(updateGraph()), mainwindow, SIGNAL(updateGraphOptionsSig())); + connect(_ui->pushButtonSelectFekoInstallPath, SIGNAL(clicked()), this, SLOT(on_PushButtonSelectPath())); init(); } GraphOptionDialog::~GraphOptionDialog() @@ -141,6 +149,11 @@ namespace Setting int trans = _graphOption->getTransparency(); _ui->TranspSlider->setValue(trans); + + _ui->lineEditFEKOPath->setText(BusAPI::instance()->getFekoInstallPath()); + _ui->lineEdit_CADFeko->setText(BusAPI::instance()->getFekocadPath()); + _ui->lineEditPreFEKO->setText(BusAPI::instance()->getPreFekoPath()); + _ui->lineEdit_RunFeko->setText(BusAPI::instance()->getRunFekoPath()); } void GraphOptionDialog::accept() { @@ -175,5 +188,71 @@ namespace Setting accept(); QDialog::accept(); } + void GraphOptionDialog::on_PushButtonSelectPath() { + QString FEKOBinPath = QFileDialog::getExistingDirectory( + this, tr("Select FEKO Install Path"), BusAPI::instance()->getApplicationExePath()); + if(QDir(FEKOBinPath).exists()) { + _ui->lineEditFEKOPath->setText(FEKOBinPath); + BusAPI::instance()->setFekoInstallPath(FEKOBinPath); + } else { + QMessageBox::warning(this, u8"警告", u8"检查Feko安装,找不到cadFEKO"); + return; + } + // 检查当前目录中是否存在cadfeko.exe、prefeko.exe、runfeko.exe + QMap fekoexelist = this->checkFEKOExecutablesAndReturnPaths(FEKOBinPath); + //ccafeko + if(fekoexelist.contains("cadfeko.exe")) { + if(QFile(fekoexelist.value("cadfeko.exe")).exists()) { + BusAPI::instance()->setFekocadPath(fekoexelist.value("cadfeko.exe")); + _ui->lineEdit_CADFeko->setText(fekoexelist.value("cadfeko.exe")); + } else { + return; + } + + } else { + QMessageBox::warning(this, u8"警告", "检查Feko安装,找不到cadFEKO"); + } + + //prefeko + if(fekoexelist.contains("prefeko.exe")) { + if(QFile(fekoexelist.value("prefeko.exe")).exists()) { + BusAPI::instance()->setPreFekoPath(fekoexelist.value("prefeko.exe")); + _ui->lineEditPreFEKO->setText(fekoexelist.value("prefeko.exe")); + } else { + return; + } + } else { + QMessageBox::warning(this, u8"警告", "检查Feko安装,prefeko"); + } + + //runfeko + if(fekoexelist.contains("runfeko.exe")) { + if(QFile(fekoexelist.value("runfeko.exe")).exists()) { + BusAPI::instance()->setRunFekoPath(fekoexelist.value("runfeko.exe")); + _ui->lineEdit_RunFeko->setText(fekoexelist.value("runfeko.exe")); + } else { + return; + } + } else { + QMessageBox::warning(this, u8"警告", "检查Feko安装,runfeko"); + } + } + + QMap GraphOptionDialog::checkFEKOExecutablesAndReturnPaths(const QString& directoryPath) { + QStringList fekoExecutables = {"cadfeko.exe", "prefeko.exe", "runfeko.exe"}; + QMap executablePaths; + qDebug()< checkFEKOExecutablesAndReturnPaths(const QString& directoryPath); + private: /** * @brief 绘图信息配置窗口的ui对象