mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-09-25 19:08:47 +02:00
Fix "Import plugins" not working issue.
This commit is contained in:
parent
3465cac7ce
commit
f03ce289d3
@ -5447,6 +5447,52 @@ vector<generic_string> Notepad_plus::addNppComponents(const TCHAR *destDir, cons
|
|||||||
return copiedFiles;
|
return copiedFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<generic_string> Notepad_plus::addNppPlugins(const TCHAR *extFilterName, const TCHAR *extFilter)
|
||||||
|
{
|
||||||
|
FileDialog fDlg(_pPublicInterface->getHSelf(), _pPublicInterface->getHinst());
|
||||||
|
fDlg.setExtFilter(extFilterName, extFilter, NULL);
|
||||||
|
|
||||||
|
vector<generic_string> copiedFiles;
|
||||||
|
|
||||||
|
if (stringVector *pfns = fDlg.doOpenMultiFilesDlg())
|
||||||
|
{
|
||||||
|
// Get plugins dir
|
||||||
|
generic_string destDirName = (NppParameters::getInstance())->getPluginRootDir();
|
||||||
|
|
||||||
|
if (!::PathFileExists(destDirName.c_str()))
|
||||||
|
{
|
||||||
|
::CreateDirectory(destDirName.c_str(), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t sz = pfns->size();
|
||||||
|
for (size_t i = 0 ; i < sz ; ++i)
|
||||||
|
{
|
||||||
|
if (::PathFileExists(pfns->at(i).c_str()))
|
||||||
|
{
|
||||||
|
// copy to plugins directory
|
||||||
|
generic_string destName = destDirName;
|
||||||
|
|
||||||
|
generic_string nameExt = ::PathFindFileName(pfns->at(i).c_str());
|
||||||
|
auto pos = nameExt.find_last_of(TEXT("."));
|
||||||
|
if (pos == generic_string::npos)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
generic_string name = nameExt.substr(0, pos);
|
||||||
|
PathAppend(destName, name);
|
||||||
|
if (!::PathFileExists(destName.c_str()))
|
||||||
|
{
|
||||||
|
::CreateDirectory(destName.c_str(), NULL);
|
||||||
|
}
|
||||||
|
PathAppend(destName, nameExt);
|
||||||
|
|
||||||
|
if (::CopyFile(pfns->at(i).c_str(), destName.c_str(), FALSE))
|
||||||
|
copiedFiles.push_back(destName.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return copiedFiles;
|
||||||
|
}
|
||||||
|
|
||||||
void Notepad_plus::setWorkingDir(const TCHAR *dir)
|
void Notepad_plus::setWorkingDir(const TCHAR *dir)
|
||||||
{
|
{
|
||||||
NppParameters * params = NppParameters::getInstance();
|
NppParameters * params = NppParameters::getInstance();
|
||||||
|
@ -240,6 +240,7 @@ public:
|
|||||||
bool replaceInFiles();
|
bool replaceInFiles();
|
||||||
void setFindReplaceFolderFilter(const TCHAR *dir, const TCHAR *filters);
|
void setFindReplaceFolderFilter(const TCHAR *dir, const TCHAR *filters);
|
||||||
std::vector<generic_string> addNppComponents(const TCHAR *destDir, const TCHAR *extFilterName, const TCHAR *extFilter);
|
std::vector<generic_string> addNppComponents(const TCHAR *destDir, const TCHAR *extFilterName, const TCHAR *extFilter);
|
||||||
|
std::vector<generic_string> addNppPlugins(const TCHAR *extFilterName, const TCHAR *extFilter);
|
||||||
int getHtmlXmlEncoding(const TCHAR *fileName) const;
|
int getHtmlXmlEncoding(const TCHAR *fileName) const;
|
||||||
HACCEL getAccTable() const{
|
HACCEL getAccTable() const{
|
||||||
return _accelerator.getAccTable();
|
return _accelerator.getAccTable();
|
||||||
|
@ -2429,23 +2429,21 @@ void Notepad_plus::command(int id)
|
|||||||
|
|
||||||
case IDM_SETTING_IMPORTPLUGIN :
|
case IDM_SETTING_IMPORTPLUGIN :
|
||||||
{
|
{
|
||||||
// get plugin source path
|
// Copy plugins to Plugins Home
|
||||||
const TCHAR *extFilterName = TEXT("Notepad++ plugin");
|
const TCHAR *extFilterName = TEXT("Notepad++ plugin");
|
||||||
const TCHAR *extFilter = TEXT(".dll");
|
const TCHAR *extFilter = TEXT(".dll");
|
||||||
const TCHAR *destDir = TEXT("plugins");
|
vector<generic_string> copiedFiles = addNppPlugins(extFilterName, extFilter);
|
||||||
|
|
||||||
vector<generic_string> copiedFiles = addNppComponents(destDir, extFilterName, extFilter);
|
// Tell users to restart Notepad++ to load plugin
|
||||||
|
if (copiedFiles.size())
|
||||||
// load plugin
|
|
||||||
for (size_t i = 0, len = copiedFiles.size() ; i < len ; ++i)
|
|
||||||
{
|
{
|
||||||
int index = _pluginsManager.loadPlugin(copiedFiles[i].c_str());
|
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker();
|
||||||
if (_pluginsManager.getMenuHandle())
|
pNativeSpeaker->messageBox("NeedToRestartToLoadPlugins",
|
||||||
_pluginsManager.addInMenuFromPMIndex(index);
|
NULL,
|
||||||
|
TEXT("You have to restart Notepad++ to load plugins you installed."),
|
||||||
|
TEXT("Notepad++ need to be relaunched"),
|
||||||
|
MB_OK | MB_APPLMODAL);
|
||||||
}
|
}
|
||||||
if (!_pluginsManager.getMenuHandle())
|
|
||||||
_pluginsManager.setMenu(_mainMenuHandle, NULL);
|
|
||||||
::DrawMenuBar(_pPublicInterface->getHSelf());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user