diff --git a/sources/exportdialog.cpp b/sources/exportdialog.cpp index 5dfdc6fd6..3aa5559a3 100644 --- a/sources/exportdialog.cpp +++ b/sources/exportdialog.cpp @@ -191,7 +191,7 @@ QWidget *ExportDialog::leftPart() { QHBoxLayout *hboxLayout = new QHBoxLayout(); QLabel *dirpath_label = new QLabel(tr("Dossier cible :"), this); dirpath = new QLineEdit(this); - dirpath -> setText(QDir::toNativeSeparators(QDir::homePath())); + dirpath -> setText(QDir::toNativeSeparators(project_ -> currentDir())); QCompleter *completer = new QCompleter(this); completer -> setModel(new QDirModel(completer)); dirpath -> setCompleter(completer); @@ -358,7 +358,7 @@ void ExportDialog::slot_chooseADirectory() { QString user_dir = QFileDialog::getExistingDirectory( this, tr("Exporter dans le dossier", "dialog title"), - QDir::homePath() + dirpath -> text() ); if (!user_dir.isEmpty()) { dirpath -> setText(user_dir); diff --git a/sources/projectview.cpp b/sources/projectview.cpp index 7325bd003..c3ca4505c 100644 --- a/sources/projectview.cpp +++ b/sources/projectview.cpp @@ -650,7 +650,7 @@ bool ProjectView::saveAs() { QString filepath = QFileDialog::getSaveFileName( this, tr("Enregistrer sous", "dialog title"), - (project_ -> filePath().isEmpty() ? QDir::homePath() : QDir(project_ -> filePath())).absolutePath(), + project_ -> currentDir(), tr("Sch\351ma QElectroTech (*.qet)", "filetypes allowed when saving a diagram file") ); diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 3331d8e98..5c6cbade4 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -34,7 +34,7 @@ */ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) : QMainWindow(parent), - open_dialog_dir(QDir::homePath()), + open_dialog_dir(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)), can_update_actions(true) { // mise en place de l'interface MDI au centre de l'application diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index 5f3567405..2544b4595 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -169,6 +169,21 @@ void QETProject::setFilePath(const QString &filepath) { emit(projectInformationsChanged(this)); } +/** + @return le dossier contenant le fichier projet si celui-ci a ete + enregistre ; dans le cas contraire, cette methode retourne l'emplacement + du bureau de l'utilisateur. +*/ +QString QETProject::currentDir() const { + QString current_directory; + if (file_path_.isEmpty()) { + current_directory = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); + } else { + current_directory = QFileInfo(file_path_).absoluteDir().absolutePath(); + } + return(current_directory); +} + /** @return une chaine de caractere du type "Projet titre du projet". diff --git a/sources/qetproject.h b/sources/qetproject.h index 6228209da..2df09e9e1 100644 --- a/sources/qetproject.h +++ b/sources/qetproject.h @@ -73,6 +73,7 @@ class QETProject : public QObject { ElementsCollection *embeddedCollection() const; QString filePath(); void setFilePath(const QString &); + QString currentDir() const; QString pathNameTitle() const; QString title() const; void setTitle(const QString &);