src/config.cpp

changeset 3
d0b278fd29d5
parent 2
1d544788a8b3
child 4
3c23aa03190d
equal deleted inserted replaced
2:1d544788a8b3 3:d0b278fd29d5
1 #include <QFileDialog>
1 #include "config.h" 2 #include "config.h"
2 #include "ui_configbox.h" 3 #include "ui_configbox.h"
3 4
4 ConfigBox::ConfigBox( QWidget* parent, Qt::WindowFlags f ) : QDialog( parent, f ) { 5 ConfigBox::ConfigBox( QWidget* parent, Qt::WindowFlags f ) : QDialog( parent, f ) {
5 ui = new Ui_ConfigBox; 6 ui = new Ui_ConfigBox;
6 ui->setupUi( this ); 7 ui->setupUi( this );
8 setWindowTitle( fmt( APPNAME " %1", versionString()));
9
10 connect( ui->wad_add, SIGNAL( clicked() ), this, SLOT( addPath() ));
11 connect( ui->wad_pathEntry, SIGNAL( returnPressed() ), this, SLOT( addPath() ));
12 connect( ui->wad_findPath, SIGNAL( clicked() ), this, SLOT( findPath() ));
13 connect( ui->wad_del, SIGNAL( clicked() ), this, SLOT( delPath() ));
7 } 14 }
8 15
9 ConfigBox::~ConfigBox() { 16 ConfigBox::~ConfigBox() {
10 delete ui; 17 delete ui;
11 } 18 }
19
20 void ConfigBox::initFromSettings() {
21 ui->wad_pathsList->clear();
22
23 list<var> paths = cfg->value( "wads/paths", list<var>() ).toList();
24 for( const var& it : paths )
25 addPath( it.toString() );
26 }
27
28 void ConfigBox::addPath() {
29 addPath( ui->wad_pathEntry->text() );
30 ui->wad_pathEntry->clear();
31 }
32
33 void ConfigBox::addPath( str path ) {
34 ui->wad_pathsList->addItem( path );
35 }
36
37 void ConfigBox::findPath() {
38 str path = QFileDialog::getExistingDirectory( this );
39 if( path.isEmpty() )
40 return;
41
42 ui->wad_pathEntry->setText( path );
43 }
44
45 void ConfigBox::delPath() {
46 delete ui->wad_pathsList->currentItem();
47 }

mercurial