View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001675 | Draft | Bug | public | 2014-08-08 18:44 | 2015-01-05 22:44 |
Reporter | mghansen256 | Assigned To | yorik | ||
Priority | low | Severity | trivial | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | Linux | OS | Kubuntu | OS Version | 14.04 |
Product Version | 0.14 | ||||
Fixed in Version | 0.15 | ||||
Summary | 0001675: File selection dialog for texture image starts in /usr/lib/freecad | ||||
Description | The file selection dialog for the texture image for draft rectangles starts in /usr/lib/freecad. IMHO it would be useful to start it in the directory of the freecad document, then, assuming that images are located close to that document's file, the user does not have to navigate there. | ||||
Additional Information | OS: Ubuntu 14.04.1 LTS Word size: 64-bit Version: 0.15.3844 (Git) Branch: master Hash: 28490532f50135e2490f94cdf401b613a94b1ec2 Python version: 2.7.6 Qt version: 4.8.6 Coin version: 4.0.0a SoQt version: 1.6.0a OCC version: 6.7.0 | ||||
Tags | No tags attached. | ||||
FreeCAD Information | |||||
|
Not sure how easy this is to do, but I'll have a look. |
|
Hi Yorik, I made a pull request for this one: https://github.com/FreeCAD/FreeCAD_sf_master/pull/31 I will also attach the patch. Best regards, Michael |
|
1675-patch.diff (1,503 bytes)
diff --git a/src/Gui/FileDialog.cpp b/src/Gui/FileDialog.cpp index af58991..50b6a94 100644 --- a/src/Gui/FileDialog.cpp +++ b/src/Gui/FileDialog.cpp @@ -38,6 +38,7 @@ #include <Base/Parameter.h> #include <App/Application.h> +#include <App/Document.h> #include "FileDialog.h" #include "MainWindow.h" @@ -525,11 +526,24 @@ void FileChooser::setFileName( const QString& s ) */ void FileChooser::chooseFile() { + QString prechosenDirectory = lineEdit->text(); + if (prechosenDirectory.isEmpty()) { + App::Document* const doc = App::GetApplication().getActiveDocument(); + const QString filename = QString::fromStdString(doc->FileName.getStrValue()); + + // if the document has no filename yet, start browsing in the users home directory + if (!filename.isEmpty()) { + prechosenDirectory = filename; + } else { + prechosenDirectory = QDir::homePath(); + } + } + QString fn; if ( mode() == File ) - fn = QFileDialog::getOpenFileName( this, tr( "Select a file" ), lineEdit->text(), _filter ); + fn = QFileDialog::getOpenFileName( this, tr( "Select a file" ), prechosenDirectory, _filter ); else - fn = QFileDialog::getExistingDirectory( this, tr( "Select a directory" ), lineEdit->text() ); + fn = QFileDialog::getExistingDirectory( this, tr( "Select a directory" ), prechosenDirectory ); if (!fn.isEmpty()) { lineEdit->setText(fn); |
|
https://github.com/mghansen256/FreeCAD_sf_master/commit/bff32fb6fb7b0260ba1c4cc1dd33d25fe908a19e IMO, it's not a good idea to make a widget dependent on the document stuff. A better way could be to add a further Q_PROPERTY where the pre-chosen directory/file can be set from outside. This makes the usage of this widget more flexible. Btw, your patch will lead to a crash when there is no document open. |
|
Hi wmayer, thank you for the note about the crash. I updated the pull request to use FileDialog::getWorkingDirectory() to get an initial directory, then no new dependencies are introduced. The only drawback is that now the directory is taken from the last opened file, but still better than before. Michael |
Date Modified | Username | Field | Change |
---|---|---|---|
2014-08-08 18:44 | mghansen256 | New Issue | |
2014-08-08 19:24 | yorik | Assigned To | => yorik |
2014-08-08 19:24 | yorik | Status | new => assigned |
2014-08-08 19:25 | yorik | Note Added: 0004930 | |
2014-08-18 19:44 | mghansen256 | Note Added: 0004962 | |
2014-08-18 19:46 | mghansen256 | File Added: 1675-patch.diff | |
2014-08-19 13:46 | wmayer | Note Added: 0004971 | |
2014-09-18 13:39 | yorik | Status | assigned => feedback |
2014-11-25 20:37 | mghansen256 | Note Added: 0005343 | |
2014-11-25 20:37 | mghansen256 | Status | feedback => assigned |
2015-01-05 22:44 | wmayer | Changeset attached | => FreeCAD Master master be919bb6 |
2015-01-05 22:44 | wmayer | Status | assigned => closed |
2015-01-05 22:44 | wmayer | Resolution | open => fixed |
2015-01-05 22:44 | wmayer | Fixed in Version | => 0.15 |