|
|
@ -1,7 +1,10 @@
|
|
|
|
#include "existinginstallationpage.hpp"
|
|
|
|
#include "existinginstallationpage.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
|
|
|
#include <QFile>
|
|
|
|
|
|
|
|
|
|
|
|
#include "mainwizard.hpp"
|
|
|
|
#include "mainwizard.hpp"
|
|
|
|
|
|
|
|
|
|
|
@ -32,16 +35,14 @@ void Wizard::ExistingInstallationPage::on_browseButton_clicked()
|
|
|
|
if (!info.exists())
|
|
|
|
if (!info.exists())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
QDir dir(info.absolutePath());
|
|
|
|
QString path(QDir::toNativeSeparators(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);
|
|
|
|
QList<QListWidgetItem*> items = detectedList->findItems(path, Qt::MatchExactly);
|
|
|
|
|
|
|
|
|
|
|
|
if (items.isEmpty())
|
|
|
|
if (items.isEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Path is not yet in the list, add it
|
|
|
|
// Path is not yet in the list, add it
|
|
|
|
|
|
|
|
mWizard->addInstallation(path);
|
|
|
|
|
|
|
|
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(path);
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(path);
|
|
|
|
detectedList->addItem(item);
|
|
|
|
detectedList->addItem(item);
|
|
|
|
detectedList->setCurrentItem(item); // Select it too
|
|
|
|
detectedList->setCurrentItem(item); // Select it too
|
|
|
@ -55,13 +56,13 @@ void Wizard::ExistingInstallationPage::textChanged(const QString &text)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Set the installation path manually, as registerField doesn't work
|
|
|
|
// Set the installation path manually, as registerField doesn't work
|
|
|
|
if (!text.isEmpty())
|
|
|
|
if (!text.isEmpty())
|
|
|
|
wizard()->setField("installation.path", text);
|
|
|
|
mWizard->setField("installation.path", text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Wizard::ExistingInstallationPage::initializePage()
|
|
|
|
void Wizard::ExistingInstallationPage::initializePage()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
QStringList paths = mWizard->mInstallations.keys();
|
|
|
|
QStringList paths(mWizard->mInstallations.keys());
|
|
|
|
|
|
|
|
|
|
|
|
if (paths.isEmpty())
|
|
|
|
if (paths.isEmpty())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -75,6 +76,50 @@ void Wizard::ExistingInstallationPage::initializePage()
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::ExistingInstallationPage::validatePage()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// See if Morrowind.ini is detected, if not, ask the user
|
|
|
|
|
|
|
|
// It can be missing entirely
|
|
|
|
|
|
|
|
// Or failed to be detected due to the target being a symlink
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString path(field("installation.path").toString());
|
|
|
|
|
|
|
|
QFile file(mWizard->mInstallations[path]->iniPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
|
|
|
msgBox.setWindowTitle(tr("Error detecting Morrowind configuration"));
|
|
|
|
|
|
|
|
msgBox.setIcon(QMessageBox::Warning);
|
|
|
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Cancel);
|
|
|
|
|
|
|
|
msgBox.setText(QObject::tr("<br><b>Could not find Morrowind.ini</b><br><br> \
|
|
|
|
|
|
|
|
The Wizard needs to update settings in this file.<br><br> \
|
|
|
|
|
|
|
|
Press \"Browse...\" to specify the location manually.<br>"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QAbstractButton *browseButton =
|
|
|
|
|
|
|
|
msgBox.addButton(QObject::tr("B&rowse..."), QMessageBox::ActionRole);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
msgBox.exec();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString iniFile;
|
|
|
|
|
|
|
|
if (msgBox.clickedButton() == browseButton) {
|
|
|
|
|
|
|
|
iniFile = QFileDialog::getOpenFileName(
|
|
|
|
|
|
|
|
NULL,
|
|
|
|
|
|
|
|
QObject::tr("Select configuration file"),
|
|
|
|
|
|
|
|
QDir::currentPath(),
|
|
|
|
|
|
|
|
QString(tr("Morrowind configuration file (*.ini)")));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (iniFile.isEmpty()) {
|
|
|
|
|
|
|
|
return false; // Cancel was clicked;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// A proper Morrowind.ini was selected, set it
|
|
|
|
|
|
|
|
QFileInfo info(iniFile);
|
|
|
|
|
|
|
|
mWizard->mInstallations[path]->iniPath = info.absoluteFilePath();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Wizard::ExistingInstallationPage::isComplete() const
|
|
|
|
bool Wizard::ExistingInstallationPage::isComplete() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (detectedList->selectionModel()->hasSelection()) {
|
|
|
|
if (detectedList->selectionModel()->hasSelection()) {
|
|
|
@ -86,14 +131,11 @@ bool Wizard::ExistingInstallationPage::isComplete() const
|
|
|
|
|
|
|
|
|
|
|
|
int Wizard::ExistingInstallationPage::nextId() const
|
|
|
|
int Wizard::ExistingInstallationPage::nextId() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QString path = field("installation.path").toString();
|
|
|
|
QString path(field("installation.path").toString());
|
|
|
|
|
|
|
|
|
|
|
|
if (path.isEmpty())
|
|
|
|
if (path.isEmpty())
|
|
|
|
return MainWizard::Page_ComponentSelection;
|
|
|
|
return MainWizard::Page_ComponentSelection;
|
|
|
|
|
|
|
|
|
|
|
|
if (!mWizard->mInstallations.contains(path))
|
|
|
|
|
|
|
|
return MainWizard::Page_ComponentSelection;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mWizard->mInstallations[path]->hasMorrowind == true &&
|
|
|
|
if (mWizard->mInstallations[path]->hasMorrowind == true &&
|
|
|
|
mWizard->mInstallations[path]->hasTribunal == true &&
|
|
|
|
mWizard->mInstallations[path]->hasTribunal == true &&
|
|
|
|
mWizard->mInstallations[path]->hasBloodmoon == true)
|
|
|
|
mWizard->mInstallations[path]->hasBloodmoon == true)
|
|
|
|