mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Settings tab is fully functional now
This commit is contained in:
parent
a2c129f655
commit
f8bb797b8a
5 changed files with 104 additions and 53 deletions
|
@ -42,7 +42,7 @@ void Launcher::DataFilesPage::loadSettings()
|
||||||
|
|
||||||
QString profileName = ui.profilesComboBox->currentText();
|
QString profileName = ui.profilesComboBox->currentText();
|
||||||
|
|
||||||
QStringList files = mLauncherSettings.values(QString("Profiles/") + profileName, Qt::MatchExactly);
|
QStringList files = mLauncherSettings.values(QString("Profiles/") + profileName + QString("/content"), Qt::MatchExactly);
|
||||||
|
|
||||||
QStringList filepaths;
|
QStringList filepaths;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ void Launcher::DataFilesPage::saveSettings(const QString &profile)
|
||||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), ui.profilesComboBox->currentText());
|
mLauncherSettings.setValue(QString("Profiles/currentprofile"), ui.profilesComboBox->currentText());
|
||||||
|
|
||||||
foreach(const ContentSelectorModel::EsmFile *item, items) {
|
foreach(const ContentSelectorModel::EsmFile *item, items) {
|
||||||
mLauncherSettings.setMultiValue(QString("Profiles/") + profileName, item->fileName());
|
mLauncherSettings.setMultiValue(QString("Profiles/") + profileName + QString("/content"), item->fileName());
|
||||||
mGameSettings.setMultiValue(QString("content"), item->fileName());
|
mGameSettings.setMultiValue(QString("content"), item->fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,21 +192,21 @@ void Launcher::DataFilesPage::setupDataFiles()
|
||||||
if (!mDataLocal.isEmpty())
|
if (!mDataLocal.isEmpty())
|
||||||
mSelector->addFiles(mDataLocal);
|
mSelector->addFiles(mDataLocal);
|
||||||
|
|
||||||
QStringList profiles;
|
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
|
||||||
QString currentProfile = mLauncherSettings.getSettings().value("Profiles/currentprofile");
|
QString currentProfile = mLauncherSettings.getSettings().value("Profiles/currentprofile");
|
||||||
|
|
||||||
foreach (QString key, mLauncherSettings.getSettings().keys())
|
// foreach (QString key, mLauncherSettings.getSettings().keys())
|
||||||
{
|
// {
|
||||||
if (key.contains("Profiles/"))
|
// if (key.contains("Profiles/"))
|
||||||
{
|
// {
|
||||||
QString profile = key.mid (9);
|
// QString profile = key.mid (9);
|
||||||
if (profile != "currentprofile")
|
// if (profile != "currentprofile")
|
||||||
{
|
// {
|
||||||
if (!profiles.contains(profile))
|
// if (!profiles.contains(profile))
|
||||||
profiles << profile;
|
// profiles << profile;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
foreach (const QString &item, profiles)
|
foreach (const QString &item, profiles)
|
||||||
addProfile (item, false);
|
addProfile (item, false);
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#include "settingspage.hpp"
|
#include "settingspage.hpp"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
#include <components/config/gamesettings.hpp>
|
#include <components/config/gamesettings.hpp>
|
||||||
#include <components/config/launchersettings.hpp>
|
#include <components/config/launchersettings.hpp>
|
||||||
|
@ -20,13 +22,13 @@ Launcher::SettingsPage::SettingsPage(Config::GameSettings &gameSettings,
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
QStringList languages;
|
QStringList languages;
|
||||||
languages << "English"
|
languages << QLatin1String("English")
|
||||||
<< "French"
|
<< QLatin1String("French")
|
||||||
<< "German"
|
<< QLatin1String("German")
|
||||||
<< "Italian"
|
<< QLatin1String("Italian")
|
||||||
<< "Polish"
|
<< QLatin1String("Polish")
|
||||||
<< "Russian"
|
<< QLatin1String("Russian")
|
||||||
<< "Spanish";
|
<< QLatin1String("Spanish");
|
||||||
|
|
||||||
languageComboBox->addItems(languages);
|
languageComboBox->addItems(languages);
|
||||||
|
|
||||||
|
@ -50,22 +52,31 @@ Launcher::SettingsPage::SettingsPage(Config::GameSettings &gameSettings,
|
||||||
connect(mProfileDialog->lineEdit(), SIGNAL(textChanged(QString)),
|
connect(mProfileDialog->lineEdit(), SIGNAL(textChanged(QString)),
|
||||||
this, SLOT(updateOkButton(QString)));
|
this, SLOT(updateOkButton(QString)));
|
||||||
|
|
||||||
// // Detect Morrowind configuration files
|
// Detect Morrowind configuration files
|
||||||
// foreach (const QString &path, mGameSettings.getDataDirs()) {
|
QStringList iniPaths;
|
||||||
// QDir dir(path);
|
|
||||||
// dir.setPath(dir.canonicalPath()); // Resolve symlinks
|
|
||||||
|
|
||||||
// if (dir.exists(QString("Morrowind.ini")))
|
foreach (const QString &path, mGameSettings.getDataDirs()) {
|
||||||
// iniPaths.append(dir.absoluteFilePath(QString("Morrowind.ini")));
|
QDir dir(path);
|
||||||
// else
|
dir.setPath(dir.canonicalPath()); // Resolve symlinks
|
||||||
// {
|
|
||||||
// if (!dir.cdUp())
|
|
||||||
// continue; // Cannot move from Data Files
|
|
||||||
|
|
||||||
// if (dir.exists(QString("Morrowind.ini")))
|
if (dir.exists(QString("Morrowind.ini")))
|
||||||
// iniPaths.append(dir.absoluteFilePath(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()
|
void Launcher::SettingsPage::on_wizardButton_clicked()
|
||||||
|
@ -80,6 +91,32 @@ void Launcher::SettingsPage::on_importerButton_clicked()
|
||||||
return;
|
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()
|
void Launcher::SettingsPage::wizardStarted()
|
||||||
{
|
{
|
||||||
qDebug() << "wizard started!";
|
qDebug() << "wizard started!";
|
||||||
|
@ -109,18 +146,27 @@ void Launcher::SettingsPage::importerFinished(int exitCode, QProcess::ExitStatus
|
||||||
if (exitCode != 0 || exitStatus == QProcess::CrashExit)
|
if (exitCode != 0 || exitStatus == QProcess::CrashExit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
foreach (const QString &file, files) {
|
||||||
|
mLauncherSettings.setMultiValue(QLatin1String("Profiles/") + profile + QLatin1String("/content"), file);
|
||||||
|
}
|
||||||
|
|
||||||
|
mGameSettings.remove(QLatin1String("content"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mMain->writeSettings();
|
mMain->writeSettings();
|
||||||
mMain->reloadSettings();
|
mMain->reloadSettings();
|
||||||
|
|
||||||
|
|
||||||
if (addonsCheckBox->isChecked()) {
|
|
||||||
|
|
||||||
if (mProfileDialog->exec() == QDialog::Accepted) {
|
|
||||||
QString profile = mProfileDialog->lineEdit()->text();
|
|
||||||
qDebug() << profile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
importerButton->setEnabled(true);
|
importerButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,8 +178,9 @@ void Launcher::SettingsPage::updateOkButton(const QString &text)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QStringList profiles(mLauncherSettings.subKeys(QString("Profiles/")));
|
||||||
|
|
||||||
// (profilesComboBox->findText(text) == -1)
|
(profiles.contains(text))
|
||||||
// ? mNewProfileDialog->setOkButtonEnabled(true)
|
? mProfileDialog->setOkButtonEnabled(false)
|
||||||
// : mNewProfileDialog->setOkButtonEnabled(false);
|
: mProfileDialog->setOkButtonEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ namespace Launcher
|
||||||
private slots:
|
private slots:
|
||||||
void on_wizardButton_clicked();
|
void on_wizardButton_clicked();
|
||||||
void on_importerButton_clicked();
|
void on_importerButton_clicked();
|
||||||
|
void on_browseButton_clicked();
|
||||||
|
|
||||||
void wizardStarted();
|
void wizardStarted();
|
||||||
void wizardFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
void wizardFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||||
|
|
|
@ -72,7 +72,7 @@ bool Wizard::ExistingInstallationPage::validatePage()
|
||||||
QString iniFile;
|
QString iniFile;
|
||||||
if (msgBox.clickedButton() == browseButton) {
|
if (msgBox.clickedButton() == browseButton) {
|
||||||
iniFile = QFileDialog::getOpenFileName(
|
iniFile = QFileDialog::getOpenFileName(
|
||||||
NULL,
|
this,
|
||||||
QObject::tr("Select configuration file"),
|
QObject::tr("Select configuration file"),
|
||||||
QDir::currentPath(),
|
QDir::currentPath(),
|
||||||
QString(tr("Morrowind configuration file (*.ini)")));
|
QString(tr("Morrowind configuration file (*.ini)")));
|
||||||
|
@ -100,6 +100,9 @@ void Wizard::ExistingInstallationPage::on_browseButton_clicked()
|
||||||
NULL,
|
NULL,
|
||||||
QFileDialog::DontResolveSymlinks);
|
QFileDialog::DontResolveSymlinks);
|
||||||
|
|
||||||
|
if (selectedFile.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
QFileInfo info(selectedFile);
|
QFileInfo info(selectedFile);
|
||||||
|
|
||||||
if (!info.exists())
|
if (!info.exists())
|
||||||
|
|
|
@ -14,13 +14,13 @@ Wizard::LanguageSelectionPage::LanguageSelectionPage(MainWizard *wizard) :
|
||||||
void Wizard::LanguageSelectionPage::initializePage()
|
void Wizard::LanguageSelectionPage::initializePage()
|
||||||
{
|
{
|
||||||
QStringList languages;
|
QStringList languages;
|
||||||
languages << "English"
|
languages << QLatin1String("English")
|
||||||
<< "French"
|
<< QLatin1String("French")
|
||||||
<< "German"
|
<< QLatin1String("German")
|
||||||
<< "Italian"
|
<< QLatin1String("Italian")
|
||||||
<< "Polish"
|
<< QLatin1String("Polish")
|
||||||
<< "Russian"
|
<< QLatin1String("Russian")
|
||||||
<< "Spanish";
|
<< QLatin1String("Spanish");
|
||||||
|
|
||||||
languageComboBox->addItems(languages);
|
languageComboBox->addItems(languages);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue