mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 22:04:55 +02:00
Enhance Save file dialog
Make file extensions shorter in the file extension list for Save file dialog, so it displays more nicely while user clicking the drop down commbobox.
This commit is contained in:
parent
a8bde7fdaf
commit
d4124108bc
@ -583,8 +583,8 @@ private:
|
||||
int getLangFromMenuName(const TCHAR * langName);
|
||||
generic_string getLangFromMenu(const Buffer * buf);
|
||||
|
||||
generic_string exts2Filters(const generic_string& exts) const;
|
||||
int setFileOpenSaveDlgFilters(FileDialog & fDlg, int langType = -1);
|
||||
generic_string exts2Filters(const generic_string& exts, int maxExtsLen = -1) const; // maxExtsLen default value -1 makes no limit of whole exts length
|
||||
int setFileOpenSaveDlgFilters(FileDialog & fDlg, bool showAllExt, int langType = -1); // showAllExt should be true if it's used for open file dialog - all set exts should be used for filtering files
|
||||
Style * getStyleFromName(const TCHAR *styleName);
|
||||
bool dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix = TEXT("")); //helper func
|
||||
void drawTabbarColoursFromStylerArray();
|
||||
|
@ -739,7 +739,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne, bool doDeleteBackup)
|
||||
return;
|
||||
}
|
||||
|
||||
generic_string Notepad_plus::exts2Filters(const generic_string& exts) const
|
||||
generic_string Notepad_plus::exts2Filters(const generic_string& exts, int maxExtsLen) const
|
||||
{
|
||||
const TCHAR *extStr = exts.c_str();
|
||||
TCHAR aExt[MAX_PATH];
|
||||
@ -747,6 +747,7 @@ generic_string Notepad_plus::exts2Filters(const generic_string& exts) const
|
||||
|
||||
int j = 0;
|
||||
bool stop = false;
|
||||
|
||||
for (size_t i = 0, len = exts.length(); i < len && j < MAX_PATH - 1; ++i)
|
||||
{
|
||||
if (extStr[i] == ' ')
|
||||
@ -763,6 +764,12 @@ generic_string Notepad_plus::exts2Filters(const generic_string& exts) const
|
||||
filters += TEXT(";");
|
||||
}
|
||||
j = 0;
|
||||
|
||||
if (maxExtsLen != -1 && i >= maxExtsLen)
|
||||
{
|
||||
filters += TEXT(" ... ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -789,7 +796,7 @@ generic_string Notepad_plus::exts2Filters(const generic_string& exts) const
|
||||
return filters;
|
||||
}
|
||||
|
||||
int Notepad_plus::setFileOpenSaveDlgFilters(FileDialog & fDlg, int langType)
|
||||
int Notepad_plus::setFileOpenSaveDlgFilters(FileDialog & fDlg, bool showAllExt, int langType)
|
||||
{
|
||||
NppParameters& nppParam = NppParameters::getInstance();
|
||||
NppGUI & nppGUI = (NppGUI & )nppParam.getNppGUI();
|
||||
@ -835,7 +842,7 @@ int Notepad_plus::setFileOpenSaveDlgFilters(FileDialog & fDlg, int langType)
|
||||
list += userList;
|
||||
}
|
||||
|
||||
generic_string stringFilters = exts2Filters(list);
|
||||
generic_string stringFilters = exts2Filters(list, showAllExt ? -1 : 40);
|
||||
const TCHAR *filters = stringFilters.c_str();
|
||||
if (filters[0])
|
||||
{
|
||||
@ -1583,7 +1590,7 @@ bool Notepad_plus::fileSaveAs(BufferID id, bool isSaveCopy)
|
||||
FileDialog fDlg(_pPublicInterface->getHSelf(), _pPublicInterface->getHinst());
|
||||
|
||||
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL);
|
||||
int langTypeIndex = setFileOpenSaveDlgFilters(fDlg, buf->getLangType());
|
||||
int langTypeIndex = setFileOpenSaveDlgFilters(fDlg, false, buf->getLangType());
|
||||
fDlg.setDefFileName(buf->getFileName());
|
||||
|
||||
fDlg.setExtIndex(langTypeIndex+1); // +1 for "All types"
|
||||
@ -1649,7 +1656,7 @@ bool Notepad_plus::fileRename(BufferID id)
|
||||
FileDialog fDlg(_pPublicInterface->getHSelf(), _pPublicInterface->getHinst());
|
||||
|
||||
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL);
|
||||
setFileOpenSaveDlgFilters(fDlg);
|
||||
setFileOpenSaveDlgFilters(fDlg, false);
|
||||
|
||||
fDlg.setDefFileName(buf->getFileName());
|
||||
TCHAR *pfn = fDlg.doSaveDlg();
|
||||
@ -1759,7 +1766,7 @@ void Notepad_plus::fileOpen()
|
||||
FileDialog fDlg(_pPublicInterface->getHSelf(), _pPublicInterface->getHinst());
|
||||
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL);
|
||||
|
||||
setFileOpenSaveDlgFilters(fDlg);
|
||||
setFileOpenSaveDlgFilters(fDlg, true);
|
||||
|
||||
BufferID lastOpened = BUFFER_INVALID;
|
||||
if (stringVector *pfns = fDlg.doOpenMultiFilesDlg())
|
||||
|
Loading…
x
Reference in New Issue
Block a user