mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
- Settings are now preserved and a backup is created when loading themes through Manage
- Fixed that Manage/About didn't always appear on foreground
This commit is contained in:
parent
6629527e83
commit
2df0f6f7f6
@ -82,7 +82,7 @@ void CDialogAbout::Open(int tab)
|
||||
}
|
||||
}
|
||||
|
||||
BringWindowToTop(c_Dialog->m_Window);
|
||||
SetForegroundWindow(c_Dialog->m_Window);
|
||||
|
||||
// Fake WM_NOTIFY to change tab
|
||||
NMHDR nm;
|
||||
|
@ -80,7 +80,7 @@ void CDialogManage::Open(int tab)
|
||||
}
|
||||
}
|
||||
|
||||
BringWindowToTop(c_Dialog->m_Window);
|
||||
SetForegroundWindow(c_Dialog->m_Window);
|
||||
|
||||
// Fake WM_NOTIFY to change tab
|
||||
NMHDR nm;
|
||||
@ -662,7 +662,7 @@ void CDialogManage::CTabSkins::ReadSkin()
|
||||
|
||||
SetControls();
|
||||
|
||||
WCHAR buffer[MAX_LINE_LENGTH];
|
||||
WCHAR* buffer = new WCHAR[MAX_LINE_LENGTH];
|
||||
|
||||
item = GetDlgItem(m_Window, IDC_MANAGESKINS_AUTHOR_TEXT);
|
||||
GetPrivateProfileString(L"Rainmeter", L"Author", NULL, buffer, MAX_LINE_LENGTH, file.c_str());
|
||||
@ -683,14 +683,23 @@ void CDialogManage::CTabSkins::ReadSkin()
|
||||
SetWindowText(item, buffer);
|
||||
|
||||
item = GetDlgItem(m_Window, IDC_MANAGESKINS_DESCRIPTION_TEXT);
|
||||
std::wstring text;
|
||||
if (GetPrivateProfileString(L"Metadata", L"Information", NULL, buffer, MAX_LINE_LENGTH, file.c_str()) > 0)
|
||||
{
|
||||
text = buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
// For backwards compatibility
|
||||
GetPrivateProfileString(L"Metadata", L"Description", NULL, buffer, MAX_LINE_LENGTH, file.c_str());
|
||||
std::wstring text = buffer;
|
||||
text = buffer;
|
||||
|
||||
if (GetPrivateProfileString(L"Metadata", L"Instructions", NULL, buffer, MAX_LINE_LENGTH, file.c_str()) > 0)
|
||||
{
|
||||
text += L"\r\n\r\n";
|
||||
text += buffer;
|
||||
}
|
||||
}
|
||||
|
||||
// Replace | with newline
|
||||
std::wstring::size_type pos;
|
||||
@ -724,6 +733,8 @@ void CDialogManage::CTabSkins::ReadSkin()
|
||||
SetWindowText(item, L"");
|
||||
ShowScrollBar(item, SB_VERT, FALSE);
|
||||
}
|
||||
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1129,7 +1140,7 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam)
|
||||
file += m_SkinName;
|
||||
file += L"\\";
|
||||
file += m_FileName;
|
||||
WritePrivateProfileString(L"Rainmeter", L"\r\n[Metadata]\r\nDescription=\r\nLicense=\r\nVersion", L"", file.c_str());
|
||||
WritePrivateProfileString(L"Rainmeter", L"\r\n[Metadata]\r\nInformation=\r\nLicense=\r\nVersion", L"", file.c_str());
|
||||
SendMessage(m_Window, WM_COMMAND, MAKEWPARAM(IDC_MANAGESKINS_EDIT_BUTTON, 0), 0);
|
||||
ShowWindow(nm->hwndFrom, SW_HIDE);
|
||||
}
|
||||
@ -1319,32 +1330,46 @@ void CDialogManage::CTabThemes::Update()
|
||||
{
|
||||
if (m_LoadTheme)
|
||||
{
|
||||
m_LoadTheme = false;
|
||||
HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LOAD_BUTTON);
|
||||
EnableWindow(item, TRUE);
|
||||
|
||||
// Called by ClearDeleteLaterList(), all MeterWindows have been deleted now so
|
||||
// proceed to loading theme
|
||||
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
|
||||
int sel = ListBox_GetCurSel(item);
|
||||
|
||||
m_LoadTheme = false;
|
||||
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
|
||||
|
||||
std::wstring path = Rainmeter->GetSettingsPath() + L"Themes\\";
|
||||
path += themes[sel].c_str();
|
||||
std::wstring theme = path + L"\\Rainmeter.thm";
|
||||
std::wstring wallpaper = path + L"\\RainThemes.bmp";
|
||||
HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
|
||||
int sel = ListBox_GetCurSel(item);
|
||||
|
||||
// Make a copy of current Rainmeter.ini
|
||||
std::wstring backup = Rainmeter->GetSettingsPath() + L"Themes\\Backup";
|
||||
CreateDirectory(backup.c_str(), NULL);
|
||||
backup += L"\\Rainmeter.thm";
|
||||
CSystem::CopyFiles(Rainmeter->GetIniFile(), backup);
|
||||
|
||||
// Replace Rainmeter.ini with theme
|
||||
std::wstring theme = Rainmeter->GetSettingsPath() + L"Themes\\";
|
||||
theme += themes[sel].c_str();
|
||||
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);
|
||||
|
||||
Rainmeter->ReadGeneralSettings(Rainmeter->GetIniFile());
|
||||
|
||||
if (_waccess(wallpaper.c_str(), 0) != -1)
|
||||
{
|
||||
// Set wallpaper
|
||||
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)wallpaper.c_str(), 0);
|
||||
}
|
||||
|
||||
Rainmeter->ReadGeneralSettings(Rainmeter->GetIniFile());
|
||||
|
||||
// Create meter windows for active configs
|
||||
const std::multimap<int, int>& configOrders = Rainmeter->m_ConfigOrders;
|
||||
for (std::multimap<int, int>::const_iterator iter = configOrders.begin(); iter != configOrders.end(); ++iter)
|
||||
@ -1355,9 +1380,25 @@ void CDialogManage::CTabThemes::Update()
|
||||
Rainmeter->ActivateConfig((*iter).second, config.active - 1);
|
||||
}
|
||||
}
|
||||
|
||||
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LOAD_BUTTON);
|
||||
EnableWindow(item, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void CDialogManage::CTabThemes::PreserveSetting(const std::wstring& backupFile, LPCTSTR key, bool replace)
|
||||
{
|
||||
WCHAR* buffer = new WCHAR[MAX_LINE_LENGTH];
|
||||
|
||||
if ((replace || GetPrivateProfileString(L"Rainmeter", key, L"", buffer, 4, Rainmeter->GetIniFile().c_str()) == 0) &&
|
||||
GetPrivateProfileString(L"Rainmeter", key, L"", buffer, MAX_LINE_LENGTH, backupFile.c_str()) > 0)
|
||||
{
|
||||
WritePrivateProfileString(L"Rainmeter", key, buffer, Rainmeter->GetIniFile().c_str());
|
||||
}
|
||||
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
** DlgProc
|
||||
**
|
||||
|
@ -90,6 +90,8 @@ private:
|
||||
void Update();
|
||||
|
||||
private:
|
||||
void PreserveSetting(const std::wstring& backupFile, LPCTSTR key, bool replace = true);
|
||||
|
||||
bool m_LoadTheme;
|
||||
};
|
||||
|
||||
|
@ -268,14 +268,14 @@ BEGIN
|
||||
PUSHBUTTON "Refresh", IDC_MANAGESKINS_REFRESH_BUTTON, 364, 0, 50, 14, WS_DISABLED | WS_TABSTOP
|
||||
PUSHBUTTON "Edit", IDC_MANAGESKINS_EDIT_BUTTON, 418, 0, 50, 14, WS_DISABLED | WS_TABSTOP
|
||||
|
||||
LTEXT "Author:", IDC_STATIC, 165, 30, 50, 9
|
||||
LTEXT "", IDC_MANAGESKINS_AUTHOR_TEXT, 215, 30, 260, 9, SS_ENDELLIPSIS | SS_NOPREFIX
|
||||
LTEXT "Version:", IDC_STATIC, 165, 43, 50, 9
|
||||
LTEXT "", IDC_MANAGESKINS_VERSION_TEXT, 215, 43, 260, 9, SS_ENDELLIPSIS | SS_NOPREFIX
|
||||
LTEXT "License:", IDC_STATIC, 165, 57, 50, 9
|
||||
LTEXT "", IDC_MANAGESKINS_LICENSE_TEXT, 215, 57, 260, 9, SS_ENDELLIPSIS | SS_NOPREFIX
|
||||
LTEXT "Description:", IDC_STATIC, 165, 71, 50, 9
|
||||
EDITTEXT IDC_MANAGESKINS_DESCRIPTION_TEXT, 213, 71, 253, 64, ES_MULTILINE | ES_READONLY
|
||||
LTEXT "Author:", IDC_STATIC, 165, 30, 80, 9
|
||||
LTEXT "", IDC_MANAGESKINS_AUTHOR_TEXT, 230, 30, 245, 9, SS_ENDELLIPSIS | SS_NOPREFIX
|
||||
LTEXT "Version:", IDC_STATIC, 165, 43, 80, 9
|
||||
LTEXT "", IDC_MANAGESKINS_VERSION_TEXT, 230, 43, 245, 9, SS_ENDELLIPSIS | SS_NOPREFIX
|
||||
LTEXT "License:", IDC_STATIC, 165, 56, 80, 9
|
||||
LTEXT "", IDC_MANAGESKINS_LICENSE_TEXT, 230, 56, 245, 9, SS_ENDELLIPSIS | SS_NOPREFIX
|
||||
LTEXT "Information:", IDC_STATIC, 165, 69, 80, 9
|
||||
EDITTEXT IDC_MANAGESKINS_DESCRIPTION_TEXT, 228, 69, 238, 64, ES_MULTILINE | ES_READONLY
|
||||
CONTROL "<a>Add metadata</a>", IDC_MANAGESKINS_ADDMETADATA_LINK, "SysLink", 0x0, 410, 142, 50, 9
|
||||
|
||||
CONTROL "", IDC_STATIC, STATIC, SS_ETCHEDHORZ | WS_CHILD | WS_VISIBLE, 165, 156, 304, 1
|
||||
@ -291,11 +291,11 @@ BEGIN
|
||||
LTEXT "On hover:", IDC_STATIC, 165, 247, 80, 9
|
||||
COMBOBOX IDC_MANAGESKINS_ONHOVER_COMBOBOX, 230, 244, 70, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | WS_DISABLED
|
||||
PUSHBUTTON "", IDC_MANAGESKINS_DISPLAYMONITOR_BUTTON, 330, 166, 90, 14, WS_DISABLED | WS_TABSTOP
|
||||
AUTOCHECKBOX "Draggable", IDC_MANAGESKINS_DRAGGABLE_CHECKBOX, 330, 190, 70, 9, WS_DISABLED
|
||||
AUTOCHECKBOX "Click through", IDC_MANAGESKINS_CLICKTHROUGH_CHECKBOX, 330, 203, 70, 9, WS_DISABLED
|
||||
AUTOCHECKBOX "Keep on screen", IDC_MANAGESKINS_KEEPONSCREEN_CHECKBOX, 330, 216, 70, 9, WS_DISABLED
|
||||
AUTOCHECKBOX "Save position", IDC_MANAGESKINS_SAVEPOSITION_CHECKBOX, 330, 229, 70, 9, WS_DISABLED
|
||||
AUTOCHECKBOX "Snap to edges", IDC_MANAGESKINS_SNAPTOEDGES_CHECKBOX, 330, 242, 70, 9, WS_DISABLED
|
||||
AUTOCHECKBOX "Draggable", IDC_MANAGESKINS_DRAGGABLE_CHECKBOX, 330, 190, 80, 9, WS_DISABLED
|
||||
AUTOCHECKBOX "Click through", IDC_MANAGESKINS_CLICKTHROUGH_CHECKBOX, 330, 203, 80, 9, WS_DISABLED
|
||||
AUTOCHECKBOX "Keep on screen", IDC_MANAGESKINS_KEEPONSCREEN_CHECKBOX, 330, 216, 80, 9, WS_DISABLED
|
||||
AUTOCHECKBOX "Save position", IDC_MANAGESKINS_SAVEPOSITION_CHECKBOX, 330, 229, 80, 9, WS_DISABLED
|
||||
AUTOCHECKBOX "Snap to edges", IDC_MANAGESKINS_SNAPTOEDGES_CHECKBOX, 330, 242, 80, 9, WS_DISABLED
|
||||
END
|
||||
|
||||
IDD_MANAGETHEMES_DIALOG DIALOGEX 15, 30, 470, 260
|
||||
|
@ -1444,6 +1444,10 @@ void RainmeterAboutWide(const WCHAR* arg)
|
||||
{
|
||||
tab = 2;
|
||||
}
|
||||
else if (_wcsnicmp(arg, L"Version", 7) == 0)
|
||||
{
|
||||
tab = 3;
|
||||
}
|
||||
}
|
||||
|
||||
CDialogAbout::Open(tab);
|
||||
|
Loading…
Reference in New Issue
Block a user