diff options
author | Andreas Loibl <andreas@andreas-loibl.de> | 2011-03-17 05:07:10 +0100 |
---|---|---|
committer | Andreas Loibl <andreas@andreas-loibl.de> | 2011-03-17 05:07:10 +0100 |
commit | 00286a5db286e21a766b6af057052dc5d17561ad (patch) | |
tree | 7232dadf6dc3570705c3104fe0c000f480c7a0ee /wizard | |
download | acritoxinstaller-00286a5db286e21a766b6af057052dc5d17561ad.zip acritoxinstaller-00286a5db286e21a766b6af057052dc5d17561ad.tar.gz |
Initial commit
Diffstat (limited to 'wizard')
36 files changed, 2320 insertions, 0 deletions
diff --git a/wizard/bootloader.cpp b/wizard/bootloader.cpp new file mode 100644 index 0000000..a066d05 --- /dev/null +++ b/wizard/bootloader.cpp @@ -0,0 +1,74 @@ +#include <QtGui> +#include "bootloader.h" +#include "../listdelegate.h" +#include "../listitem.h" + +wpBootloader::wpBootloader(QWidget *parent) : QWizardPage(parent) +{ + setupUi(this); + backend = Backend::instance(); + connect(backend, SIGNAL(receivedDataLine(QString,QString)), this, SLOT(receivedDataLine(QString,QString))); + connect(backend, SIGNAL(finishedCommand(QString)), this, SLOT(backendFinishedCommand(QString))); + connect(bootloader, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete())); + connect(bootloaderTarget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete())); + //bootloader->setItemDelegate(new ListDelegate(this)); +} + +void wpBootloader::initializePage() +{ + clearPage(); +} + +void wpBootloader::clearPage() +{ + backend->exec("send_bootloaders"); + bootloader->clear(); + backend->exec("send_bootloader_targets"); + bootloaderTarget->clear(); +} + +void wpBootloader::receivedDataLine(QString data, QString line) +{ + if(data == "bootloaders") + { + QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme("system-run"), line); + bootloader->addItem(item); + } + if(data == "bootloader_targets") + { + QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme("drive-harddisk"), line); + bootloaderTarget->addItem(item); + } +} + +void wpBootloader::backendFinishedCommand(QString command) +{ + if(command == "send_bootloaders") + { + bootloader->setCurrentRow(0); + } + if(command == "send_bootloader_targets") + { + bootloaderTarget->setCurrentRow(0); + } +} + +void wpBootloader::updateComplete() +{ + emit completeChanged(); +} + +bool wpBootloader::isComplete() const +{ + if(!bootloader->currentItem()) return false; + if(!bootloaderTarget->currentItem()) return false; + return true; +} + +bool wpBootloader::validatePage() +{ + if(!isComplete()) return false; + backend->cfg("bootloader", bootloader->currentItem()->text().section(" ",0,0).toLower()); + backend->cfg("bootloader_target", bootloaderTarget->currentItem()->text().section(" ",0,0).toLower()); + return true; +} diff --git a/wizard/bootloader.h b/wizard/bootloader.h new file mode 100644 index 0000000..87bcd4f --- /dev/null +++ b/wizard/bootloader.h @@ -0,0 +1,28 @@ +#ifndef bootloader_H +#define bootloader_H + +#include "ui_bootloader.h" +#include "../backend.h" + +class wpBootloader : public QWizardPage, Ui::wpBootloader +{ + Q_OBJECT + + public: + wpBootloader(QWidget *parent = 0); + void initializePage(); + void clearPage(); + bool isComplete() const; + bool validatePage(); + + private: + Backend* backend; + + private slots: + void receivedDataLine(QString data, QString line); + void backendFinishedCommand(QString command); + void updateComplete(); + +}; + +#endif // bootloader_H diff --git a/wizard/bootloader.ui b/wizard/bootloader.ui new file mode 100644 index 0000000..f7b39b5 --- /dev/null +++ b/wizard/bootloader.ui @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>wpBootloader</class> + <widget class="QWizardPage" name="wpBootloader"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>540</width> + <height>400</height> + </rect> + </property> + <property name="windowTitle"> + <string>WizardPage</string> + </property> + <property name="title"> + <string>Bootloader</string> + </property> + <property name="subTitle"> + <string>Select a bootloader and its installation target</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="lblHelpText"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>HelpText</string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QListWidget" name="bootloader"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>3</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="2" column="0" rowspan="2"> + <widget class="QLabel" name="lblHelpText_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>HelpText</string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QListWidget" name="bootloaderTarget"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>2</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="3" column="1"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/wizard/installation.cpp b/wizard/installation.cpp new file mode 100644 index 0000000..452273f --- /dev/null +++ b/wizard/installation.cpp @@ -0,0 +1,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; +} diff --git a/wizard/installation.h b/wizard/installation.h new file mode 100644 index 0000000..0209007 --- /dev/null +++ b/wizard/installation.h @@ -0,0 +1,29 @@ +#ifndef installation_H +#define installation_H + +#include "ui_installation.h" +#include "../backend.h" + +class wpInstallation : public QWizardPage, Ui::wpInstallation +{ + Q_OBJECT + + public: + wpInstallation(QWidget *parent = 0); + void initializePage(); + void cleanupPage(); + bool isComplete() const; + bool validatePage(); + + private: + Backend* backend; + bool complete; + void setComplete(bool c); + + private slots: + void setProgress(int percent); + void receivedCommand(QString command, QString args); + void finishedCommand(QString command); +}; + +#endif // installation_H diff --git a/wizard/installation.ui b/wizard/installation.ui new file mode 100644 index 0000000..67cdb81 --- /dev/null +++ b/wizard/installation.ui @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>wpInstallation</class> + <widget class="QWizardPage" name="wpInstallation"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>515</width> + <height>389</height> + </rect> + </property> + <property name="title"> + <string>Installation</string> + </property> + <property name="subTitle"> + <string>This may take some time...</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QListWidget" name="listWidget"/> + </item> + <item> + <widget class="QLabel" name="lblCurrent"> + <property name="text"> + <string>Current task:</string> + </property> + </widget> + </item> + <item> + <widget class="QProgressBar" name="progressCurrent"/> + </item> + <item> + <widget class="QLabel" name="lblCompleted"> + <property name="text"> + <string>Installation completed:</string> + </property> + </widget> + </item> + <item> + <widget class="QProgressBar" name="progressCompleted"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/wizard/network.cpp b/wizard/network.cpp new file mode 100644 index 0000000..9d45fc5 --- /dev/null +++ b/wizard/network.cpp @@ -0,0 +1,40 @@ +#include <QtGui> +#include "network.h" +#include "../listdelegate.h" +#include "../listitem.h" + +wpNetwork::wpNetwork(QWidget *parent) : QWizardPage(parent) +{ + setupUi(this); + connect(hostname, SIGNAL(textChanged(QString)), this, SLOT(updateStatus())); + + QValidator* hostnameValidator = new QRegExpValidator(QRegExp("[a-zA-Z0-9][a-zA-Z0-9.-]*[a-zA-Z0-9]"), this); + hostname->setValidator( hostnameValidator ); + + backend = Backend::instance(); +} + +void wpNetwork::initializePage() +{ + hostname->setText(backend->cfg("hostname")); + updateStatus(); +} + +void wpNetwork::updateStatus() +{ + emit completeChanged(); +} + +bool wpNetwork::isComplete() const +{ + if(hostname->text().length()) return true; + return false; +} + +bool wpNetwork::validatePage() +{ + if(!isComplete()) return false; + backend->cfg("hostname", hostname->text()); + return true; +} + diff --git a/wizard/network.h b/wizard/network.h new file mode 100644 index 0000000..4242a5a --- /dev/null +++ b/wizard/network.h @@ -0,0 +1,25 @@ +#ifndef network_H +#define network_H + +#include "ui_network.h" +#include "../backend.h" + +class wpNetwork : public QWizardPage, Ui::wpNetwork +{ + Q_OBJECT + + public: + wpNetwork(QWidget *parent = 0); + void initializePage(); + bool isComplete() const; + bool validatePage(); + + private: + Backend* backend; + + private slots: + void updateStatus(); + +}; + +#endif // network_H diff --git a/wizard/network.ui b/wizard/network.ui new file mode 100644 index 0000000..7f6a36c --- /dev/null +++ b/wizard/network.ui @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>wpNetwork</class> + <widget class="QWizardPage" name="wpNetwork"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>546</width> + <height>338</height> + </rect> + </property> + <property name="windowTitle"> + <string>WizardPage</string> + </property> + <property name="title"> + <string>Network configuration</string> + </property> + <property name="subTitle"> + <string>Set your hostname</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0" rowspan="2"> + <widget class="QLabel" name="lblHelpText"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>HelpText</string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="lblHostname"> + <property name="text"> + <string>Hostname:</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLineEdit" name="hostname"/> + </item> + <item> + <widget class="QLabel" name="hostnameStatus"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item row="1" column="1"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>264</width> + <height>197</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <tabstops> + <tabstop>hostname</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> diff --git a/wizard/partitions.cpp b/wizard/partitions.cpp new file mode 100644 index 0000000..d35e94f --- /dev/null +++ b/wizard/partitions.cpp @@ -0,0 +1,63 @@ +#include <QtGui> +#include "partitions.h" +#include "../listdelegate.h" +#include "../listitem.h" +#include "../mainwizard.h" + +wpPartitions::wpPartitions(QWidget *parent) : QWizardPage(parent) +{ + setupUi(this); + backend = Backend::instance(); + connect(listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete())); + listWidget->setItemDelegate(new ListDelegate(this)); +} + +void wpPartitions::initializePage() +{ + listWidget->clear(); + listWidget->addItem(new ListItem(tr("Manual partitioning"), tr("You will have to do the partitioning with a partition-manager manually. This way you have more possibilities to adjust the installation to your needs. The automatic partitioning lacks several features and is only a (computer generated) list of some possible options."), "partitionmanager", "manual")); + listWidget->addItem(new ListItem(tr("Already partitioned"), tr("If you have already partitioned for the installation and don't want to start a partition manager then select this."), "drive-harddisk", "already")); + clearPage(); +} + +void wpPartitions::clearPage() +{ +} + +void wpPartitions::receivedDataLine(QString data, QString line) +{ + if(data == "install_choice") + { + listWidget->addItem(new ListItem(line, line, "tools-wizard", line.section(" ",0,0))); + } +} + +void wpPartitions::updateComplete() +{ + emit completeChanged(); +} + +bool wpPartitions::isComplete() const +{ + if(!listWidget->currentItem()) return false; + return true; +} + +bool wpPartitions::validatePage() +{ + if(!isComplete()) return false; +// backend->cfg("install_choice", listWidget->currentItem()->data(ListItem::ItemData).toString()); + return true; +} + +int wpPartitions::nextId() const +{ + if(listWidget->currentItem()) + { + QString choice = listWidget->currentItem()->data(ListItem::ItemData).toString(); + if(choice == "manual") + return MainWizard::Page_PartManSel; + else if(choice == "already") + return MainWizard::Page_RootPartition; + } +} diff --git a/wizard/partitions.h b/wizard/partitions.h new file mode 100644 index 0000000..4f442a6 --- /dev/null +++ b/wizard/partitions.h @@ -0,0 +1,27 @@ +#ifndef partitions_H +#define partitions_H + +#include "ui_partitions.h" +#include "../backend.h" + +class wpPartitions : public QWizardPage, Ui::wpPartitions +{ + Q_OBJECT + + public: + wpPartitions(QWidget *parent = 0); + void initializePage(); + void clearPage(); + int nextId() const; + bool isComplete() const; + bool validatePage(); + + private: + Backend* backend; + + private slots: + void receivedDataLine(QString data, QString line); + void updateComplete(); +}; + +#endif // partitions_H diff --git a/wizard/partitions.ui b/wizard/partitions.ui new file mode 100644 index 0000000..f9badf4 --- /dev/null +++ b/wizard/partitions.ui @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>wpPartitions</class> + <widget class="QWizardPage" name="wpPartitions"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>515</width> + <height>389</height> + </rect> + </property> + <property name="title"> + <string>Partitions</string> + </property> + <property name="subTitle"> + <string>Mmmmmh! Partitions!</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QListWidget" name="listWidget"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/wizard/partman.cpp b/wizard/partman.cpp new file mode 100644 index 0000000..3e232f4 --- /dev/null +++ b/wizard/partman.cpp @@ -0,0 +1,55 @@ +#include <QtGui> +#include "partman.h" +#include "config.h" +#include "../listdelegate.h" +#include "../listitem.h" + +wpPartMan::wpPartMan(QWidget *parent) : QWizardPage(parent) +{ + setupUi(this); + backend = Backend::instance(); +} + +void wpPartMan::initializePage() +{ + clearPage(); +} + +void wpPartMan::clearPage() +{ + setComplete(false); + delete terminal; + delete gridLayout; + delete label; + setupUi(this); + connect(terminal, SIGNAL(finished()), this, SLOT(terminalFinished())); + QStringList args; + args << "/bin/bash" << BACKEND_PATH << "-e" << "run_partmgr" << backend->cfg("partman_program") << backend->cfg("partman_disk"); + terminal->setArgs(args); + terminal->startShellProgram(); + terminal->setFocus(Qt::OtherFocusReason); +} + +void wpPartMan::terminalFinished() +{ + terminal->releaseKeyboard(); + terminal->clearFocus(); + setComplete(true); +} + +void wpPartMan::setComplete(bool c) +{ + complete = c; + emit completeChanged(); +} + +bool wpPartMan::isComplete() const +{ + return complete; +} + +bool wpPartMan::validatePage() +{ + return complete; +} + diff --git a/wizard/partman.h b/wizard/partman.h new file mode 100644 index 0000000..240d8f7 --- /dev/null +++ b/wizard/partman.h @@ -0,0 +1,27 @@ +#ifndef partman_H +#define partman_H + +#include "ui_partman.h" +#include "../backend.h" + +class wpPartMan : public QWizardPage, Ui::wpPartMan +{ + Q_OBJECT + + public: + wpPartMan(QWidget *parent = 0); + void initializePage(); + void clearPage(); + bool isComplete() const; + bool validatePage(); + + private: + Backend* backend; + bool complete; + void setComplete(bool c); + + private slots: + void terminalFinished(); +}; + +#endif // partman_H diff --git a/wizard/partman.ui b/wizard/partman.ui new file mode 100644 index 0000000..2ddf54f --- /dev/null +++ b/wizard/partman.ui @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>wpPartMan</class> + <widget class="QWizardPage" name="wpPartMan"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>WizardPage</string> + </property> + <property name="title"> + <string>Partition Manager</string> + </property> + <property name="subTitle"> + <string>Partition your disk</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QTermWidget" name="terminal" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>save and/or quit the partition manager to continue</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>QTermWidget</class> + <extends>QWidget</extends> + <header>../qtermwidget/qtermwidget.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/wizard/partmansel.cpp b/wizard/partmansel.cpp new file mode 100644 index 0000000..ae74f0e --- /dev/null +++ b/wizard/partmansel.cpp @@ -0,0 +1,93 @@ +#include <QtGui> +#include "partmansel.h" +#include "../listdelegate.h" +#include "../listitem.h" + +wpPartManSel::wpPartManSel(QWidget *parent) : QWizardPage(parent) +{ + setupUi(this); + backend = Backend::instance(); + connect(backend, SIGNAL(receivedDataLine(QString,QString)), this, SLOT(receivedDataLine(QString,QString))); + connect(partMan, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete())); + connect(partDisk, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete())); + partMan->setItemDelegate(new ListDelegate(this)); +} + +void wpPartManSel::initializePage() +{ + clearPage(); +} + +void wpPartManSel::clearPage() +{ + backend->exec("send_partition_managers"); + partMan->clear(); + backend->exec("send_list_of_disks"); + partDisk->clear(); +} + +void wpPartManSel::receivedDataLine(QString data, QString line) +{ + if(data == "partition_managers") + { + QString app = line.section(" ",0,0); + QString title, desc, icon; + if(app == "cfdisk") + { + title = tr("cfdisk"); + desc = tr("cfdisk is a curses-based partition editor. It is text-only (curses), but it is easy to use [recommended]"); + icon = "terminal"; + } + else if(app == "fdisk") + { + title = tr("fdisk"); + desc = tr("fdisk is a classic partition table manipulator for Linux. It has a Command Line Interface."); + icon = "terminal"; + } + else if(app == "gparted") + { + title = tr("GParted"); + desc = tr("GParted is the Gnome Partition Editor application. It has a Graphical User Interface."); + icon = "gparted"; + } + else if(app == "qtparted") + { + title = tr("QtParted"); + desc = tr("QTParted is a Partition Magic clone, so it has a GUI. Sometimes it's a bit buggy, so it is not recommended to use for huge changes on the partition table."); + icon = "qtparted"; + } + else + { + title = app; + desc = tr("No description available..."); + icon = "partitionmanager"; + } + QListWidgetItem *item = new ListItem(title, desc, icon, app); + partMan->addItem(item); + } + if(data == "list_of_disks") + { + QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme("drive-harddisk"), line); + partDisk->addItem(item); + } +} + +void wpPartManSel::updateComplete() +{ + emit completeChanged(); +} + +bool wpPartManSel::isComplete() const +{ + if(!partMan->currentItem()) return false; + if(!partDisk->currentItem()) return false; + return true; +} + +bool wpPartManSel::validatePage() +{ + if(!isComplete()) return false; + backend->cfg("partman_program", partMan->currentItem()->data(ListItem::ItemData).toString()); + backend->cfg("partman_disk", partDisk->currentItem()->text().section(" ",0,0)); + return true; +} diff --git a/wizard/partmansel.h b/wizard/partmansel.h new file mode 100644 index 0000000..7bfabd8 --- /dev/null +++ b/wizard/partmansel.h @@ -0,0 +1,27 @@ +#ifndef partmansel_H +#define partmansel_H + +#include "ui_partmansel.h" +#include "../backend.h" + +class wpPartManSel : public QWizardPage, Ui::wpPartManSel +{ + Q_OBJECT + + public: + wpPartManSel(QWidget *parent = 0); + void initializePage(); + void clearPage(); + bool isComplete() const; + bool validatePage(); + + private: + Backend* backend; + + private slots: + void receivedDataLine(QString data, QString line); + void updateComplete(); + +}; + +#endif // partmansel_H diff --git a/wizard/partmansel.ui b/wizard/partmansel.ui new file mode 100644 index 0000000..15a0302 --- /dev/null +++ b/wizard/partmansel.ui @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>wpPartManSel</class> + <widget class="QWizardPage" name="wpPartManSel"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>584</width> + <height>358</height> + </rect> + </property> + <property name="windowTitle"> + <string>WizardPage</string> + </property> + <property name="title"> + <string>Partitions</string> + </property> + <property name="subTitle"> + <string>Select partition manager</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="lblHelpText"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>HelpText</string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QListWidget" name="partMan"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>3</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="1" column="0" rowspan="2" colspan="2"> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="3" column="0" rowspan="4"> + <widget class="QLabel" name="lblHelpText_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>HelpText</string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="6" column="1"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + </spacer> + </item> + <item row="3" column="1"> + <widget class="QListWidget" name="partDisk"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>2</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/wizard/rootpartition.cpp b/wizard/rootpartition.cpp new file mode 100644 index 0000000..6341a0f --- /dev/null +++ b/wizard/rootpartition.cpp @@ -0,0 +1,58 @@ +#include <QtGui> +#include "rootpartition.h" +#include "../listdelegate.h" +#include "../listitem.h" + +wpRootPartition::wpRootPartition(QWidget *parent) : QWizardPage(parent) +{ + setupUi(this); + backend = Backend::instance(); + connect(backend, SIGNAL(receivedDataLine(QString,QString)), this, SLOT(receivedDataLine(QString,QString))); + connect(rootPartitionDev, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete())); +} + +void wpRootPartition::initializePage() +{ + clearPage(); +} + +void wpRootPartition::clearPage() +{ + backend->exec("send_possible_root_partitions"); + rootPartitionDev->clear(); + backend->exec("send_possible_root_filesystems"); + rootPartitionFs->clear(); +} + +void wpRootPartition::receivedDataLine(QString data, QString line) +{ + if(data == "possible_root_partitions") + { + QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme("drive-harddisk"), line); + rootPartitionDev->addItem(item); + } + if(data == "possible_root_filesystems") + { + rootPartitionFs->addItem(line); + } +} + +void wpRootPartition::updateComplete() +{ + emit completeChanged(); +} + +bool wpRootPartition::isComplete() const +{ + if(!rootPartitionDev->currentItem()) return false; + return true; +} + +bool wpRootPartition::validatePage() +{ + if(!isComplete()) return false; + backend->exec(QString("hdmap_set %1:/:%2:auto") + .arg(rootPartitionDev->currentItem()->text().section(" ",0,0)) + .arg(chkFormat->isChecked() ? rootPartitionFs->currentText() : "")); + return true; +} diff --git a/wizard/rootpartition.h b/wizard/rootpartition.h new file mode 100644 index 0000000..16e95ef --- /dev/null +++ b/wizard/rootpartition.h @@ -0,0 +1,27 @@ +#ifndef rootpartition_H +#define rootpartition_H + +#include "ui_rootpartition.h" +#include "../backend.h" + +class wpRootPartition : public QWizardPage, Ui::wpRootPartition +{ + Q_OBJECT + + public: + wpRootPartition(QWidget *parent = 0); + void initializePage(); + void clearPage(); + bool isComplete() const; + bool validatePage(); + + private: + Backend* backend; + + private slots: + void receivedDataLine(QString data, QString line); + void updateComplete(); + +}; + +#endif // rootpartition_H diff --git a/wizard/rootpartition.ui b/wizard/rootpartition.ui new file mode 100644 index 0000000..119c00f --- /dev/null +++ b/wizard/rootpartition.ui @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>wpRootPartition</class> + <widget class="QWizardPage" name="wpRootPartition"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>584</width> + <height>405</height> + </rect> + </property> + <property name="windowTitle"> + <string>WizardPage</string> + </property> + <property name="title"> + <string>Partitions</string> + </property> + <property name="subTitle"> + <string>Select root partition</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0" rowspan="3"> + <widget class="QLabel" name="lblHelpText"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>HelpText</string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QListWidget" name="rootPartitionDev"/> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="chkFormat"> + <property name="text"> + <string>format partition with filesystem:</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="rootPartitionFs"/> + </item> + <item row="3" column="0" colspan="2"> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="4" column="0" rowspan="2"> + <widget class="QLabel" name="lblHelpText_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>HelpText</string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QCheckBox" name="chkAdvanced"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>advanced partition options</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>228</width> + <height>108</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>chkFormat</sender> + <signal>toggled(bool)</signal> + <receiver>rootPartitionFs</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>388</x> + <y>213</y> + </hint> + <hint type="destinationlabel"> + <x>390</x> + <y>246</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/wizard/rootpwd.cpp b/wizard/rootpwd.cpp new file mode 100644 index 0000000..9ec4417 --- /dev/null +++ b/wizard/rootpwd.cpp @@ -0,0 +1,69 @@ +#include <QtGui> +#include "rootpwd.h" +#include "../listdelegate.h" +#include "../listitem.h" + +wpRootPwd::wpRootPwd(QWidget *parent) : QWizardPage(parent) +{ + setupUi(this); + connect(password, SIGNAL(textChanged(QString)), this, SLOT(updateStatus())); + connect(retypePassword, SIGNAL(textChanged(QString)), this, SLOT(updateStatus())); + backend = Backend::instance(); + updateStatus(); +} + +void wpRootPwd::initializePage() +{ +} + +void wpRootPwd::updateStatus() +{ + QString pw1 = password->text(); + QString pw2 = retypePassword->text(); + + passwordStatus->setPixmap(QPixmap()); + retypePasswordStatus->setPixmap(QPixmap()); + + complete = true; + + if(!pw1.length()) + { + passwordStatus->setToolTip(tr("Please enter a password!")); + passwordStatus->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(24,24)); + complete = false; + } + else if(pw1.length() < 6) + { + passwordStatus->setToolTip(tr("Password must have at least 6 characters!")); + passwordStatus->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(24,24)); + complete = false; + } + else + { + passwordStatus->setPixmap(QIcon::fromTheme("dialog-ok").pixmap(24,24)); + + if(pw1 != pw2) + { + retypePasswordStatus->setToolTip(tr("Passwords don't match!")); + retypePasswordStatus->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(24,24)); + complete = false; + } + else + retypePasswordStatus->setPixmap(QIcon::fromTheme("dialog-ok").pixmap(24,24)); + } + + emit completeChanged(); +} + +bool wpRootPwd::isComplete() const +{ + return complete; +} + +bool wpRootPwd::validatePage() +{ + if(!complete) return false; + backend->cfg("rootpwd", backend->encryptPassword(password->text())); + return true; +} + diff --git a/wizard/rootpwd.h b/wizard/rootpwd.h new file mode 100644 index 0000000..62bcb7b --- /dev/null +++ b/wizard/rootpwd.h @@ -0,0 +1,26 @@ +#ifndef rootpwd_H +#define rootpwd_H + +#include "ui_rootpwd.h" +#include "../backend.h" + +class wpRootPwd : public QWizardPage, Ui::wpRootPwd +{ + Q_OBJECT + + public: + wpRootPwd(QWidget *parent = 0); + void initializePage(); + bool isComplete() const; + bool validatePage(); + + private: + Backend* backend; + bool complete; + + private slots: + void updateStatus(); + +}; + +#endif // rootpwd_H diff --git a/wizard/rootpwd.ui b/wizard/rootpwd.ui new file mode 100644 index 0000000..2e47950 --- /dev/null +++ b/wizard/rootpwd.ui @@ -0,0 +1,178 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>wpRootPwd</class> + <widget class="QWizardPage" name="wpRootPwd"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>546</width> + <height>338</height> + </rect> + </property> + <property name="windowTitle"> + <string>WizardPage</string> + </property> + <property name="title"> + <string>User configuration</string> + </property> + <property name="subTitle"> + <string>Password for the system administrator account (root)</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0" rowspan="3"> + <widget class="QLabel" name="lblHelpText"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>HelpText</string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="lblPwd"> + <property name="text"> + <string>Password:</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLineEdit" name="password"> + <property name="maxLength"> + <number>20</number> + </property> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="passwordStatus"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item row="1" column="1"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="lblRetypePwd"> + <property name="text"> + <string>Retype Password:</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLineEdit" name="retypePassword"> + <property name="maxLength"> + <number>20</number> + </property> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="retypePasswordStatus"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item row="2" column="1"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>264</width> + <height>197</height> + </size> + </property> + </spacer> + </item> + <item row="3" column="0" colspan="2"> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="lblPwdLenNote"> + <property name="text"> + <string><b>Note that all passwords must have 6 - 20 characters!</b></string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <tabstops> + <tabstop>password</tabstop> + <tabstop>retypePassword</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> diff --git a/wizard/summary.cpp b/wizard/summary.cpp new file mode 100644 index 0000000..b09f2c1 --- /dev/null +++ b/wizard/summary.cpp @@ -0,0 +1,66 @@ +#include <QtGui> +#include "summary.h" +#include "../listdelegate.h" +#include "../listitem.h" + +wpSummary::wpSummary(QWidget *parent) : QWizardPage(parent) +{ + setComplete(true); + setupUi(this); + backend = Backend::instance(); +// connect(backend, SIGNAL(processExited()), this, SLOT(WeAreDone())); + listWidget->setItemDelegate(new ListDelegate(this)); + setCommitPage(true); + setButtonText(QWizard::CommitButton, tr("Start Installation")); +// QListWidgetItem *item = new ListItem("Start", "Let's go!", "dialog-ok"); +// listWidget->addItem(item); +} + +void wpSummary::initializePage() +{ + listWidget->clear(); + listWidget->addItem(new ListItem(tr("Installation type"), tr("HD install"), "acritoxinstaller")); + QStringList hdMapList = backend->cfg("hdmap").split("\n"); + for (QStringList::Iterator it = hdMapList.begin(); it != hdMapList.end(); ++it) + { + QString line = *it; + QString device = line.section(":",0,0); + QString mountpoint = line.section(":",1,1); + QString filesystem = line.section(":",2,2); + QString automount = line.section(":",3,3); + QString title = tr("%1 will be used as %2").arg(device).arg(mountpoint); + QString description; + if(filesystem.length()) description = QString("<li>") + tr("It will be formatted with %1").arg(filesystem) + QString("</li>"); + if(automount == "auto") description += QString("<li>") + tr("It will be mounted automatically on boot") + QString("</li>"); + listWidget->addItem(new ListItem(title, "<ul>" + description + "</ul>", "drive-harddisk")); + } + listWidget->addItem(new ListItem(tr("Bootloader"), tr("%1 will be installed to %2").arg(backend->cfg("bootloader")).arg(backend->cfg("bootloader_target")), "system-run")); +} + +void wpSummary::cleanupPage() +{ + initializePage(); +} + +// void wpSummary::() +// { +// QListWidgetItem *item = new ListItem("Finished.", "The backend has finished its job.", "dialog-ok"); +// listWidget->addItem(item); +// setComplete(true); +// } + +void wpSummary::setComplete(bool c) +{ + complete = c; + emit completeChanged(); +} + +bool wpSummary::isComplete() const +{ + return complete; +} + +bool wpSummary::validatePage() +{ + return complete; +} diff --git a/wizard/summary.h b/wizard/summary.h new file mode 100644 index 0000000..677340b --- /dev/null +++ b/wizard/summary.h @@ -0,0 +1,28 @@ +#ifndef summary_H +#define summary_H + +#include "ui_summary.h" +#include "../backend.h" + +class wpSummary : public QWizardPage, Ui::wpSummary +{ + Q_OBJECT + + public: + wpSummary(QWidget *parent = 0); + void initializePage(); + void cleanupPage(); + bool isComplete() const; + bool validatePage(); + + private: + Backend* backend; + bool complete; + void setComplete(bool c); + + private slots: + + +}; + +#endif // summary_H diff --git a/wizard/summary.ui b/wizard/summary.ui new file mode 100644 index 0000000..9a36791 --- /dev/null +++ b/wizard/summary.ui @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>wpSummary</class> + <widget class="QWizardPage" name="wpSummary"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>515</width> + <height>389</height> + </rect> + </property> + <property name="title"> + <string>Installation</string> + </property> + <property name="subTitle"> + <string>Summary</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QListWidget" name="listWidget"/> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/wizard/usercfg.cpp b/wizard/usercfg.cpp new file mode 100644 index 0000000..0e625d6 --- /dev/null +++ b/wizard/usercfg.cpp @@ -0,0 +1,52 @@ +#include <QtGui> +#include "usercfg.h" +#include "../listdelegate.h" +#include "../listitem.h" + +wpUserCfg::wpUserCfg(QWidget *parent) : QWizardPage(parent) +{ + setupUi(this); + connect(realname, SIGNAL(editingFinished()), this, SLOT(realnameChanged())); + connect(realname, SIGNAL(textChanged(QString)), this, SLOT(updateStatus())); + connect(username, SIGNAL(textChanged(QString)), this, SLOT(updateStatus())); + + QValidator* usernameValidator = new QRegExpValidator(QRegExp("[a-zA-Z0-9-_.]*"), this); + username->setValidator( usernameValidator ); + + backend = Backend::instance(); + complete = false; + updateStatus(); +} + +void wpUserCfg::initializePage() +{ +} + +void wpUserCfg::realnameChanged() +{ + if(username->text().length()) return; + if(realname->text().contains(" ")) + username->setText(backend->cleanUsername(realname->text().section(" ",0,0).toLower())); + updateStatus(); +} + +void wpUserCfg::updateStatus() +{ + complete = false; + if(realname->text().length() && username->text().length()) complete = true; + emit completeChanged(); +} + +bool wpUserCfg::isComplete() const +{ + return complete; +} + +bool wpUserCfg::validatePage() +{ + if(!complete) return false; + backend->cfg("username", username->text()); + backend->cfg("realname", realname->text()); + return true; +} + diff --git a/wizard/usercfg.h b/wizard/usercfg.h new file mode 100644 index 0000000..17efa9a --- /dev/null +++ b/wizard/usercfg.h @@ -0,0 +1,27 @@ +#ifndef usercfg_H +#define usercfg_H + +#include "ui_usercfg.h" +#include "../backend.h" + +class wpUserCfg : public QWizardPage, Ui::wpUserCfg +{ + Q_OBJECT + + public: + wpUserCfg(QWidget *parent = 0); + void initializePage(); + bool isComplete() const; + bool validatePage(); + + private: + Backend* backend; + bool complete; + + private slots: + void realnameChanged(); + void updateStatus(); + +}; + +#endif // usercfg_H diff --git a/wizard/usercfg.ui b/wizard/usercfg.ui new file mode 100644 index 0000000..3e5ded9 --- /dev/null +++ b/wizard/usercfg.ui @@ -0,0 +1,143 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>wpUserCfg</class> + <widget class="QWizardPage" name="wpUserCfg"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>546</width> + <height>338</height> + </rect> + </property> + <property name="windowTitle"> + <string>WizardPage</string> + </property> + <property name="title"> + <string>User configuration</string> + </property> + <property name="subTitle"> + <string>Username</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0" rowspan="3"> + <widget class="QLabel" name="lblHelpText"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>HelpText</string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="lblRealname"> + <property name="text"> + <string>Realname:</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLineEdit" name="realname"/> + </item> + <item> + <widget class="QLabel" name="realnameStatus"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item row="1" column="1"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="lblUsername"> + <property name="text"> + <string>Username:</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLineEdit" name="username"/> + </item> + <item> + <widget class="QLabel" name="usernameStatus"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item row="2" column="1"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>264</width> + <height>197</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <tabstops> + <tabstop>realname</tabstop> + <tabstop>username</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> diff --git a/wizard/userpwd.cpp b/wizard/userpwd.cpp new file mode 100644 index 0000000..48a9e91 --- /dev/null +++ b/wizard/userpwd.cpp @@ -0,0 +1,69 @@ +#include <QtGui> +#include "userpwd.h" +#include "../listdelegate.h" +#include "../listitem.h" + +wpUserPwd::wpUserPwd(QWidget *parent) : QWizardPage(parent) +{ + setupUi(this); + connect(password, SIGNAL(textChanged(QString)), this, SLOT(updateStatus())); + connect(retypePassword, SIGNAL(textChanged(QString)), this, SLOT(updateStatus())); + backend = Backend::instance(); + updateStatus(); +} + +void wpUserPwd::initializePage() +{ +} + +void wpUserPwd::updateStatus() +{ + QString pw1 = password->text(); + QString pw2 = retypePassword->text(); + + passwordStatus->setPixmap(QPixmap()); + retypePasswordStatus->setPixmap(QPixmap()); + + complete = true; + + if(!pw1.length()) + { + passwordStatus->setToolTip(tr("Please enter a password!")); + passwordStatus->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(24,24)); + complete = false; + } + else if(pw1.length() < 6) + { + passwordStatus->setToolTip(tr("Password must have at least 6 characters!")); + passwordStatus->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(24,24)); + complete = false; + } + else + { + passwordStatus->setPixmap(QIcon::fromTheme("dialog-ok").pixmap(24,24)); + + if(pw1 != pw2) + { + retypePasswordStatus->setToolTip(tr("Passwords don't match!")); + retypePasswordStatus->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(24,24)); + complete = false; + } + else + retypePasswordStatus->setPixmap(QIcon::fromTheme("dialog-ok").pixmap(24,24)); + } + emit completeChanged(); +} + +bool wpUserPwd::isComplete() const +{ + return complete; +} + +bool wpUserPwd::validatePage() +{ + if(!complete) return false; + backend->cfg("userpwd", backend->encryptPassword(password->text())); + backend->cfg("autologin", (autologin->isChecked() ? "on" : "off")); + return true; +} + diff --git a/wizard/userpwd.h b/wizard/userpwd.h new file mode 100644 index 0000000..7ea209d --- /dev/null +++ b/wizard/userpwd.h @@ -0,0 +1,26 @@ +#ifndef userpwd_H +#define userpwd_H + +#include "ui_userpwd.h" +#include "../backend.h" + +class wpUserPwd : public QWizardPage, Ui::wpUserPwd +{ + Q_OBJECT + + public: + wpUserPwd(QWidget *parent = 0); + void initializePage(); + bool isComplete() const; + bool validatePage(); + + private: + Backend* backend; + bool complete; + + private slots: + void updateStatus(); + +}; + +#endif // userpwd_H diff --git a/wizard/userpwd.ui b/wizard/userpwd.ui new file mode 100644 index 0000000..ff559a2 --- /dev/null +++ b/wizard/userpwd.ui @@ -0,0 +1,237 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>wpUserPwd</class> + <widget class="QWizardPage" name="wpUserPwd"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>546</width> + <height>338</height> + </rect> + </property> + <property name="windowTitle"> + <string>WizardPage</string> + </property> + <property name="title"> + <string>User configuration</string> + </property> + <property name="subTitle"> + <string>Password for your user account</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0" rowspan="3"> + <widget class="QLabel" name="lblHelpText"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>HelpText</string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="lblPwd"> + <property name="text"> + <string>Password:</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLineEdit" name="password"> + <property name="maxLength"> + <number>20</number> + </property> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="passwordStatus"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item row="1" column="1"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="lblRetypePwd"> + <property name="text"> + <string>Retype Password:</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLineEdit" name="retypePassword"> + <property name="maxLength"> + <number>20</number> + </property> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="retypePasswordStatus"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>25</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item row="2" column="1"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>264</width> + <height>91</height> + </size> + </property> + </spacer> + </item> + <item row="3" column="0" colspan="2"> + <widget class="Line" name="line_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="4" column="0" rowspan="3"> + <widget class="QLabel" name="lblHelpText_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>HelpText</string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QCheckBox" name="autologin"> + <property name="text"> + <string>Enable Auto-Login</string> + </property> + </widget> + </item> + <item row="6" column="1"> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>264</width> + <height>59</height> + </size> + </property> + </spacer> + </item> + <item row="7" column="0" colspan="2"> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="lblPwdLenNote"> + <property name="text"> + <string><b>Note that all passwords must have 6 - 20 characters!</b></string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <tabstops> + <tabstop>password</tabstop> + <tabstop>retypePassword</tabstop> + <tabstop>autologin</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> diff --git a/wizard/welcome.cpp b/wizard/welcome.cpp new file mode 100644 index 0000000..56210e0 --- /dev/null +++ b/wizard/welcome.cpp @@ -0,0 +1,35 @@ +#include <QtGui> +#include "welcome.h" +#include "../listdelegate.h" +#include "../listitem.h" + +wpWelcome::wpWelcome(QWidget *parent) : QWizardPage(parent) +{ + setupUi(this); + backend = Backend::instance(); + connect(backend, SIGNAL(finishedCommand(QString)), this, SLOT(backendFinishedCommand(QString))); + setComplete(false); + backend->exec("init_installer"); +} + +void wpWelcome::backendFinishedCommand(QString command) +{ + if(command == "init_installer") setComplete(true); +} + +void wpWelcome::setComplete(bool c) +{ + complete = c; + emit completeChanged(); +} + +bool wpWelcome::isComplete() const +{ + return complete; +} + +bool wpWelcome::validatePage() +{ + return complete; +} + diff --git a/wizard/welcome.h b/wizard/welcome.h new file mode 100644 index 0000000..792f127 --- /dev/null +++ b/wizard/welcome.h @@ -0,0 +1,26 @@ +#ifndef welcome_H +#define welcome_H + +#include "ui_welcome.h" +#include "../backend.h" + +class wpWelcome : public QWizardPage, Ui::wpWelcome +{ + Q_OBJECT + + public: + wpWelcome(QWidget *parent = 0); + bool isComplete() const; + bool validatePage(); + + private: + Backend* backend; + bool complete; + void setComplete(bool c); + + private slots: + void backendFinishedCommand(QString command); + +}; + +#endif // welcome_H diff --git a/wizard/welcome.ui b/wizard/welcome.ui new file mode 100644 index 0000000..6fbc95f --- /dev/null +++ b/wizard/welcome.ui @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>wpWelcome</class> + <widget class="QWizardPage" name="wpWelcome"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>WizardPage</string> + </property> + <property name="title"> + <string>Installer</string> + </property> + </widget> + <resources/> + <connections/> +</ui> |