mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-25 14:54:39 +02:00
parent
7fd8eb7f80
commit
2fb7da73d7
@ -479,7 +479,8 @@ namespace NppDarkMode
|
||||
|
||||
generic_string getThemeName()
|
||||
{
|
||||
return NppDarkMode::isEnabled() ? g_advOptions._darkDefaults._xmlFileName : g_advOptions._lightDefaults._xmlFileName;
|
||||
auto& theme = NppDarkMode::isEnabled() ? g_advOptions._darkDefaults._xmlFileName : g_advOptions._lightDefaults._xmlFileName;
|
||||
return (lstrcmp(theme.c_str(), L"stylers.xml") == 0) ? L"" : theme;
|
||||
}
|
||||
|
||||
static bool g_isCustomToolIconUsed = NppParameters::getInstance().getCustomizedToolIcons() != nullptr;
|
||||
|
@ -1244,7 +1244,7 @@ bool NppParameters::load()
|
||||
BOOL doRecover = FALSE;
|
||||
if (::PathFileExists(langs_xml_path.c_str()))
|
||||
{
|
||||
WIN32_FILE_ATTRIBUTE_DATA attributes;
|
||||
WIN32_FILE_ATTRIBUTE_DATA attributes{};
|
||||
|
||||
if (GetFileAttributesEx(langs_xml_path.c_str(), GetFileExInfoStandard, &attributes) != 0)
|
||||
{
|
||||
@ -1792,7 +1792,7 @@ void NppParameters::setFontList(HWND hWnd)
|
||||
//---------------//
|
||||
// Sys font list //
|
||||
//---------------//
|
||||
LOGFONT lf;
|
||||
LOGFONT lf{};
|
||||
_fontlist.clear();
|
||||
_fontlist.reserve(64); // arbitrary
|
||||
_fontlist.push_back(generic_string());
|
||||
@ -2350,7 +2350,7 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session& s
|
||||
const TCHAR *encStr = (childNode->ToElement())->Attribute(TEXT("encoding"), &encoding);
|
||||
const TCHAR *backupFilePath = (childNode->ToElement())->Attribute(TEXT("backupFilePath"));
|
||||
|
||||
FILETIME fileModifiedTimestamp;
|
||||
FILETIME fileModifiedTimestamp{};
|
||||
(childNode->ToElement())->Attribute(TEXT("originalFileLastModifTimestamp"), reinterpret_cast<int32_t*>(&fileModifiedTimestamp.dwLowDateTime));
|
||||
(childNode->ToElement())->Attribute(TEXT("originalFileLastModifTimestampHigh"), reinterpret_cast<int32_t*>(&fileModifiedTimestamp.dwHighDateTime));
|
||||
|
||||
@ -5603,28 +5603,6 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
|
||||
}
|
||||
}
|
||||
|
||||
else if (!lstrcmp(nm, TEXT("stylerTheme")))
|
||||
{
|
||||
const TCHAR *themePath = element->Attribute(TEXT("path"));
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (!lstrcmp(nm, TEXT("insertDateTime")))
|
||||
{
|
||||
const TCHAR* customFormat = element->Attribute(TEXT("customizedFormat"));
|
||||
@ -5942,17 +5920,60 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
|
||||
return defaultValue;
|
||||
};
|
||||
|
||||
_nppGUI._darkmode._advOptions._enableWindowsMode = parseYesNoBoolAttribute(TEXT("enableWindowsMode"));
|
||||
auto& windowsMode = _nppGUI._darkmode._advOptions._enableWindowsMode;
|
||||
windowsMode = parseYesNoBoolAttribute(TEXT("enableWindowsMode"));
|
||||
|
||||
_nppGUI._darkmode._advOptions._darkDefaults._xmlFileName = parseStringAttribute(TEXT("darkThemeName"), TEXT("DarkModeDefault.xml"));
|
||||
_nppGUI._darkmode._advOptions._darkDefaults._toolBarIconSet = parseToolBarIconsAttribute(TEXT("darkToolBarIconSet"), 0);
|
||||
_nppGUI._darkmode._advOptions._darkDefaults._tabIconSet = parseTabIconsAttribute(TEXT("darkTabIconSet"), 2);
|
||||
_nppGUI._darkmode._advOptions._darkDefaults._tabUseTheme = parseYesNoBoolAttribute(TEXT("darkTabUseTheme"));
|
||||
auto& darkDefaults = _nppGUI._darkmode._advOptions._darkDefaults;
|
||||
auto& darkThemeName = darkDefaults._xmlFileName;
|
||||
darkThemeName = parseStringAttribute(TEXT("darkThemeName"), TEXT("DarkModeDefault.xml"));
|
||||
darkDefaults._toolBarIconSet = parseToolBarIconsAttribute(TEXT("darkToolBarIconSet"), 0);
|
||||
darkDefaults._tabIconSet = parseTabIconsAttribute(TEXT("darkTabIconSet"), 2);
|
||||
darkDefaults._tabUseTheme = parseYesNoBoolAttribute(TEXT("darkTabUseTheme"));
|
||||
|
||||
_nppGUI._darkmode._advOptions._lightDefaults._xmlFileName = parseStringAttribute(TEXT("lightThemeName"));
|
||||
_nppGUI._darkmode._advOptions._lightDefaults._toolBarIconSet = parseToolBarIconsAttribute(TEXT("lightToolBarIconSet"), 4);
|
||||
_nppGUI._darkmode._advOptions._lightDefaults._tabIconSet = parseTabIconsAttribute(TEXT("lightTabIconSet"), 0);
|
||||
_nppGUI._darkmode._advOptions._lightDefaults._tabUseTheme = parseYesNoBoolAttribute(TEXT("lightTabUseTheme"), true);
|
||||
auto& lightDefaults = _nppGUI._darkmode._advOptions._lightDefaults;
|
||||
auto& lightThemeName = lightDefaults._xmlFileName;
|
||||
lightThemeName = parseStringAttribute(TEXT("lightThemeName"));
|
||||
lightDefaults._toolBarIconSet = parseToolBarIconsAttribute(TEXT("lightToolBarIconSet"), 4);
|
||||
lightDefaults._tabIconSet = parseTabIconsAttribute(TEXT("lightTabIconSet"), 0);
|
||||
lightDefaults._tabUseTheme = parseYesNoBoolAttribute(TEXT("lightTabUseTheme"), true);
|
||||
|
||||
// Windows mode is handled later in Notepad_plus_Window::init from Notepad_plus_Window.cpp
|
||||
if (!windowsMode)
|
||||
{
|
||||
generic_string themePath;
|
||||
generic_string xmlFileName = _nppGUI._darkmode._isEnabled ? darkThemeName : lightThemeName;
|
||||
const bool isLocalOnly = _isLocal && !_isCloud;
|
||||
|
||||
if (!xmlFileName.empty() && lstrcmp(xmlFileName.c_str(), TEXT("stylers.xml")) != 0)
|
||||
{
|
||||
themePath = isLocalOnly ? _nppPath : _userPath;
|
||||
pathAppend(themePath, TEXT("themes\\"));
|
||||
pathAppend(themePath, xmlFileName);
|
||||
|
||||
if (!isLocalOnly && ::PathFileExists(themePath.c_str()) == FALSE)
|
||||
{
|
||||
themePath = _nppPath;
|
||||
pathAppend(themePath, TEXT("themes\\"));
|
||||
pathAppend(themePath, xmlFileName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
themePath = isLocalOnly ? _nppPath : _userPath;
|
||||
pathAppend(themePath, TEXT("stylers.xml"));
|
||||
|
||||
if (!isLocalOnly && ::PathFileExists(themePath.c_str()) == FALSE)
|
||||
{
|
||||
themePath = _nppPath;
|
||||
pathAppend(themePath, TEXT("stylers.xml"));
|
||||
}
|
||||
}
|
||||
|
||||
if (::PathFileExists(themePath.c_str()) == TRUE)
|
||||
{
|
||||
_nppGUI._themeName.assign(themePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6947,13 +6968,6 @@ void NppParameters::createXmlTreeFromGUIParams()
|
||||
GUIConfigElement->SetAttribute(TEXT("short"), pStr);
|
||||
}
|
||||
|
||||
// <GUIConfig name="stylerTheme" path="C:\sources\notepad-plus-plus\PowerEditor\visual.net\..\bin\stylers.xml" />
|
||||
{
|
||||
TiXmlElement *GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
|
||||
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("stylerTheme"));
|
||||
GUIConfigElement->SetAttribute(TEXT("path"), _nppGUI._themeName.c_str());
|
||||
}
|
||||
|
||||
// <GUIConfig name="insertDateTime" path="C:\sources\notepad-plus-plus\PowerEditor\visual.net\..\bin\stylers.xml" />
|
||||
{
|
||||
TiXmlElement* GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
|
||||
|
@ -405,7 +405,7 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
|
||||
::SendMessage(_hParent, WM_UPDATEMAINMENUBITMAPS, 0, 0);
|
||||
|
||||
const TCHAR* fn = ::PathFindFileName(_themeName.c_str());
|
||||
NppDarkMode::setThemeName(lstrcmp(fn, L"stylers.xml") == 0 ? L"" : fn);
|
||||
NppDarkMode::setThemeName((!NppDarkMode::isEnabled() && lstrcmp(fn, L"stylers.xml") == 0) ? L"" : fn);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user