mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Added Themes submenu to the Rainmeter's context and tray menus.
This commit is contained in:
parent
c895803238
commit
1d1290e3fa
@ -831,6 +831,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
m_TrayWindow = new CTrayWindow(m_Instance);
|
||||
|
||||
ScanForConfigs(m_SkinPath);
|
||||
ScanForThemes(GetSettingsPath() + L"Themes");
|
||||
|
||||
if(m_ConfigStrings.empty())
|
||||
{
|
||||
@ -990,6 +991,7 @@ void CRainmeter::CreateDefaultConfigFile(std::wstring strFile)
|
||||
void CRainmeter::ReloadSettings()
|
||||
{
|
||||
ScanForConfigs(m_SkinPath);
|
||||
ScanForThemes(GetSettingsPath() + L"Themes");
|
||||
ReadGeneralSettings(m_IniFile);
|
||||
}
|
||||
|
||||
@ -1234,6 +1236,36 @@ int CRainmeter::ScanForConfigsRecursive(std::wstring& path, std::wstring base, i
|
||||
return index;
|
||||
}
|
||||
|
||||
/*
|
||||
** ScanForThemes
|
||||
**
|
||||
** Scans the given folder for themes
|
||||
*/
|
||||
void CRainmeter::ScanForThemes(std::wstring& path)
|
||||
{
|
||||
m_Themes.clear();
|
||||
|
||||
WIN32_FIND_DATA fileData; // Data structure describes the file found
|
||||
HANDLE hSearch; // Search handle returned by FindFirstFile
|
||||
|
||||
// Scan for folders
|
||||
std::wstring folders = path + L"\\*";
|
||||
hSearch = FindFirstFile(folders.c_str(), &fileData);
|
||||
do
|
||||
{
|
||||
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
if(fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
|
||||
wcscmp(L".", fileData.cFileName) != 0 &&
|
||||
wcscmp(L"..", fileData.cFileName) != 0)
|
||||
{
|
||||
m_Themes.push_back(fileData.cFileName);
|
||||
}
|
||||
} while(FindNextFile(hSearch, &fileData));
|
||||
|
||||
FindClose(hSearch);
|
||||
}
|
||||
|
||||
void CRainmeter::SaveSettings()
|
||||
{
|
||||
// Just one setting for writing at the moment
|
||||
@ -1781,10 +1813,17 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
|
||||
InsertMenu(subMenu, 3, MF_BYPOSITION | MF_POPUP, (UINT_PTR)configMenu, L"Configs");
|
||||
}
|
||||
|
||||
HMENU themeMenu = CreateThemeMenu();
|
||||
if (themeMenu)
|
||||
{
|
||||
InsertMenu(subMenu, 4, MF_BYPOSITION | MF_POPUP, (UINT_PTR)themeMenu, L"Themes");
|
||||
InsertMenu(subMenu, 5, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
|
||||
}
|
||||
|
||||
if (meterWindow)
|
||||
{
|
||||
HMENU skinMenu = CreateSkinMenu(meterWindow, 0);
|
||||
InsertMenu(subMenu, 8, MF_BYPOSITION | MF_POPUP, (UINT_PTR)skinMenu, L"Skin menu");
|
||||
InsertMenu(subMenu, 10, MF_BYPOSITION | MF_POPUP, (UINT_PTR)skinMenu, L"Skin Menu");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1796,7 +1835,7 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
|
||||
{
|
||||
CMeterWindow* mw = ((*iter).second);
|
||||
HMENU skinMenu = CreateSkinMenu(mw, index);
|
||||
InsertMenu(subMenu, 8, MF_BYPOSITION | MF_POPUP, (UINT_PTR)skinMenu, mw->GetSkinName().c_str());
|
||||
InsertMenu(subMenu, 10, MF_BYPOSITION | MF_POPUP, (UINT_PTR)skinMenu, mw->GetSkinName().c_str());
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@ -1851,6 +1890,25 @@ HMENU CRainmeter::CreateConfigMenu(std::vector<CONFIGMENU>& configMenuData)
|
||||
return configMenu;
|
||||
}
|
||||
|
||||
HMENU CRainmeter::CreateThemeMenu()
|
||||
{
|
||||
HMENU themeMenu = CreatePopupMenu();
|
||||
|
||||
for (size_t i = 0; i < m_Themes.size(); i++)
|
||||
{
|
||||
AppendMenu(themeMenu, 0, ID_THEME_FIRST + i, m_Themes[i].c_str());
|
||||
}
|
||||
|
||||
if (!m_Themes.empty())
|
||||
{
|
||||
AppendMenu(themeMenu, MF_SEPARATOR, 0, NULL);
|
||||
}
|
||||
|
||||
AppendMenu(themeMenu, 0, ID_CONTEXT_MANAGETHEMES, L"Manage Themes...");
|
||||
|
||||
return themeMenu;
|
||||
}
|
||||
|
||||
HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index)
|
||||
{
|
||||
HMENU skinMenu = LoadMenu(m_Instance, MAKEINTRESOURCE(IDR_SKIN_MENU));
|
||||
|
@ -113,6 +113,7 @@ public:
|
||||
CMeterWindow* GetMeterWindow(const std::wstring& config);
|
||||
std::map<std::wstring, CMeterWindow*>& GetAllMeterWindows() { return m_Meters; };
|
||||
const std::vector<CONFIG>& GetAllConfigs() { return m_ConfigStrings; };
|
||||
const std::vector<std::wstring>& GetAllThemes() { return m_Themes; };
|
||||
|
||||
void ActivateConfig(int configIndex, int iniIndex);
|
||||
bool DeactivateConfig(CMeterWindow* meterWindow, int configIndex);
|
||||
@ -167,6 +168,7 @@ private:
|
||||
void CreateMeterWindow(std::wstring path, std::wstring config, std::wstring iniFile);
|
||||
bool DeleteMeterWindow(CMeterWindow* meterWindow);
|
||||
void ScanForConfigs(std::wstring& path);
|
||||
void ScanForThemes(std::wstring& path);
|
||||
void ReadGeneralSettings(std::wstring& path);
|
||||
bool SetActiveConfig(std::wstring& skinName, std::wstring& skinIni);
|
||||
void Refresh(const WCHAR* arg);
|
||||
@ -174,6 +176,7 @@ private:
|
||||
void ChangeSkinIndex(HMENU subMenu, int index);
|
||||
int ScanForConfigsRecursive(std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu);
|
||||
HMENU CreateConfigMenu(std::vector<CONFIGMENU>& configMenuData);
|
||||
HMENU CreateThemeMenu();
|
||||
void CreateDefaultConfigFile(std::wstring strFile);
|
||||
void TestSettingsFile(bool bDefaultIniLocation);
|
||||
void CopyFiles(std::wstring strFrom, std::wstring strTo);
|
||||
@ -183,6 +186,7 @@ private:
|
||||
std::vector<CONFIG> m_ConfigStrings; // All configs found in the given folder
|
||||
std::vector<CONFIGMENU> m_ConfigMenu;
|
||||
std::map<std::wstring, CMeterWindow*> m_Meters; // The meter windows
|
||||
std::vector<std::wstring> m_Themes;
|
||||
|
||||
std::wstring m_Path; // Path to the main folder
|
||||
std::wstring m_IniFile; // The main ini file
|
||||
|
@ -466,6 +466,13 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
std::wstring command = Rainmeter->GetConfigEditor();
|
||||
command += L" \"";
|
||||
command += Rainmeter->GetIniFile();
|
||||
command += L"\"";
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_MANAGETHEMES)
|
||||
{
|
||||
std::wstring command = Rainmeter->GetPath();
|
||||
command += L"\\Addons\\RainThemes\\RainThemes.exe";
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_QUIT)
|
||||
@ -481,6 +488,20 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
command += L"\"";
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if((wParam & 0x0ffff) >= ID_THEME_FIRST)
|
||||
{
|
||||
int pos = (wParam & 0x0ffff) - ID_THEME_FIRST;
|
||||
|
||||
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
|
||||
if (pos >= 0 && pos < themes.size())
|
||||
{
|
||||
std::wstring command = Rainmeter->GetPath();
|
||||
command += L"\\Addons\\RainThemes\\RainThemes.exe /load \"";
|
||||
command += themes[pos];
|
||||
command += L"\"";
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
}
|
||||
else if((wParam & 0x0ffff) >= ID_CONFIG_FIRST)
|
||||
{
|
||||
wParam = wParam & 0x0ffff;
|
||||
|
@ -54,9 +54,11 @@
|
||||
#define ID_CONTEXT_SKINMENU_YPERCENTAGE 4043
|
||||
#define ID_CONTEXT_OPENSKINSFOLDER 4044
|
||||
#define ID_CONTEXT_SKINMENU_OPENSKINSFOLDER 4045
|
||||
#define ID_CONTEXT_MANAGETHEMES 4046
|
||||
|
||||
#define ID_CONFIG_EDIT 30000
|
||||
#define ID_CONFIG_FIRST 30001
|
||||
#define ID_THEME_FIRST 31001
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user