summaryrefslogtreecommitdiff
path: root/wizard/installation.cpp
blob: 452273fd165145e4999d1e3db9578acace7dc340 (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
#include <QtGui>
#include "installation.h"
#include "../listdelegate.h"
#include "../listitem.h"

wpInstallation::wpInstallation(QWidget *parent) : QWizardPage(parent)
{
  setComplete(false);
  setupUi(this);
  backend = Backend::instance();
//   connect(backend, SIGNAL(processExited()), this, SLOT(WeAreDone()));
  listWidget->setItemDelegate(new ListDelegate(this));
  setCommitPage(true);
//   QListWidgetItem *item = new ListItem("Start", "Let's go!", "dialog-ok");
//   listWidget->addItem(item);
}

void wpInstallation::initializePage()
{
  listWidget->clear();
  progressCompleted->setRange(0,12);
  connect(backend, SIGNAL(receivedProgress(int)), this, SLOT(setProgress(int)));
  connect(backend, SIGNAL(receivedCommand(QString,QString)), this, SLOT(receivedCommand(QString,QString)));
  connect(backend, SIGNAL(finishedCommand(QString)), this, SLOT(finishedCommand(QString)));
  backend->exec("do_install");
}

void wpInstallation::cleanupPage()
{
  initializePage();
}

void wpInstallation::setProgress(int percent)
{
  progressCurrent->setRange(0, 100);
  progressCurrent->setValue(percent);
}

void wpInstallation::receivedCommand(QString command, QString args)
{
  if(command != "install_step") return;
  QListWidgetItem *item = new ListItem(args, tr("TODO: use descriptive titles, descriptions and icons in this list..."), "acritoxinstaller");
  listWidget->addItem(item);
  listWidget->scrollToItem(item);
  progressCompleted->setValue(progressCompleted->value()+1);
  progressCurrent->reset();
  progressCurrent->setRange(0,0);
}

void wpInstallation::finishedCommand(QString command)
{
  if(command != "do_install") return;
  progressCompleted->setRange(0,100);
  progressCompleted->setValue(100);
  progressCurrent->setRange(0,100);
  progressCurrent->setValue(100);
  setComplete(true);
}

// void wpInstallation::()
// {
//   QListWidgetItem *item = new ListItem("Finished.", "The backend has finished its job.", "dialog-ok");
//   listWidget->addItem(item);
//   setComplete(true);
// }

void wpInstallation::setComplete(bool c)
{
  complete = c;
  emit completeChanged();
}

bool wpInstallation::isComplete() const
{
  return complete;
}

bool wpInstallation::validatePage()
{
  return complete;
}