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