mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Added support for !SetOption and ContextTitle and ContextAction. Also added a disabled label for top level actions.
This commit is contained in:
parent
823b68132e
commit
e35c6dbd7d
@ -140,8 +140,7 @@ CMeterWindow::CMeterWindow(const std::wstring& folderPath, const std::wstring& f
|
|||||||
m_UpdateCounter(),
|
m_UpdateCounter(),
|
||||||
m_MouseMoveCounter(),
|
m_MouseMoveCounter(),
|
||||||
m_FontCollection(),
|
m_FontCollection(),
|
||||||
m_ToolTipHidden(false),
|
m_ToolTipHidden(false)
|
||||||
m_HasCustomContextMenu(false)
|
|
||||||
{
|
{
|
||||||
if (!c_DwmInstance && CSystem::GetOSPlatform() >= OSPLATFORM_VISTA)
|
if (!c_DwmInstance && CSystem::GetOSPlatform() >= OSPLATFORM_VISTA)
|
||||||
{
|
{
|
||||||
@ -1387,6 +1386,19 @@ void CMeterWindow::SetOption(const std::wstring& section, const std::wstring& op
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContextTitle and ContextAction in [Rainmeter] are dynamic
|
||||||
|
if ((_wcsicmp(section.c_str(), L"Rainmeter") == 0) && (wcsnicmp(option.c_str(), L"Context", 7) == 0))
|
||||||
|
{
|
||||||
|
if (value.empty())
|
||||||
|
{
|
||||||
|
m_Parser.DeleteValue(section, option);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Parser.SetValue(section, option, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Is it a style?
|
// Is it a style?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1926,16 +1938,6 @@ bool CMeterWindow::ReadSkin()
|
|||||||
// Read options from Rainmeter.ini.
|
// Read options from Rainmeter.ini.
|
||||||
ReadOptions();
|
ReadOptions();
|
||||||
|
|
||||||
std::wstring cTitle = m_Parser.ReadString(L"Rainmeter", L"ContextTitle", L"");
|
|
||||||
if (!cTitle.empty())
|
|
||||||
{
|
|
||||||
std::wstring cAction = m_Parser.ReadString(L"Rainmeter", L"ContextAction", L"");
|
|
||||||
if (!cAction.empty() || _wcsicmp(cTitle.c_str(), L"SEPARATOR") == 0)
|
|
||||||
{
|
|
||||||
m_HasCustomContextMenu = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the version
|
// Check the version
|
||||||
UINT appVersion = m_Parser.ReadUInt(L"Rainmeter", L"AppVersion", 0);
|
UINT appVersion = m_Parser.ReadUInt(L"Rainmeter", L"AppVersion", 0);
|
||||||
if (appVersion > RAINMETER_VERSION)
|
if (appVersion > RAINMETER_VERSION)
|
||||||
|
@ -234,8 +234,6 @@ public:
|
|||||||
|
|
||||||
bool GetMeterToolTipHidden() { return m_ToolTipHidden; }
|
bool GetMeterToolTipHidden() { return m_ToolTipHidden; }
|
||||||
|
|
||||||
bool HasCustomContextMenu() { return m_HasCustomContextMenu; }
|
|
||||||
|
|
||||||
const CMouse& GetMouse() { return m_Mouse; }
|
const CMouse& GetMouse() { return m_Mouse; }
|
||||||
|
|
||||||
void MakePathAbsolute(std::wstring& path);
|
void MakePathAbsolute(std::wstring& path);
|
||||||
@ -434,8 +432,6 @@ private:
|
|||||||
|
|
||||||
bool m_ToolTipHidden;
|
bool m_ToolTipHidden;
|
||||||
|
|
||||||
bool m_HasCustomContextMenu;
|
|
||||||
|
|
||||||
static int c_InstanceCount;
|
static int c_InstanceCount;
|
||||||
|
|
||||||
static HINSTANCE c_DwmInstance;
|
static HINSTANCE c_DwmInstance;
|
||||||
|
@ -3161,12 +3161,13 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU men
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add custom actions to the context menu
|
// Add custom actions to the context menu
|
||||||
if (meterWindow->HasCustomContextMenu())
|
std::wstring contextTitle = meterWindow->GetParser().ReadString(L"Rainmeter", L"ContextTitle", L"");
|
||||||
|
std::wstring contextAction = meterWindow->GetParser().ReadString(L"Rainmeter", L"ContextAction", L"");
|
||||||
|
|
||||||
|
if (!contextTitle.empty() && (!contextAction.empty() || _wcsicmp(contextTitle.c_str(), L"SEPARATOR") == 0))
|
||||||
{
|
{
|
||||||
// Read context menu titles (also read the actions)
|
// Read context menu titles (also read the actions)
|
||||||
std::vector<std::wstring> cTitles;
|
std::vector<std::wstring> cTitles;
|
||||||
std::wstring contextTitle = meterWindow->GetParser().ReadString(L"Rainmeter", L"ContextTitle", L"");
|
|
||||||
std::wstring contextAction = meterWindow->GetParser().ReadString(L"Rainmeter", L"ContextAction", L"");
|
|
||||||
WCHAR buffer[128];
|
WCHAR buffer[128];
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
@ -3192,22 +3193,28 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU men
|
|||||||
size_t titleSize = cTitles.size();
|
size_t titleSize = cTitles.size();
|
||||||
if (titleSize <= 3)
|
if (titleSize <= 3)
|
||||||
{
|
{
|
||||||
|
size_t position = 0;
|
||||||
for (size_t i = 0; i < titleSize; ++i)
|
for (size_t i = 0; i < titleSize; ++i)
|
||||||
{
|
{
|
||||||
if (_wcsicmp(cTitles[i].c_str(), L"SEPARATOR") == 0)
|
if (_wcsicmp(cTitles[i].c_str(), L"SEPARATOR") == 0)
|
||||||
{
|
{
|
||||||
InsertMenu(skinMenu, i + 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
|
// Separators not allowed in main top-level menu
|
||||||
|
--position;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
InsertMenu(skinMenu, i + 1, MF_BYPOSITION | MF_STRING, (index << 16) | (IDM_SKIN_CUSTOMCONTEXTMENU_FIRST + i), cTitles[i].c_str());
|
InsertMenu(skinMenu, position + 1, MF_BYPOSITION | MF_STRING, (index << 16) | (IDM_SKIN_CUSTOMCONTEXTMENU_FIRST + i), cTitles[i].c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
++position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InsertMenu(skinMenu, 1, MF_BYPOSITION | MF_STRING | MF_GRAYED, NULL, L"Custom skin actions:");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HMENU customMenu = CreatePopupMenu();
|
HMENU customMenu = CreatePopupMenu();
|
||||||
InsertMenu(skinMenu, 1, MF_BYPOSITION | MF_POPUP, (UINT_PTR)customMenu, L"Skin Actions");
|
InsertMenu(skinMenu, 1, MF_BYPOSITION | MF_POPUP, (UINT_PTR)customMenu, L"Custom skin actions");
|
||||||
|
|
||||||
for (size_t i = 0; i < titleSize; ++i)
|
for (size_t i = 0; i < titleSize; ++i)
|
||||||
{
|
{
|
||||||
@ -3221,6 +3228,8 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU men
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InsertMenu(skinMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user