summaryrefslogtreecommitdiff
path: root/mainwizard.cpp
blob: 903719cb28ec9bd537212eb90fa1646f60bcdde7 (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
87
88
89
90
91
92
93
94
#include <QtGui>
#include "mainwizard.h"
#include "listdelegate.h"
#include "listitem.h"
#include "wizard/welcome.h"
#include "wizard/partitions.h"
#include "wizard/partmansel.h"
#include "wizard/partman.h"
#include "wizard/rootpartition.h"
#include "wizard/hdmap.h"
#include "wizard/bootloader.h"
#include "wizard/rootpwd.h"
#include "wizard/usercfg.h"
#include "wizard/userpwd.h"
#include "wizard/network.h"
#include "wizard/summary.h"
#include "wizard/installation.h"

MainWizard::MainWizard()
{
  setMinimumSize(QSize(640,480));
  
  backend = Backend::instance();
  backend->runBackend();
    
  connect(backend, SIGNAL(isBusy(bool)), this, SLOT(backendBusy(bool)));
  connect(backend, SIGNAL(receivedCommand(QString,QString)), this, SLOT(processCommand(QString,QString)));
  
  setPage(Page_Welcome, new wpWelcome(this));
  setPage(Page_Partitions, new wpPartitions(this));
  setPage(Page_PartManSel, new wpPartManSel(this));
  setPage(Page_PartMan, new wpPartMan(this));
  setPage(Page_RootPartition, new wpRootPartition(this));
  setPage(Page_HdMap, new wpHdMap(this));
  setPage(Page_Bootloader, new wpBootloader(this));
  setPage(Page_RootPwd, new wpRootPwd(this));
  setPage(Page_UserCfg, new wpUserCfg(this));
  setPage(Page_UserPwd, new wpUserPwd(this));
  setPage(Page_Network, new wpNetwork(this));
  setPage(Page_Summary, new wpSummary(this));
  setPage(Page_Installation, new wpInstallation(this));
  setStartId(Page_Welcome);
  setWizardStyle(ModernStyle);
  setWindowTitle(tr("Installer"));

  filter = new BusyAppFilter;
  
  setPixmap(QWizard::LogoPixmap, QIcon::fromTheme("acritoxinstaller").pixmap(64,64));
}

void MainWizard::reject()
{
  backend->exitBackend();
  QWizard::reject();
}

void MainWizard::backendBusy(bool busy)
{
  qDebug() << "MainWizard::backendBusy:" << (busy ? "yes" : "no");
  if(!busy)
  {
    QApplication::restoreOverrideCursor();
    QApplication::instance()->removeEventFilter(filter);
  }
  else if(!QApplication::overrideCursor())
  {
    QApplication::setOverrideCursor(Qt::WaitCursor);
    QApplication::instance()->installEventFilter(filter);
  }
}

void MainWizard::processCommand(QString command, QString args)
{
  if(command == "loadpage")
  {
    QList<int> pages = pageIds();
    for(int i = 0; i < pages.size(); ++i)
      if(page(i)->objectName() == args)
      {
	break;
      }
  }
  else if(command == "error")
  {
    backendBusy(false);
    QMessageBox::critical(0, tr("Backend Error"), tr("An error occurred:\n\n%1").arg(args)); 
    backendBusy(true);
  }
}

QSize MainWizard::sizeHint() const
{
  return QSize(800,600);
}