summaryrefslogtreecommitdiff
path: root/wizard/installation.cpp
blob: c5126bf83daa41edc8abb0bfb636dd8cfe330e8c (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#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");
  timer.start();
}

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;
  QString title = args, desc, icon = "acritoxinstaller";
  if(args == "check_partitions_for_install")
  {
    title = tr("Checking the installation configuration...");
    icon = "document-edit-verify";
  }
  else if(args == "prepare_target")
  {
    title = tr("Setting up the installation target...");
    icon = "configure";
  }
  else if(args == "prepare_partitions_for_install")
  {
    title = tr("Preparing partitions for install...");
    desc = tr("Formatting, setting up mountpoints and mounting partitions according to your settings.");
    icon = "partitionmanager";
  }
  else if(args == "copy_system_to_target")
  {
    title = tr("Copying system to installation target...");
    icon = "edit-copy";
  }
  else if(args == "update_fstab_on_target")
  {
    title = tr("Updating /etc/fstab on installation target...");
    icon = "story-editor";
  }
  else if(args == "update_passwd_on_target")
  {
    title = tr("Setting up users and passwords...");
    icon = "user-properties";
  }
  else if(args == "copy_home_to_target")
  {
    title = tr("Copying data for the default user...");
    desc = tr("The home-directory of the live user is copied to the home-directory of the user on the installation target.");
    icon = "user-home";
  }
  else if(args == "copy_etc_to_target")
  {
    title = tr("Copying system settings...");
    desc = tr("Selected files from /etc are copied to the installation target.");
    icon = "folder-development";
  }
  else if(args == "configure_target_update_files")
  {
    title = tr("Updating configuration files...");
    icon = "run-build-configure";
  }
  else if(args == "configure_target_purge_live_only_stuff")
  {
    title = tr("Removing live-only stuff...");
    desc = tr("Removing packages that are only needed on a live system from the installation (e.g. this installer)");
    icon = "user-trash-full";
  }
  else if(args == "configure_target_services")
  {
    title = tr("Configuring services...");
    desc = tr("Setting up the services which get started automatically when booting the installation.");
    icon = "services";
  }
  else if(args == "install_bootmanager_to_target")
  {
    title = tr("Installing bootmanager to the selected target...");
    desc = tr("Generating an initial ramdisk and installing %1 to %2")
      .arg(backend->cfg("bootloader")).arg(backend->cfg("bootloader_target"));
    icon = "system-run";
  }
  else if(args == "cleanup")
  {
    title = tr("Cleaning up...");
    icon = "run-build-clean";
  }
  QListWidgetItem *item = new ListItem(title, desc, icon);
  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);
  int elapsed = timer.elapsed()/1000;
  QString desc = tr("The installation took %1m%2s.").arg(elapsed/60).arg(elapsed % 60, 2, 10, QLatin1Char('0'));
  QListWidgetItem *item = new ListItem(tr("Finished."), desc, "dialog-ok-apply");
  listWidget->addItem(item);
  listWidget->scrollToItem(item);
  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;
}