Suggest sensible defaults in file dialogs
Went through first the diff of the referenced commit,
then all instances of "Create(Open|Save)FileDialog";
added SuggestFilename() calls where a default exists
This has been previously removed in
6b5db58971
Closes #538
pull/846/head
parent
a8b8a347c1
commit
e59186a413
|
@ -904,11 +904,13 @@ try_again:
|
|||
} else if(linkMap.count(g.linkFile) == 0) {
|
||||
dbp("Missing file for group: %s", g.name.c_str());
|
||||
// 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->SuggestFilename(linkFileRelative);
|
||||
if(dialog->RunModal()) {
|
||||
dialog->FreezeChoices(settings, "LinkSketch");
|
||||
linkMap[g.linkFile] = dialog->GetFilename();
|
||||
|
@ -985,6 +987,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->SuggestFilename(filename->RelativeTo(saveFile));
|
||||
if(dialog->RunModal()) {
|
||||
dialog->FreezeChoices(settings, "LinkImage");
|
||||
*filename = dialog->GetFilename();
|
||||
|
|
|
@ -356,6 +356,7 @@ public:
|
|||
|
||||
virtual Platform::Path GetFilename() = 0;
|
||||
virtual void SetFilename(Platform::Path path) = 0;
|
||||
virtual void SuggestFilename(Platform::Path path) = 0;
|
||||
|
||||
virtual void AddFilter(std::string name, std::vector<std::string> extensions) = 0;
|
||||
void AddFilter(const FileFilter &filter);
|
||||
|
|
|
@ -1246,6 +1246,10 @@ public:
|
|||
gtkChooser->set_filename(path.raw);
|
||||
}
|
||||
|
||||
void SuggestFilename(Platform::Path path) override {
|
||||
SetFilename(path.WithExtension("")); // TODO
|
||||
}
|
||||
|
||||
void AddFilter(std::string name, std::vector<std::string> extensions) override {
|
||||
Glib::RefPtr<Gtk::FileFilter> gtkFilter = Gtk::FileFilter::create();
|
||||
Glib::ustring desc;
|
||||
|
|
|
@ -1274,6 +1274,10 @@ public:
|
|||
nsPanel.nameFieldStringValue = Wrap(path.FileStem());
|
||||
}
|
||||
|
||||
void SuggestFilename(Platform::Path path) override {
|
||||
SetFilename(path.WithExtension(""));
|
||||
}
|
||||
|
||||
void FreezeChoices(SettingsRef settings, const std::string &key) override {
|
||||
settings->FreezeString("Dialog_" + key + "_Folder",
|
||||
[nsPanel.directoryURL.absoluteString UTF8String]);
|
||||
|
|
|
@ -1582,6 +1582,10 @@ public:
|
|||
wcsncpy(filenameWC, Widen(path.raw).c_str(), sizeof(filenameWC) / sizeof(wchar_t) - 1);
|
||||
}
|
||||
|
||||
void SuggestFilename(Platform::Path path) override {
|
||||
SetFilename(Platform::Path::From(path.FileStem()));
|
||||
}
|
||||
|
||||
void AddFilter(std::string name, std::vector<std::string> extensions) override {
|
||||
std::string desc, patterns;
|
||||
for(auto extension : extensions) {
|
||||
|
|
|
@ -627,6 +627,7 @@ void SolveSpaceUI::MenuFile(Command id) {
|
|||
Platform::FileDialogRef dialog = Platform::CreateSaveFileDialog(SS.GW.window);
|
||||
dialog->AddFilters(Platform::RasterFileFilters);
|
||||
dialog->ThawChoices(settings, "ExportImage");
|
||||
dialog->SuggestFilename(SS.saveFile);
|
||||
if(dialog->RunModal()) {
|
||||
dialog->FreezeChoices(settings, "ExportImage");
|
||||
SS.ExportAsPngTo(dialog->GetFilename());
|
||||
|
@ -638,6 +639,7 @@ void SolveSpaceUI::MenuFile(Command id) {
|
|||
Platform::FileDialogRef dialog = Platform::CreateSaveFileDialog(SS.GW.window);
|
||||
dialog->AddFilters(Platform::VectorFileFilters);
|
||||
dialog->ThawChoices(settings, "ExportView");
|
||||
dialog->SuggestFilename(SS.saveFile);
|
||||
if(!dialog->RunModal()) break;
|
||||
dialog->FreezeChoices(settings, "ExportView");
|
||||
|
||||
|
@ -661,6 +663,7 @@ void SolveSpaceUI::MenuFile(Command id) {
|
|||
Platform::FileDialogRef dialog = Platform::CreateSaveFileDialog(SS.GW.window);
|
||||
dialog->AddFilters(Platform::Vector3dFileFilters);
|
||||
dialog->ThawChoices(settings, "ExportWireframe");
|
||||
dialog->SuggestFilename(SS.saveFile);
|
||||
if(!dialog->RunModal()) break;
|
||||
dialog->FreezeChoices(settings, "ExportWireframe");
|
||||
|
||||
|
@ -672,6 +675,7 @@ void SolveSpaceUI::MenuFile(Command id) {
|
|||
Platform::FileDialogRef dialog = Platform::CreateSaveFileDialog(SS.GW.window);
|
||||
dialog->AddFilters(Platform::VectorFileFilters);
|
||||
dialog->ThawChoices(settings, "ExportSection");
|
||||
dialog->SuggestFilename(SS.saveFile);
|
||||
if(!dialog->RunModal()) break;
|
||||
dialog->FreezeChoices(settings, "ExportSection");
|
||||
|
||||
|
@ -683,6 +687,7 @@ void SolveSpaceUI::MenuFile(Command id) {
|
|||
Platform::FileDialogRef dialog = Platform::CreateSaveFileDialog(SS.GW.window);
|
||||
dialog->AddFilters(Platform::MeshFileFilters);
|
||||
dialog->ThawChoices(settings, "ExportMesh");
|
||||
dialog->SuggestFilename(SS.saveFile);
|
||||
if(!dialog->RunModal()) break;
|
||||
dialog->FreezeChoices(settings, "ExportMesh");
|
||||
|
||||
|
@ -694,6 +699,7 @@ void SolveSpaceUI::MenuFile(Command id) {
|
|||
Platform::FileDialogRef dialog = Platform::CreateSaveFileDialog(SS.GW.window);
|
||||
dialog->AddFilters(Platform::SurfaceFileFilters);
|
||||
dialog->ThawChoices(settings, "ExportSurfaces");
|
||||
dialog->SuggestFilename(SS.saveFile);
|
||||
if(!dialog->RunModal()) break;
|
||||
dialog->FreezeChoices(settings, "ExportSurfaces");
|
||||
|
||||
|
@ -910,6 +916,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");
|
||||
|
||||
|
|
Loading…
Reference in New Issue