Commit 6681d133 authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

PluginFunctions: Added convenient wrappers for getOpenFileName and

getSaveFileName which remember their last location the next time they open up.


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13281 383ad7c9-94d9-4d36-a494-682f7c89f535
parent aea8db35
......@@ -50,6 +50,7 @@
//=============================================================================
#include <OpenFlipper/common/Types.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
#include <QGLWidget>
#include "PluginFunctions.hh"
......@@ -1130,4 +1131,30 @@ QMap< std::string ,ACG::QtWidgets::SceneGraphWidgetGenerator* > getSceneGraphGen
return sceneGraphGenerators_;
}
QString getOpenFileName(const QString &configProperty,
QWidget * parent, const QString & caption,
const QString & defaultDir, const QString & filter,
QString * selectedFilter, QFileDialog::Options options) {
const QString dir = OpenFlipperSettings().value(configProperty, defaultDir).toString();
const QString result = QFileDialog::getOpenFileName(parent, caption, dir,
filter, selectedFilter, options);
if (result.length())
OpenFlipperSettings().setValue(configProperty, result);
return result;
}
QString getSaveFileName(const QString &configProperty,
QWidget * parent, const QString & caption,
const QString & defaultDir, const QString & filter,
QString * selectedFilter, QFileDialog::Options options) {
const QString dir = OpenFlipperSettings().value(configProperty, defaultDir).toString();
const QString result = QFileDialog::getSaveFileName(parent, caption, dir,
filter, selectedFilter, options);
if (result.length())
OpenFlipperSettings().setValue(configProperty, result);
return result;
}
} // End namespace PluginFunctions
......@@ -59,6 +59,7 @@
#define PLUGINFUNCTIONS_HH
#include <QPair>
#include <QFileDialog>
#include <OpenFlipper/common/Types.hh>
......@@ -675,6 +676,39 @@ int viewerId();
DLLEXPORT
BaseObject*& objectRoot();
/**
* The same as QFileDialog::getOpenFileName, except the dialog remembers its
* last location within the file systems and opens at the same location the
* next time.
*
* @param configProperty The name of the property in which to store the
* last location. Should be of the form "Plugin-Foo/OpenBarFile".
*
* @param defaultDir If the property doesn't exist yet, defaultDir is used
* as the initial location.
*/
DLLEXPORT
QString getOpenFileName(const QString &configProperty,
QWidget * parent = 0, const QString & caption = QString(),
const QString & defaultDir = QString(), const QString & filter = QString(),
QString * selectedFilter = 0, QFileDialog::Options options = 0);
/**
* The same as QFileDialog::getSaveFileName, except the dialog remembers its
* last location within the file systems and opens at the same location the
* next time.
*
* @param configProperty The name of the property in which to store the
* last location. Should be of the form "Plugin-Foo/SaveBarFile".
*
* @param defaultDir If the property doesn't exist yet, defaultDir is used
* as the initial location.
*/
DLLEXPORT
QString getSaveFileName(const QString &configProperty,
QWidget * parent = 0, const QString & caption = QString(),
const QString & defaultDir = QString(), const QString & filter = QString(),
QString * selectedFilter = 0, QFileDialog::Options options = 0);
}
#endif //PLUGINFUNCTIONS_HH
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment