1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 12:32:36 +00:00

Added writeConfig in Data Files tab and implemented the close button

This commit is contained in:
Pieter van der Kloet 2011-04-24 23:03:21 +02:00
parent de78b81a8f
commit 8c4fad1f59
4 changed files with 48 additions and 4 deletions

View File

@ -332,3 +332,28 @@ void DataFilesPage::resizeRows()
mPluginsTable->resizeRowsToContents(); mPluginsTable->resizeRowsToContents();
} }
void DataFilesPage::writeConfig()
{
// TODO: Testing the config here
QSettings settings("launcher.cfg", QSettings::IniFormat);
settings.beginGroup("Profiles");
settings.beginGroup(mProfileComboBox->currentText());
// First write all the masters to the config
for (int i = 0; i < mMastersWidget->rowCount(); ++i) {
const QTableWidgetItem *item = mMastersWidget->item(i, 0);
settings.setValue(QString("Master"), item->data(Qt::DisplayRole).toString());
}
// Now write all checked plugins
foreach (const QString &currentPlugin, checkedItems())
{
settings.setValue(QString("Plugin"), currentPlugin);
}
settings.endGroup();
settings.endGroup();
}

View File

@ -22,13 +22,14 @@ public:
QComboBox *mProfileComboBox; QComboBox *mProfileComboBox;
QStringListModel *mProfileModel; QStringListModel *mProfileModel;
const QStringList checkedItems();
void writeConfig();
public slots: public slots:
void masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); void masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
void setCheckstate(QModelIndex index); void setCheckstate(QModelIndex index);
void resizeRows(); void resizeRows();
const QStringList checkedItems();
private: private:
QTableWidget *mMastersWidget; QTableWidget *mMastersWidget;
QTableView *mPluginsTable; QTableView *mPluginsTable;
@ -41,7 +42,6 @@ private:
void setupDataFiles(); void setupDataFiles();
void addPlugins(const QModelIndex &index); void addPlugins(const QModelIndex &index);
void removePlugins(const QModelIndex &index); void removePlugins(const QModelIndex &index);
}; };
#endif #endif

View File

@ -68,7 +68,7 @@ MainDialog::MainDialog()
QDialogButtonBox *buttonBox = new QDialogButtonBox(this); QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
buttonBox->setStandardButtons(QDialogButtonBox::Close); buttonBox->setStandardButtons(QDialogButtonBox::Close);
buttonBox->addButton(playButton, QDialogButtonBox::ActionRole); buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole);
//QSpacerItem *vSpacer1 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); //QSpacerItem *vSpacer1 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
@ -85,6 +85,9 @@ MainDialog::MainDialog()
setMinimumSize(QSize(550, 450)); setMinimumSize(QSize(550, 450));
createIcons(); createIcons();
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(play()));
} }
void MainDialog::createIcons() void MainDialog::createIcons()
@ -118,6 +121,7 @@ void MainDialog::createIcons()
connect(mIconWidget, connect(mIconWidget,
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*))); this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
} }
void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
@ -145,3 +149,15 @@ void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
} }
void MainDialog::closeEvent(QCloseEvent *event)
{
qDebug() << "Close event";
mDataFilesPage->writeConfig();
event->accept();
}
void MainDialog::play()
{
}

View File

@ -22,9 +22,12 @@ public:
public slots: public slots:
void changePage(QListWidgetItem *current, QListWidgetItem *previous); void changePage(QListWidgetItem *current, QListWidgetItem *previous);
void play();
private: private:
void createIcons(); void createIcons();
void closeEvent(QCloseEvent *event);
QListWidget *mIconWidget; QListWidget *mIconWidget;
QStackedWidget *mPagesWidget; QStackedWidget *mPagesWidget;