Cosmetic changes.

This commit is contained in:
spx 2012-02-21 19:15:10 +00:00
parent bcb2326d33
commit bb865ec514
5 changed files with 55 additions and 56 deletions

View File

@ -284,12 +284,7 @@ INT_PTR CDialogManage::OnCommand(WPARAM wParam, LPARAM lParam)
break; break;
case IDC_EDITSETTINGS_BUTTON: case IDC_EDITSETTINGS_BUTTON:
{ Rainmeter->EditSettings();
std::wstring command = Rainmeter->GetConfigEditor() + L" \"";
command += Rainmeter->GetIniFile();
command += L'"';
RunCommand(Rainmeter->GetTrayWindow()->GetWindow(), command.c_str(), SW_SHOWNORMAL);
}
break; break;
case IDC_OPENLOG_BUTTON: case IDC_OPENLOG_BUTTON:
@ -918,19 +913,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
break; break;
case IDC_MANAGESKINS_EDIT_BUTTON: case IDC_MANAGESKINS_EDIT_BUTTON:
{ Rainmeter->EditSkinFile(m_SkinName, m_FileName);
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);
}
break; break;
case IDC_MANAGESKINS_X_TEXT: case IDC_MANAGESKINS_X_TEXT:
@ -1113,10 +1096,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
case IDM_MANAGESKINSMENU_OPENFOLDER: case IDM_MANAGESKINSMENU_OPENFOLDER:
{ {
HWND tree = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW); HWND tree = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW);
std::wstring command = L'"' + Rainmeter->GetSkinPath(); Rainmeter->OpenSkinFolder(GetTreeSelectionPath(tree));
command += GetTreeSelectionPath(tree);
command += L'"';
RunCommand(NULL, command.c_str(), SW_SHOWNORMAL);
} }
break; break;
@ -1743,10 +1723,7 @@ INT_PTR CDialogManage::CTabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
break; break;
case IDC_MANAGESETTINGS_SHOWLOGFILE_BUTTON: case IDC_MANAGESETTINGS_SHOWLOGFILE_BUTTON:
{ Rainmeter->ShowLogFile();
std::wstring command = Rainmeter->GetLogViewer() + Rainmeter->GetLogFile();
RunCommand(NULL, command.c_str(), SW_SHOWNORMAL);
}
break; break;
case IDC_MANAGESETTINGS_DELETELOGFILE_BUTTON: case IDC_MANAGESETTINGS_DELETELOGFILE_BUTTON:

View File

@ -3408,17 +3408,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
if (wParam == IDM_SKIN_EDITSKIN) if (wParam == IDM_SKIN_EDITSKIN)
{ {
std::wstring command = m_Rainmeter->GetSkinPath() + m_SkinName; m_Rainmeter->EditSkinFile(m_SkinName, m_SkinIniFile);
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);
} }
else if (wParam == IDM_SKIN_REFRESH) 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) else if (wParam == IDM_SKIN_OPENSKINSFOLDER)
{ {
std::wstring command = L'"' + m_Rainmeter->GetSkinPath(); m_Rainmeter->OpenSkinFolder(m_SkinName);
command += m_SkinName;
command += L'"';
RunCommand(NULL, command.c_str(), SW_SHOWNORMAL);
} }
else if (wParam == IDM_SKIN_MANAGESKIN) else if (wParam == IDM_SKIN_MANAGESKIN)
{ {

View File

@ -1145,6 +1145,37 @@ void CRainmeter::ReloadSettings()
ReadGeneralSettings(m_IniFile); 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() void CRainmeter::ActivateActiveConfigs()
{ {
std::multimap<int, int>::const_iterator iter = m_ConfigOrders.begin(); std::multimap<int, int>::const_iterator iter = m_ConfigOrders.begin();
@ -3031,6 +3062,17 @@ void CRainmeter::StopLogging()
SetLogging(false); 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() void CRainmeter::DeleteLogFile()
{ {
// Check if the file exists // Check if the file exists

View File

@ -173,6 +173,9 @@ public:
GlobalConfig& GetGlobalConfig() { return m_GlobalConfig; } GlobalConfig& GetGlobalConfig() { return m_GlobalConfig; }
void ReloadSettings(); 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 UpdateStats();
void ReadStats(); void ReadStats();
@ -187,6 +190,7 @@ public:
bool GetLogging() { return m_Logging; } bool GetLogging() { return m_Logging; }
void StartLogging(); void StartLogging();
void StopLogging(); void StopLogging();
void ShowLogFile();
void DeleteLogFile(); void DeleteLogFile();
bool GetDisableRDP() { return m_DisableRDP; } bool GetDisableRDP() { return m_DisableRDP; }

View File

@ -438,13 +438,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
} }
else if (wParam == IDM_SHOWLOGFILE) else if (wParam == IDM_SHOWLOGFILE)
{ {
// Check if the file exists Rainmeter->ShowLogFile();
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);
}
} }
else if (wParam == IDM_STARTLOG) 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) else if (wParam == IDM_EDITCONFIG)
{ {
std::wstring command = Rainmeter->GetConfigEditor() + L" \""; Rainmeter->EditSettings();
command += Rainmeter->GetIniFile();
command += L'"';
RunCommand(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
} }
else if (wParam == IDM_QUIT) 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) else if (wParam == IDM_OPENSKINSFOLDER)
{ {
std::wstring command = L'"' + Rainmeter->GetSkinPath(); Rainmeter->OpenSkinFolder();
command += L'"';
RunCommand(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
} }
else if ((wParam & 0x0ffff) >= ID_THEME_FIRST && (wParam & 0x0ffff) <= ID_THEME_LAST) else if ((wParam & 0x0ffff) >= ID_THEME_FIRST && (wParam & 0x0ffff) <= ID_THEME_LAST)
{ {