From bb865ec514e03b2295538ede552486703aa1057c Mon Sep 17 00:00:00 2001 From: spx Date: Tue, 21 Feb 2012 19:15:10 +0000 Subject: [PATCH] Cosmetic changes. --- Library/DialogManage.cpp | 31 ++++------------------------- Library/MeterWindow.cpp | 17 ++-------------- Library/Rainmeter.cpp | 42 ++++++++++++++++++++++++++++++++++++++++ Library/Rainmeter.h | 4 ++++ Library/TrayWindow.cpp | 17 +++------------- 5 files changed, 55 insertions(+), 56 deletions(-) diff --git a/Library/DialogManage.cpp b/Library/DialogManage.cpp index f81902d8..a09c9160 100644 --- a/Library/DialogManage.cpp +++ b/Library/DialogManage.cpp @@ -284,12 +284,7 @@ INT_PTR CDialogManage::OnCommand(WPARAM wParam, LPARAM lParam) break; case IDC_EDITSETTINGS_BUTTON: - { - std::wstring command = Rainmeter->GetConfigEditor() + L" \""; - command += Rainmeter->GetIniFile(); - command += L'"'; - RunCommand(Rainmeter->GetTrayWindow()->GetWindow(), command.c_str(), SW_SHOWNORMAL); - } + Rainmeter->EditSettings(); break; case IDC_OPENLOG_BUTTON: @@ -918,19 +913,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam) break; case IDC_MANAGESKINS_EDIT_BUTTON: - { - std::wstring command = Rainmeter->GetSkinPath() + m_SkinName; - command += L'\\'; - command += m_FileName; - bool writable = CSystem::IsFileWritable(command.c_str()); - - command.insert(0, L" \""); - command.insert(0, Rainmeter->GetConfigEditor()); - command += L'"'; - - // Execute as admin if in protected location - RunCommand(NULL, command.c_str(), SW_SHOWNORMAL, !writable); - } + Rainmeter->EditSkinFile(m_SkinName, m_FileName); break; case IDC_MANAGESKINS_X_TEXT: @@ -1113,10 +1096,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam) case IDM_MANAGESKINSMENU_OPENFOLDER: { HWND tree = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW); - std::wstring command = L'"' + Rainmeter->GetSkinPath(); - command += GetTreeSelectionPath(tree); - command += L'"'; - RunCommand(NULL, command.c_str(), SW_SHOWNORMAL); + Rainmeter->OpenSkinFolder(GetTreeSelectionPath(tree)); } break; @@ -1743,10 +1723,7 @@ INT_PTR CDialogManage::CTabSettings::OnCommand(WPARAM wParam, LPARAM lParam) break; case IDC_MANAGESETTINGS_SHOWLOGFILE_BUTTON: - { - std::wstring command = Rainmeter->GetLogViewer() + Rainmeter->GetLogFile(); - RunCommand(NULL, command.c_str(), SW_SHOWNORMAL); - } + Rainmeter->ShowLogFile(); break; case IDC_MANAGESETTINGS_DELETELOGFILE_BUTTON: diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index e64591a4..b4a91f7f 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -3408,17 +3408,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam) { if (wParam == IDM_SKIN_EDITSKIN) { - std::wstring command = m_Rainmeter->GetSkinPath() + m_SkinName; - command += L'\\'; - command += m_SkinIniFile; - bool writable = CSystem::IsFileWritable(command.c_str()); - - command.insert(0, L" \""); - command.insert(0, m_Rainmeter->GetConfigEditor()); - command += L'"'; - - // Execute as admin if in protected location - RunCommand(NULL, command.c_str(), SW_SHOWNORMAL, !writable); + m_Rainmeter->EditSkinFile(m_SkinName, m_SkinIniFile); } else if (wParam == IDM_SKIN_REFRESH) { @@ -3426,10 +3416,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam) } else if (wParam == IDM_SKIN_OPENSKINSFOLDER) { - std::wstring command = L'"' + m_Rainmeter->GetSkinPath(); - command += m_SkinName; - command += L'"'; - RunCommand(NULL, command.c_str(), SW_SHOWNORMAL); + m_Rainmeter->OpenSkinFolder(m_SkinName); } else if (wParam == IDM_SKIN_MANAGESKIN) { diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 50adbb34..5a5fe781 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1145,6 +1145,37 @@ void CRainmeter::ReloadSettings() ReadGeneralSettings(m_IniFile); } +void CRainmeter::EditSettings() +{ + std::wstring command = m_ConfigEditor + L" \""; + command += m_IniFile; + command += L'"'; + RunCommand(m_Window, command.c_str(), SW_SHOWNORMAL); +} + +void CRainmeter::EditSkinFile(const std::wstring& name, const std::wstring& iniFile) +{ + std::wstring command = m_SkinPath + name; + command += L'\\'; + command += iniFile; + bool writable = CSystem::IsFileWritable(command.c_str()); + + command.insert(0, L" \""); + command.insert(0, m_ConfigEditor); + command += L'"'; + + // Execute as admin if in protected location + RunCommand(m_Window, command.c_str(), SW_SHOWNORMAL, !writable); +} + +void CRainmeter::OpenSkinFolder(const std::wstring& name) +{ + std::wstring command = L'"' + m_SkinPath; + if (!name.empty()) command += name; + command += L'"'; + RunCommand(m_Window, command.c_str(), SW_SHOWNORMAL); +} + void CRainmeter::ActivateActiveConfigs() { std::multimap::const_iterator iter = m_ConfigOrders.begin(); @@ -3031,6 +3062,17 @@ void CRainmeter::StopLogging() SetLogging(false); } +void CRainmeter::ShowLogFile() +{ + // Check if the file exists + if (_waccess(m_LogFile.c_str(), 0) != -1) + { + std::wstring command = m_LogViewer + L" "; + command += m_LogFile; + RunCommand(m_Window, command.c_str(), SW_SHOWNORMAL); + } +} + void CRainmeter::DeleteLogFile() { // Check if the file exists diff --git a/Library/Rainmeter.h b/Library/Rainmeter.h index 7af0f35f..a6fee1e6 100644 --- a/Library/Rainmeter.h +++ b/Library/Rainmeter.h @@ -173,6 +173,9 @@ public: GlobalConfig& GetGlobalConfig() { return m_GlobalConfig; } void ReloadSettings(); + void EditSettings(); + void EditSkinFile(const std::wstring& name, const std::wstring& iniFile); + void OpenSkinFolder(const std::wstring& name = std::wstring()); void UpdateStats(); void ReadStats(); @@ -187,6 +190,7 @@ public: bool GetLogging() { return m_Logging; } void StartLogging(); void StopLogging(); + void ShowLogFile(); void DeleteLogFile(); bool GetDisableRDP() { return m_DisableRDP; } diff --git a/Library/TrayWindow.cpp b/Library/TrayWindow.cpp index 3353b9cc..d57d246f 100644 --- a/Library/TrayWindow.cpp +++ b/Library/TrayWindow.cpp @@ -438,13 +438,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } else if (wParam == IDM_SHOWLOGFILE) { - // Check if the file exists - const std::wstring& log = Rainmeter->GetLogFile(); - if (_waccess(log.c_str(), 0) != -1) - { - std::wstring command = Rainmeter->GetLogViewer() + log; - RunCommand(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL); - } + Rainmeter->ShowLogFile(); } else if (wParam == IDM_STARTLOG) { @@ -468,10 +462,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } else if (wParam == IDM_EDITCONFIG) { - std::wstring command = Rainmeter->GetConfigEditor() + L" \""; - command += Rainmeter->GetIniFile(); - command += L'"'; - RunCommand(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL); + Rainmeter->EditSettings(); } else if (wParam == IDM_QUIT) { @@ -479,9 +470,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } else if (wParam == IDM_OPENSKINSFOLDER) { - std::wstring command = L'"' + Rainmeter->GetSkinPath(); - command += L'"'; - RunCommand(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL); + Rainmeter->OpenSkinFolder(); } else if ((wParam & 0x0ffff) >= ID_THEME_FIRST && (wParam & 0x0ffff) <= ID_THEME_LAST) {