Fem: Fix Z88 preferences file chooser

This commit is contained in:
marioalexis
2025-09-06 17:12:58 -03:00
parent 344f93c2da
commit 9efc0d77a0
3 changed files with 13 additions and 98 deletions

View File

@@ -34,33 +34,8 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gl_z88">
<item row="0" column="2">
<widget class="Gui::PrefCheckBox" name="cb_z88_binary_std">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>Search in known binary directories</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseStandardZ88Location</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem/Z88</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="0" column="0">
<widget class="QLabel" name="l_z88_binary_path">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -74,15 +49,12 @@
</size>
</property>
<property name="text">
<string>z88r binary path</string>
<string>z88r path</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="Gui::PrefFileChooser" name="fc_z88_binary_path">
<property name="enabled">
<bool>false</bool>
</property>
<item row="0" column="1">
<widget class="Gui::PrefFileChooser" name="fc_z88_binary_path" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -92,7 +64,7 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
<height>0</height>
</size>
</property>
<property name="sizeIncrement">
@@ -108,7 +80,7 @@
</size>
</property>
<property name="toolTip">
<string>Leave blank to use default Z88, z88r binary file</string>
<string>Leave blank to use default z88r binary file</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>z88BinaryPath</cstring>
@@ -332,38 +304,4 @@ that &quot;MAXKOI&quot; needs to be increased.</string>
<resources>
<include location="Resources/Fem.qrc"/>
</resources>
<connections>
<connection>
<sender>cb_z88_binary_std</sender>
<signal>toggled(bool)</signal>
<receiver>l_z88_binary_path</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>406</x>
<y>45</y>
</hint>
<hint type="destinationlabel">
<x>148</x>
<y>68</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_z88_binary_std</sender>
<signal>toggled(bool)</signal>
<receiver>fc_z88_binary_path</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>406</x>
<y>45</y>
</hint>
<hint type="destinationlabel">
<x>406</x>
<y>68</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -25,6 +25,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QMessageBox>
#include <QStandardPaths>
#endif
#include <Gui/Application.h>
@@ -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"

View File

@@ -42,7 +42,7 @@ public:
~DlgSettingsFemZ88Imp() override;
protected Q_SLOTS:
void onfileNameChanged(QString FileName);
void onfileNameSelected(const QString& fileName);
protected:
void saveSettings() override;