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