mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-06 13:15:33 +00:00
Changed profile switching again; Some stylesheet modifications
This commit is contained in:
parent
7bf21262a1
commit
2b0dabe669
3 changed files with 69 additions and 59 deletions
|
@ -108,6 +108,34 @@ void MainDialog::createPages()
|
|||
mPagesWidget->addWidget(mGraphicsPage);
|
||||
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)
|
||||
|
@ -116,23 +144,6 @@ void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
|||
current = previous;
|
||||
|
||||
mPagesWidget->setCurrentIndex(mIconWidget->row(current));
|
||||
|
||||
if (previous) {
|
||||
QString previousPage = previous->data(Qt::DisplayRole).toString();
|
||||
QString currentPage = current->data(Qt::DisplayRole).toString();
|
||||
|
||||
// The user switched from Data Files to Play
|
||||
if (previousPage == QString("Data Files") && currentPage == QString("Play")) {
|
||||
mPlayPage->mProfilesComboBox->setCurrentIndex(mDataFilesPage->mProfilesComboBox->currentIndex());
|
||||
|
||||
}
|
||||
|
||||
// The user switched from Play to Data Files
|
||||
if (previousPage == QString("Play") && currentPage == QString("Data Files")) {
|
||||
mDataFilesPage->mProfilesComboBox->setCurrentIndex(mPlayPage->mProfilesComboBox->currentIndex());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainDialog::closeEvent(QCloseEvent *event)
|
||||
|
@ -141,6 +152,38 @@ void MainDialog::closeEvent(QCloseEvent *event)
|
|||
mDataFilesPage->writeConfig();
|
||||
mDataFilesPage->mLauncherConfig->sync();
|
||||
|
||||
// Now write to the game config
|
||||
writeConfig();
|
||||
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();
|
||||
|
||||
// Open our config file
|
||||
mGameConfig = new QSettings(config, QSettings::IniFormat);
|
||||
}
|
||||
|
||||
void MainDialog::writeConfig()
|
||||
{
|
||||
// Write to the openmw.cfg
|
||||
QString dataPath = mGameConfig->value("data").toString();
|
||||
dataPath.append("/");
|
||||
|
@ -171,7 +214,7 @@ void MainDialog::closeEvent(QCloseEvent *event)
|
|||
|
||||
// Now we write back the other config entries
|
||||
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);
|
||||
|
@ -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();
|
||||
|
||||
// Open our config file
|
||||
mGameConfig = new QSettings(config, QSettings::IniFormat);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -25,12 +25,14 @@ public:
|
|||
public slots:
|
||||
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
|
||||
void play();
|
||||
void profileChanged(int index);
|
||||
|
||||
|
||||
private:
|
||||
void createIcons();
|
||||
void createPages();
|
||||
void setupConfig();
|
||||
void writeConfig();
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
QListWidget *mIconWidget;
|
||||
|
|
|
@ -20,7 +20,7 @@ QPushButton {
|
|||
stop:0.9 rgba(0, 0, 0, 55),
|
||||
stop:1 rgba(0, 0, 0, 100));
|
||||
|
||||
font: 24pt "Gauntlet Thin";
|
||||
font: 24pt "FreeMono";
|
||||
color: black;
|
||||
|
||||
border-right: 1px solid rgba(0, 0, 0, 155);
|
||||
|
@ -46,7 +46,7 @@ QPushButton:pressed {
|
|||
|
||||
QLabel
|
||||
{
|
||||
font: 14pt "Gauntlet Classic";
|
||||
font: 14pt "FreeMono";
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,19 +54,17 @@ QComboBox
|
|||
{
|
||||
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-color: rgba(0, 0, 0, 125);
|
||||
border-style: solid;
|
||||
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 {
|
||||
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #D3D3D3, stop: 0.4 #D8D8D8,
|
||||
stop: 0.5 #DDDDDD, stop: 1.0 #E1E1E1);
|
||||
}*/
|
||||
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 */
|
||||
|
@ -102,7 +100,3 @@ QListWidget {
|
|||
background-attachment: scroll;
|
||||
background-position: right;
|
||||
}
|
||||
|
||||
QListWidgetItem {
|
||||
alignment: center;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue