Changed profile switching again; Some stylesheet modifications

actorid
Pieter van der Kloet 14 years ago
parent 7bf21262a1
commit 2b0dabe669

@ -108,6 +108,34 @@ void MainDialog::createPages()
mPagesWidget->addWidget(mGraphicsPage); mPagesWidget->addWidget(mGraphicsPage);
mPagesWidget->addWidget(mDataFilesPage); mPagesWidget->addWidget(mDataFilesPage);
// Select the first page
mIconWidget->setCurrentItem(mIconWidget->item(0), QItemSelectionModel::Select);
connect(mPlayPage->mProfilesComboBox,
SIGNAL(currentIndexChanged(int)),
this, SLOT(profileChanged(int)));
connect(mDataFilesPage->mProfilesComboBox,
SIGNAL(currentIndexChanged(int)),
this, SLOT(profileChanged(int)));
}
void MainDialog::profileChanged(int index)
{
// Just to be sure, should always have a selection
if (!mIconWidget->selectionModel()->hasSelection()) {
return;
}
QString currentPage = mIconWidget->currentItem()->data(Qt::DisplayRole).toString();
if (currentPage == QString("Play")) {
mDataFilesPage->mProfilesComboBox->setCurrentIndex(index);
}
if (currentPage == QString("Data Files")) {
mPlayPage->mProfilesComboBox->setCurrentIndex(index);
}
} }
void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
@ -116,31 +144,46 @@ void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
current = previous; current = previous;
mPagesWidget->setCurrentIndex(mIconWidget->row(current)); mPagesWidget->setCurrentIndex(mIconWidget->row(current));
}
if (previous) { void MainDialog::closeEvent(QCloseEvent *event)
QString previousPage = previous->data(Qt::DisplayRole).toString(); {
QString currentPage = current->data(Qt::DisplayRole).toString(); qDebug() << "Close event";
mDataFilesPage->writeConfig();
mDataFilesPage->mLauncherConfig->sync();
// The user switched from Data Files to Play // Now write to the game config
if (previousPage == QString("Data Files") && currentPage == QString("Play")) { writeConfig();
mPlayPage->mProfilesComboBox->setCurrentIndex(mDataFilesPage->mProfilesComboBox->currentIndex()); event->accept();
} }
// The user switched from Play to Data Files void MainDialog::play()
if (previousPage == QString("Play") && currentPage == QString("Data Files")) { {
mDataFilesPage->mProfilesComboBox->setCurrentIndex(mPlayPage->mProfilesComboBox->currentIndex());
}
}
} }
void MainDialog::closeEvent(QCloseEvent *event) void MainDialog::setupConfig()
{ {
qDebug() << "Close event"; // First we read the OpenMW config
mDataFilesPage->writeConfig(); QString config = "openmw.cfg";
mDataFilesPage->mLauncherConfig->sync(); QFile file(config);
if (!file.exists()) {
config = QString::fromStdString(Files::getPath(Files::Path_ConfigUser,
"openmw", "launcher.cfg"));
}
file.setFileName(config); // Just for displaying information
qDebug() << "Using config file from " << file.fileName();
file.close();
// Open our config file
mGameConfig = new QSettings(config, QSettings::IniFormat);
}
void MainDialog::writeConfig()
{
// Write to the openmw.cfg // Write to the openmw.cfg
QString dataPath = mGameConfig->value("data").toString(); QString dataPath = mGameConfig->value("data").toString();
dataPath.append("/"); dataPath.append("/");
@ -171,7 +214,7 @@ void MainDialog::closeEvent(QCloseEvent *event)
// Now we write back the other config entries // Now we write back the other config entries
if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
// File cannot be opened or created TODO: throw error // File cannot be opened or created TODO: throw error
} }
file.write(buffer); file.write(buffer);
@ -190,34 +233,5 @@ void MainDialog::closeEvent(QCloseEvent *event)
} }
} }
file.close();
event->accept();
}
void MainDialog::play()
{
}
void MainDialog::setupConfig()
{
// First we read the OpenMW config
QString config = "openmw.cfg";
QFile file(config);
if (!file.exists()) {
config = QString::fromStdString(Files::getPath(Files::Path_ConfigUser,
"openmw", "launcher.cfg"));
}
file.setFileName(config); // Just for displaying information
qDebug() << "Using config file from " << file.fileName();
file.close(); file.close();
// Open our config file
mGameConfig = new QSettings(config, QSettings::IniFormat);
} }

@ -25,12 +25,14 @@ public:
public slots: public slots:
void changePage(QListWidgetItem *current, QListWidgetItem *previous); void changePage(QListWidgetItem *current, QListWidgetItem *previous);
void play(); void play();
void profileChanged(int index);
private: private:
void createIcons(); void createIcons();
void createPages(); void createPages();
void setupConfig(); void setupConfig();
void writeConfig();
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
QListWidget *mIconWidget; QListWidget *mIconWidget;

@ -20,7 +20,7 @@ QPushButton {
stop:0.9 rgba(0, 0, 0, 55), stop:0.9 rgba(0, 0, 0, 55),
stop:1 rgba(0, 0, 0, 100)); stop:1 rgba(0, 0, 0, 100));
font: 24pt "Gauntlet Thin"; font: 24pt "FreeMono";
color: black; color: black;
border-right: 1px solid rgba(0, 0, 0, 155); border-right: 1px solid rgba(0, 0, 0, 155);
@ -46,7 +46,7 @@ QPushButton:pressed {
QLabel QLabel
{ {
font: 14pt "Gauntlet Classic"; font: 14pt "FreeMono";
} }
@ -54,19 +54,17 @@ QComboBox
{ {
padding: 1px 18px 1px 3px; padding: 1px 18px 1px 3px;
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 gray, stop:0.2 white, stop:1 rgba(255, 255, 255, 55)); 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));
border-width: 1px; border-width: 1px;
border-color: rgba(0, 0, 0, 125); border-color: rgba(0, 0, 0, 125);
border-style: solid; border-style: solid;
border-radius: 2px; border-radius: 2px;
} }
/* QComboBox gets the "on" state when the popup is open * / /*QComboBox gets the "on" state when the popup is open */
QComboBox:!editable:on, QComboBox::drop-down:editable:on { QComboBox:!editable:on, QComboBox::drop-down:editable:on {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 gray, stop:0.2 white);
stop: 0 #D3D3D3, stop: 0.4 #D8D8D8, }
stop: 0.5 #DDDDDD, stop: 1.0 #E1E1E1);
}*/
QComboBox { /* shift the text when the popup opens */ QComboBox { /* shift the text when the popup opens */
@ -102,7 +100,3 @@ QListWidget {
background-attachment: scroll; background-attachment: scroll;
background-position: right; background-position: right;
} }
QListWidgetItem {
alignment: center;
}

Loading…
Cancel
Save