From 409bd0fe7eb306e1806b6fcf982bbdcc5b2af393 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Tue, 10 May 2011 22:47:08 +0200 Subject: [PATCH] Moved the stylesheet to main.cpp and made some stylesheet-related changes --- apps/launcher/datafilespage.cpp | 15 ++++---------- apps/launcher/main.cpp | 23 ++++++++++++--------- apps/launcher/playpage.cpp | 26 ++++++++++-------------- files/launcher.qss | 36 ++++++++++++++++++--------------- 4 files changed, 48 insertions(+), 52 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 8c6cced68..3c9eae461 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -17,7 +17,6 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent) mPluginsSelectModel = new QItemSelectionModel(mPluginsModel); - //QPushButton *deselectButton = new QPushButton(tr("Deselect All")); QLabel *filterLabel = new QLabel(tr("Filter:"), this); LineEdit *filterLineEdit = new LineEdit(this); @@ -31,6 +30,7 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent) mMastersWidget = new QTableWidget(this); // Contains the available masters mPluginsTable = new QTableView(this); + mMastersWidget->setObjectName("MastersWidget"); mMastersWidget->setSelectionBehavior(QAbstractItemView::SelectRows); mMastersWidget->setSelectionMode(QAbstractItemView::MultiSelection); mMastersWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); @@ -72,24 +72,22 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent) // Bottom part with profile options QLabel *profileLabel = new QLabel(tr("Current Profile:"), this); - //mProfilesModel = new QStringListModel(); - mProfilesComboBox = new ComboBox(this); - //mProfilesComboBox->setModel(mProfilesModel); - mProfilesComboBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); mProfilesComboBox->setInsertPolicy(QComboBox::InsertAtBottom); - //mProfileComboBox->addItem(QString("New Profile")); mNewProfileButton = new QPushButton(this); mNewProfileButton->setIcon(QIcon::fromTheme("document-new")); + mNewProfileButton->setToolTip(tr("New Profile")); mNewProfileButton->setShortcut(QKeySequence(tr("Ctrl+N"))); mCopyProfileButton = new QPushButton(this); mCopyProfileButton->setIcon(QIcon::fromTheme("edit-copy")); + mCopyProfileButton->setToolTip(tr("Copy Profile")); mDeleteProfileButton = new QPushButton(this); mDeleteProfileButton->setIcon(QIcon::fromTheme("edit-delete")); + mDeleteProfileButton->setToolTip(tr("Delete Profile")); mDeleteProfileButton->setShortcut(QKeySequence(tr("Delete"))); QHBoxLayout *bottomLayout = new QHBoxLayout(); @@ -102,11 +100,9 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent) QVBoxLayout *pageLayout = new QVBoxLayout(this); // Add some space above and below the page items - //QSpacerItem *vSpacer1 = new QSpacerItem(5, 5, QSizePolicy::Minimum, QSizePolicy::Minimum); QSpacerItem *vSpacer2 = new QSpacerItem(5, 5, QSizePolicy::Minimum, QSizePolicy::Minimum); QSpacerItem *vSpacer3 = new QSpacerItem(5, 5, QSizePolicy::Minimum, QSizePolicy::Minimum); - //pageLayout->addItem(vSpacer1); pageLayout->addLayout(topLayout); pageLayout->addItem(vSpacer2); pageLayout->addWidget(splitter); @@ -120,9 +116,6 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent) connect(mPluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckstate(QModelIndex))); connect(mPluginsModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(resizeRows())); - //connect(mProfileComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(profileChanged(const QString&))); - - connect(mNewProfileButton, SIGNAL(pressed()), this, SLOT(newProfile())); connect(mCopyProfileButton, SIGNAL(pressed()), this, SLOT(copyProfile())); connect(mDeleteProfileButton, SIGNAL(pressed()), this, SLOT(deleteProfile())); diff --git a/apps/launcher/main.cpp b/apps/launcher/main.cpp index d008c3a48..4e438a4db 100644 --- a/apps/launcher/main.cpp +++ b/apps/launcher/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "maindialog.hpp" @@ -9,22 +10,24 @@ int main(int argc, char *argv[]) // Now we make sure the current dir is set to application path QDir dir(QCoreApplication::applicationDirPath()); -#if defined(Q_OS_WIN) - if (dir.dirName().toLower() == "debug" || - dir.dirName().toLower() == "release") - { - dir.cdUp(); - } -#elif defined(Q_OS_MAC) - if (dir.dirName() == "MacOS") - { + + #if defined(Q_OS_MAC) + if (dir.dirName() == "MacOS") { dir.cdUp(); dir.cdUp(); dir.cdUp(); } -#endif + #endif QDir::setCurrent(dir.absolutePath()); + + // Load the stylesheet + QFile file("./launcher.qss"); + + file.open(QFile::ReadOnly); + QString styleSheet = QLatin1String(file.readAll()); + app.setStyleSheet(styleSheet); + MainDialog dialog; return dialog.exec(); diff --git a/apps/launcher/playpage.cpp b/apps/launcher/playpage.cpp index 27e2f08bb..2ad62d7c8 100644 --- a/apps/launcher/playpage.cpp +++ b/apps/launcher/playpage.cpp @@ -4,25 +4,21 @@ PlayPage::PlayPage(QWidget *parent) : QWidget(parent) { - // Load the stylesheet - QFile file("./launcher.qss"); + QWidget *playWidget = new QWidget(this); + playWidget->setObjectName("PlayGroup"); + playWidget->setFixedSize(QSize(425, 375)); - file.open(QFile::ReadOnly); - QString styleSheet = QLatin1String(file.readAll()); - setStyleSheet(styleSheet); - - QGroupBox *playBox = new QGroupBox(this); - playBox->setFixedSize(QSize(425, 375)); - playBox->setFlat(true); - - mPlayButton = new QPushButton(tr("Play"), playBox); + mPlayButton = new QPushButton(tr("Play"), playWidget); + mPlayButton->setObjectName("PlayButton"); mPlayButton->setMinimumSize(QSize(200, 50)); - QLabel *profileLabel = new QLabel(tr("Current Profile:"), playBox); + QLabel *profileLabel = new QLabel(tr("Current Profile:"), playWidget); + profileLabel->setObjectName("ProfileLabel"); - mProfilesComboBox = new QComboBox(playBox); + mProfilesComboBox = new QComboBox(playWidget); + mProfilesComboBox->setObjectName("ProfilesComboBox"); - QGridLayout *playLayout = new QGridLayout(playBox); + QGridLayout *playLayout = new QGridLayout(playWidget); QSpacerItem *hSpacer1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); QSpacerItem *hSpacer2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); @@ -40,6 +36,6 @@ PlayPage::PlayPage(QWidget *parent) : QWidget(parent) QHBoxLayout *pageLayout = new QHBoxLayout(this); - pageLayout->addWidget(playBox); + pageLayout->addWidget(playWidget); } \ No newline at end of file diff --git a/files/launcher.qss b/files/launcher.qss index 2866f858e..e9f8a3c9f 100644 --- a/files/launcher.qss +++ b/files/launcher.qss @@ -1,4 +1,4 @@ -QGroupBox { +#PlayGroup { background-image: url(":/images/playpage-background.png"); background-repeat: no-repeat; background-position: top; @@ -6,7 +6,11 @@ QGroupBox { padding-right: 30px; } -QPushButton { +#MastersWidget { + selection-background-color: palette(highlight); +} + +#PlayButton { height: 50px; @@ -20,7 +24,7 @@ QPushButton { stop:0.9 rgba(0, 0, 0, 55), stop:1 rgba(0, 0, 0, 100)); - font: 24pt "FreeMono"; + font: 24pt "Trebuchet MS"; color: black; border-right: 1px solid rgba(0, 0, 0, 155); @@ -31,7 +35,7 @@ QPushButton { border-radius: 5px; } -QPushButton:hover { +#PlayButton:hover { border-bottom: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(164, 192, 228, 255), stop:1 rgba(255, 255, 255, 0)); border-top: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(164, 192, 228, 255), stop:1 rgba(255, 255, 255, 0)); border-right: qlineargradient(spread:pad, x1:1, y1:0, x2:0, y2:0, stop:0 rgba(164, 192, 228, 255), stop:1 rgba(255, 255, 255, 0)); @@ -40,18 +44,16 @@ QPushButton:hover { border-style: solid; } -QPushButton:pressed { +#PlayButton:pressed { } -QLabel -{ - font: 14pt "FreeMono"; +#ProfileLabel { + font: 14pt "Trebuchet MS"; } -QComboBox -{ +#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 rgba(255, 255, 255, 200)); @@ -62,17 +64,19 @@ QComboBox } /*QComboBox gets the "on" state when the popup is open */ -QComboBox:!editable:on, QComboBox::drop-down:editable:on { +#ProfilesComboBox:!editable:on, #ProfilesComboBox::drop-down:editable:on { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 gray, stop:0.2 white); } -QComboBox { /* shift the text when the popup opens */ +#ProfilesComboBox { /* shift the text when the popup opens */ padding-top: 3px; padding-left: 4px; + + font: 11pt "Trebuchet MS"; } -QComboBox::drop-down { +#ProfilesComboBox::drop-down { subcontrol-origin: padding; subcontrol-position: top right; @@ -84,16 +88,16 @@ QComboBox::drop-down { border-bottom-right-radius: 3px; } -QComboBox::down-arrow { +#ProfilesComboBox::down-arrow { image: url(":/images/down.png"); } -QComboBox::down-arrow:on { /* shift the arrow when popup is open */ +#ProfilesComboBox::down-arrow:on { /* shift the arrow when popup is open */ top: 1px; left: 1px; } -QListWidget { +#IconWidget { background-image: url(":/images/openmw-header.png"); background-color: white; background-repeat: no-repeat;