|
|
|
@ -1,7 +1,9 @@
|
|
|
|
|
#include "settingspage.hpp"
|
|
|
|
|
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
|
|
|
|
|
#include <components/config/gamesettings.hpp>
|
|
|
|
|
#include <components/config/launchersettings.hpp>
|
|
|
|
@ -20,13 +22,13 @@ Launcher::SettingsPage::SettingsPage(Config::GameSettings &gameSettings,
|
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
|
|
QStringList languages;
|
|
|
|
|
languages << "English"
|
|
|
|
|
<< "French"
|
|
|
|
|
<< "German"
|
|
|
|
|
<< "Italian"
|
|
|
|
|
<< "Polish"
|
|
|
|
|
<< "Russian"
|
|
|
|
|
<< "Spanish";
|
|
|
|
|
languages << QLatin1String("English")
|
|
|
|
|
<< QLatin1String("French")
|
|
|
|
|
<< QLatin1String("German")
|
|
|
|
|
<< QLatin1String("Italian")
|
|
|
|
|
<< QLatin1String("Polish")
|
|
|
|
|
<< QLatin1String("Russian")
|
|
|
|
|
<< QLatin1String("Spanish");
|
|
|
|
|
|
|
|
|
|
languageComboBox->addItems(languages);
|
|
|
|
|
|
|
|
|
@ -50,22 +52,31 @@ Launcher::SettingsPage::SettingsPage(Config::GameSettings &gameSettings,
|
|
|
|
|
connect(mProfileDialog->lineEdit(), SIGNAL(textChanged(QString)),
|
|
|
|
|
this, SLOT(updateOkButton(QString)));
|
|
|
|
|
|
|
|
|
|
// // Detect Morrowind configuration files
|
|
|
|
|
// foreach (const QString &path, mGameSettings.getDataDirs()) {
|
|
|
|
|
// QDir dir(path);
|
|
|
|
|
// dir.setPath(dir.canonicalPath()); // Resolve symlinks
|
|
|
|
|
|
|
|
|
|
// if (dir.exists(QString("Morrowind.ini")))
|
|
|
|
|
// iniPaths.append(dir.absoluteFilePath(QString("Morrowind.ini")));
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// if (!dir.cdUp())
|
|
|
|
|
// continue; // Cannot move from Data Files
|
|
|
|
|
|
|
|
|
|
// if (dir.exists(QString("Morrowind.ini")))
|
|
|
|
|
// iniPaths.append(dir.absoluteFilePath(QString("Morrowind.ini")));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// Detect Morrowind configuration files
|
|
|
|
|
QStringList iniPaths;
|
|
|
|
|
|
|
|
|
|
foreach (const QString &path, mGameSettings.getDataDirs()) {
|
|
|
|
|
QDir dir(path);
|
|
|
|
|
dir.setPath(dir.canonicalPath()); // Resolve symlinks
|
|
|
|
|
|
|
|
|
|
if (dir.exists(QString("Morrowind.ini")))
|
|
|
|
|
iniPaths.append(dir.absoluteFilePath(QString("Morrowind.ini")));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!dir.cdUp())
|
|
|
|
|
continue; // Cannot move from Data Files
|
|
|
|
|
|
|
|
|
|
if (dir.exists(QString("Morrowind.ini")))
|
|
|
|
|
iniPaths.append(dir.absoluteFilePath(QString("Morrowind.ini")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!iniPaths.isEmpty()) {
|
|
|
|
|
settingsComboBox->addItems(iniPaths);
|
|
|
|
|
importerButton->setEnabled(true);
|
|
|
|
|
} else {
|
|
|
|
|
importerButton->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Launcher::SettingsPage::on_wizardButton_clicked()
|
|
|
|
@ -80,6 +91,32 @@ void Launcher::SettingsPage::on_importerButton_clicked()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Launcher::SettingsPage::on_browseButton_clicked()
|
|
|
|
|
{
|
|
|
|
|
QString iniFile = QFileDialog::getOpenFileName(
|
|
|
|
|
this,
|
|
|
|
|
QObject::tr("Select configuration file"),
|
|
|
|
|
QDir::currentPath(),
|
|
|
|
|
QString(tr("Morrowind configuration file (*.ini)")));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (iniFile.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QFileInfo info(iniFile);
|
|
|
|
|
|
|
|
|
|
if (!info.exists() || !info.isReadable())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const QString path(QDir::toNativeSeparators(info.absoluteFilePath()));
|
|
|
|
|
|
|
|
|
|
if (settingsComboBox->findText(path) == -1) {
|
|
|
|
|
settingsComboBox->addItem(path);
|
|
|
|
|
settingsComboBox->setCurrentIndex(settingsComboBox->findText(path));
|
|
|
|
|
importerButton->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Launcher::SettingsPage::wizardStarted()
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "wizard started!";
|
|
|
|
@ -109,18 +146,27 @@ void Launcher::SettingsPage::importerFinished(int exitCode, QProcess::ExitStatus
|
|
|
|
|
if (exitCode != 0 || exitStatus == QProcess::CrashExit)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
mMain->writeSettings();
|
|
|
|
|
mMain->reloadSettings();
|
|
|
|
|
// Import selected data files from openmw.cfg
|
|
|
|
|
if (addonsCheckBox->isChecked())
|
|
|
|
|
{
|
|
|
|
|
if (mProfileDialog->exec() == QDialog::Accepted)
|
|
|
|
|
{
|
|
|
|
|
const QString profile(mProfileDialog->lineEdit()->text());
|
|
|
|
|
const QStringList files(mGameSettings.values(QLatin1String("content")));
|
|
|
|
|
|
|
|
|
|
// Doesn't quite work right now
|
|
|
|
|
mLauncherSettings.setValue(QLatin1String("Profiles/currentprofile"), profile);
|
|
|
|
|
|
|
|
|
|
if (addonsCheckBox->isChecked()) {
|
|
|
|
|
foreach (const QString &file, files) {
|
|
|
|
|
mLauncherSettings.setMultiValue(QLatin1String("Profiles/") + profile + QLatin1String("/content"), file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mProfileDialog->exec() == QDialog::Accepted) {
|
|
|
|
|
QString profile = mProfileDialog->lineEdit()->text();
|
|
|
|
|
qDebug() << profile;
|
|
|
|
|
mGameSettings.remove(QLatin1String("content"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mMain->writeSettings();
|
|
|
|
|
mMain->reloadSettings();
|
|
|
|
|
importerButton->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -132,8 +178,9 @@ void Launcher::SettingsPage::updateOkButton(const QString &text)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QStringList profiles(mLauncherSettings.subKeys(QString("Profiles/")));
|
|
|
|
|
|
|
|
|
|
// (profilesComboBox->findText(text) == -1)
|
|
|
|
|
// ? mNewProfileDialog->setOkButtonEnabled(true)
|
|
|
|
|
// : mNewProfileDialog->setOkButtonEnabled(false);
|
|
|
|
|
(profiles.contains(text))
|
|
|
|
|
? mProfileDialog->setOkButtonEnabled(false)
|
|
|
|
|
: mProfileDialog->setOkButtonEnabled(true);
|
|
|
|
|
}
|
|
|
|
|