More wizard cleanup I can't be bothered to categorize
This also fixes language repopulation when you return to the language selection page.
This commit is contained in:
@@ -15,8 +15,9 @@ Wizard::ConclusionPage::ConclusionPage(QWidget* parent)
|
||||
|
||||
void Wizard::ConclusionPage::initializePage()
|
||||
{
|
||||
const bool retailDisc = field(QLatin1String("installation.retailDisc")).toBool();
|
||||
// Write the path to openmw.cfg
|
||||
if (field(QLatin1String("installation.retailDisc")).toBool() == true)
|
||||
if (retailDisc)
|
||||
{
|
||||
const QString path(field(QLatin1String("installation.path")).toString());
|
||||
mWizard->addInstallation(path);
|
||||
@@ -24,17 +25,15 @@ void Wizard::ConclusionPage::initializePage()
|
||||
|
||||
if (!mWizard->mError)
|
||||
{
|
||||
if ((field(QLatin1String("installation.retailDisc")).toBool() == true)
|
||||
|| (field(QLatin1String("installation.import-settings")).toBool() == true))
|
||||
if (retailDisc || field(QLatin1String("installation.import-settings")).toBool())
|
||||
{
|
||||
qDebug() << "IMPORT SETTINGS";
|
||||
mWizard->runSettingsImporter();
|
||||
}
|
||||
}
|
||||
|
||||
if (!mWizard->mError)
|
||||
{
|
||||
if (field(QLatin1String("installation.retailDisc")).toBool() == true)
|
||||
if (retailDisc)
|
||||
{
|
||||
textLabel->setText(
|
||||
tr("<html><head/><body><p>The OpenMW Wizard successfully installed Morrowind on your "
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
#include "installationtargetpage.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/files/qtconversion.hpp>
|
||||
#include <components/misc/scalableicon.hpp>
|
||||
|
||||
#include "mainwizard.hpp"
|
||||
@@ -28,10 +26,7 @@ Wizard::InstallationTargetPage::InstallationTargetPage(QWidget* parent, const Fi
|
||||
|
||||
void Wizard::InstallationTargetPage::initializePage()
|
||||
{
|
||||
QString path(QFile::decodeName(Files::pathToUnicodeString(mCfgMgr.getUserDataPath()).c_str()));
|
||||
path.append(QDir::separator() + QLatin1String("basedata"));
|
||||
|
||||
const QDir dir(path);
|
||||
const QDir dir(Files::pathToQString(mCfgMgr.getUserDataPath() / "basedata"));
|
||||
targetLineEdit->setText(QDir::toNativeSeparators(dir.absolutePath()));
|
||||
}
|
||||
|
||||
@@ -101,10 +96,7 @@ void Wizard::InstallationTargetPage::browseButtonClicked()
|
||||
|
||||
qDebug() << selectedPath;
|
||||
const QFileInfo info(selectedPath);
|
||||
if (!info.exists())
|
||||
return;
|
||||
|
||||
if (info.isWritable())
|
||||
if (info.exists() && info.isWritable())
|
||||
targetLineEdit->setText(info.absoluteFilePath());
|
||||
}
|
||||
|
||||
|
||||
@@ -14,15 +14,12 @@ Wizard::LanguageSelectionPage::LanguageSelectionPage(QWidget* parent)
|
||||
flagIcon->setIcon(Misc::ScalableIcon::load(":preferences-desktop-locale"));
|
||||
|
||||
registerField(QLatin1String("installation.language"), languageComboBox, "currentData", "currentDataChanged");
|
||||
}
|
||||
|
||||
void Wizard::LanguageSelectionPage::initializePage()
|
||||
{
|
||||
const QVector<std::pair<QString, QString>> languages = { { "English", tr("English") }, { "French", tr("French") },
|
||||
{ "German", tr("German") }, { "Italian", tr("Italian") }, { "Polish", tr("Polish") },
|
||||
{ "Russian", tr("Russian") }, { "Spanish", tr("Spanish") } };
|
||||
const QVector<std::pair<QString, QString>> languages = { { tr("English"), "English" }, { tr("French"), "French" },
|
||||
{ tr("German"), "German" }, { tr("Italian"), "Italian" }, { tr("Polish"), "Polish" },
|
||||
{ tr("Russian"), "Russian" }, { tr("Spanish"), "Spanish" } };
|
||||
|
||||
for (const auto& [name, localizedName] : languages)
|
||||
for (const auto& [localizedName, name] : languages)
|
||||
{
|
||||
languageComboBox->addItem(localizedName, name);
|
||||
}
|
||||
|
||||
@@ -23,9 +23,6 @@ namespace Wizard
|
||||
|
||||
private:
|
||||
MainWizard* mWizard;
|
||||
|
||||
protected:
|
||||
void initializePage() override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+17
-31
@@ -1,5 +1,7 @@
|
||||
#include "mainwizard.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
@@ -25,15 +27,10 @@
|
||||
#include "installationpage.hpp"
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace Process;
|
||||
|
||||
Wizard::MainWizard::MainWizard(Files::ConfigurationManager&& cfgMgr, QWidget* parent)
|
||||
: QWizard(parent)
|
||||
, mInstallations()
|
||||
, mCfgMgr(cfgMgr)
|
||||
, mError(false)
|
||||
, mImporterInvoker(new Process::ProcessInvoker())
|
||||
, mGameSettings(mCfgMgr)
|
||||
{
|
||||
#ifndef Q_OS_MAC
|
||||
@@ -49,10 +46,6 @@ Wizard::MainWizard::MainWizard(Files::ConfigurationManager&& cfgMgr, QWidget* pa
|
||||
// Set the property for comboboxes to the text instead of index
|
||||
setDefaultProperty("QComboBox", "currentText", "currentIndexChanged");
|
||||
|
||||
mImporterInvoker = new ProcessInvoker();
|
||||
|
||||
connect(mImporterInvoker->getProcess(), &QProcess::started, this, &MainWizard::importerStarted);
|
||||
|
||||
connect(mImporterInvoker->getProcess(), qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this,
|
||||
&MainWizard::importerFinished);
|
||||
|
||||
@@ -73,10 +66,7 @@ Wizard::MainWizard::MainWizard(Files::ConfigurationManager&& cfgMgr, QWidget* pa
|
||||
}
|
||||
}
|
||||
|
||||
Wizard::MainWizard::~MainWizard()
|
||||
{
|
||||
delete mImporterInvoker;
|
||||
}
|
||||
Wizard::MainWizard::~MainWizard() = default;
|
||||
|
||||
void Wizard::MainWizard::setupGameSettings()
|
||||
{
|
||||
@@ -109,10 +99,9 @@ void Wizard::MainWizard::setupGameSettings()
|
||||
Misc::ensureUtf8Encoding(stream);
|
||||
|
||||
mGameSettings.readUserFile(stream, QFileInfo(path).dir().path());
|
||||
file.close();
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
// Now the rest
|
||||
const QStringList paths = Files::getActiveConfigPathsQString(mCfgMgr);
|
||||
|
||||
@@ -138,15 +127,15 @@ void Wizard::MainWizard::setupGameSettings()
|
||||
Misc::ensureUtf8Encoding(stream);
|
||||
|
||||
mGameSettings.readFile(stream, QFileInfo(path2).dir().path());
|
||||
file.close();
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void Wizard::MainWizard::setupLauncherSettings()
|
||||
{
|
||||
QString path(Files::pathToQString(mCfgMgr.getUserConfigPath()));
|
||||
path.append(QLatin1String(Config::LauncherSettings::sLauncherConfigFileName));
|
||||
const std::filesystem::path configPath = mCfgMgr.getUserConfigPath();
|
||||
const QString path(Files::pathToQString(configPath / Config::LauncherSettings::sLauncherConfigFileName));
|
||||
|
||||
const QString message(
|
||||
tr("<html><head/><body><p><b>Could not open %1 for reading</b></p>"
|
||||
@@ -175,8 +164,6 @@ void Wizard::MainWizard::setupLauncherSettings()
|
||||
|
||||
mLauncherSettings.readFile(stream);
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
void Wizard::MainWizard::setupInstallations()
|
||||
@@ -194,6 +181,7 @@ void Wizard::MainWizard::runSettingsImporter()
|
||||
writeSettings();
|
||||
|
||||
const QString path(field(QLatin1String("installation.path")).toString());
|
||||
const bool retailDisc(field(QLatin1String("installation.retailDisc")).toBool());
|
||||
|
||||
QFile file(Files::getUserConfigPathQString(mCfgMgr));
|
||||
|
||||
@@ -201,8 +189,7 @@ void Wizard::MainWizard::runSettingsImporter()
|
||||
QStringList arguments;
|
||||
|
||||
// Import plugin selection?
|
||||
if (field(QLatin1String("installation.retailDisc")).toBool() == true
|
||||
|| field(QLatin1String("installation.import-addons")).toBool() == true)
|
||||
if (retailDisc || field(QLatin1String("installation.import-addons")).toBool())
|
||||
arguments.append(QLatin1String("--game-files"));
|
||||
|
||||
arguments.append(QLatin1String("--encoding"));
|
||||
@@ -223,15 +210,15 @@ void Wizard::MainWizard::runSettingsImporter()
|
||||
}
|
||||
|
||||
// Import fonts
|
||||
if (field(QLatin1String("installation.import-fonts")).toBool() == true)
|
||||
if (field(QLatin1String("installation.import-fonts")).toBool())
|
||||
arguments.append(QLatin1String("--fonts"));
|
||||
|
||||
// Now the paths
|
||||
arguments.append(QLatin1String("--ini"));
|
||||
|
||||
if (field(QLatin1String("installation.retailDisc")).toBool() == true)
|
||||
if (retailDisc)
|
||||
{
|
||||
arguments.append(path + QDir::separator() + QLatin1String("Morrowind.ini"));
|
||||
arguments.append(QDir(path).filePath(QLatin1String("Morrowind.ini")));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -248,7 +235,7 @@ void Wizard::MainWizard::runSettingsImporter()
|
||||
void Wizard::MainWizard::addInstallation(const QString& path)
|
||||
{
|
||||
qDebug() << "add installation in: " << path;
|
||||
Installation install; // = new Installation();
|
||||
Installation install;
|
||||
|
||||
install.hasMorrowind = findFiles(QLatin1String("Morrowind"), path);
|
||||
install.hasTribunal = findFiles(QLatin1String("Tribunal"), path);
|
||||
@@ -290,8 +277,6 @@ void Wizard::MainWizard::setupPages()
|
||||
setStartId(Page_Intro);
|
||||
}
|
||||
|
||||
void Wizard::MainWizard::importerStarted() {}
|
||||
|
||||
void Wizard::MainWizard::importerFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
if (exitCode != 0 || exitStatus == QProcess::CrashExit)
|
||||
@@ -430,7 +415,8 @@ bool Wizard::MainWizard::findFiles(const QString& name, const QString& path)
|
||||
if (!dir.exists())
|
||||
return false;
|
||||
|
||||
const QStringList entries = dir.entryList();
|
||||
// TODO: add MIME handling to make sure the files are real
|
||||
return (dir.entryList().contains(name + QLatin1String(".esm"), Qt::CaseInsensitive)
|
||||
&& dir.entryList().contains(name + QLatin1String(".bsa"), Qt::CaseInsensitive));
|
||||
return entries.contains(name + QLatin1String(".esm"), Qt::CaseInsensitive)
|
||||
&& entries.contains(name + QLatin1String(".bsa"), Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
@@ -56,9 +56,9 @@ namespace Wizard
|
||||
|
||||
Files::ConfigurationManager mCfgMgr;
|
||||
|
||||
Process::ProcessInvoker* mImporterInvoker;
|
||||
std::unique_ptr<Process::ProcessInvoker> mImporterInvoker;
|
||||
|
||||
bool mError;
|
||||
bool mError{ false };
|
||||
|
||||
private:
|
||||
void setupGameSettings();
|
||||
@@ -73,7 +73,6 @@ namespace Wizard
|
||||
|
||||
private slots:
|
||||
|
||||
void importerStarted();
|
||||
void importerFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
|
||||
void accept() override;
|
||||
|
||||
@@ -20,7 +20,6 @@ Wizard::MethodSelectionPage::MethodSelectionPage(QWidget* parent)
|
||||
#ifndef OPENMW_USE_UNSHIELD
|
||||
retailDiscRadioButton->setEnabled(false);
|
||||
existingLocationRadioButton->setChecked(true);
|
||||
buyLinkButton->released();
|
||||
#endif
|
||||
|
||||
QFont font = existingLocationRadioButton->font();
|
||||
|
||||
Reference in New Issue
Block a user