WIP: Working on the installation selection and added the ui for the language page
parent
0e1d3237fe
commit
d7f9604140
@ -1,14 +1,115 @@
|
||||
#include "componentselectionpage.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QAbstractButton>
|
||||
|
||||
#include "mainwizard.hpp"
|
||||
|
||||
Wizard::ComponentSelectionPage::ComponentSelectionPage(QWidget *parent) :
|
||||
QWizardPage(parent)
|
||||
Wizard::ComponentSelectionPage::ComponentSelectionPage(MainWizard *wizard) :
|
||||
QWizardPage(wizard),
|
||||
mWizard(wizard)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
setCommitPage(true);
|
||||
setButtonText(QWizard::CommitButton, tr("&Install"));
|
||||
|
||||
connect(componentsList, SIGNAL(itemChanged(QListWidgetItem*)),
|
||||
this, SLOT(updateButton(QListWidgetItem*)));
|
||||
}
|
||||
|
||||
void Wizard::ComponentSelectionPage::updateButton(QListWidgetItem *item)
|
||||
{
|
||||
if (field("installation.new").toBool() == true)
|
||||
return; // Morrowind is always checked here
|
||||
|
||||
bool unchecked = true;
|
||||
|
||||
for (int i =0; i < componentsList->count(); ++i) {
|
||||
QListWidgetItem *item = componentsList->item(i);
|
||||
|
||||
qDebug() << "item is " << item->text();
|
||||
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
if (item->checkState() == Qt::Checked) {
|
||||
unchecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (unchecked) {
|
||||
setCommitPage(false);
|
||||
setButtonText(QWizard::NextButton, tr("&Skip"));
|
||||
} else {
|
||||
setCommitPage(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Wizard::ComponentSelectionPage::initializePage()
|
||||
{
|
||||
componentsList->clear();
|
||||
|
||||
QString path = field("installation.path").toString();
|
||||
|
||||
QListWidgetItem *morrowindItem = new QListWidgetItem(QString("Morrowind"));
|
||||
QListWidgetItem *tribunalItem = new QListWidgetItem(QString("Tribunal"));
|
||||
QListWidgetItem *bloodmoonItem = new QListWidgetItem(QString("Bloodmoon"));
|
||||
|
||||
if (field("installation.new").toBool() == true)
|
||||
{
|
||||
morrowindItem->setFlags(morrowindItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable);
|
||||
morrowindItem->setData(Qt::CheckStateRole, Qt::Checked);
|
||||
componentsList->addItem(morrowindItem);
|
||||
|
||||
tribunalItem->setFlags(tribunalItem->flags() | Qt::ItemIsUserCheckable);
|
||||
tribunalItem->setData(Qt::CheckStateRole, Qt::Checked);
|
||||
componentsList->addItem(tribunalItem);
|
||||
|
||||
bloodmoonItem->setFlags(bloodmoonItem->flags() | Qt::ItemIsUserCheckable);
|
||||
bloodmoonItem->setData(Qt::CheckStateRole, Qt::Checked);
|
||||
componentsList->addItem(bloodmoonItem);
|
||||
} else {
|
||||
|
||||
if (mWizard->mInstallations[path]->hasMorrowind == true) {
|
||||
morrowindItem->setText(tr("Morrowind\t\t(installed)"));
|
||||
morrowindItem->setFlags(morrowindItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable);
|
||||
morrowindItem->setData(Qt::CheckStateRole, Qt::Unchecked);
|
||||
} else {
|
||||
morrowindItem->setText(tr("Morrowind"));
|
||||
morrowindItem->setData(Qt::CheckStateRole, Qt::Checked);
|
||||
}
|
||||
|
||||
componentsList->addItem(morrowindItem);
|
||||
|
||||
if (mWizard->mInstallations[path]->hasTribunal == true) {
|
||||
tribunalItem->setText(tr("Tribunal\t\t(installed)"));
|
||||
tribunalItem->setFlags(tribunalItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable);
|
||||
tribunalItem->setData(Qt::CheckStateRole, Qt::Unchecked);
|
||||
} else {
|
||||
tribunalItem->setText(tr("Tribunal"));
|
||||
tribunalItem->setData(Qt::CheckStateRole, Qt::Checked);
|
||||
}
|
||||
|
||||
componentsList->addItem(tribunalItem);
|
||||
|
||||
if (mWizard->mInstallations[path]->hasBloodmoon == true) {
|
||||
bloodmoonItem->setText(tr("Bloodmoon\t\t(installed)"));
|
||||
bloodmoonItem->setFlags(bloodmoonItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable);
|
||||
bloodmoonItem->setData(Qt::CheckStateRole, Qt::Unchecked);
|
||||
} else {
|
||||
bloodmoonItem->setText(tr("Bloodmoon"));
|
||||
bloodmoonItem->setData(Qt::CheckStateRole, Qt::Checked);
|
||||
}
|
||||
|
||||
componentsList->addItem(bloodmoonItem);
|
||||
}
|
||||
}
|
||||
|
||||
int Wizard::ComponentSelectionPage::nextId() const
|
||||
{
|
||||
return MainWizard::Page_Installation;
|
||||
if (isCommitPage())
|
||||
return MainWizard::Page_Installation;
|
||||
|
||||
return MainWizard::Page_Import;
|
||||
}
|
||||
|
@ -1,14 +1,105 @@
|
||||
#include "existinginstallationpage.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "mainwizard.hpp"
|
||||
|
||||
Wizard::ExistingInstallationPage::ExistingInstallationPage(QWidget *parent) :
|
||||
QWizardPage(parent)
|
||||
Wizard::ExistingInstallationPage::ExistingInstallationPage(MainWizard *wizard) :
|
||||
QWizardPage(wizard),
|
||||
mWizard(wizard)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
connect(detectedList, SIGNAL(currentTextChanged(QString)),
|
||||
this, SLOT(textChanged(QString)));
|
||||
|
||||
connect(detectedList,SIGNAL(itemSelectionChanged()),
|
||||
this, SIGNAL(completeChanged()));
|
||||
}
|
||||
|
||||
void Wizard::ExistingInstallationPage::on_browseButton_clicked()
|
||||
{
|
||||
QString selectedFile = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Select master file"),
|
||||
QDir::currentPath(),
|
||||
QString(tr("Morrowind master file (*.esm)")),
|
||||
NULL,
|
||||
QFileDialog::DontResolveSymlinks);
|
||||
|
||||
QFileInfo info(selectedFile);
|
||||
if (!info.exists())
|
||||
return;
|
||||
|
||||
QDir dir(info.absolutePath());
|
||||
if (!dir.cdUp())
|
||||
return; // Cannot move out of the Data Files directory
|
||||
|
||||
QString path = QDir::toNativeSeparators(dir.absolutePath());
|
||||
QList<QListWidgetItem*> items = detectedList->findItems(path, Qt::MatchExactly);
|
||||
|
||||
if (items.isEmpty())
|
||||
{
|
||||
// Path is not yet in the list, add it
|
||||
QListWidgetItem *item = new QListWidgetItem(path);
|
||||
detectedList->addItem(item);
|
||||
detectedList->setCurrentItem(item); // Select it too
|
||||
} else {
|
||||
detectedList->setCurrentItem(items.first());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Wizard::ExistingInstallationPage::textChanged(const QString &text)
|
||||
{
|
||||
// Set the installation path manually, as registerField doesn't work
|
||||
if (!text.isEmpty())
|
||||
wizard()->setField("installation.path", text);
|
||||
}
|
||||
|
||||
void Wizard::ExistingInstallationPage::initializePage()
|
||||
{
|
||||
|
||||
QStringList paths = mWizard->mInstallations.keys();
|
||||
|
||||
if (paths.isEmpty())
|
||||
return;
|
||||
|
||||
detectedList->clear();
|
||||
|
||||
foreach (const QString &path, paths) {
|
||||
QListWidgetItem *item = new QListWidgetItem(path);
|
||||
detectedList->addItem(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool Wizard::ExistingInstallationPage::isComplete() const
|
||||
{
|
||||
if (detectedList->selectionModel()->hasSelection()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int Wizard::ExistingInstallationPage::nextId() const
|
||||
{
|
||||
return MainWizard::Page_ComponentSelection;
|
||||
QString path = field("installation.path").toString();
|
||||
|
||||
if (path.isEmpty())
|
||||
return MainWizard::Page_ComponentSelection;
|
||||
|
||||
if (!mWizard->mInstallations.contains(path))
|
||||
return MainWizard::Page_ComponentSelection;
|
||||
|
||||
if (mWizard->mInstallations[path]->hasMorrowind == true &&
|
||||
mWizard->mInstallations[path]->hasTribunal == true &&
|
||||
mWizard->mInstallations[path]->hasBloodmoon == true)
|
||||
{
|
||||
return MainWizard::Page_Import;
|
||||
} else {
|
||||
return MainWizard::Page_ComponentSelection;
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,23 @@
|
||||
#include "methodselectionpage.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
#include "mainwizard.hpp"
|
||||
|
||||
Wizard::MethodSelectionPage::MethodSelectionPage(QWidget *parent) :
|
||||
QWizardPage(parent)
|
||||
Wizard::MethodSelectionPage::MethodSelectionPage(MainWizard *wizard) :
|
||||
QWizardPage(wizard),
|
||||
mWizard(wizard)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
registerField("installation.new", newLocationRadioButton);
|
||||
}
|
||||
|
||||
int Wizard::MethodSelectionPage::nextId() const
|
||||
{
|
||||
if (newLocationRadioButton->isChecked()) {
|
||||
//wizard()->setField("installation.new", true);
|
||||
return MainWizard::Page_InstallationTarget;
|
||||
} else {
|
||||
//wizard()->setField("installation.new", false);
|
||||
return MainWizard::Page_ExistingInstallation;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>WizardPage</class>
|
||||
<widget class="QWizardPage" name="WizardPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>398</width>
|
||||
<height>298</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>WizardPage</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="folderIconLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><img src=":/icons/tango/48x48/preferences-desktop-locale.png"/></p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="infoLabel">
|
||||
<property name="text">
|
||||
<string>What is the language of the Morrowind installation?</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>230</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../wizard/wizard.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,7 +1,8 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="icons/tango">
|
||||
<RCC>
|
||||
<qresource prefix="icons/tango">
|
||||
<file alias="48x48/preferences-desktop-locale.png">icons/tango/48x48/preferences-desktop-locale.png</file>
|
||||
<file alias="index.theme">icons/tango/index.theme</file>
|
||||
<file alias="48x48/folder.png">icons/tango/48x48/folder.png</file>
|
||||
<file alias="48x48/system-installer.png">icons/tango/48x48/system-installer.png</file>
|
||||
</qresource>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
Reference in New Issue