Make theme portable

Fix 6518f3e4b8 (commitcomment-93601484)

Close #12671
This commit is contained in:
ozone10 2022-12-19 23:44:20 +01:00 committed by Don Ho
parent 58416114da
commit f10753d2da
2 changed files with 17 additions and 6 deletions

View File

@ -228,11 +228,7 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
fileNames.clear(); fileNames.clear();
generic_string nppThemeDir; generic_string nppThemeDir = nppDir.c_str(); // <- should use the pointer to avoid the constructor of copy
if (!nppParams.isLocal())
{
nppThemeDir = nppDir.c_str(); // <- should use the pointer to avoid the constructor of copy
}
pathAppend(nppThemeDir, TEXT("themes\\")); pathAppend(nppThemeDir, TEXT("themes\\"));
// Set theme directory to their installation directory // Set theme directory to their installation directory

View File

@ -5607,8 +5607,23 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
{ {
const TCHAR *themePath = element->Attribute(TEXT("path")); const TCHAR *themePath = element->Attribute(TEXT("path"));
if (themePath != NULL && themePath[0]) if (themePath != NULL && themePath[0])
{
// for local/portable setup, only themefilename.xml is needed
// ignore if cloud setting is used
if (_isLocal && !_isCloud)
{
auto themeFileName = ::PathFindFileName(themePath);
generic_string nppThemePath = _nppPath;
pathAppend(nppThemePath, TEXT("themes\\"));
pathAppend(nppThemePath, themeFileName);
_nppGUI._themeName = nppThemePath;
}
else
{
_nppGUI._themeName.assign(themePath); _nppGUI._themeName.assign(themePath);
} }
}
}
else if (!lstrcmp(nm, TEXT("insertDateTime"))) else if (!lstrcmp(nm, TEXT("insertDateTime")))
{ {