From 8c4fad1f59c704c130f68f1fbee163d91482c903 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Sun, 24 Apr 2011 23:03:21 +0200 Subject: [PATCH] Added writeConfig in Data Files tab and implemented the close button --- apps/launcher/datafilespage.cpp | 25 +++++++++++++++++++++++++ apps/launcher/datafilespage.hpp | 6 +++--- apps/launcher/maindialog.cpp | 18 +++++++++++++++++- apps/launcher/maindialog.hpp | 3 +++ 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 10c5b71a46..95af780fa4 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -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(); + +} diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 85f9e9405a..01d92e1396 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -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 diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index c338b7ef50..536fbe2621 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -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() +{ + +} \ No newline at end of file diff --git a/apps/launcher/maindialog.hpp b/apps/launcher/maindialog.hpp index b94727bd44..520964c37a 100644 --- a/apps/launcher/maindialog.hpp +++ b/apps/launcher/maindialog.hpp @@ -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;