aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu/migration_worker.h
blob: 0a8a5b8275f050cc12e9cd1791d2e2799517f1a9 (plain) (blame)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include <QObject>
#include "common/fs/path_util.h"

typedef struct Emulator {
    const char* m_name;

    Common::FS::EmuPath e_user_dir;
    Common::FS::EmuPath e_config_dir;
    Common::FS::EmuPath e_cache_dir;

    const std::string get_user_dir() const {
        return Common::FS::GetLegacyPath(e_user_dir).string();
    }

    const std::string get_config_dir() const {
        return Common::FS::GetLegacyPath(e_config_dir).string();
    }

    const std::string get_cache_dir() const {
        return Common::FS::GetLegacyPath(e_cache_dir).string();
    }

    const QString name() const {
        return QObject::tr(m_name);
    }

    const QString lower_name() const {
        return name().toLower();
    }
} Emulator;

#define STRUCT_EMU(name, enumName)                                                                 \
    Emulator {                                                                                     \
        name, Common::FS::enumName##Dir, Common::FS::enumName##ConfigDir,                          \
            Common::FS::enumName##CacheDir                                                         \
    }

static constexpr std::array<Emulator, 4> legacy_emus = {
    STRUCT_EMU(QT_TR_NOOP("Citron"), Citron),
    STRUCT_EMU(QT_TR_NOOP("Sudachi"), Sudachi),
    STRUCT_EMU(QT_TR_NOOP("Suyu"), Suyu),
    STRUCT_EMU(QT_TR_NOOP("Yuzu"), Yuzu),
};

class MigrationWorker : public QObject {
    Q_OBJECT
public:
    enum class MigrationStrategy {
        Copy,
        Move,
        Link,
    };

    MigrationWorker(const Emulator selected_emu, const bool clear_shader_cache,
                    const MigrationStrategy strategy);

public slots:
    void process();

signals:
    void finished(const QString& success_text, const std::string& user_dir);
    void error(const QString& error_message);

private:
    Emulator selected_emu;
    bool clear_shader_cache;
    MigrationStrategy strategy;
    QString success_text = tr("Data was migrated successfully.");
};