Manage Themes: Fixed that loading backup just reloaded current setup.

This commit is contained in:
Birunthan Mohanathas 2011-09-18 07:38:14 +00:00
parent 6f2a7211c2
commit 559d2d2d17
2 changed files with 37 additions and 24 deletions

View File

@ -1363,7 +1363,11 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
case IDC_MANAGETHEMES_NAME_TEXT: case IDC_MANAGETHEMES_NAME_TEXT:
if (HIWORD(wParam) == EN_CHANGE) 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); EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_SAVE_BUTTON), state);
} }
break; break;

View File

@ -3565,34 +3565,43 @@ void CRainmeter::LoadTheme(const std::wstring& name)
// Delete all meter windows // Delete all meter windows
DeleteMeterWindow(NULL, false); DeleteMeterWindow(NULL, false);
// Make a copy of current Rainmeter.ini
std::wstring backup = GetSettingsPath() + L"Themes\\Backup"; std::wstring backup = GetSettingsPath() + L"Themes\\Backup";
CreateDirectory(backup.c_str(), NULL); CreateDirectory(backup.c_str(), NULL);
backup += L"\\Rainmeter.thm"; backup += L"\\Rainmeter.thm";
CSystem::CopyFiles(m_IniFile, backup);
// Replace Rainmeter.ini with theme if (_wcsicmp(name.c_str(), L"Backup") == 0)
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); // 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(); ReloadSettings();