diff options
author | Kiril Zvezdarov <kzvezdarov@gmail.com> | 2024-06-08 16:54:50 -0400 |
---|---|---|
committer | Kiril Zvezdarov <kzvezdarov@gmail.com> | 2024-06-08 17:56:36 -0400 |
commit | 180953b399b8ae48ead049d17b73cab7a2717f17 (patch) | |
tree | b515d4aadd800661ca4adc8dbbfe43929e727c5d /proto-wine/ftnoir_protocol_wine_dialog.cpp | |
parent | 788d478be6c363d151a9693b3b1d4e4eaa11c021 (diff) |
Refactored proton_path to be the dist dir location
From Proton 9.0 and up, the directory containing
library files and wine executables - previously
called `dist`, appears to have been renamed to
`files`. This breaks OpenTrack with newer Proton
versions, because the path to the `wine` executable
and proton library files is constructed as
`:PROTON_PATH/dist/bin/wine`, i.e. the dist dir
name is hardcoded.
To fix this while preserving backward compatibility,
this commit changes `proton_path` to point to the
`dist` dir directly, be it `files` for 9.0+ or
`dist` for older versions. Templated variables
are adjusted accordingly to omit the dist dir.
Obtaining the dist. dir path for a specific Proton
version is done by recursively iterating the version's
directory, looking for the `wine` executable. The
first match is used to discover the grandparent dir path,
which is the desired `:PROTON_PATH/:DIST_DIR` path.
Diffstat (limited to 'proto-wine/ftnoir_protocol_wine_dialog.cpp')
-rw-r--r-- | proto-wine/ftnoir_protocol_wine_dialog.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/proto-wine/ftnoir_protocol_wine_dialog.cpp b/proto-wine/ftnoir_protocol_wine_dialog.cpp index 07dc1469..23f82fda 100644 --- a/proto-wine/ftnoir_protocol_wine_dialog.cpp +++ b/proto-wine/ftnoir_protocol_wine_dialog.cpp @@ -2,6 +2,9 @@ #include <QDebug> #include <QFileDialog> #include <QDir> +#include <QDirIterator> +#include <qdebug.h> +#include <qdir.h> #include "api/plugin-api.hpp" @@ -46,13 +49,27 @@ FTControls::FTControls() QDir dir(QDir::homePath() + path); dir.setFilter(QDir::Dirs); dir.setNameFilters({ "Proton*" }); - QFileInfoList list = dir.entryInfoList(); - for (int i = 0; i < list.size(); ++i) { - QFileInfo fileInfo = list.at(i); - ui.proton_version->addItem(fileInfo.fileName(), QVariant{fileInfo.filePath()}); + + 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(); + + QDirIterator proton_executable_it(proton_dir.canonicalFilePath(), QStringList() << "wine", QDir::Files, QDirIterator::Subdirectories); + + if (proton_executable_it.hasNext()) { + QString proton_executable_path = proton_executable_it.next(); + 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); |