summaryrefslogtreecommitdiffstats
path: root/src/yuzu/applets/qt_profile_select.h
blob: 637a3bda2a0ddc3f1792068c95dc332c2b5108e7 (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
75
76
77
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <vector>
#include <QDialog>
#include <QList>
#include "core/frontend/applets/profile_select.h"
#include "core/hle/service/acc/profile_manager.h"

class ControllerNavigation;
class GMainWindow;
class QDialogButtonBox;
class QGraphicsScene;
class QLabel;
class QScrollArea;
class QStandardItem;
class QStandardItemModel;
class QTreeView;
class QVBoxLayout;

namespace Core::HID {
class HIDCore;
} // namespace Core::HID

class QtProfileSelectionDialog final : public QDialog {
    Q_OBJECT

public:
    explicit QtProfileSelectionDialog(Core::HID::HIDCore& hid_core, QWidget* parent);
    ~QtProfileSelectionDialog() override;

    int exec() override;
    void accept() override;
    void reject() override;

    int GetIndex() const;

private:
    void SelectUser(const QModelIndex& index);

    int user_index = 0;

    QVBoxLayout* layout;
    QTreeView* tree_view;
    QStandardItemModel* item_model;
    QGraphicsScene* scene;

    std::vector<QList<QStandardItem*>> list_items;

    QVBoxLayout* outer_layout;
    QLabel* instruction_label;
    QScrollArea* scroll_area;
    QDialogButtonBox* buttons;

    std::unique_ptr<Service::Account::ProfileManager> profile_manager;
    ControllerNavigation* controller_navigation = nullptr;
};

class QtProfileSelector final : public QObject, public Core::Frontend::ProfileSelectApplet {
    Q_OBJECT

public:
    explicit QtProfileSelector(GMainWindow& parent);
    ~QtProfileSelector() override;

    void SelectProfile(SelectProfileCallback callback_) const override;

signals:
    void MainWindowSelectProfile() const;

private:
    void MainWindowFinishedSelection(std::optional<Common::UUID> uuid);

    mutable SelectProfileCallback callback;
};