# HG changeset patch # User Teemu Piippo # Date 1374015237 -10800 # Node ID d0b278fd29d5ea097d15c34c8e895c0dd1f3ae7c # Parent 1d544788a8b37d6604a368fb072923bdca494569 Implemented wad path list diff -r 1d544788a8b3 -r d0b278fd29d5 src/config.cpp --- a/src/config.cpp Wed Jul 17 00:31:04 2013 +0300 +++ b/src/config.cpp Wed Jul 17 01:53:57 2013 +0300 @@ -1,11 +1,47 @@ +#include #include "config.h" #include "ui_configbox.h" ConfigBox::ConfigBox( QWidget* parent, Qt::WindowFlags f ) : QDialog( parent, f ) { ui = new Ui_ConfigBox; ui->setupUi( this ); + setWindowTitle( fmt( APPNAME " %1", versionString())); + + connect( ui->wad_add, SIGNAL( clicked() ), this, SLOT( addPath() )); + connect( ui->wad_pathEntry, SIGNAL( returnPressed() ), this, SLOT( addPath() )); + connect( ui->wad_findPath, SIGNAL( clicked() ), this, SLOT( findPath() )); + connect( ui->wad_del, SIGNAL( clicked() ), this, SLOT( delPath() )); } ConfigBox::~ConfigBox() { delete ui; -} \ No newline at end of file +} + +void ConfigBox::initFromSettings() { + ui->wad_pathsList->clear(); + + list paths = cfg->value( "wads/paths", list() ).toList(); + for( const var& it : paths ) + addPath( it.toString() ); +} + +void ConfigBox::addPath() { + addPath( ui->wad_pathEntry->text() ); + ui->wad_pathEntry->clear(); +} + +void ConfigBox::addPath( str path ) { + ui->wad_pathsList->addItem( path ); +} + +void ConfigBox::findPath() { + str path = QFileDialog::getExistingDirectory( this ); + if( path.isEmpty() ) + return; + + ui->wad_pathEntry->setText( path ); +} + +void ConfigBox::delPath() { + delete ui->wad_pathsList->currentItem(); +} diff -r 1d544788a8b3 -r d0b278fd29d5 src/config.h --- a/src/config.h Wed Jul 17 00:31:04 2013 +0300 +++ b/src/config.h Wed Jul 17 01:53:57 2013 +0300 @@ -2,13 +2,24 @@ #define CONFIG_H #include +#include "main.h" +#include "types.h" class Ui_ConfigBox; class ConfigBox : public QDialog { + Q_OBJECT + public: - explicit ConfigBox( QWidget* parent = 0, Qt::WindowFlags f = 0 ); + explicit ConfigBox( QWidget* parent = null, Qt::WindowFlags f = 0 ); virtual ~ConfigBox(); + void addPath( str path ); + void initFromSettings(); + +public slots: + void addPath(); + void findPath(); + void delPath(); private: Ui_ConfigBox* ui; diff -r 1d544788a8b3 -r d0b278fd29d5 src/main.cpp --- a/src/main.cpp Wed Jul 17 00:31:04 2013 +0300 +++ b/src/main.cpp Wed Jul 17 01:53:57 2013 +0300 @@ -1,11 +1,19 @@ #include +#include #include "types.h" #include "config.h" +QSettings* cfg; + // ============================================================================= // ----------------------------------------------------------------------------- int main( int argc, char* argv[] ) { QApplication app( argc, argv ); + app.setApplicationName( APPNAME ); + app.setApplicationVersion( versionString() ); + + QSettings settings; + cfg = &settings; for( int i = 1; i < argc; ++i ) { str arg = argv[i]; diff -r 1d544788a8b3 -r d0b278fd29d5 src/main.h --- a/src/main.h Wed Jul 17 00:31:04 2013 +0300 +++ b/src/main.h Wed Jul 17 01:53:57 2013 +0300 @@ -15,7 +15,11 @@ #define BUILD_RC 3 #define BUILD_RELEASE 4 -class QString; +#include + +static const std::nullptr_t null = nullptr; + +extern QSettings* cfg; QString versionString(); #endif // MAIN_H \ No newline at end of file diff -r 1d544788a8b3 -r d0b278fd29d5 src/types.h --- a/src/types.h Wed Jul 17 00:31:04 2013 +0300 +++ b/src/types.h Wed Jul 17 01:53:57 2013 +0300 @@ -4,9 +4,11 @@ #include "main.h" #include #include +#include typedef QString str; typedef QChar qchar; +typedef QVariant var; template using list = QList; typedef unsigned int uint; typedef unsigned short ushort; diff -r 1d544788a8b3 -r d0b278fd29d5 src/ui/configbox.ui --- a/src/ui/configbox.ui Wed Jul 17 00:31:04 2013 +0300 +++ b/src/ui/configbox.ui Wed Jul 17 01:53:57 2013 +0300 @@ -33,7 +33,7 @@ - + Add @@ -42,10 +42,10 @@ - + - + ... @@ -54,46 +54,32 @@ - + + + true + + + QAbstractItemView::DragDrop + + + Qt::MoveAction + + + QAbstractItemView::ExtendedSelection + + - - - Move Up - - - - - - - Move Down - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - + Delete - + Clear @@ -151,8 +137,8 @@ accept() - 248 - 254 + 254 + 313 157 @@ -167,8 +153,8 @@ reject() - 316 - 260 + 322 + 313 286 @@ -176,5 +162,21 @@ + + wad_clear + clicked(bool) + wad_pathsList + clear() + + + 441 + 217 + + + 219 + 189 + + +