Fixed some problems with the launcher and the wizard

loadfix
pvdk 11 years ago
parent a390dde818
commit 6348af586e

@ -36,7 +36,7 @@ Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, Config:
this, SLOT(updateOkButton(QString))); this, SLOT(updateOkButton(QString)));
buildView(); buildView();
setupDataFiles(); loadSettings();
} }
void Launcher::DataFilesPage::buildView() void Launcher::DataFilesPage::buildView()
@ -67,7 +67,7 @@ void Launcher::DataFilesPage::buildView()
this, SLOT (slotProfileChangedByUser(QString, QString))); this, SLOT (slotProfileChangedByUser(QString, QString)));
} }
void Launcher::DataFilesPage::setupDataFiles() bool Launcher::DataFilesPage::loadSettings()
{ {
QStringList paths = mGameSettings.getDataDirs(); QStringList paths = mGameSettings.getDataDirs();
@ -79,12 +79,6 @@ void Launcher::DataFilesPage::setupDataFiles()
if (!mDataLocal.isEmpty()) if (!mDataLocal.isEmpty())
mSelector->addFiles(mDataLocal); mSelector->addFiles(mDataLocal);
loadSettings();
}
bool Launcher::DataFilesPage::loadSettings()
{
QStringList paths = mGameSettings.getDataDirs();
paths.insert (0, mDataLocal); paths.insert (0, mDataLocal);
PathIterator pathIterator (paths); PathIterator pathIterator (paths);

@ -41,8 +41,6 @@ namespace Launcher
void saveSettings(const QString &profile = ""); void saveSettings(const QString &profile = "");
bool loadSettings(); bool loadSettings();
void setupDataFiles();
signals: signals:
void signalProfileChanged (int index); void signalProfileChanged (int index);

@ -52,12 +52,12 @@ int main(int argc, char *argv[])
Launcher::MainDialog mainWin; Launcher::MainDialog mainWin;
if (!mainWin.setup()) { if (!mainWin.showFirstRunDialog())
return 0; return 0;
//mainWin.show();
}/* else { // if (!mainWin.setup())
return 0; // return 0;
}*/
int returnValue = app.exec(); int returnValue = app.exec();
SDL_Quit(); SDL_Quit();

@ -165,40 +165,44 @@ void Launcher::MainDialog::createPages()
bool Launcher::MainDialog::showFirstRunDialog() bool Launcher::MainDialog::showFirstRunDialog()
{ {
QMessageBox msgBox; if (!setupLauncherSettings())
msgBox.setWindowTitle(tr("First run")); return false;
msgBox.setIcon(QMessageBox::Question);
msgBox.setStandardButtons(QMessageBox::NoButton); if (mLauncherSettings.value(QString("General/firstrun"), QString("true")) == QLatin1String("true"))
msgBox.setText(tr("<html><head/><body><p><b>Welcome to OpenMW!</b></p> \
<p>It is recommended to run the Installation Wizard.</p> \
<p>The Wizard will let you select an existing Morrowind installation, \
or install Morrowind for OpenMW to use.</p></body></html>"));
QAbstractButton *wizardButton =
msgBox.addButton(tr("Run &Installation Wizard"), QMessageBox::AcceptRole); // ActionRole doesn't work?!
QAbstractButton *skipButton =
msgBox.addButton(tr("Skip"), QMessageBox::RejectRole);
Q_UNUSED(skipButton); // Surpress compiler unused warning
msgBox.exec();
if (msgBox.clickedButton() == wizardButton)
{ {
if (!mWizardInvoker->startProcess(QLatin1String("openmw-wizard"), false)) { QMessageBox msgBox;
return false; msgBox.setWindowTitle(tr("First run"));
} else { msgBox.setIcon(QMessageBox::Question);
return true; msgBox.setStandardButtons(QMessageBox::NoButton);
msgBox.setText(tr("<html><head/><body><p><b>Welcome to OpenMW!</b></p> \
<p>It is recommended to run the Installation Wizard.</p> \
<p>The Wizard will let you select an existing Morrowind installation, \
or install Morrowind for OpenMW to use.</p></body></html>"));
QAbstractButton *wizardButton =
msgBox.addButton(tr("Run &Installation Wizard"), QMessageBox::AcceptRole); // ActionRole doesn't work?!
QAbstractButton *skipButton =
msgBox.addButton(tr("Skip"), QMessageBox::RejectRole);
Q_UNUSED(skipButton); // Surpress compiler unused warning
msgBox.exec();
if (msgBox.clickedButton() == wizardButton)
{
if (!mWizardInvoker->startProcess(QLatin1String("openmw-wizard"), false)) {
return false;
} else {
return true;
}
} }
} }
show(); return setup();
return true;
} }
bool Launcher::MainDialog::setup() bool Launcher::MainDialog::setup()
{ {
if (!setupLauncherSettings())
return false;
if (!setupGameSettings()) if (!setupGameSettings())
return false; return false;
@ -214,17 +218,7 @@ bool Launcher::MainDialog::setup()
loadSettings(); loadSettings();
// Check if we need to run the wizard show();
if (mLauncherSettings.value(QString("General/firstrun"), QString("true")) == QLatin1String("true"))
{
if (!showFirstRunDialog()) {
return false;
} else {
return true;
}
}
show(); // Show ourselves if the wizard is not being run
return true; return true;
} }
@ -629,6 +623,9 @@ void Launcher::MainDialog::wizardFinished(int exitCode, QProcess::ExitStatus exi
if (exitCode != 0 || exitStatus == QProcess::CrashExit) if (exitCode != 0 || exitStatus == QProcess::CrashExit)
return qApp->quit(); return qApp->quit();
if (!setup())
return;
reloadSettings(); reloadSettings();
show(); show();
} }

@ -15,14 +15,16 @@ Wizard::ExistingInstallationPage::ExistingInstallationPage(QWidget *parent) :
setupUi(this); setupUi(this);
// Add a placeholder item to the list of installations
QListWidgetItem *emptyItem = new QListWidgetItem(tr("No existing installations detected"));
emptyItem->setFlags(Qt::NoItemFlags);
installationsList->insertItem(0, emptyItem);
} }
void Wizard::ExistingInstallationPage::initializePage() void Wizard::ExistingInstallationPage::initializePage()
{ {
QListWidgetItem *emptyItem = new QListWidgetItem(tr("No existing installations detected"));
emptyItem->setFlags(Qt::NoItemFlags);
installationsList->addItem(emptyItem);
// Add the available installation paths // Add the available installation paths
QStringList paths(mWizard->mInstallations.keys()); QStringList paths(mWizard->mInstallations.keys());
@ -35,7 +37,9 @@ void Wizard::ExistingInstallationPage::initializePage()
foreach (const QString &path, paths) { foreach (const QString &path, paths) {
QListWidgetItem *item = new QListWidgetItem(path); QListWidgetItem *item = new QListWidgetItem(path);
installationsList->addItem(item);
if (installationsList->findItems(path, Qt::MatchExactly).isEmpty())
installationsList->addItem(item);
} }
connect(installationsList, SIGNAL(currentTextChanged(QString)), connect(installationsList, SIGNAL(currentTextChanged(QString)),

@ -37,9 +37,6 @@ Wizard::MainWizard::MainWizard(QWidget *parent) :
setWindowIcon(QIcon(QLatin1String(":/images/openmw-wizard.png"))); setWindowIcon(QIcon(QLatin1String(":/images/openmw-wizard.png")));
setMinimumWidth(550); setMinimumWidth(550);
// This prevents initializePage() being called multiple times
setOption(QWizard::IndependentPages);
// Set the property for comboboxes to the text instead of index // Set the property for comboboxes to the text instead of index
setDefaultProperty("QComboBox", "currentText", "currentIndexChanged"); setDefaultProperty("QComboBox", "currentText", "currentIndexChanged");
@ -283,9 +280,6 @@ void Wizard::MainWizard::runSettingsImporter()
if (!mImporterInvoker->startProcess(QLatin1String("mwiniimport"), arguments, false)) if (!mImporterInvoker->startProcess(QLatin1String("mwiniimport"), arguments, false))
return qApp->quit(); return qApp->quit();
// Re-read the game settings
setupGameSettings();
} }
void Wizard::MainWizard::addInstallation(const QString &path) void Wizard::MainWizard::addInstallation(const QString &path)

Loading…
Cancel
Save