mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-29 09:32:45 +00:00
Added writeConfig in Data Files tab and implemented the close button
This commit is contained in:
parent
de78b81a8f
commit
8c4fad1f59
@ -332,3 +332,28 @@ void DataFilesPage::resizeRows()
|
||||
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 ¤tPlugin, checkedItems())
|
||||
{
|
||||
settings.setValue(QString("Plugin"), currentPlugin);
|
||||
}
|
||||
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
|
||||
}
|
||||
|
@ -22,13 +22,14 @@ public:
|
||||
QComboBox *mProfileComboBox;
|
||||
QStringListModel *mProfileModel;
|
||||
|
||||
const QStringList checkedItems();
|
||||
void writeConfig();
|
||||
|
||||
public slots:
|
||||
void masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||
void setCheckstate(QModelIndex index);
|
||||
void resizeRows();
|
||||
|
||||
const QStringList checkedItems();
|
||||
|
||||
private:
|
||||
QTableWidget *mMastersWidget;
|
||||
QTableView *mPluginsTable;
|
||||
@ -41,7 +42,6 @@ private:
|
||||
void setupDataFiles();
|
||||
void addPlugins(const QModelIndex &index);
|
||||
void removePlugins(const QModelIndex &index);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -68,7 +68,7 @@ MainDialog::MainDialog()
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Close);
|
||||
buttonBox->addButton(playButton, QDialogButtonBox::ActionRole);
|
||||
buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole);
|
||||
|
||||
//QSpacerItem *vSpacer1 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
|
||||
@ -85,6 +85,9 @@ MainDialog::MainDialog()
|
||||
setMinimumSize(QSize(550, 450));
|
||||
|
||||
createIcons();
|
||||
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(play()));
|
||||
}
|
||||
|
||||
void MainDialog::createIcons()
|
||||
@ -118,6 +121,7 @@ void MainDialog::createIcons()
|
||||
connect(mIconWidget,
|
||||
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||
this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
|
||||
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
@ -22,9 +22,12 @@ public:
|
||||
|
||||
public slots:
|
||||
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
|
||||
void play();
|
||||
|
||||
|
||||
private:
|
||||
void createIcons();
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
QListWidget *mIconWidget;
|
||||
QStackedWidget *mPagesWidget;
|
||||
|
Loading…
x
Reference in New Issue
Block a user