Skip to content

Commit

Permalink
SetFilename() file dialogs with sensible defaults
Browse files Browse the repository at this point in the history
Went through first the diff of the referenced commit,
then all instances of "Create(Open|Save)FileDialog";
added SetFilename() calls where a default exists.

This has been previously removed in
6b5db58
Closes #538
  • Loading branch information
nabijaczleweli committed Mar 21, 2020
1 parent e355a09 commit cc6926b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/file.cpp
Expand Up @@ -893,11 +893,13 @@ bool SolveSpaceUI::ReloadAllLinked(const Platform::Path &saveFile, bool canCance
}
} else if(linkMap.count(g.linkFile) == 0) {
// The file was moved; prompt the user for its new location.
switch(LocateImportedFile(g.linkFile.RelativeTo(saveFile), canCancel)) {
const auto linkFileRelative = g.linkFile.RelativeTo(saveFile);
switch(LocateImportedFile(linkFileRelative, canCancel)) {
case Platform::MessageDialog::Response::YES: {
Platform::FileDialogRef dialog = Platform::CreateOpenFileDialog(SS.GW.window);
dialog->AddFilters(Platform::SolveSpaceModelFileFilters);
dialog->ThawChoices(settings, "LinkSketch");
dialog->SetFilename(linkFileRelative);
if(dialog->RunModal()) {
dialog->FreezeChoices(settings, "LinkSketch");
linkMap[g.linkFile] = dialog->GetFilename();
Expand Down Expand Up @@ -974,6 +976,7 @@ bool SolveSpaceUI::ReloadLinkedImage(const Platform::Path &saveFile,
Platform::FileDialogRef dialog = Platform::CreateOpenFileDialog(SS.GW.window);
dialog->AddFilters(Platform::RasterFileFilters);
dialog->ThawChoices(settings, "LinkImage");
dialog->SetFilename(filename->RelativeTo(saveFile));
if(dialog->RunModal()) {
dialog->FreezeChoices(settings, "LinkImage");
*filename = dialog->GetFilename();
Expand Down
7 changes: 7 additions & 0 deletions src/solvespace.cpp
Expand Up @@ -599,6 +599,7 @@ void SolveSpaceUI::MenuFile(Command id) {
Platform::FileDialogRef dialog = Platform::CreateSaveFileDialog(SS.GW.window);
dialog->AddFilters(Platform::RasterFileFilters);
dialog->ThawChoices(settings, "ExportImage");
dialog->SetFilename(SS.saveFile);
if(dialog->RunModal()) {
dialog->FreezeChoices(settings, "ExportImage");
SS.ExportAsPngTo(dialog->GetFilename());
Expand All @@ -610,6 +611,7 @@ void SolveSpaceUI::MenuFile(Command id) {
Platform::FileDialogRef dialog = Platform::CreateSaveFileDialog(SS.GW.window);
dialog->AddFilters(Platform::VectorFileFilters);
dialog->ThawChoices(settings, "ExportView");
dialog->SetFilename(SS.saveFile);
if(!dialog->RunModal()) break;
dialog->FreezeChoices(settings, "ExportView");

Expand All @@ -633,6 +635,7 @@ void SolveSpaceUI::MenuFile(Command id) {
Platform::FileDialogRef dialog = Platform::CreateSaveFileDialog(SS.GW.window);
dialog->AddFilters(Platform::Vector3dFileFilters);
dialog->ThawChoices(settings, "ExportWireframe");
dialog->SetFilename(SS.saveFile);
if(!dialog->RunModal()) break;
dialog->FreezeChoices(settings, "ExportWireframe");

Expand All @@ -644,6 +647,7 @@ void SolveSpaceUI::MenuFile(Command id) {
Platform::FileDialogRef dialog = Platform::CreateSaveFileDialog(SS.GW.window);
dialog->AddFilters(Platform::VectorFileFilters);
dialog->ThawChoices(settings, "ExportSection");
dialog->SetFilename(SS.saveFile);
if(!dialog->RunModal()) break;
dialog->FreezeChoices(settings, "ExportSection");

Expand All @@ -655,6 +659,7 @@ void SolveSpaceUI::MenuFile(Command id) {
Platform::FileDialogRef dialog = Platform::CreateSaveFileDialog(SS.GW.window);
dialog->AddFilters(Platform::MeshFileFilters);
dialog->ThawChoices(settings, "ExportMesh");
dialog->SetFilename(SS.saveFile);
if(!dialog->RunModal()) break;
dialog->FreezeChoices(settings, "ExportMesh");

Expand All @@ -666,6 +671,7 @@ void SolveSpaceUI::MenuFile(Command id) {
Platform::FileDialogRef dialog = Platform::CreateSaveFileDialog(SS.GW.window);
dialog->AddFilters(Platform::SurfaceFileFilters);
dialog->ThawChoices(settings, "ExportSurfaces");
dialog->SetFilename(SS.saveFile);
if(!dialog->RunModal()) break;
dialog->FreezeChoices(settings, "ExportSurfaces");

Expand Down Expand Up @@ -879,6 +885,7 @@ void SolveSpaceUI::MenuAnalyze(Command id) {
Platform::FileDialogRef dialog = Platform::CreateSaveFileDialog(SS.GW.window);
dialog->AddFilters(Platform::CsvFileFilters);
dialog->ThawChoices(settings, "Trace");
dialog->SetFilename(SS.saveFile);
if(dialog->RunModal()) {
dialog->FreezeChoices(settings, "Trace");

Expand Down

0 comments on commit cc6926b

Please sign in to comment.