summaryrefslogtreecommitdiff
path: root/horizonwizard.cc
blob: 1b6613687416746f7e9712c106847d6b2be5df29 (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
78
79
80
81
#include "horizonwizard.hh"
#include "horizonhelpwindow.hh"

#include <QDebug>
#include <QFile>
#include <QMessageBox>
#include <map>
#include <string>

#include "welcomepage.hh"
#ifndef NOT_NATIVE
#       include <horizon/networkinterface.hh>
using Horizon::NetworkInterface;
#endif
#include "partitionpage.hh"
#include "networkingpage.hh"
#include "netsimplewifipage.hh"
#include "softwarepage.hh"

using std::map;
using std::string;

static map<int, string> help_id_map = {
        {HorizonWizard::Page_Welcome, "welcome"},
        {HorizonWizard::Page_Partition, "partition"},
        {HorizonWizard::Page_Networking, "network-start"},
        {HorizonWizard::Page_Network_SimpleWireless, "network-wifi"},
        {HorizonWizard::Page_Network_SimpleWired, "network-wired"},
        {HorizonWizard::Page_Network_Advanced, "network-advanced"},
        {HorizonWizard::Page_Software, "software"},
        {HorizonWizard::Page_AdvancedSoftware, "software-advanced"},
        {HorizonWizard::Page_Startup, "startup"},
        {HorizonWizard::Page_Commit, "commit"},
        {HorizonWizard::Page_Save, "save"},
        {HorizonWizard::Page_Finished, "finished"}
};

HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent)
{
        setWindowTitle(tr("Adélie Linux System Installation"));

        setFixedSize(QSize(650, 450));

        setOption(DisabledBackButtonOnLastPage);
        setOption(HaveHelpButton);
        setOption(NoCancelButton);

        setSizeGripEnabled(false);

        setPage(Page_Welcome, new WelcomePage);
        setPage(Page_Partition, new PartitionPage);
        setPage(Page_Networking, new NetworkingPage);
        setPage(Page_Network_SimpleWireless, new NetworkSimpleWirelessPage);
        setPage(Page_Software, new SoftwarePage);

        QObject::connect(this, static_cast<void (QWizard:: *)(void)>(&QWizard::helpRequested),
                         [=](void) {
                if(help_id_map.find(currentId()) == help_id_map.end())
                {
                        qDebug() << "no help available for " << currentId();
                        QMessageBox nohelp(QMessageBox::Warning,
                                           tr("No Help Available"),
                                           tr("Help is not available for the current page.  Consult the Installation Guide for more information."),
                                           QMessageBox::Ok,
                                           this);
                        nohelp.exec();
                        return;
                }
                string helppath = ":/wizard_help/resources/" +
                                  help_id_map.at(currentId()) + "-help.txt";
                QFile helpfile(helppath.c_str());
                helpfile.open(QFile::ReadOnly);
                HorizonHelpWindow help(&helpfile, this);
                help.exec();
        });

        this->selected.insert("adelie-base");
#ifndef NOT_NATIVE
        this->interfaces = NetworkInterface::list_available_ifs();
#endif
}