Commit 4a319366 authored by Christophe Courtaut's avatar Christophe Courtaut Committed by root

Save the last used path in import dialog

parent 7ddb905e
......@@ -29,6 +29,7 @@
#include "Library.h"
#include <QPalette>
#include <QSettings>
#include <QTime>
ImportController::ImportController(QWidget *parent) :
......@@ -57,9 +58,12 @@ ImportController::ImportController(QWidget *parent) :
m_filesModel->setNameFilters( filters );
Library::getInstance()->setFilter( filters );
restoreCurrentPath();
m_ui->treeView->setModel( m_filesModel );
m_ui->treeView->setRootIndex( m_filesModel->index( QDir::rootPath() ) );
m_ui->treeView->setCurrentIndex( m_filesModel->index( QDir::homePath() ) );
m_ui->treeView->setCurrentIndex( m_filesModel->index( m_currentlyWatchedDir ) );
m_ui->treeView->setExpanded( m_ui->treeView->currentIndex() , true );
m_ui->treeView->setColumnHidden( 1, true );
m_ui->treeView->setColumnHidden( 2, true );
......@@ -67,8 +71,7 @@ ImportController::ImportController(QWidget *parent) :
m_ui->forwardButton->setEnabled( false );
m_fsWatcher = new QFileSystemWatcher();
m_fsWatcher->addPath( QDir::homePath() );
m_currentlyWatchedDir = QDir::homePath();
m_fsWatcher->addPath( m_currentlyWatchedDir );
connect( m_fsWatcher, SIGNAL( directoryChanged( QString ) ),
m_filesModel, SLOT( refresh() ) );
......@@ -250,6 +253,7 @@ ImportController::treeViewClicked( const QModelIndex& index )
m_fsWatcher->removePath( m_currentlyWatchedDir );
m_currentlyWatchedDir = m_filesModel->filePath( index );
m_fsWatcher->addPath( m_filesModel->filePath( index ) );
saveCurrentPath();
}
m_ui->forwardButton->setEnabled( true );
}
......@@ -340,3 +344,20 @@ ImportController::restoreContext()
m_currentUuid = m_savedUuid;
m_controllerSwitched = false;
}
void
ImportController::saveCurrentPath()
{
QSettings s;
s.setValue( "ImportPreviouslySelectPath", m_currentlyWatchedDir );
s.sync();
}
void
ImportController::restoreCurrentPath()
{
QSettings s;
QVariant path = s.value( "ImportPreviouslySelectPath", QDir::homePath() );
QFileInfo info = path.toString();
m_currentlyWatchedDir = info.absoluteFilePath();
}
......@@ -64,6 +64,8 @@ class ImportController : public QDialog
void changeEvent( QEvent *e );
private:
void saveCurrentPath();
void restoreCurrentPath();
Ui::ImportController* m_ui;
PreviewWidget* m_preview;
StackViewController* m_stackNav;
......
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