From 128c2a32708496167d85438050198e262dd1f710 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 5 Jul 2013 05:17:46 +0200 Subject: [PATCH] Changed the Shader widget a little. --HG-- branch : gsoc2013-dfighter --- .../plugins/material_editor/shader_editor.cpp | 6 +-- .../plugins/material_editor/shader_editor.h | 3 -- .../plugins/material_editor/shader_widget.cpp | 44 +++++++------------ .../plugins/material_editor/shader_widget.ui | 17 ++----- 4 files changed, 23 insertions(+), 47 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.cpp index a9a3e4d3f..dd9eb602b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.cpp @@ -78,13 +78,12 @@ namespace MaterialEditor void ShaderEditorWidget::onOKClicked() { - close(); - Q_EMIT okClicked(); + accept(); } void ShaderEditorWidget::onCancelClicked() { - close(); + reject(); } void ShaderEditorWidget::reset() @@ -94,6 +93,7 @@ namespace MaterialEditor descriptionEdit->setPlainText( empty ); vsEdit->setPlainText( empty ); fsEdit->setPlainText( empty ); + setResult( QDialog::Rejected ); } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.h index 0045e0ae5..389aa47cc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_editor.h @@ -45,9 +45,6 @@ namespace MaterialEditor void onOKClicked(); void onCancelClicked(); - Q_SIGNALS: - void okClicked(); - private: void setupConnections(); }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.cpp index deee377b7..309da0ca8 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.cpp @@ -53,11 +53,9 @@ namespace MaterialEditor bool ShaderWidget::nameExists( const QString &name ) { - QTreeWidgetItem *item = NULL; - for( int i = 0; i < shaderListWidget->topLevelItemCount(); i++ ) + for( int i = 0; i < shaderList->count(); i++ ) { - item = shaderListWidget->topLevelItem( i ); - if( item->text( 0 ) == name ) + if( shaderList->item( i )->text() == name ) return true; } @@ -100,28 +98,13 @@ namespace MaterialEditor return; } - QString fn = - QFileDialog::getSaveFileName( - this, - tr( "Shader filename" ), - tr( "/" ), - tr( "Nel shader files ( *.nelshdr )" ) - ); - - if( fn.isEmpty() ) - return; - - QTreeWidgetItem *item = new QTreeWidgetItem(); - item->setText( 0, name ); - item->setText( 1, fn ); - shaderListWidget->addTopLevelItem( item ); - + shaderList->addItem( name ); } void ShaderWidget::onRemoveClicked() { - QTreeWidgetItem *item = shaderListWidget->currentItem(); - if( item == NULL ) + int i = shaderList->currentRow(); + if( i < 0 ) return; int selection = @@ -134,25 +117,32 @@ namespace MaterialEditor ); if( selection == QMessageBox::Yes ) + { + QListWidgetItem *item = shaderList->takeItem( i ); delete item; + } } void ShaderWidget::onEditClicked() { - QTreeWidgetItem *item = shaderListWidget->currentItem(); - if( item == NULL ) + int i = shaderList->currentRow(); + if( i < 0 ) return; - QString name = item->text( 0 ); + QString name = shaderList->item( i )->text(); shaderEditorWidget->reset(); shaderEditorWidget->setName( name ); QString sname; bool ok; + int res; do{ ok = true; - shaderEditorWidget->exec(); + res = shaderEditorWidget->exec(); + if( res == QDialog::Rejected ) + return; + shaderEditorWidget->getName( sname ); if( sname != name ) @@ -166,7 +156,7 @@ namespace MaterialEditor }while( !ok ); - item->setText( 0, sname ); + shaderList->item( i )->setText( sname ); // save diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.ui index 3e98aadad..3d0a0e151 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/shader_widget.ui @@ -10,7 +10,7 @@ 0 0 502 - 467 + 401 @@ -25,18 +25,7 @@ - - - - Name - - - - - Path - - - + @@ -84,7 +73,7 @@ - + Description