Code cleanup.

This commit is contained in:
spx 2011-10-29 10:36:07 +00:00
parent a336c916f6
commit 1808930c5a
7 changed files with 489 additions and 541 deletions

View File

@ -60,6 +60,35 @@ CDialogAbout::~CDialogAbout()
delete m_TabVersion; delete m_TabVersion;
} }
/*
** Open
**
** Opens the About dialog by tab name.
**
*/
void CDialogAbout::Open(const WCHAR* name)
{
int tab = 0;
if (name)
{
if (_wcsnicmp(name, L"Measures", 8) == 0)
{
tab = 1;
}
else if (_wcsnicmp(name, L"Plugins", 7) == 0)
{
tab = 2;
}
else if (_wcsnicmp(name, L"Version", 7) == 0)
{
tab = 3;
}
}
Open(tab);
}
/* /*
** Open ** Open
** **

View File

@ -34,6 +34,7 @@ public:
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam); INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam); INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
static void Open(const WCHAR* name);
static void Open(int tab = 0); static void Open(int tab = 0);
static void ShowAboutLog(); static void ShowAboutLog();

View File

@ -59,6 +59,31 @@ CDialogManage::~CDialogManage()
delete m_TabSettings; delete m_TabSettings;
} }
/*
** Open
**
** Opens the Manage dialog by tab name.
**
*/
void CDialogManage::Open(const WCHAR* name)
{
int tab = 0;
if (name)
{
if (_wcsnicmp(name, L"Themes", 6) == 0)
{
tab = 1;
}
else if (_wcsnicmp(name, L"Settings", 8) == 0)
{
tab = 2;
}
}
Open(tab);
}
/* /*
** Open ** Open
** **
@ -266,7 +291,7 @@ INT_PTR CDialogManage::OnCommand(WPARAM wParam, LPARAM lParam)
break; break;
case IDC_OPENLOG_BUTTON: case IDC_OPENLOG_BUTTON:
RainmeterAbout(); CDialogAbout::Open();
break; break;
case IDCLOSE: case IDCLOSE:

View File

@ -35,6 +35,7 @@ public:
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam); INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam); INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
static void Open(const WCHAR* name);
static void Open(int tab = 0); static void Open(int tab = 0);
static void OpenSkin(CMeterWindow* meterWindow); static void OpenSkin(CMeterWindow* meterWindow);

File diff suppressed because it is too large Load Diff

View File

@ -39,23 +39,6 @@
#define WIDEN(x) WIDEN2(x) #define WIDEN(x) WIDEN2(x)
#define APPDATE WIDEN(__DATE__) #define APPDATE WIDEN(__DATE__)
// Callbacks
void RainmeterActivateConfig(const WCHAR* arg);
void RainmeterDeactivateConfig(const WCHAR* arg);
void RainmeterToggleConfig(const WCHAR* arg);
void RainmeterDeactivateConfigGroup(const WCHAR* arg);
void RainmeterRefreshApp();
void RainmeterAbout(const WCHAR* arg = NULL);
void RainmeterManage(const WCHAR* arg = NULL);
void RainmeterSkinMenu(const WCHAR* arg);
void RainmeterTrayMenu();
void RainmeterResetStats();
void RainmeterWriteKeyValue(const WCHAR* arg);
void RainmeterQuit();
void BangWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs);
void BangGroupWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs);
struct GlobalConfig struct GlobalConfig
{ {
double netInSpeed; double netInSpeed;
@ -72,7 +55,7 @@ public:
{ {
std::wstring config; std::wstring config;
std::vector<std::wstring> iniFiles; std::vector<std::wstring> iniFiles;
std::vector<UINT> commands; UINT commandBase;
int active; int active;
}; };
@ -104,6 +87,7 @@ public:
CMeterWindow* GetMeterWindowByINI(const std::wstring& ini_searching); CMeterWindow* GetMeterWindowByINI(const std::wstring& ini_searching);
std::pair<int, int> GetMeterWindowIndex(const std::wstring& config, const std::wstring& iniFile); std::pair<int, int> GetMeterWindowIndex(const std::wstring& config, const std::wstring& iniFile);
std::pair<int, int> GetMeterWindowIndex(CMeterWindow* meterWindow) { return GetMeterWindowIndex(meterWindow->GetSkinName(), meterWindow->GetSkinIniFile()); } std::pair<int, int> GetMeterWindowIndex(CMeterWindow* meterWindow) { return GetMeterWindowIndex(meterWindow->GetSkinName(), meterWindow->GetSkinIniFile()); }
std::pair<int, int> GetMeterWindowIndex(UINT menuCommand);
CMeterWindow* GetMeterWindow(HWND hwnd); CMeterWindow* GetMeterWindow(HWND hwnd);
void GetMeterWindowsByLoadOrder(std::multimap<int, CMeterWindow*>& windows, const std::wstring& group = L""); void GetMeterWindowsByLoadOrder(std::multimap<int, CMeterWindow*>& windows, const std::wstring& group = L"");
@ -113,6 +97,7 @@ public:
void ActivateConfig(int configIndex, int iniIndex); void ActivateConfig(int configIndex, int iniIndex);
bool DeactivateConfig(CMeterWindow* meterWindow, int configIndex, bool save = true); bool DeactivateConfig(CMeterWindow* meterWindow, int configIndex, bool save = true);
void ToggleConfig(int configIndex, int iniIndex);
const std::wstring& GetPath() { return m_Path; } const std::wstring& GetPath() { return m_Path; }
const std::wstring& GetIniFile() { return m_IniFile; } const std::wstring& GetIniFile() { return m_IniFile; }
@ -191,6 +176,16 @@ public:
friend class CDialogManage; friend class CDialogManage;
private: private:
void BangWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs);
void BangGroupWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs);
void RainmeterActivateConfig(const WCHAR* arg);
void RainmeterDeactivateConfig(const WCHAR* arg);
void RainmeterToggleConfig(const WCHAR* arg);
void RainmeterDeactivateConfigGroup(const WCHAR* arg);
void RainmeterSkinMenu(const WCHAR* arg);
void RainmeterTrayMenu();
void RainmeterWriteKeyValue(const WCHAR* arg);
void ActivateActiveConfigs(); void ActivateActiveConfigs();
void CreateMeterWindow(const std::wstring& path, const std::wstring& config, const std::wstring& iniFile); void CreateMeterWindow(const std::wstring& path, const std::wstring& config, const std::wstring& iniFile);
bool DeleteMeterWindow(CMeterWindow* meterWindow, bool bLater); bool DeleteMeterWindow(CMeterWindow* meterWindow, bool bLater);
@ -204,7 +199,7 @@ private:
HMENU CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU configMenu); HMENU CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU configMenu);
void ChangeSkinIndex(HMENU subMenu, int index); void ChangeSkinIndex(HMENU subMenu, int index);
int ScanForConfigsRecursive(const std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu, bool DontRecurse); int ScanForConfigsRecursive(const std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu, bool DontRecurse);
HMENU CreateConfigMenu(HMENU configMenu, std::vector<CONFIGMENU>& configMenuData); HMENU CreateConfigMenu(HMENU configMenu, const std::vector<CONFIGMENU>& configMenuData);
void CreateThemeMenu(HMENU themeMenu); void CreateThemeMenu(HMENU themeMenu);
void CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow); void CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow);
void CreateDefaultConfigFile(const std::wstring& strFile); void CreateDefaultConfigFile(const std::wstring& strFile);

View File

@ -486,29 +486,10 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
} }
else if ((wParam & 0x0ffff) >= ID_CONFIG_FIRST && (wParam & 0x0ffff) <= ID_CONFIG_LAST) else if ((wParam & 0x0ffff) >= ID_CONFIG_FIRST && (wParam & 0x0ffff) <= ID_CONFIG_LAST)
{ {
wParam = wParam & 0x0ffff; std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex((UINT)(wParam & 0x0ffff));
if (indexes.first != -1 && indexes.second != -1)
// Check which config was selected
const std::vector<CRainmeter::CONFIG>& configs = Rainmeter->GetAllConfigs();
for (int i = 0, isize = (int)configs.size(); i < isize; ++i)
{ {
for (int j = 0, jsize = (int)configs[i].commands.size(); j < jsize; ++j) Rainmeter->ToggleConfig(indexes.first, indexes.second);
{
if (configs[i].commands[j] == wParam)
{
if (configs[i].active == j + 1)
{
CMeterWindow* meterWindow = Rainmeter->GetMeterWindow(configs[i].config);
Rainmeter->DeactivateConfig(meterWindow, i);
}
else
{
Rainmeter->ActivateConfig(i, j);
}
return 0;
}
}
} }
} }
else else