diff --git a/Library/DialogManage.cpp b/Library/DialogManage.cpp index 0791e4f5..1a7687eb 100644 --- a/Library/DialogManage.cpp +++ b/Library/DialogManage.cpp @@ -1363,7 +1363,11 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam) case IDC_MANAGETHEMES_NAME_TEXT: if (HIWORD(wParam) == EN_CHANGE) { - BOOL state = (Edit_GetTextLength((HWND)lParam) != 0); + WCHAR buffer[32]; + Edit_GetText((HWND)lParam, buffer, 32); + + // Disable save button if no text or if name is "Backup" + BOOL state = (wcslen(buffer) != 0 && _wcsicmp(buffer, L"Backup") != 0); EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_SAVE_BUTTON), state); } break; diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index c3a80579..3b7dd521 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -3565,34 +3565,43 @@ void CRainmeter::LoadTheme(const std::wstring& name) // Delete all meter windows DeleteMeterWindow(NULL, false); - // Make a copy of current Rainmeter.ini std::wstring backup = GetSettingsPath() + L"Themes\\Backup"; CreateDirectory(backup.c_str(), NULL); backup += L"\\Rainmeter.thm"; - CSystem::CopyFiles(m_IniFile, backup); - // Replace Rainmeter.ini with theme - std::wstring theme = Rainmeter->GetSettingsPath() + L"Themes\\"; - theme += name; - std::wstring wallpaper = theme + L"\\RainThemes.bmp"; - theme += L"\\Rainmeter.thm"; - CSystem::CopyFiles(theme, Rainmeter->GetIniFile()); - - PreserveSetting(backup, L"SkinPath"); - PreserveSetting(backup, L"ConfigEditor"); - PreserveSetting(backup, L"LogViewer"); - PreserveSetting(backup, L"Logging"); - PreserveSetting(backup, L"DisableVersionCheck"); - PreserveSetting(backup, L"TrayExecuteL", false); - PreserveSetting(backup, L"TrayExecuteM", false); - PreserveSetting(backup, L"TrayExecuteR", false); - PreserveSetting(backup, L"TrayExecuteDM", false); - PreserveSetting(backup, L"TrayExecuteDR", false); - - // Set wallpaper if it exists - if (_waccess(wallpaper.c_str(), 0) != -1) + if (_wcsicmp(name.c_str(), L"Backup") == 0) { - SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)wallpaper.c_str(), 0); + // Just load the backup + CSystem::CopyFiles(backup, m_IniFile); + } + else + { + // Make a copy of current Rainmeter.ini + CSystem::CopyFiles(m_IniFile, backup); + + // Replace Rainmeter.ini with theme + std::wstring theme = Rainmeter->GetSettingsPath() + L"Themes\\"; + theme += name; + std::wstring wallpaper = theme + L"\\RainThemes.bmp"; + theme += L"\\Rainmeter.thm"; + CSystem::CopyFiles(theme, Rainmeter->GetIniFile()); + + PreserveSetting(backup, L"SkinPath"); + PreserveSetting(backup, L"ConfigEditor"); + PreserveSetting(backup, L"LogViewer"); + PreserveSetting(backup, L"Logging"); + PreserveSetting(backup, L"DisableVersionCheck"); + PreserveSetting(backup, L"TrayExecuteL", false); + PreserveSetting(backup, L"TrayExecuteM", false); + PreserveSetting(backup, L"TrayExecuteR", false); + PreserveSetting(backup, L"TrayExecuteDM", false); + PreserveSetting(backup, L"TrayExecuteDR", false); + + // Set wallpaper if it exists + if (_waccess(wallpaper.c_str(), 0) != -1) + { + SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)wallpaper.c_str(), 0); + } } ReloadSettings();