Gui: Default load/save img to working directory (#26182)
- FileOptionsDialog is only used in the 'save screenshot / save image' codepath, and currently it doesn't set a directory to it defaults to process CWD, which is surely not what the user wants. - The load image codepath uses a custom QFileDialog instead of the helper code in FileDialog, there doesn't seem to be a great reason for this, although the helper doesn't have support for mime types it seems. - I haven't changed the dialogs to 'set/store' the working directory. I'm not sure this is desired as this isn't a 'normal' save/load operation. - It would be ideal to remove the FileOptionsDialog in future. The extended functionality could be turned into a separate dialog which opens before or after the file chooser. This would allow native dialogs to be used and would unify the code paths for file selection. - Further, it would be nice to just merge at least the load image into the existing import/open option, and to put 'save image' next to 'export', but those changes may be much more time consuming. For now I've kept it simple. Let's see what others think.
This commit is contained in:
@@ -2238,6 +2238,7 @@ void StdViewLoadImage::activated(int iMsg)
|
||||
// Reading an image
|
||||
QFileDialog dialog(Gui::getMainWindow());
|
||||
dialog.setWindowTitle(QObject::tr("Choose an Image File to Open"));
|
||||
dialog.setDirectory(FileDialog::getWorkingDirectory());
|
||||
dialog.setMimeTypeFilters(mimeTypeFilters);
|
||||
dialog.selectMimeTypeFilter(QStringLiteral("image/png"));
|
||||
dialog.setDefaultSuffix(QStringLiteral("png"));
|
||||
|
||||
@@ -562,6 +562,7 @@ FileOptionsDialog::FileOptionsDialog(QWidget* parent, Qt::WindowFlags fl)
|
||||
extensionButton->setText(tr("Extended"));
|
||||
|
||||
setOption(QFileDialog::DontUseNativeDialog);
|
||||
setDirectory(FileDialog::getWorkingDirectory());
|
||||
|
||||
// search for the grid layout and add the new button
|
||||
auto grid = this->findChild<QGridLayout*>();
|
||||
|
||||
Reference in New Issue
Block a user