summaryrefslogtreecommitdiffhomepage
path: root/proto-wine/ftnoir_protocol_wine_dialog.cpp
blob: a954a7526c57f477c0c25f4f94df24d23a1da821 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "ftnoir_protocol_wine.h"
#include <QDebug>
#include <QDir>

#include "api/plugin-api.hpp"

static const char* proton_paths[] = {
    "/.steam/steam/steamapps/common",
    "/.steam/root/compatibilitytools.d",
    "/.local/share/Steam/steamapps/common",
};

FTControls::FTControls()
{
    ui.setupUi(this);

    for (const char* path : proton_paths) {
        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()});
        }
    }
    tie_setting(s.proton_path, ui.proton_version);
    tie_setting(s.variant_wine, ui.variant_wine);
    tie_setting(s.variant_proton, ui.variant_proton);
    tie_setting(s.esync, ui.esync);
    tie_setting(s.fsync, ui.fsync);
    tie_setting(s.proton_appid, ui.proton_appid);
    tie_setting(s.wineprefix, ui.wineprefix);
    tie_setting(s.protocol, ui.protocol_selection);

    connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &FTControls::doOK);
    connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &FTControls::doCancel);
}

void FTControls::doOK()
{
    s.b->save();
    close();
}

void FTControls::doCancel()
{
    s.b->reload();
    close();
}