mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-01 03:21:41 +00:00
Fix for Bug #306: launcher now creates the config dir and returns proper error codes
This commit is contained in:
parent
f81e127701
commit
e21442f6cc
@ -1063,8 +1063,24 @@ void DataFilesPage::writeConfig(QString profile)
|
||||
return;
|
||||
}
|
||||
|
||||
QString pathStr = QString::fromStdString(mCfgMgr.getUserPath().string());
|
||||
QDir userPath(pathStr);
|
||||
|
||||
if (!userPath.exists()) {
|
||||
if (!userPath.mkpath(pathStr)) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("Error creating OpenMW configuration directory");
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not create %0</b><br><br> \Please make sure you have the right permissions and try again.<br>").arg(pathStr));
|
||||
msgBox.exec();
|
||||
|
||||
qApp->exit(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Open the OpenMW config as a QFile
|
||||
QFile file(QString::fromStdString((mCfgMgr.getUserPath() / "openmw.cfg").string()));
|
||||
QFile file(pathStr.append("openmw.cfg"));
|
||||
|
||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
|
||||
// File cannot be opened or created
|
||||
|
@ -17,7 +17,7 @@ FileDialog::FileDialog(QWidget *parent)
|
||||
box->addButton(mChooseButton, QDialogButtonBox::AcceptRole);
|
||||
|
||||
connect(this, SIGNAL(directoryEntered(const QString&)), this, SLOT(updateChooseButton(const QString&)));
|
||||
emit directoryEntered(directory().absolutePath());
|
||||
emit directoryEntered(QDir::currentPath());
|
||||
}
|
||||
|
||||
QString FileDialog::getExistingDirectory(QWidget *parent,
|
||||
|
@ -31,8 +31,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
QDir::setCurrent(dir.absolutePath());
|
||||
|
||||
MainDialog dialog;
|
||||
return dialog.exec();
|
||||
MainDialog mainWin;
|
||||
mainWin.show();
|
||||
|
||||
return app.exec();
|
||||
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,10 @@ MainDialog::MainDialog()
|
||||
mSettings.loadUser(globaldefault);
|
||||
|
||||
|
||||
mIconWidget = new QListWidget;
|
||||
QWidget *centralWidget = new QWidget(this);
|
||||
setCentralWidget(centralWidget);
|
||||
|
||||
mIconWidget = new QListWidget(centralWidget);
|
||||
mIconWidget->setObjectName("IconWidget");
|
||||
mIconWidget->setViewMode(QListView::IconMode);
|
||||
mIconWidget->setWrapping(false);
|
||||
@ -43,7 +46,7 @@ MainDialog::MainDialog()
|
||||
mIconWidget->setCurrentRow(0);
|
||||
mIconWidget->setFlow(QListView::LeftToRight);
|
||||
|
||||
QGroupBox *groupBox = new QGroupBox(this);
|
||||
QGroupBox *groupBox = new QGroupBox(centralWidget);
|
||||
QVBoxLayout *groupLayout = new QVBoxLayout(groupBox);
|
||||
|
||||
mPagesWidget = new QStackedWidget(groupBox);
|
||||
@ -51,16 +54,15 @@ MainDialog::MainDialog()
|
||||
|
||||
QPushButton *playButton = new QPushButton(tr("Play"));
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(centralWidget);
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Close);
|
||||
buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole);
|
||||
|
||||
QVBoxLayout *dialogLayout = new QVBoxLayout(this);
|
||||
QVBoxLayout *dialogLayout = new QVBoxLayout(centralWidget);
|
||||
dialogLayout->addWidget(mIconWidget);
|
||||
dialogLayout->addWidget(groupBox);
|
||||
dialogLayout->addWidget(buttonBox);
|
||||
|
||||
|
||||
setWindowTitle(tr("OpenMW Launcher"));
|
||||
setWindowIcon(QIcon(":/images/openmw.png"));
|
||||
// Remove what's this? button
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef MAINDIALOG_H
|
||||
#define MAINDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
@ -17,7 +17,7 @@ class PlayPage;
|
||||
class GraphicsPage;
|
||||
class DataFilesPage;
|
||||
|
||||
class MainDialog : public QDialog
|
||||
class MainDialog : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user