diff options
Diffstat (limited to 'proto-wine/ftnoir_protocol_wine_dialog.cpp')
-rw-r--r-- | proto-wine/ftnoir_protocol_wine_dialog.cpp | 144 |
1 files changed, 118 insertions, 26 deletions
diff --git a/proto-wine/ftnoir_protocol_wine_dialog.cpp b/proto-wine/ftnoir_protocol_wine_dialog.cpp index 23f82fda..2b7d08e0 100644 --- a/proto-wine/ftnoir_protocol_wine_dialog.cpp +++ b/proto-wine/ftnoir_protocol_wine_dialog.cpp @@ -3,10 +3,13 @@ #include <QFileDialog> #include <QDir> #include <QDirIterator> +#include <qcombobox.h> #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 @@ -18,17 +21,18 @@ static const char* wine_paths[][3] = { {"/.var/app/net.lutris.Lutris/data/lutris/runners/wine/", "/bin/wine", "Flatpak Lutris"} }; -static const char* proton_paths[] = { - "/.steam/steam/steamapps/common", - "/.steam/root/compatibilitytools.d", - "/.local/share/Steam/steamapps/common", +static const char* proton_paths[][2] = { + {"/.steam/steam/steamapps/common", "Proton*"}, + {"/.steam/root/compatibilitytools.d", "*"}, + {"/.local/share/Steam/steamapps/common", "Proton*"}, + {"/.local/share/Steam/compatibilitytools.d", "*"}, }; 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,16 +48,19 @@ FTControls::FTControls() } ui.wine_path_combo->addItem("Custom path to Wine executable", QVariant{"CUSTOM"}); - //populate proton select - for (const char* path : proton_paths) { - QDir dir(QDir::homePath() + path); - dir.setFilter(QDir::Dirs); - dir.setNameFilters({ "Proton*" }); + // populate proton select + for (const char** path : proton_paths) { + QDir dir(QDir::homePath() + path[0]); + dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); + dir.setNameFilters({ path[1] }); QFileInfoList proton_dir_list = dir.entryInfoList(); for (int i = 0; i < proton_dir_list.size(); ++i) { const QFileInfo &proton_dir = proton_dir_list.at(i); - qDebug() << proton_dir.canonicalFilePath(); + + // check if this Proton Version is already present in any way + if (ui.proton_version->findText(proton_dir.fileName()) != -1) + continue; QDirIterator proton_executable_it(proton_dir.canonicalFilePath(), QStringList() << "wine", QDir::Files, QDirIterator::Subdirectories); @@ -62,38 +69,53 @@ FTControls::FTControls() QDir proton_dist_dir(proton_executable_path); proton_dist_dir.cd("../../"); - qDebug() << proton_dist_dir.canonicalPath(); - ui.proton_version->addItem(proton_dir.fileName(), QVariant{proton_dist_dir.canonicalPath()}); } } } - - 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 + 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.browse_wine_prefix_button, &QPushButton::clicked, this, &FTControls::doBrowseWinePrefix); + connect(ui.browse_proton_prefix_button, &QPushButton::clicked, this, &FTControls::doBrowseProtonPrefix); 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()); + onWinePathComboUpdated(); + // hide the correct items + onRadioButtonsChanged(); } -void FTControls::onWinePathComboUpdated(QString selection) { +void FTControls::onWinePathComboUpdated() { // enable the custom text field if required - if (selection == "Custom path to Wine executable") { + if (ui.wine_path_combo->currentData() == "CUSTOM") { ui.wine_path->setEnabled(true); ui.browse_wine_path_button->setEnabled(true); } @@ -103,6 +125,63 @@ void FTControls::onWinePathComboUpdated(QString selection) { } } +void FTControls::onRadioButtonsChanged() { + if (ui.variant_wine->isChecked()) { + // wine settings selected + + // enable wine settings + ui.wine_path_combo->setEnabled(true); + ui.wineprefix->setEnabled(true); + ui.browse_wine_prefix_button->setEnabled(true); + if (ui.wine_path_combo->currentData() == "CUSTOM") { + ui.wine_path->setEnabled(true); + ui.browse_wine_path_button->setEnabled(true); + } + + // disable proton settings + ui.proton_version->setEnabled(false); + ui.proton_subgroup->setEnabled(false); + } + else if (ui.variant_proton->isChecked()) { + // proton settings selected + + // disable wine settings + ui.wine_path_combo->setEnabled(false); + ui.wine_path->setEnabled(false); + ui.browse_wine_path_button->setEnabled(false); + ui.wineprefix->setEnabled(false); + ui.browse_wine_prefix_button->setEnabled(false); + + // enable proton settings + ui.proton_version->setEnabled(true); + ui.proton_subgroup->setEnabled(true); + + // run proton radio buttons logic + if (ui.subvariant_steamplay->isChecked()) { + // enable steamplay settings + ui.proton_appid->setEnabled(true); + + // disable external settings + ui.protonprefix->setEnabled(false); + ui.browse_proton_prefix_button->setEnabled(false); + } + else if (ui.subvariant_external->isChecked()) { + // disable steamplay settings + ui.proton_appid->setEnabled(false); + + // enable external settinsg + ui.protonprefix->setEnabled(true); + ui.browse_proton_prefix_button->setEnabled(true); + } + } + else { + // for some reason QTs auto exclusive feature is not always correctly working + // this is a somewhat hacky solution + ui.variant_wine->setChecked(ui.wine_path_combo->isEnabled()); + ui.variant_proton->setChecked(ui.proton_version->isEnabled()); + } +} + void FTControls::doBrowseWine() { QFileDialog d(this); d.setFileMode(QFileDialog::FileMode::ExistingFile); @@ -114,7 +193,7 @@ void FTControls::doBrowseWine() { s.wine_custom_path = d.selectedFiles()[0]; } } -void FTControls::doBrowsePrefix() { +void FTControls::doBrowseWinePrefix() { QFileDialog d(this); d.setFileMode(QFileDialog::FileMode::Directory); d.setOption(QFileDialog::Option::ShowDirsOnly, true); @@ -127,6 +206,19 @@ void FTControls::doBrowsePrefix() { } } +void FTControls::doBrowseProtonPrefix() { + QFileDialog d(this); + d.setFileMode(QFileDialog::FileMode::Directory); + d.setOption(QFileDialog::Option::ShowDirsOnly, true); + d.setWindowTitle(tr("Select Proton Prefix")); + if (s.protonprefix->startsWith("/") || s.protonprefix->startsWith("~")) { + d.selectFile(s.protonprefix); + } + if (d.exec()) { + s.protonprefix = d.selectedFiles()[0]; + } +} + void FTControls::doOK() { s.b->save(); |