From c42f99a586ba7c84f0aad98658f6e867fcc73b41 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Tue, 3 May 2011 03:17:01 +0200 Subject: [PATCH] Implemented starting the game by pressing either the big play button or the dialog play button --- apps/launcher/maindialog.cpp | 26 ++++++++++++++++++++++++++ apps/launcher/playpage.cpp | 8 +++----- apps/launcher/playpage.hpp | 5 +++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index d9629d6581..7fa73e6a2d 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -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() diff --git a/apps/launcher/playpage.cpp b/apps/launcher/playpage.cpp index c1ba616c0a..5f9949eb6f 100644 --- a/apps/launcher/playpage.cpp +++ b/apps/launcher/playpage.cpp @@ -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); diff --git a/apps/launcher/playpage.hpp b/apps/launcher/playpage.hpp index 21db7b0f14..efec6f2b38 100644 --- a/apps/launcher/playpage.hpp +++ b/apps/launcher/playpage.hpp @@ -4,7 +4,7 @@ #include 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 \ No newline at end of file