From 9efc0d77a0cdf1e4c0379d0085390975ce4c2be1 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Sat, 6 Sep 2025 17:12:58 -0300 Subject: [PATCH] Fem: Fix Z88 preferences file chooser --- src/Mod/Fem/Gui/DlgSettingsFemZ88.ui | 74 ++---------------------- src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp | 35 ++--------- src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.h | 2 +- 3 files changed, 13 insertions(+), 98 deletions(-) diff --git a/src/Mod/Fem/Gui/DlgSettingsFemZ88.ui b/src/Mod/Fem/Gui/DlgSettingsFemZ88.ui index 3de679c26f..53c18dedbf 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemZ88.ui +++ b/src/Mod/Fem/Gui/DlgSettingsFemZ88.ui @@ -34,33 +34,8 @@ - - - - - 0 - 20 - - - - Search in known binary directories - - - true - - - UseStandardZ88Location - - - Mod/Fem/Z88 - - - - + - - true - 0 @@ -74,15 +49,12 @@ - z88r binary path + z88r path - - - - false - + + 0 @@ -92,7 +64,7 @@ 0 - 20 + 0 @@ -108,7 +80,7 @@ - Leave blank to use default Z88, z88r binary file + Leave blank to use default z88r binary file z88BinaryPath @@ -332,38 +304,4 @@ that "MAXKOI" needs to be increased. - - - cb_z88_binary_std - toggled(bool) - l_z88_binary_path - setDisabled(bool) - - - 406 - 45 - - - 148 - 68 - - - - - cb_z88_binary_std - toggled(bool) - fc_z88_binary_path - setDisabled(bool) - - - 406 - 45 - - - 406 - 68 - - - - diff --git a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp index 91cab3df54..ddbd2b7b8d 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp @@ -25,6 +25,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ #include +#include #endif #include @@ -42,16 +43,15 @@ DlgSettingsFemZ88Imp::DlgSettingsFemZ88Imp(QWidget* parent) ui->setupUi(this); connect(ui->fc_z88_binary_path, - &Gui::PrefFileChooser::fileNameChanged, + &Gui::PrefFileChooser::fileNameSelected, this, - &DlgSettingsFemZ88Imp::onfileNameChanged); + &DlgSettingsFemZ88Imp::onfileNameSelected); } DlgSettingsFemZ88Imp::~DlgSettingsFemZ88Imp() = default; void DlgSettingsFemZ88Imp::saveSettings() { - ui->cb_z88_binary_std->onSave(); ui->fc_z88_binary_path->onSave(); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( @@ -66,7 +66,6 @@ void DlgSettingsFemZ88Imp::saveSettings() void DlgSettingsFemZ88Imp::loadSettings() { - ui->cb_z88_binary_std->onRestore(); ui->fc_z88_binary_path->onRestore(); ui->cmb_solver->onRestore(); ui->sb_Z88_MaxGS->onRestore(); @@ -100,33 +99,11 @@ void DlgSettingsFemZ88Imp::changeEvent(QEvent* e) } } -void DlgSettingsFemZ88Imp::onfileNameChanged(QString FileName) +void DlgSettingsFemZ88Imp::onfileNameSelected(const QString& fileName) { - if (!QFileInfo::exists(FileName)) { - QMessageBox::critical(this, - tr("File does not exist"), - tr("The specified z88r executable\n'%1'\n does not exist!\n" - "Specify another file.") - .arg(FileName)); - return; + if (!fileName.isEmpty() && QStandardPaths::findExecutable(fileName).isEmpty()) { + QMessageBox::critical(this, tr("Z88"), tr("Executable '%1' not found").arg(fileName)); } - - // since the Z88 folder is full of files like "z88h", "z88o" etc. one can easily make a - // mistake and is then lost why the solver fails. Therefore check for the correct filename. - auto strName = FileName.toStdString(); -#if defined(FC_OS_WIN32) - if (strName.substr(strName.length() - 8) != "z88r.exe") { - QMessageBox::critical(this, - tr("Wrong file"), - tr("You must specify the path to the z88r.exe!")); - return; - } -#elif defined(FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD) - if (strName.substr(strName.length() - 4) != "z88r") { - QMessageBox::critical(this, tr("Wrong file"), tr("You must specify the path to the z88r!")); - return; - } -#endif } #include "moc_DlgSettingsFemZ88Imp.cpp" diff --git a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.h b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.h index 9097756226..3cef1bea80 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.h @@ -42,7 +42,7 @@ public: ~DlgSettingsFemZ88Imp() override; protected Q_SLOTS: - void onfileNameChanged(QString FileName); + void onfileNameSelected(const QString& fileName); protected: void saveSettings() override;