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

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;
......@@ -264,37 +267,40 @@ QString dirSeparator() {
return QString("/");
}
QDir applicationDir() { return applicationDir_; }
QDir configDir() { return configDir_; }
QDir pluginDir() { return pluginDir_; }
QDir shaderDir() { return shaderDir_; }
QDir textureDir() { return textureDir_; }
QDir iconDir() { return iconDir_; }
QDir fontsDir() { return fontsDir_; }
QDir currentDir() { return currentDir_; }
QDir currentScriptDir(){ return currentScriptDir_; }
QString applicationDirStr() { return applicationDir_.absolutePath() ; }
QString configDirStr() { return configDir_.absolutePath(); }
QString pluginDirStr() { return pluginDir_.absolutePath(); }
QString shaderDirStr() { return shaderDir_.absolutePath(); }
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();}
QDir applicationDir() { return applicationDir_; }
QDir configDir() { return configDir_; }
QDir pluginDir() { return pluginDir_; }
QDir shaderDir() { return shaderDir_; }
QDir textureDir() { return textureDir_; }
QDir iconDir() { return iconDir_; }
QDir fontsDir() { return fontsDir_; }
QDir currentDir() { return currentDir_; }
QDir currentScriptDir() { return currentScriptDir_; }
QDir currentTextureDir(){ return currentTextureDir_; }
QString applicationDirStr() { return applicationDir_.absolutePath(); }
QString configDirStr() { return configDir_.absolutePath(); }
QString pluginDirStr() { return pluginDir_.absolutePath(); }
QString shaderDirStr() { return shaderDir_.absolutePath(); }
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 currentTextureDirStr() { return currentTextureDir_.absolutePath(); }
QStringList optionFiles() { return optionFiles_; }
void applicationDir(QDir _dir) { applicationDir_ = _dir; }
void pluginDir(QDir _dir) { pluginDir_ = _dir; }
void shaderDir(QDir _dir) { shaderDir_ = _dir; }
void textureDir(QDir _dir) { textureDir_ = _dir; }
void iconDir(QDir _dir) { iconDir_ = _dir; }
void applicationDir(QDir _dir) { applicationDir_ = _dir; }
void pluginDir(QDir _dir) { pluginDir_ = _dir; }
void shaderDir(QDir _dir) { shaderDir_ = _dir; }
void textureDir(QDir _dir) { textureDir_ = _dir; }
void iconDir(QDir _dir) { iconDir_ = _dir; }
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 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();
......@@ -308,7 +328,7 @@ void fontsDir(QDir _dir);
/// get if a gui should be visible or not
DLLEXPORT
bool gui( );
/// Store stereo support setting
DLLEXPORT
void stereo( bool _stereo );
......@@ -510,7 +530,7 @@ void fontsDir(QDir _dir);
DLLEXPORT
bool splash( );
/// Default background color
/// Default background color
DLLEXPORT
void defaultBackgroundColor( QColor _color );
......@@ -518,7 +538,7 @@ void fontsDir(QDir _dir);
DLLEXPORT
QColor defaultBackgroundColor();
/// Default base color
/// Default base color
DLLEXPORT
void defaultBaseColor( QColor _color );
......@@ -526,11 +546,11 @@ void fontsDir(QDir _dir);
DLLEXPORT
QColor defaultBaseColor();
/// use randomized base color
/// use randomized base color
DLLEXPORT
void randomBaseColor(bool _random);
/// use randomized base color
/// use randomized base color
DLLEXPORT
bool randomBaseColor();
......
......@@ -103,7 +103,7 @@ LoadWidget::~LoadWidget()
// (the fileplugins control the optionWidgets)
for (int i=0; i < boxWidgets_.size(); i++){
boxLayout_->removeWidget( boxWidgets_[i] );
boxWidgets_[i]->setParent(0);
boxWidgets_[i]->setParent(0);
}
}
......@@ -112,7 +112,7 @@ void LoadWidget::currentFilterChanged(QString _currentFilter){
for (int i=0; i < boxWidgets_.size(); i++){
boxLayout_->removeWidget( boxWidgets_[i] );
boxWidgets_[i]->setParent(0);
boxWidgets_[i]->setParent(0);
}
boxWidgets_.clear();
......@@ -138,7 +138,7 @@ void LoadWidget::currentFilterChanged(QString _currentFilter){
//add Widget for new Filter
QWidget* nuWidget = 0;
nuWidget = supportedTypes_[i].plugin->saveOptionsWidget(_currentFilter);
if (nuWidget != 0){
boxLayout_->addWidget( nuWidget );
boxWidgets_.push_back( nuWidget );
......@@ -154,7 +154,7 @@ void LoadWidget::slotSetLoadFilters(int _typeIndex){
for (int i=0; i < boxWidgets_.size(); i++){
boxLayout_->removeWidget( boxWidgets_[i] );
boxWidgets_[i]->setParent(0);
boxWidgets_[i]->setParent(0);
}
boxWidgets_.clear();
......@@ -188,7 +188,7 @@ void LoadWidget::slotSetSaveFilters(int _typeIndex){
for (int i=0; i < boxWidgets_.size(); i++){
boxLayout_->removeWidget( boxWidgets_[i] );
boxWidgets_[i]->setParent(0);
boxWidgets_[i]->setParent(0);
}
boxWidgets_.clear();
......@@ -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