Made the Play page use a .ui file too

pull/37/head
Pieter van der Kloet 12 years ago
parent f2193bb1ba
commit 0a6e3701ab

@ -94,8 +94,8 @@ void MainDialog::createPages()
mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
// Set the combobox of the play page to imitate the combobox on the datafilespage
mPlayPage->mProfilesComboBox->setModel(mDataFilesPage->mProfilesComboBox->model());
mPlayPage->mProfilesComboBox->setCurrentIndex(mDataFilesPage->mProfilesComboBox->currentIndex());
mPlayPage->setProfilesComboBoxModel(mDataFilesPage->mProfilesComboBox->model());
mPlayPage->setProfilesComboBoxIndex(mDataFilesPage->mProfilesComboBox->currentIndex());
// Add the pages to the stacked widget
pagesWidget->addWidget(mPlayPage);
@ -105,15 +105,10 @@ void MainDialog::createPages()
// Select the first page
iconWidget->setCurrentItem(iconWidget->item(0), QItemSelectionModel::Select);
connect(mPlayPage->mPlayButton, SIGNAL(clicked()), this, SLOT(play()));
connect(mPlayPage, SIGNAL(playButtonClicked()), this, SLOT(play()));
connect(mPlayPage->mProfilesComboBox,
SIGNAL(currentIndexChanged(int)),
mDataFilesPage->mProfilesComboBox, SLOT(setCurrentIndex(int)));
connect(mDataFilesPage->mProfilesComboBox,
SIGNAL(currentIndexChanged(int)),
mPlayPage->mProfilesComboBox, SLOT(setCurrentIndex(int)));
connect(mPlayPage, SIGNAL(profileChanged(int)), mDataFilesPage->mProfilesComboBox, SLOT(setCurrentIndex(int)));
connect(mDataFilesPage->mProfilesComboBox, SIGNAL(currentIndexChanged(int)), mPlayPage, SLOT(setProfilesComboBoxIndex(int)));
}

@ -28,12 +28,6 @@ class MainDialog : public QMainWindow, private Ui::MainWindow
public:
MainDialog();
// GameSettings &gameSettings,
// GraphicsSettings &GraphicsSettings,
// LauncherSettings &launcherSettings);
bool setup();
bool showFirstRunDialog();
@ -58,9 +52,6 @@ private:
void closeEvent(QCloseEvent *event);
// QListWidget *mIconWidget;
// QStackedWidget *mPagesWidget;
PlayPage *mPlayPage;
GraphicsPage *mGraphicsPage;
DataFilesPage *mDataFilesPage;

@ -4,45 +4,37 @@
PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
{
QWidget *playWidget = new QWidget(this);
playWidget->setObjectName("PlayGroup");
playWidget->setFixedSize(QSize(425, 375));
mPlayButton = new QPushButton(tr("Play"), playWidget);
mPlayButton->setObjectName("PlayButton");
mPlayButton->setMinimumSize(QSize(200, 50));
QLabel *profileLabel = new QLabel(tr("Current Profile:"), playWidget);
profileLabel->setObjectName("ProfileLabel");
setupUi(this);
// Hacks to get the stylesheet look properly on different platforms
QPlastiqueStyle *style = new QPlastiqueStyle;
QFont font = QApplication::font();
font.setPointSize(12); // Fixes problem with overlapping items
mProfilesComboBox = new QComboBox(playWidget);
mProfilesComboBox->setObjectName("ProfilesComboBox");
mProfilesComboBox->setStyle(style);
mProfilesComboBox->setFont(font);
QGridLayout *playLayout = new QGridLayout(playWidget);
profilesComboBox->setStyle(style);
profilesComboBox->setFont(font);
QSpacerItem *hSpacer1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
QSpacerItem *hSpacer2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
connect(profilesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentIndexChanged(int)));
connect(playButton, SIGNAL(clicked()), this, SLOT(slotPlayClicked()));
QSpacerItem *vSpacer1 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
QSpacerItem *vSpacer2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
}
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);
playLayout->addItem(hSpacer2, 2, 2, 1, 1);
playLayout->addItem(vSpacer1, 0, 1, 1, 1);
playLayout->addItem(vSpacer2, 4, 1, 1, 1);
void PlayPage::setProfilesComboBoxModel(QAbstractItemModel *model)
{
profilesComboBox->setModel(model);
}
QHBoxLayout *pageLayout = new QHBoxLayout(this);
void PlayPage::setProfilesComboBoxIndex(int index)
{
profilesComboBox->setCurrentIndex(index);
}
pageLayout->addWidget(playWidget);
void PlayPage::slotCurrentIndexChanged(int index)
{
emit profileChanged(index);
}
void PlayPage::slotPlayClicked()
{
emit playButtonClicked();
}

@ -3,18 +3,32 @@
#include <QWidget>
#include "ui_playpage.h"
class QComboBox;
class QPushButton;
class QAbstractItemModel;
class PlayPage : public QWidget
class PlayPage : public QWidget, private Ui::PlayPage
{
Q_OBJECT
public:
PlayPage(QWidget *parent = 0);
void setProfilesComboBoxModel(QAbstractItemModel *model);
signals:
void profileChanged(int index);
void playButtonClicked();
public slots:
void setProfilesComboBoxIndex(int index);
private slots:
void slotCurrentIndexChanged(int index);
void slotPlayClicked();
QComboBox *mProfilesComboBox;
QPushButton *mPlayButton;
};

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>graphicsPage</class>
<widget class="QWidget" name="graphicsPage">
<class>GraphicsPage</class>
<widget class="QWidget" name="GraphicsPage">
<property name="geometry">
<rect>
<x>0</x>

@ -1,15 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>playPage</class>
<widget class="QWidget" name="playPage">
<class>PlayPage</class>
<widget class="QWidget" name="PlayPage">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="Scroll">
<property name="styleSheet">
<string notr="true">#playPage {
<string notr="true">#Scroll {
background-image: url(&quot;:/images/playpage-background.png&quot;);
background-repeat: no-repeat;
background-position: top;
}
</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>30</number>
@ -20,7 +29,81 @@
<property name="rightMargin">
<number>30</number>
</property>
<item row="0" column="0">
<item row="4" column="1">
<widget class="QComboBox" name="profilesComboBox">
<property name="styleSheet">
<string notr="true">#profilesComboBox {
padding: 1px 18px 1px 3px;
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:0.2 rgba(0, 0, 0, 25), stop:1 white);
border-width: 1px;
border-color: rgba(0, 0, 0, 125);
border-style: solid;
border-radius: 2px;
}
/*QComboBox gets the &quot;on&quot; state when the popup is open */
#profilesComboBox:!editable:on, #ProfilesComboBox::drop-down:editable:on {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 rgba(0, 0, 0, 75),
stop:0.1 rgba(0, 0, 0, 15),
stop:0.2 rgba(255, 255, 255, 55));
border: 1px solid rgba(0, 0, 0, 55);
}
#profilesComboBox { /* shift the text when the popup opens */
padding-top: 3px;
padding-left: 4px;
font-size: 12pt;
font-family: &quot;EB Garamond&quot;, &quot;EB Garamond 08&quot;;
}
#profilesComboBox::drop-down {
subcontrol-origin: padding;
subcontrol-position: top right;
border-width: 1px;
border-left-width: 1px;
border-left-color: darkgray;
border-left-style: solid; /* just a single line */
border-top-right-radius: 3px; /* same radius as the QComboBox */
border-bottom-right-radius: 3px;
}
#profilesComboBox::down-arrow {
image: url(&quot;:/images/down.png&quot;);
}
#profilesComboBox::down-arrow:on { /* shift the arrow when popup is open */
top: 1px;
left: 1px;
}
#profilesComboBox QAbstractItemView {
border: 2px solid lightgray;
border-radius: 5px;
}
</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="profileLabel">
<property name="styleSheet">
<string notr="true">#profileLabel {
font-size: 18pt;
font-family: &quot;EB Garamond&quot;, &quot;EB Garamond 08&quot;;
}
</string>
</property>
<property name="text">
<string>Current Profile:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="playButton">
<property name="minimumSize">
<size>
@ -84,81 +167,7 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="profileLabel">
<property name="styleSheet">
<string notr="true">#profileLabel {
font-size: 18pt;
font-family: &quot;EB Garamond&quot;, &quot;EB Garamond 08&quot;;
}
</string>
</property>
<property name="text">
<string>Current Profile:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QComboBox" name="profilesComboBox">
<property name="styleSheet">
<string notr="true">#profilesComboBox {
padding: 1px 18px 1px 3px;
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:0.2 rgba(0, 0, 0, 25), stop:1 white);
border-width: 1px;
border-color: rgba(0, 0, 0, 125);
border-style: solid;
border-radius: 2px;
}
/*QComboBox gets the &quot;on&quot; state when the popup is open */
#profilesComboBox:!editable:on, #ProfilesComboBox::drop-down:editable:on {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 rgba(0, 0, 0, 75),
stop:0.1 rgba(0, 0, 0, 15),
stop:0.2 rgba(255, 255, 255, 55));
border: 1px solid rgba(0, 0, 0, 55);
}
#profilesComboBox { /* shift the text when the popup opens */
padding-top: 3px;
padding-left: 4px;
font-size: 12pt;
font-family: &quot;EB Garamond&quot;, &quot;EB Garamond 08&quot;;
}
#profilesComboBox::drop-down {
subcontrol-origin: padding;
subcontrol-position: top right;
border-width: 1px;
border-left-width: 1px;
border-left-color: darkgray;
border-left-style: solid; /* just a single line */
border-top-right-radius: 3px; /* same radius as the QComboBox */
border-bottom-right-radius: 3px;
}
#profilesComboBox::down-arrow {
image: url(&quot;:/images/down.png&quot;);
}
#profilesComboBox::down-arrow:on { /* shift the arrow when popup is open */
top: 1px;
left: 1px;
}
#profilesComboBox QAbstractItemView {
border: 2px solid lightgray;
border-radius: 5px;
}
</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="5" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -173,6 +182,9 @@
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
</resources>

Loading…
Cancel
Save