Fixed the first run dialog, makes sure Morrowind.ini is found

This commit is contained in:
pvdk 2013-03-16 01:46:28 +01:00
parent a74749099e
commit c15d920133
2 changed files with 56 additions and 40 deletions

View file

@ -147,7 +147,7 @@ void DataFilesPage::setupDataFiles()
profilesComboBox->addItems(profiles); profilesComboBox->addItems(profiles);
// Add the current profile if empty // Add the current profile if empty
if (profilesComboBox->findText(profile) == -1) if (profilesComboBox->findText(profile) == -1 && !profile.isEmpty())
profilesComboBox->addItem(profile); profilesComboBox->addItem(profile);
if (profilesComboBox->findText(QString("Default")) == -1) if (profilesComboBox->findText(QString("Default")) == -1)

View file

@ -122,32 +122,6 @@ void MainDialog::createPages()
bool MainDialog::showFirstRunDialog() bool MainDialog::showFirstRunDialog()
{ {
CheckableMessageBox msgBox(this);
msgBox.setWindowTitle(tr("Morrowind installation detected"));
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion);
int size = QApplication::style()->pixelMetric(QStyle::PM_MessageBoxIconSize);
msgBox.setIconPixmap(icon.pixmap(size, size));
QAbstractButton *importerButton =
msgBox.addButton(tr("Import"), QDialogButtonBox::AcceptRole); // ActionRole doesn't work?!
QAbstractButton *skipButton =
msgBox.addButton(tr("Skip"), QDialogButtonBox::RejectRole);
Q_UNUSED(skipButton); // Surpress compiler unused warning
msgBox.setStandardButtons(QDialogButtonBox::NoButton);
msgBox.setText(tr("<br><b>An existing Morrowind installation was detected</b><br><br> \
Would you like to import settings from Morrowind.ini?<br>"));
msgBox.setCheckBoxText(tr("Include selected masters and plugins (creates a new profile)"));
msgBox.exec();
if (msgBox.clickedButton() == importerButton) {
QStringList iniPaths; QStringList iniPaths;
foreach (const QString &path, mGameSettings.getDataDirs()) { foreach (const QString &path, mGameSettings.getDataDirs()) {
@ -161,18 +135,61 @@ bool MainDialog::showFirstRunDialog()
iniPaths.append(dir.absoluteFilePath(QString("Morrowind.ini"))); iniPaths.append(dir.absoluteFilePath(QString("Morrowind.ini")));
} }
if (iniPaths.isEmpty()) { // Ask the user where the Morrowind.ini is
if (iniPaths.empty()) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error reading Morrowind configuration file")); msgBox.setWindowTitle(tr("Error detecting Morrowind configuration"));
msgBox.setIcon(QMessageBox::Warning); msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setStandardButtons(QMessageBox::Cancel);
msgBox.setText(QObject::tr("<br><b>Could not find Morrowind.ini</b><br><br> \ msgBox.setText(QObject::tr("<br><b>Could not find Morrowind.ini</b><br><br> \
The problem may be due to an incomplete installation of Morrowind.<br> \ OpenMW needs to import settings from this file.<br><br> \
Reinstalling Morrowind may resolve the problem.")); Press \"Browse...\" to specify the location manually.<br>"));
QAbstractButton *dirSelectButton =
msgBox.addButton(QObject::tr("B&rowse..."), QMessageBox::ActionRole);
msgBox.exec(); msgBox.exec();
return false;
QString iniFile;
if (msgBox.clickedButton() == dirSelectButton) {
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;
QFileInfo info(iniFile);
iniPaths.clear();
iniPaths.append(info.absoluteFilePath());
}
CheckableMessageBox msgBox(this);
msgBox.setWindowTitle(tr("Morrowind installation detected"));
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion);
int size = QApplication::style()->pixelMetric(QStyle::PM_MessageBoxIconSize);
msgBox.setIconPixmap(icon.pixmap(size, size));
QAbstractButton *importerButton =
msgBox.addButton(tr("Import"), QDialogButtonBox::AcceptRole); // ActionRole doesn't work?!
QAbstractButton *skipButton =
msgBox.addButton(tr("Skip"), QDialogButtonBox::RejectRole);
Q_UNUSED(skipButton); // Surpress compiler unused warning
msgBox.setStandardButtons(QDialogButtonBox::NoButton);
msgBox.setText(tr("<br><b>An existing Morrowind configuration was detected</b><br><br> \
Would you like to import settings from Morrowind.ini?<br>"));
msgBox.setCheckBoxText(tr("Include selected masters and plugins (creates a new profile)"));
msgBox.exec();
if (msgBox.clickedButton() == importerButton) {
if (iniPaths.count() > 1) { if (iniPaths.count() > 1) {
// Multiple Morrowind.ini files found // Multiple Morrowind.ini files found
bool ok; bool ok;
@ -183,7 +200,7 @@ bool MainDialog::showFirstRunDialog()
iniPaths.clear(); iniPaths.clear();
iniPaths.append(path); iniPaths.append(path);
} else { } else {
// Cancel was clicked TODO: should we abort here? // Cancel was clicked
return false; return false;
} }
} }
@ -212,7 +229,6 @@ bool MainDialog::showFirstRunDialog()
// Construct the arguments to run the importer // Construct the arguments to run the importer
QStringList arguments; QStringList arguments;
if (msgBox.isChecked()) if (msgBox.isChecked())
arguments.append(QString("--game-files")); arguments.append(QString("--game-files"));
@ -232,7 +248,7 @@ bool MainDialog::showFirstRunDialog()
// Add a new profile // Add a new profile
if (msgBox.isChecked()) { if (msgBox.isChecked()) {
mLauncherSettings.setValue(QString("Profiles/CurrentProfile"), QString("Imported")); mLauncherSettings.setValue(QString("Profiles/currentprofile"), QString("Imported"));
mLauncherSettings.remove(QString("Profiles/Imported/master")); mLauncherSettings.remove(QString("Profiles/Imported/master"));
mLauncherSettings.remove(QString("Profiles/Imported/plugin")); mLauncherSettings.remove(QString("Profiles/Imported/plugin"));