aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/studiowelcome/wizardhandler.h
blob: 8cdf00f832e4664ac0087c40aea4b7730eadae58 (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
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
78
79
80
81
82
83
84
85
86
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include "presetmodel.h"

#include <utils/filepath.h>
#include <utils/infolabel.h>

QT_BEGIN_NAMESPACE
class QWizard;
class QWizardPage;
class QStandardItemModel;
QT_END_NAMESPACE

namespace ProjectExplorer {
class JsonFieldPage;
}

namespace StudioWelcome {

class WizardHandler: public QObject
{
    Q_OBJECT

public:
    void reset(const std::shared_ptr<PresetItem> &presetInfo, int presetSelection);
    void setScreenSizeIndex(int index);
    int screenSizeIndex(const QString &sizeName) const;
    QString screenSizeName(int index) const;
    int screenSizeIndex() const;
    int targetQtVersionIndex() const;
    int targetQtVersionIndex(const QString &qtVersionName) const;
    void setTargetQtVersionIndex(int index);
    bool haveTargetQtVersion() const;
    QString targetQtVersionName(int index) const;

    void setStyleIndex(int index);
    int styleIndex() const;
    int styleIndex(const QString &styleName) const;
    QString styleName(int index) const;
    bool haveStyleModel() const;

    void destroyWizard();

    void setUseVirtualKeyboard(bool value);
    bool haveVirtualKeyboard() const;

    void setProjectName(const QString &name);
    void setProjectLocation(const Utils::FilePath &location);

    void run(const std::function<void (QWizardPage *)> &processPage);

    std::shared_ptr<PresetItem> preset() const { return m_preset; }

signals:
    void deletingWizard();
    void wizardCreated(QStandardItemModel *screenSizeModel, QStandardItemModel *styleModel);
    void statusMessageChanged(Utils::InfoLabel::InfoType type, const QString &message);
    void projectCanBeCreated(bool value);
    void wizardCreationFailed();

private:
    void setupWizard();
    void initializeProjectPage(QWizardPage *page);
    void initializeFieldsPage(QWizardPage *page);

    QStandardItemModel *getScreenFactorModel(ProjectExplorer::JsonFieldPage *page);
    QStandardItemModel *getStyleModel(ProjectExplorer::JsonFieldPage *page);

private slots:
    void onWizardResetting();
    void onProjectIntroCompleteChanged();

private:
    Utils::Wizard *m_wizard = nullptr;
    ProjectExplorer::JsonFieldPage *m_detailsPage = nullptr;

    int m_selectedPreset = -1;

    std::shared_ptr<PresetItem> m_preset;
    Utils::FilePath m_projectLocation;
};

} // StudioWelcome