1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-29 22:20:33 +00:00

Some minor fixes

This commit is contained in:
pvdk 2014-02-18 12:44:27 +01:00
parent 6916c0bc94
commit 755c99df3c
7 changed files with 36 additions and 40 deletions

View File

@ -16,7 +16,7 @@ Wizard::ComponentSelectionPage::ComponentSelectionPage(MainWizard *wizard) :
setCommitPage(true); setCommitPage(true);
setButtonText(QWizard::CommitButton, tr("&Install")); setButtonText(QWizard::CommitButton, tr("&Install"));
registerField("installation.components", componentsList); registerField(QLatin1String("installation.components"), componentsList);
connect(componentsList, SIGNAL(itemChanged(QListWidgetItem *)), connect(componentsList, SIGNAL(itemChanged(QListWidgetItem *)),
this, SLOT(updateButton(QListWidgetItem *))); this, SLOT(updateButton(QListWidgetItem *)));
@ -25,7 +25,7 @@ Wizard::ComponentSelectionPage::ComponentSelectionPage(MainWizard *wizard) :
void Wizard::ComponentSelectionPage::updateButton(QListWidgetItem *item) void Wizard::ComponentSelectionPage::updateButton(QListWidgetItem *item)
{ {
if (field("installation.new").toBool() == true) if (field(QLatin1String("installation.new")).toBool() == true)
return; // Morrowind is always checked here return; // Morrowind is always checked here
bool unchecked = true; bool unchecked = true;
@ -53,13 +53,13 @@ void Wizard::ComponentSelectionPage::initializePage()
{ {
componentsList->clear(); componentsList->clear();
QString path(field("installation.path").toString()); QString path(field(QLatin1String("installation.path")).toString());
QListWidgetItem *morrowindItem = new QListWidgetItem(QLatin1String("Morrowind")); QListWidgetItem *morrowindItem = new QListWidgetItem(QLatin1String("Morrowind"));
QListWidgetItem *tribunalItem = new QListWidgetItem(QLatin1String("Tribunal")); QListWidgetItem *tribunalItem = new QListWidgetItem(QLatin1String("Tribunal"));
QListWidgetItem *bloodmoonItem = new QListWidgetItem(QLatin1String("Bloodmoon")); QListWidgetItem *bloodmoonItem = new QListWidgetItem(QLatin1String("Bloodmoon"));
if (field("installation.new").toBool() == true) if (field(QLatin1String("installation.new")).toBool() == true)
{ {
morrowindItem->setFlags(morrowindItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable); morrowindItem->setFlags(morrowindItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable);
morrowindItem->setData(Qt::CheckStateRole, Qt::Checked); morrowindItem->setData(Qt::CheckStateRole, Qt::Checked);
@ -111,12 +111,12 @@ void Wizard::ComponentSelectionPage::initializePage()
bool Wizard::ComponentSelectionPage::validatePage() bool Wizard::ComponentSelectionPage::validatePage()
{ {
QStringList components(field("installation.components").toStringList()); QStringList components(field(QLatin1String("installation.components")).toStringList());
QString path(field("installation.path").toString()); QString path(field(QLatin1String("installation.path")).toString());
qDebug() << components << path << mWizard->mInstallations[path]; qDebug() << components << path << mWizard->mInstallations[path];
if (field("installation.new").toBool() == false) { if (field(QLatin1String("installation.new")).toBool() == false) {
if (components.contains(QLatin1String("Tribunal")) && !components.contains(QLatin1String("Bloodmoon"))) if (components.contains(QLatin1String("Tribunal")) && !components.contains(QLatin1String("Bloodmoon")))
{ {
if (mWizard->mInstallations[path]->hasBloodmoon) if (mWizard->mInstallations[path]->hasBloodmoon)

View File

@ -13,9 +13,15 @@ Wizard::ConclusionPage::ConclusionPage(MainWizard *wizard) :
void Wizard::ConclusionPage::initializePage() void Wizard::ConclusionPage::initializePage()
{ {
// Write the path to openmw.cfg
if (field(QLatin1String("installation.new")).toBool() == true) {
QString path(field(QLatin1String("installation.path")).toString());
mWizard->addInstallation(path);
}
if (!mWizard->mError) if (!mWizard->mError)
{ {
if (field("installation.new").toBool() == true) if (field(QLatin1String("installation.new")).toBool() == true)
{ {
textLabel->setText(tr("<html><head/><body><p>The OpenMW Wizard successfully installed Morrowind on your computer.</p> \ textLabel->setText(tr("<html><head/><body><p>The OpenMW Wizard successfully installed Morrowind on your computer.</p> \
<p>Click Finish to close the Wizard.</p></body></html>")); <p>Click Finish to close the Wizard.</p></body></html>"));

View File

@ -82,7 +82,7 @@ bool Wizard::ExistingInstallationPage::validatePage()
// It can be missing entirely // It can be missing entirely
// Or failed to be detected due to the target being a symlink // Or failed to be detected due to the target being a symlink
QString path(field("installation.path").toString()); QString path(field(QLatin1String("installation.path")).toString());
QFile file(mWizard->mInstallations[path]->iniPath); QFile file(mWizard->mInstallations[path]->iniPath);
if (!file.exists()) { if (!file.exists()) {
@ -131,7 +131,7 @@ bool Wizard::ExistingInstallationPage::isComplete() const
int Wizard::ExistingInstallationPage::nextId() const int Wizard::ExistingInstallationPage::nextId() const
{ {
QString path(field("installation.path").toString()); QString path(field(QLatin1String("installation.path")).toString());
if (path.isEmpty()) if (path.isEmpty())
return MainWizard::Page_LanguageSelection; return MainWizard::Page_LanguageSelection;

View File

@ -131,30 +131,20 @@ bool Wizard::IniSettings::writeFile(const QString &path, QTextStream &stream)
int index = buffer.lastIndexOf(section); int index = buffer.lastIndexOf(section);
if (index != -1) { if (index != -1) {
// Append the new keys to the bottom of the section // Look for the next section
index = buffer.indexOf(QLatin1Char('['), index + 1); index = buffer.indexOf(QLatin1Char('['), index + 1);
if (index == -1 ) if (index == -1 ) {
{ // We are at the last section, append it to the bottom of the file
// Beginning of next section not found, we are at the last section buffer.append(QString("\n%1=%2").arg(key, i.value().toString()));
if (buffer.lastIndexOf(QLatin1String("\n")) > (buffer.lastIndexOf(section) + section.length())) { mSettings.remove(i.key());
// There is a newline after the section continue;
index = buffer.lastIndexOf(QLatin1String("\n")) - 1; } else {
buffer.insert(index - 2, QString("\n%1=%2").arg(key, i.value().toString())); // Not at last section, add the key at the index
mSettings.remove(i.key()); buffer.insert(index - 1, QString("\n%1=%2").arg(key, i.value().toString()));
continue; mSettings.remove(i.key());
} else {
// No newline found, or the last newline is before the last section
// Append the key to the bottom of the file
buffer.append(QString("\n%1=%2").arg(key, i.value().toString()));
mSettings.remove(i.key());
continue;
}
} }
// Add the key at the index
buffer.insert(index - 1, QString("\n%1=%2").arg(key, i.value().toString()));
mSettings.remove(i.key());
} else { } else {
// Add the section to the end of the file, because it's not found // Add the section to the end of the file, because it's not found
buffer.append(QString("\n%1\n").arg(section)); buffer.append(QString("\n%1\n").arg(section));

View File

@ -20,8 +20,8 @@ Wizard::InstallationPage::InstallationPage(MainWizard *wizard) :
void Wizard::InstallationPage::initializePage() void Wizard::InstallationPage::initializePage()
{ {
QString path(field("installation.path").toString()); QString path(field(QLatin1String("installation.path")).toString());
QStringList components(field("installation.components").toStringList()); QStringList components(field(QLatin1String("installation.components")).toStringList());
logTextEdit->appendPlainText(QString("Installing to %1").arg(path)); logTextEdit->appendPlainText(QString("Installing to %1").arg(path));
logTextEdit->appendPlainText(QString("Installing %1.").arg(components.join(", "))); logTextEdit->appendPlainText(QString("Installing %1.").arg(components.join(", ")));
@ -32,7 +32,7 @@ void Wizard::InstallationPage::initializePage()
// That way installing all three components would yield 300% // That way installing all three components would yield 300%
// When one component is done the bar will be filled by 33% // When one component is done the bar will be filled by 33%
if (field("installation.new").toBool() == true) { if (field(QLatin1String("installation.new")).toBool() == true) {
installProgressBar->setMaximum((components.count() * 100)); installProgressBar->setMaximum((components.count() * 100));
} else { } else {
if (components.contains(QLatin1String("Tribunal")) if (components.contains(QLatin1String("Tribunal"))
@ -49,8 +49,8 @@ void Wizard::InstallationPage::initializePage()
void Wizard::InstallationPage::startInstallation() void Wizard::InstallationPage::startInstallation()
{ {
QStringList components(field("installation.components").toStringList()); QStringList components(field(QLatin1String("installation.components")).toStringList());
QString path(field("installation.path").toString()); QString path(field(QLatin1String("installation.path")).toString());
QThread *thread = new QThread(); QThread *thread = new QThread();
mUnshield = new UnshieldWorker(); mUnshield = new UnshieldWorker();
@ -86,7 +86,7 @@ void Wizard::InstallationPage::startInstallation()
connect(mUnshield, SIGNAL(requestFileDialog(Wizard::Component)), connect(mUnshield, SIGNAL(requestFileDialog(Wizard::Component)),
this, SLOT(showFileDialog(Wizard::Component)), Qt::QueuedConnection); this, SLOT(showFileDialog(Wizard::Component)), Qt::QueuedConnection);
if (field("installation.new").toBool() == true) if (field(QLatin1String("installation.new")).toBool() == true)
{ {
// Always install Morrowind // Always install Morrowind
mUnshield->setInstallComponent(Wizard::Component_Morrowind, true); mUnshield->setInstallComponent(Wizard::Component_Morrowind, true);
@ -117,7 +117,7 @@ void Wizard::InstallationPage::startInstallation()
mUnshield->setPath(path); mUnshield->setPath(path);
// Set the right codec to use for Morrowind.ini // Set the right codec to use for Morrowind.ini
QString language(field("installation.language").toString()); QString language(field(QLatin1String("installation.language")).toString());
if (language == QLatin1String("Polish")) { if (language == QLatin1String("Polish")) {
mUnshield->setIniCodec(QTextCodec::codecForName("windows-1250")); mUnshield->setIniCodec(QTextCodec::codecForName("windows-1250"));

View File

@ -27,7 +27,7 @@ void Wizard::InstallationTargetPage::initializePage()
bool Wizard::InstallationTargetPage::validatePage() bool Wizard::InstallationTargetPage::validatePage()
{ {
QString path(field("installation.path").toString()); QString path(field(QLatin1String("installation.path")).toString());
qDebug() << "Validating path: " << path; qDebug() << "Validating path: " << path;

View File

@ -8,12 +8,12 @@ Wizard::MethodSelectionPage::MethodSelectionPage(MainWizard *wizard) :
{ {
setupUi(this); setupUi(this);
registerField("installation.new", newLocationRadioButton); registerField(QLatin1String("installation.new"), newLocationRadioButton);
} }
int Wizard::MethodSelectionPage::nextId() const int Wizard::MethodSelectionPage::nextId() const
{ {
if (field("installation.new").toBool() == true) { if (field(QLatin1String("installation.new")).toBool() == true) {
return MainWizard::Page_InstallationTarget; return MainWizard::Page_InstallationTarget;
} else { } else {
return MainWizard::Page_ExistingInstallation; return MainWizard::Page_ExistingInstallation;