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,10 +3565,18 @@ 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";
if (_wcsicmp(name.c_str(), L"Backup") == 0)
{
// Just load the backup
CSystem::CopyFiles(backup, m_IniFile);
}
else
{
// Make a copy of current Rainmeter.ini
CSystem::CopyFiles(m_IniFile, backup); CSystem::CopyFiles(m_IniFile, backup);
// Replace Rainmeter.ini with theme // Replace Rainmeter.ini with theme
@ -3594,6 +3602,7 @@ void CRainmeter::LoadTheme(const std::wstring& name)
{ {
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)wallpaper.c_str(), 0); SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)wallpaper.c_str(), 0);
} }
}
ReloadSettings(); ReloadSettings();