1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 10:09:39 +00:00

Merge remote branch 'pvdk/filedialog'

This commit is contained in:
Marc Zinnschlag 2012-06-20 09:28:43 +02:00
commit 95d9c99d0d
5 changed files with 31 additions and 11 deletions

View file

@ -1063,8 +1063,24 @@ void DataFilesPage::writeConfig(QString profile)
return; 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 // 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)) { if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
// File cannot be opened or created // File cannot be opened or created

View file

@ -17,7 +17,7 @@ FileDialog::FileDialog(QWidget *parent)
box->addButton(mChooseButton, QDialogButtonBox::AcceptRole); box->addButton(mChooseButton, QDialogButtonBox::AcceptRole);
connect(this, SIGNAL(directoryEntered(const QString&)), this, SLOT(updateChooseButton(const QString&))); connect(this, SIGNAL(directoryEntered(const QString&)), this, SLOT(updateChooseButton(const QString&)));
emit directoryEntered(directory().absolutePath()); emit directoryEntered(QDir::currentPath());
} }
QString FileDialog::getExistingDirectory(QWidget *parent, QString FileDialog::getExistingDirectory(QWidget *parent,

View file

@ -31,8 +31,10 @@ int main(int argc, char *argv[])
QDir::setCurrent(dir.absolutePath()); QDir::setCurrent(dir.absolutePath());
MainDialog dialog; MainDialog mainWin;
return dialog.exec(); mainWin.show();
return app.exec();
} }

View file

@ -29,7 +29,10 @@ MainDialog::MainDialog()
mSettings.loadUser(globaldefault); mSettings.loadUser(globaldefault);
mIconWidget = new QListWidget; QWidget *centralWidget = new QWidget(this);
setCentralWidget(centralWidget);
mIconWidget = new QListWidget(centralWidget);
mIconWidget->setObjectName("IconWidget"); mIconWidget->setObjectName("IconWidget");
mIconWidget->setViewMode(QListView::IconMode); mIconWidget->setViewMode(QListView::IconMode);
mIconWidget->setWrapping(false); mIconWidget->setWrapping(false);
@ -43,7 +46,7 @@ MainDialog::MainDialog()
mIconWidget->setCurrentRow(0); mIconWidget->setCurrentRow(0);
mIconWidget->setFlow(QListView::LeftToRight); mIconWidget->setFlow(QListView::LeftToRight);
QGroupBox *groupBox = new QGroupBox(this); QGroupBox *groupBox = new QGroupBox(centralWidget);
QVBoxLayout *groupLayout = new QVBoxLayout(groupBox); QVBoxLayout *groupLayout = new QVBoxLayout(groupBox);
mPagesWidget = new QStackedWidget(groupBox); mPagesWidget = new QStackedWidget(groupBox);
@ -51,16 +54,15 @@ MainDialog::MainDialog()
QPushButton *playButton = new QPushButton(tr("Play")); QPushButton *playButton = new QPushButton(tr("Play"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(this); QDialogButtonBox *buttonBox = new QDialogButtonBox(centralWidget);
buttonBox->setStandardButtons(QDialogButtonBox::Close); buttonBox->setStandardButtons(QDialogButtonBox::Close);
buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole); buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole);
QVBoxLayout *dialogLayout = new QVBoxLayout(this); QVBoxLayout *dialogLayout = new QVBoxLayout(centralWidget);
dialogLayout->addWidget(mIconWidget); dialogLayout->addWidget(mIconWidget);
dialogLayout->addWidget(groupBox); dialogLayout->addWidget(groupBox);
dialogLayout->addWidget(buttonBox); dialogLayout->addWidget(buttonBox);
setWindowTitle(tr("OpenMW Launcher")); setWindowTitle(tr("OpenMW Launcher"));
setWindowIcon(QIcon(":/images/openmw.png")); setWindowIcon(QIcon(":/images/openmw.png"));
// Remove what's this? button // Remove what's this? button

View file

@ -1,7 +1,7 @@
#ifndef MAINDIALOG_H #ifndef MAINDIALOG_H
#define MAINDIALOG_H #define MAINDIALOG_H
#include <QDialog> #include <QMainWindow>
#include <components/files/configurationmanager.hpp> #include <components/files/configurationmanager.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
@ -17,7 +17,7 @@ class PlayPage;
class GraphicsPage; class GraphicsPage;
class DataFilesPage; class DataFilesPage;
class MainDialog : public QDialog class MainDialog : public QMainWindow
{ {
Q_OBJECT Q_OBJECT