Improve save (new style) dialog by adding file extension automatically

1. Add file extension automatically while changing file type via combobox in new style dialog.
2. Add file extension automatically for session files and workspace files while saving in new style dialog.

Fix #4876, close #8311, close #8312
pull/5785/head
Udo Hoffmann 2020-05-24 19:29:19 +02:00 committed by Don HO
parent bb6b24ce50
commit edd746d310
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
4 changed files with 5 additions and 0 deletions

View File

@ -2217,6 +2217,7 @@ const TCHAR * Notepad_plus::fileSaveSession(size_t nbFile, TCHAR ** fileNames)
sessionExt += TEXT(".");
sessionExt += ext;
fDlg.setExtFilter(TEXT("Session file"), sessionExt.c_str(), NULL);
fDlg.setDefExt(ext);
fDlg.setExtIndex(0); // 0 index for "custom extension types"
}
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL);

View File

@ -267,6 +267,7 @@ TCHAR * FileDialog::doSaveDlg()
NppParameters& params = NppParameters::getInstance();
_ofn.lpstrInitialDir = params.getWorkingDir();
_ofn.lpstrDefExt = _defExt.c_str();
_ofn.Flags |= OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_ENABLESIZING;

View File

@ -49,6 +49,7 @@ public:
int setExtsFilter(const TCHAR *extText, const TCHAR *exts);
void setDefFileName(const TCHAR *fn){ wcscpy_s(_fileName, fn);}
void setDefExt(const TCHAR *ext){ _defExt = ext;}
TCHAR * doSaveDlg();
stringVector * doOpenMultiFilesDlg();
@ -63,6 +64,7 @@ protected :
private:
TCHAR _fileName[MAX_PATH*8];
generic_string _defExt;
TCHAR * _fileExt;
int _nbCharFileExt;

View File

@ -1188,6 +1188,7 @@ void ProjectPanel::setFileExtFilter(FileDialog & fDlg)
workspaceExt += TEXT(".");
workspaceExt += ext;
fDlg.setExtFilter(TEXT("Workspace file"), workspaceExt.c_str(), NULL);
fDlg.setDefExt(ext);
}
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL);
}