Initial commit
[vexed] / preferences.cpp
1 #include "preferences.h"
2 #include "ui_preferences.h"
3 #include "levelpack.h"
4
5 Preferences::Preferences(QList<QString> &packList, const QString &selectedPack, QWidget *parent) :
6     QDialog(parent),
7     ui(new Ui::Preferences)
8 {
9     ui->setupUi(this);
10     QListIterator<QString> i(packList);
11     while(i.hasNext())
12     {
13         QString packName=i.next();
14         ui->packList->addItem(packName);
15     }
16     ui->packList->setCurrentIndex(ui->packList->findText(selectedPack));
17 }
18
19 Preferences::~Preferences()
20 {
21     delete ui;
22 }
23 // TODO: get rid off pack loading and duplicate filename constructing
24 void Preferences::packNameSelected()
25 {
26     QString packName(ui->packList->currentText());
27     selectedPack=packName;
28     LevelPack *pack=new LevelPack(":/packs/"+packName.append(".ini"));
29     ui->packAuthor->setText(pack->getAuthor());
30     ui->packURL->setText(pack->getURL());
31     ui->packDescription->setText(pack->getDescription());
32     delete pack;
33 }