mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-03 17:37:18 +00:00
Implemented starting the game by pressing either the big play button or the dialog play button
This commit is contained in:
parent
2b0dabe669
commit
c42f99a586
@ -111,6 +111,8 @@ void MainDialog::createPages()
|
||||
// Select the first page
|
||||
mIconWidget->setCurrentItem(mIconWidget->item(0), QItemSelectionModel::Select);
|
||||
|
||||
connect(mPlayPage->mPlayButton, SIGNAL(clicked()), this, SLOT(play()));
|
||||
|
||||
connect(mPlayPage->mProfilesComboBox,
|
||||
SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(profileChanged(int)));
|
||||
@ -161,6 +163,30 @@ void MainDialog::closeEvent(QCloseEvent *event)
|
||||
void MainDialog::play()
|
||||
{
|
||||
|
||||
#if Q_WS_WIN
|
||||
// Windows TODO: proper install path handling
|
||||
QString game = "./openmw.exe";
|
||||
QFile file(game);
|
||||
# else
|
||||
QString game = "./openmw";
|
||||
QFile file(game);
|
||||
#endif
|
||||
|
||||
QProcess process;
|
||||
|
||||
if (!file.exists()) {
|
||||
// TODO: Throw error!
|
||||
qDebug() << "Could not start process";
|
||||
return;
|
||||
}
|
||||
|
||||
if(!process.startDetached(game)) {
|
||||
// TODO: Throw error!;
|
||||
qDebug() << "Could not start process";
|
||||
qDebug() << "reason was:" << process.errorString();
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
void MainDialog::setupConfig()
|
||||
|
@ -15,14 +15,12 @@ PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
|
||||
playBox->setFixedSize(QSize(425, 375));
|
||||
playBox->setFlat(true);
|
||||
|
||||
QPushButton *playButton = new QPushButton(tr("Play"), playBox);
|
||||
playButton->setMinimumSize(QSize(200, 50));
|
||||
mPlayButton = new QPushButton(tr("Play"), playBox);
|
||||
mPlayButton->setMinimumSize(QSize(200, 50));
|
||||
|
||||
QLabel *profileLabel = new QLabel(tr("Current Profile:"), playBox);
|
||||
|
||||
mProfilesModel = new QStringListModel();
|
||||
mProfilesComboBox = new QComboBox(playBox);
|
||||
mProfilesComboBox->setModel(mProfilesModel);
|
||||
|
||||
QGridLayout *playLayout = new QGridLayout(playBox);
|
||||
|
||||
@ -32,7 +30,7 @@ PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
|
||||
QSpacerItem *vSpacer1 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
QSpacerItem *vSpacer2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
|
||||
playLayout->addWidget(playButton, 1, 1, 1, 1);
|
||||
playLayout->addWidget(mPlayButton, 1, 1, 1, 1);
|
||||
playLayout->addWidget(profileLabel, 2, 1, 1, 1);
|
||||
playLayout->addWidget(mProfilesComboBox, 3, 1, 1, 1);
|
||||
playLayout->addItem(hSpacer1, 2, 0, 1, 1);
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <QWidget>
|
||||
|
||||
class QComboBox;
|
||||
class QStringListModel;
|
||||
class QPushButton;
|
||||
|
||||
class PlayPage : public QWidget
|
||||
{
|
||||
@ -14,7 +14,8 @@ public:
|
||||
PlayPage(QWidget *parent = 0);
|
||||
|
||||
QComboBox *mProfilesComboBox;
|
||||
QStringListModel *mProfilesModel;
|
||||
QPushButton *mPlayButton;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user