aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu/migration_dialog.cpp
blob: ba6a14b1565b77a0c30664479beac2353ecd7589 (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
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later

#include "migration_dialog.h"

#include <QApplication>
#include <QCheckBox>
#include <QLabel>
#include <QPushButton>
#include <QStyle>

MigrationDialog::MigrationDialog(QWidget* parent) : QDialog(parent) {
    QVBoxLayout* layout = new QVBoxLayout(this);

    m_text = new QLabel(this);
    m_boxes = new QVBoxLayout;
    m_buttons = new QHBoxLayout;

    layout->addWidget(m_text, 1);
    layout->addLayout(m_boxes, 1);
    layout->addLayout(m_buttons, 1);
}

MigrationDialog::~MigrationDialog() {
    m_boxes->deleteLater();
    m_buttons->deleteLater();
}

void MigrationDialog::setText(const QString& text) {
    m_text->setText(text);
}

void MigrationDialog::addBox(QWidget* box) {
    m_boxes->addWidget(box);
}

QAbstractButton* MigrationDialog::addButton(const QString& text, const bool reject) {
    QAbstractButton* button = new QPushButton(this);
    button->setText(text);
    m_buttons->addWidget(button, 1);

    connect(button, &QAbstractButton::clicked, this, [this, button, reject]() {
        m_clickedButton = button;

        if (reject) {
            this->reject();
        } else {
            this->accept();
        }
    });
    return button;
}

QAbstractButton* MigrationDialog::clickedButton() const {
    return m_clickedButton;
}