diff options
author | Priton-CE <thies.eric@gmail.com> | 2024-09-20 23:02:54 +0200 |
---|---|---|
committer | Priton-CE <thies.eric@gmail.com> | 2024-09-20 23:02:54 +0200 |
commit | eeced7f4878742b08a84fd00b166097182037409 (patch) | |
tree | ad3deae47444fae641bec82e684800123c3ea636 | |
parent | 9ed96e067aa6463d82197c4654028876fa15b763 (diff) |
implemented logic to disable irrelevant ui components
-rw-r--r-- | proto-wine/ftnoir_protocol_wine.h | 8 | ||||
-rw-r--r-- | proto-wine/ftnoir_protocol_wine_dialog.cpp | 74 | ||||
-rw-r--r-- | proto-wine/ftnoir_winecontrols.ui | 12 |
3 files changed, 79 insertions, 15 deletions
diff --git a/proto-wine/ftnoir_protocol_wine.h b/proto-wine/ftnoir_protocol_wine.h index f79f65dc..b6d61e58 100644 --- a/proto-wine/ftnoir_protocol_wine.h +++ b/proto-wine/ftnoir_protocol_wine.h @@ -19,8 +19,10 @@ using namespace options; struct settings : opts { settings() : opts{"proto-wine"} {} - value<bool> variant_proton{b, "variant-proton", false }, - variant_wine{b, "variant-wine", true }, + value<bool> variant_wine{b, "variant-wine", true }, + variant_proton{b, "variant-proton", false }, + variant_proton_steamplay{b, "variant-proton-steamplay", true }, + variant_proton_external{b, "variant-proton-external", false }, fsync{b, "fsync", true}, esync{b, "esync", true}; @@ -29,6 +31,7 @@ struct settings : opts value<QVariant> wine_select_path{b, "wine-select-version", {"WINE"}}; value<QString> wine_custom_path{b, "wine-custom-version", ""}; value<QString> wineprefix{b, "wineprefix", "~/.wine/"}; + value<QString> protonprefix{b, "protonprefix", ""}; value<int> protocol{b, "protocol", 2}; }; @@ -80,6 +83,7 @@ private: private slots: void onWinePathComboUpdated(QString selection); + void onRadioButtonsChanged(); void doBrowseWine(); void doBrowsePrefix(); diff --git a/proto-wine/ftnoir_protocol_wine_dialog.cpp b/proto-wine/ftnoir_protocol_wine_dialog.cpp index 23f82fda..70f62ea0 100644 --- a/proto-wine/ftnoir_protocol_wine_dialog.cpp +++ b/proto-wine/ftnoir_protocol_wine_dialog.cpp @@ -5,8 +5,10 @@ #include <QDirIterator> #include <qdebug.h> #include <qdir.h> +#include <qradiobutton.h> #include "api/plugin-api.hpp" +#include "options/tie.hpp" /* * 0: path to the directory with wine versions @@ -28,7 +30,7 @@ FTControls::FTControls() { ui.setupUi(this); - //populate wine select + // populate wine select ui.wine_path_combo->addItem("System Wine", QVariant{"WINE"}); for (const char** path : wine_paths) { QDir dir(QDir::homePath() + path[0]); @@ -44,7 +46,7 @@ FTControls::FTControls() } ui.wine_path_combo->addItem("Custom path to Wine executable", QVariant{"CUSTOM"}); - //populate proton select + // populate proton select for (const char* path : proton_paths) { QDir dir(QDir::homePath() + path); dir.setFilter(QDir::Dirs); @@ -69,24 +71,39 @@ FTControls::FTControls() } } - - tie_setting(s.proton_path, ui.proton_version); - tie_setting(s.variant_wine, ui.variant_wine); - tie_setting(s.variant_proton, ui.variant_proton); + // settings - wine + // wine + tie_setting(s.variant_wine, ui.variant_wine); // radio button + tie_setting(s.wine_select_path, ui.wine_path_combo); // combo box (dropdown) + tie_setting(s.wine_custom_path, ui.wine_path); // line edit (enabled via dropdown) + tie_setting(s.wineprefix, ui.wineprefix); // line edit + + // settings - proton + tie_setting(s.variant_proton, ui.variant_proton); // radio button + tie_setting(s.proton_path, ui.proton_version); // combo box (dropdown) + tie_setting(s.variant_proton_steamplay, ui.subvariant_steamplay); // radio button + tie_setting(s.proton_appid, ui.proton_appid); // number select + tie_setting(s.variant_proton_external, ui.subvariant_external); // radio button + tie_setting(s.protonprefix, ui.protonprefix); // line edit + + // settings - advanced tie_setting(s.esync, ui.esync); tie_setting(s.fsync, ui.fsync); - tie_setting(s.proton_appid, ui.proton_appid); - tie_setting(s.wine_select_path, ui.wine_path_combo); - tie_setting(s.wine_custom_path, ui.wine_path); - tie_setting(s.wineprefix, ui.wineprefix); tie_setting(s.protocol, ui.protocol_selection); + // setup signals and slots for UI connect(ui.wine_path_combo, &QComboBox::currentTextChanged, this, &FTControls::onWinePathComboUpdated); connect(ui.browse_wine_path_button, &QPushButton::clicked, this, &FTControls::doBrowseWine); connect(ui.browse_wine_prefix_button, &QPushButton::clicked, this, &FTControls::doBrowsePrefix); connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &FTControls::doOK); connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &FTControls::doCancel); + // setup signals and slots for UI radio buttons + connect(ui.variant_wine, &QRadioButton::clicked, this, &FTControls::onRadioButtonsChanged); + connect(ui.variant_proton, &QRadioButton::clicked, this, &FTControls::onRadioButtonsChanged); + connect(ui.subvariant_steamplay, &QRadioButton::clicked, this, &FTControls::onRadioButtonsChanged); + connect(ui.subvariant_external, &QRadioButton::clicked, this, &FTControls::onRadioButtonsChanged); + // update state of the combo box and associated ui elements onWinePathComboUpdated(ui.wine_path_combo->currentText()); } @@ -103,6 +120,43 @@ void FTControls::onWinePathComboUpdated(QString selection) { } } +void FTControls::onRadioButtonsChanged() { + if (ui.variant_wine->isChecked()) { + ui.wine_path_combo->setEnabled(true); + ui.wineprefix->setEnabled(true); + ui.browse_wine_prefix_button->setEnabled(true); + if (ui.wine_path_combo->currentText() == "Custom path to Wine executable") { + ui.wine_path->setEnabled(true); + ui.browse_wine_path_button->setEnabled(true); + } + + ui.proton_version->setEnabled(false); + ui.proton_subgroup->setEnabled(false); + } + else if (ui.variant_proton->isChecked()) { + ui.wine_path_combo->setEnabled(false); + ui.wine_path->setEnabled(false); + ui.wineprefix->setEnabled(false); + ui.browse_wine_prefix_button->setEnabled(false); + + ui.proton_version->setEnabled(true); + ui.proton_subgroup->setEnabled(true); + + if (ui.subvariant_steamplay->isChecked()) { + ui.proton_appid->setEnabled(true); + + ui.protonprefix->setEnabled(false); + ui.browse_proton_prefix_button->setEnabled(false); + } + else if (ui.subvariant_external->isChecked()) { + ui.proton_appid->setEnabled(false); + + ui.protonprefix->setEnabled(true); + ui.browse_proton_prefix_button->setEnabled(true); + } + } +} + void FTControls::doBrowseWine() { QFileDialog d(this); d.setFileMode(QFileDialog::FileMode::ExistingFile); diff --git a/proto-wine/ftnoir_winecontrols.ui b/proto-wine/ftnoir_winecontrols.ui index 1e56999a..3e7d26ea 100644 --- a/proto-wine/ftnoir_winecontrols.ui +++ b/proto-wine/ftnoir_winecontrols.ui @@ -120,6 +120,9 @@ </item> <item row="3" column="1"> <widget class="QComboBox" name="proton_version"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="sizePolicy"> <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -174,7 +177,10 @@ </widget> </item> <item row="4" column="0" colspan="2"> - <widget class="QGroupBox" name="verticalGroupBox_3"> + <widget class="QGroupBox" name="proton_subgroup"> + <property name="enabled"> + <bool>false</bool> + </property> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="1"> <widget class="QSpinBox" name="proton_appid"> @@ -197,7 +203,7 @@ </widget> </item> <item row="1" column="0"> - <widget class="QRadioButton" name="subvariant_umu"> + <widget class="QRadioButton" name="subvariant_external"> <property name="text"> <string>UMU enabled Launchers (select prefix)</string> </property> @@ -222,7 +228,7 @@ </widget> </item> <item> - <widget class="QPushButton" name="browse_proton_path_button"> + <widget class="QPushButton" name="browse_proton_prefix_button"> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <horstretch>0</horstretch> |