From c2296a2a93008298213dd8943b2c6c0f443cd61c Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 10 Jul 2013 02:34:41 +0200 Subject: [PATCH] It's not a terrible idea to remember the last used directory in the file open dialogs. --HG-- branch : gsoc2013-dfighter --- .../material_editor_window.cpp | 19 +++++++++++++++++-- .../material_editor/material_editor_window.h | 3 +++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.cpp index c03405e27..01acffe42 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -77,16 +78,23 @@ namespace MaterialEditor void MaterialEditorWindow::onOpenClicked() { + if( lastShapeDir.isEmpty() ) + lastShapeDir = "/"; + QString fn = QFileDialog::getOpenFileName( this, tr( "Open model" ), - "/", + lastShapeDir, tr( "Shape files ( *.shape )" ) ); if( fn.isEmpty() ) return; + QFileInfo info; + info.setFile( fn ); + lastShapeDir = info.absolutePath(); + std::string fname = fn.toUtf8().data(); bool ok = nl3dIface->loadShape( fname ); if( !ok ) @@ -110,16 +118,23 @@ namespace MaterialEditor void MaterialEditorWindow::onOpenMaterialClicked() { + if( lastMatDir.isEmpty() ) + lastMatDir = "/"; + QString fn = QFileDialog::getOpenFileName( this, tr( "Open material" ), - "/", + lastMatDir, tr( "Material files ( *.nelmat )" ) ); if( fn.isEmpty() ) return; + QFileInfo info; + info.setFile( fn ); + lastMatDir = info.absolutePath(); + bool ok = nl3dIface->loadMaterial( fn.toUtf8().data() ); if( !ok ) { diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.h index 283e7bdaa..27a231388 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.h @@ -65,6 +65,9 @@ private: ViewPortWidget *viewPort; Ui::MaterialEditorWindow m_ui; + + QString lastShapeDir; + QString lastMatDir; }; }