src/config.cpp

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

mercurial