Commit b06ae2de authored by Jan Möbius's avatar Jan Möbius
Browse files

Added option to remember last texture dir

Remember last load dir correctly!

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5823 383ad7c9-94d9-4d36-a494-682f7c89f535
parent b24198db
......@@ -137,9 +137,16 @@ void Core::readApplicationOptions(INIFile& _ini) {
// Load the default script directory
//============================================================================
QString script_dir;
if( _ini.get_entry(script_dir, "Options", "ScriptDir") )
if( _ini.get_entry(script_dir, "Options", "CurrentScriptDir") )
OpenFlipper::Options::currentScriptDir(script_dir);
//============================================================================
// Load the default texture directory
//============================================================================
QString current_texture_dir;
if( _ini.get_entry(current_texture_dir, "Options", "CurrentTextureDir") )
OpenFlipper::Options::currentTextureDir(current_texture_dir);
//============================================================================
// Load the random base color setting
//============================================================================
......@@ -489,7 +496,10 @@ void Core::writeApplicationOptions(INIFile& _ini) {
_ini.add_entry("Options","StartupDir",dir);
QString scriptDir = OpenFlipper::Options::currentScriptDirStr().toUtf8();
_ini.add_entry("Options","ScriptDir",scriptDir);
_ini.add_entry("Options","CurrentScriptDir",scriptDir);
QString current_texture_dir = OpenFlipper::Options::currentTextureDirStr().toUtf8();
_ini.add_entry("Options","CurrentTextureDir",current_texture_dir);
_ini.add_entry("Options","RandomBaseColor", OpenFlipper::Options::randomBaseColor() );
......
......@@ -266,11 +266,12 @@ void Core::slotObjectOpened ( int _id ) {
// ================================================================================
backupRequest(_id,"Original Object");
// ================================================================================
// Add the file to the recent files menu
// ================================================================================
QString filename = object->path() + OpenFlipper::Options::dirSeparator() + object->name();
BaseObject* object2;
PluginFunctions::getObject(_id,object2);
if ( OpenFlipper::Options::gui() )
coreWidget_->addRecent( filename, object2->dataType() );
......
......@@ -256,6 +256,15 @@ void Core::setupOptions() {
// Set the previously generated Optionfiles
OpenFlipper::Options::optionFiles(optionFiles);
// ==============================================================
// Default File open directories
// ==============================================================
// Default to OpenFlippers Texture dir
OpenFlipper::Options::currentTextureDir(OpenFlipper::Options::textureDirStr());
// Default to home directory
OpenFlipper::Options::currentDir( QDir::home() );
// ==============================================================
// Load Application options from all files available
......
......@@ -82,6 +82,9 @@ static QDir currentDir_;
/// Current script directory of the application
static QDir currentScriptDir_;
/// Current texture directory of the application
static QDir currentTextureDir_;
/// Experience level of the user
static Experience experienceLevel_ = NOVICE;
......@@ -272,9 +275,10 @@ QDir textureDir() { return textureDir_; }
QDir iconDir() { return iconDir_; }
QDir fontsDir() { return fontsDir_; }
QDir currentDir() { return currentDir_; }
QDir currentScriptDir(){ return currentScriptDir_; }
QDir currentScriptDir() { return currentScriptDir_; }
QDir currentTextureDir(){ return currentTextureDir_; }
QString applicationDirStr() { return applicationDir_.absolutePath() ; }
QString applicationDirStr() { return applicationDir_.absolutePath(); }
QString configDirStr() { return configDir_.absolutePath(); }
QString pluginDirStr() { return pluginDir_.absolutePath(); }
QString shaderDirStr() { return shaderDir_.absolutePath(); }
......@@ -282,7 +286,8 @@ QString textureDirStr() { return textureDir_.absolutePath(); }
QString iconDirStr() { return iconDir_.absolutePath(); }
QString fontsDirStr() { return fontsDir_.absolutePath(); }
QString currentDirStr() { return currentDir_.absolutePath(); }
QString currentScriptDirStr(){ return currentScriptDir_.absolutePath();}
QString currentScriptDirStr() { return currentScriptDir_.absolutePath(); }
QString currentTextureDirStr() { return currentTextureDir_.absolutePath(); }
QStringList optionFiles() { return optionFiles_; }
......@@ -295,6 +300,7 @@ void fontsDir(QDir _dir) { fontsDir_ = _dir;}
void configDir(QDir _dir) { configDir_ = _dir; }
void currentDir(QDir _dir) { currentDir_ = _dir; }
void currentScriptDir(QDir _dir) { currentScriptDir_ = _dir; }
void currentTextureDir(QDir _dir) { currentTextureDir_ = _dir; }
void optionFiles(QStringList _list) { optionFiles_ = _list; }
......@@ -391,6 +397,15 @@ bool currentScriptDir(QString _dir) {
return false;
}
bool currentTextureDir(QString _dir) {
QDir tmp(_dir);
if (tmp.exists()) {
currentTextureDir_ = tmp;
return true;
}
return false;
}
/// Get experience level
Experience getExperience() {
return experienceLevel_;
......
......@@ -225,6 +225,26 @@ void fontsDir(QDir _dir);
DLLEXPORT
bool currentScriptDir(QString _dir);
/// return the current texture-directory
DLLEXPORT
QString currentTextureDirStr();
/// return the current texture-directory
DLLEXPORT
QDir currentTextureDir();
/// Sets the Path to the current texture-directory
DLLEXPORT
void currentTextureDir(QDir _dir);
/// Sets the Path to the current texture-directory
DLLEXPORT
bool currentTextureDir(QString _dir);
/// return last used dataType
DLLEXPORT
QString lastDataType();
......
......@@ -230,7 +230,9 @@ void LoadWidget::loadFile(){
for (int i=0; i < files.size(); i++){
QFileInfo fi(files[i]);
QString filename = fi.absoluteFilePath();
OpenFlipper::Options::currentDir(fi.absolutePath());
QFile file(filename);
if (fi.isDir() || !file.exists()) continue; //do nothing if its a not a valid file
QString ext = fi.suffix();
......@@ -241,6 +243,8 @@ void LoadWidget::loadFile(){
success = true;
}
if (success) //at least one item was loaded successfully
OpenFlipper::Options::lastDataType(typeBox_->currentText());
}
......
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