From 6f3e230cad0beb1933609c19c29823fc4b1a3084 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 7 Jul 2014 19:19:03 +0200 Subject: [PATCH] Allow TextureChooser's texture selection to be queried. --- .../plugins/gui_editor/texture_chooser.cpp | 19 +++++++++++++++++++ .../src/plugins/gui_editor/texture_chooser.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/code/studio/src/plugins/gui_editor/texture_chooser.cpp b/code/studio/src/plugins/gui_editor/texture_chooser.cpp index 7545d2803..d857d9bdc 100644 --- a/code/studio/src/plugins/gui_editor/texture_chooser.cpp +++ b/code/studio/src/plugins/gui_editor/texture_chooser.cpp @@ -33,6 +33,25 @@ void TextureChooser::load() listWidget->addItem( itr->c_str() ); ++itr; } + + listWidget->setCurrentRow( 0 ); +} + +void TextureChooser::accept() +{ + QListWidgetItem *item = listWidget->currentItem(); + if( item == NULL ) + return; + + selection = item->text(); + QDialog::accept(); +} + +void TextureChooser::reject() +{ + selection = ""; + + QDialog::reject(); } void TextureChooser::onCurrentRowChanged( int row ) diff --git a/code/studio/src/plugins/gui_editor/texture_chooser.h b/code/studio/src/plugins/gui_editor/texture_chooser.h index 24b93fc40..bab1dd1dc 100644 --- a/code/studio/src/plugins/gui_editor/texture_chooser.h +++ b/code/studio/src/plugins/gui_editor/texture_chooser.h @@ -12,12 +12,19 @@ public: ~TextureChooser(); void load(); + QString getSelection(){ return selection; } + +public Q_SLOTS: + void accept(); + void reject(); private Q_SLOTS: void onCurrentRowChanged( int row ); private: void setupConnections(); + + QString selection; }; #endif