From 31ff4124f22a1b521d1e8cfa6772d8978950c938 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Sat, 6 Sep 2025 17:18:32 -0300 Subject: [PATCH] Fem: Fix Mystran preferences file chooser --- src/Mod/Fem/Gui/DlgSettingsFemMystran.ui | 59 +------------------- src/Mod/Fem/Gui/DlgSettingsFemMystranImp.cpp | 17 ++---- src/Mod/Fem/Gui/DlgSettingsFemMystranImp.h | 2 +- 3 files changed, 10 insertions(+), 68 deletions(-) diff --git a/src/Mod/Fem/Gui/DlgSettingsFemMystran.ui b/src/Mod/Fem/Gui/DlgSettingsFemMystran.ui index f8c5e82b28..4b0fd76606 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemMystran.ui +++ b/src/Mod/Fem/Gui/DlgSettingsFemMystran.ui @@ -34,22 +34,6 @@ - - - - Search in known binary directories - - - true - - - UseStandardMystranLocation - - - Mod/Fem/Mystran - - - @@ -62,15 +46,12 @@ - Mystran binary path + Mystran path - - - false - + 0 @@ -96,7 +77,7 @@ - Leave blank to use default Mystran binary file location + Leave blank to use default mystran binary file mystranBinaryPath @@ -170,38 +151,4 @@ - - - cb_mystran_binary_std - toggled(bool) - l_mystran_binary_path - setDisabled(bool) - - - 406 - 45 - - - 148 - 68 - - - - - cb_mystran_binary_std - toggled(bool) - fc_mystran_binary_path - setDisabled(bool) - - - 406 - 45 - - - 406 - 68 - - - - diff --git a/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.cpp index d5eef4e3bb..e7692a00de 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.cpp @@ -25,6 +25,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ #include +#include #endif #include "DlgSettingsFemMystranImp.h" @@ -40,23 +41,21 @@ DlgSettingsFemMystranImp::DlgSettingsFemMystranImp(QWidget* parent) ui->setupUi(this); connect(ui->fc_mystran_binary_path, - &Gui::PrefFileChooser::fileNameChanged, + &Gui::PrefFileChooser::fileNameSelected, this, - &DlgSettingsFemMystranImp::onfileNameChanged); + &DlgSettingsFemMystranImp::onfileNameSelected); } DlgSettingsFemMystranImp::~DlgSettingsFemMystranImp() = default; void DlgSettingsFemMystranImp::saveSettings() { - ui->cb_mystran_binary_std->onSave(); ui->fc_mystran_binary_path->onSave(); ui->cb_mystran_write_comments->onSave(); } void DlgSettingsFemMystranImp::loadSettings() { - ui->cb_mystran_binary_std->onRestore(); ui->fc_mystran_binary_path->onRestore(); ui->cb_mystran_write_comments->onRestore(); } @@ -74,14 +73,10 @@ void DlgSettingsFemMystranImp::changeEvent(QEvent* e) } } -void DlgSettingsFemMystranImp::onfileNameChanged(QString FileName) +void DlgSettingsFemMystranImp::onfileNameSelected(const QString& fileName) { - if (!QFileInfo::exists(FileName)) { - QMessageBox::critical(this, - tr("File does not exist"), - tr("The specified executable\n'%1'\n does not exist!\n" - "Specify another file.") - .arg(FileName)); + if (!fileName.isEmpty() && QStandardPaths::findExecutable(fileName).isEmpty()) { + QMessageBox::critical(this, tr("Mystran"), tr("Executable '%1' not found").arg(fileName)); } } diff --git a/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.h b/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.h index e00f3f6bdb..08a1a2d96c 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.h @@ -42,7 +42,7 @@ public: ~DlgSettingsFemMystranImp() override; protected Q_SLOTS: - void onfileNameChanged(QString FileName); + void onfileNameSelected(const QString& fileName); protected: void saveSettings() override;