From 6b94af07659bbe5d7635dddab3dc21262a7a78e7 Mon Sep 17 00:00:00 2001 From: dustinhartlyn <79132671+dustinhartlyn@users.noreply.github.com> Date: Thu, 1 Apr 2021 06:24:04 -0700 Subject: [PATCH] minor fix open/save dialogue on windows (#983) * minor fix open/save dialogue on windows On windows 10 the open/save dialogue box has an minor error, and I believe I fixed it. When "Open" is selected from the menu, the title of the dialogue box says "SolveSpace - Save File" and the entered file name is "united". My fix correctly titles the dialoged box, and leaves the address bar blank when a file is being opened because "united" is only needed as a default name when a file being saved. I found that class FileDialogImplWin32 from guiwin.cpp contains two if statements for "isSaveDialog". This is redundant. I removed the first where the title was originally set, but not working. I then set the title in the second if statement and moved the 'if isEmpty'' to this section. * Update guiwin.cpp replaced tabs with spaces --- src/platform/guiwin.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/platform/guiwin.cpp b/src/platform/guiwin.cpp index b93b87b..e98e873 100644 --- a/src/platform/guiwin.cpp +++ b/src/platform/guiwin.cpp @@ -1583,11 +1583,6 @@ public: ofn.nMaxFile = sizeof(filenameWC) / sizeof(wchar_t); ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - if(isSaveDialog) { - SetTitle(C_("title", "Save File")); - } else { - SetTitle(C_("title", "Open File")); - } } void SetTitle(std::string title) override { @@ -1640,13 +1635,14 @@ public: } bool RunModal() override { - if(GetFilename().IsEmpty()) { - SetFilename(Path::From(_("untitled"))); - } - if(isSaveDialog) { + SetTitle(C_("title", "Save File")); + if(GetFilename().IsEmpty()) { + SetFilename(Path::From(_("untitled"))); + } return GetSaveFileNameW(&ofn) == TRUE; } else { + SetTitle(C_("title", "Open File")); return GetOpenFileNameW(&ofn) == TRUE; } }