mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Tweaks
This commit is contained in:
parent
00a14a7673
commit
902e734e62
@ -1174,7 +1174,7 @@ INT_PTR CDialogAbout::CTabVersion::OnNotify(WPARAM wParam, LPARAM lParam)
|
|||||||
switch (nm->code)
|
switch (nm->code)
|
||||||
{
|
{
|
||||||
case NM_CLICK:
|
case NM_CLICK:
|
||||||
RunCommand(NULL, ((PNMLINK)lParam)->item.szUrl, SW_SHOWNORMAL);
|
RunFile(((PNMLINK)lParam)->item.szUrl);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1497,12 +1497,11 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
|
|||||||
int sel = ListBox_GetCurSel(item);
|
int sel = ListBox_GetCurSel(item);
|
||||||
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
|
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
|
||||||
|
|
||||||
std::wstring command = Rainmeter->GetConfigEditor() + L" \"";
|
std::wstring args = Rainmeter->GetSettingsPath();
|
||||||
command += Rainmeter->GetSettingsPath();
|
args += L"Themes\\";
|
||||||
command += L"Themes\\";
|
args += themes[sel];
|
||||||
command += themes[sel];
|
args += L"\\Rainmeter.thm";
|
||||||
command += L"\\Rainmeter.thm\"";
|
RunFile(Rainmeter->GetConfigEditor().c_str(), args.c_str());
|
||||||
RunCommand(NULL, command.c_str(), SW_SHOWNORMAL);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1546,9 +1545,8 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
case IDC_MANAGETHEMES_BACKUP_BUTTON:
|
case IDC_MANAGETHEMES_BACKUP_BUTTON:
|
||||||
{
|
{
|
||||||
std::wstring command = L'"' + Rainmeter->GetPath();
|
std::wstring file = Rainmeter->GetPath() + L"SkinInstaller.exe";
|
||||||
command += L"SkinInstaller.exe\" /BACKUP";
|
RunFile(file.c_str(), L"/BACKUP");
|
||||||
RunCommand(NULL, command.c_str(), SW_SHOWNORMAL);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -45,17 +45,12 @@ UINT GetUniqueID()
|
|||||||
return id++;
|
return id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, bool asAdmin)
|
void RunCommand(std::wstring command)
|
||||||
{
|
{
|
||||||
// The stub implementation (some of this code is taken from lsapi.cpp)
|
|
||||||
if (szCommand == NULL || *szCommand == 0) return;
|
|
||||||
|
|
||||||
std::wstring args;
|
std::wstring args;
|
||||||
std::wstring command = szCommand;
|
|
||||||
|
|
||||||
size_t notwhite = command.find_first_not_of(L" \t\r\n");
|
size_t notwhite = command.find_first_not_of(L" \t\r\n");
|
||||||
command.erase(0, notwhite);
|
command.erase(0, notwhite);
|
||||||
if (command.empty()) return;
|
|
||||||
|
|
||||||
size_t quotePos = command.find(L'"');
|
size_t quotePos = command.find(L'"');
|
||||||
if (quotePos == 0)
|
if (quotePos == 0)
|
||||||
@ -81,25 +76,27 @@ void RunCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, bool asAdmin)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!command.empty())
|
RunFile(command.c_str(), args.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void RunFile(const WCHAR* file, const WCHAR* args, bool asAdmin)
|
||||||
|
{
|
||||||
|
SHELLEXECUTEINFO si = {sizeof(SHELLEXECUTEINFO)};
|
||||||
|
si.hwnd = NULL;
|
||||||
|
si.lpVerb = asAdmin ? L"runas" : L"open";
|
||||||
|
si.lpFile = file;
|
||||||
|
si.nShow = SW_SHOWNORMAL;
|
||||||
|
|
||||||
|
DWORD type = GetFileAttributes(si.lpFile);
|
||||||
|
if (type & FILE_ATTRIBUTE_DIRECTORY && type != 0xFFFFFFFF)
|
||||||
{
|
{
|
||||||
LPCWSTR szVerb = asAdmin ? L"runas" : L"open";
|
ShellExecute(si.hwnd, si.lpVerb, si.lpFile, NULL, NULL, si.nShow);
|
||||||
DWORD type = GetFileAttributes(command.c_str());
|
}
|
||||||
if (type & FILE_ATTRIBUTE_DIRECTORY && type != 0xFFFFFFFF)
|
else
|
||||||
{
|
{
|
||||||
ShellExecute(Owner, szVerb, command.c_str(), NULL, NULL, nShowCmd ? nShowCmd : SW_SHOWNORMAL);
|
std::wstring dir = CRainmeter::ExtractPath(file);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring dir = CRainmeter::ExtractPath(command);
|
|
||||||
|
|
||||||
SHELLEXECUTEINFO si = {sizeof(SHELLEXECUTEINFO)};
|
|
||||||
si.hwnd = Owner;
|
|
||||||
si.lpVerb = szVerb;
|
|
||||||
si.lpFile = command.c_str();
|
|
||||||
si.lpParameters = args.c_str();
|
|
||||||
si.lpDirectory = dir.c_str();
|
si.lpDirectory = dir.c_str();
|
||||||
si.nShow = nShowCmd ? nShowCmd : SW_SHOWNORMAL;
|
si.lpParameters = args;
|
||||||
si.fMask = SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI;
|
si.fMask = SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI;
|
||||||
ShellExecuteEx(&si);
|
ShellExecuteEx(&si);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,8 @@ void Log(int nLevel, const WCHAR* message);
|
|||||||
void LogWithArgs(int nLevel, const WCHAR* format, ...);
|
void LogWithArgs(int nLevel, const WCHAR* format, ...);
|
||||||
void LogError(CError& error);
|
void LogError(CError& error);
|
||||||
|
|
||||||
void RunCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, bool asAdmin = false);
|
void RunCommand(std::wstring command);
|
||||||
|
void RunFile(const WCHAR* file, const WCHAR* args = NULL, bool asAdmin = false);
|
||||||
|
|
||||||
WCHAR* GetString(UINT id);
|
WCHAR* GetString(UINT id);
|
||||||
std::wstring GetFormattedString(UINT id, ...);
|
std::wstring GetFormattedString(UINT id, ...);
|
||||||
|
@ -811,7 +811,7 @@ int CRainmeter::Initialize(LPCWSTR iniPath)
|
|||||||
// Set file locations
|
// Set file locations
|
||||||
{
|
{
|
||||||
size_t len = m_IniFile.length();
|
size_t len = m_IniFile.length();
|
||||||
if (len > 4 && _wcsicmp(m_IniFile.c_str() + (len - 4), L".ini") == 0)
|
if (len > 4 && _wcsicmp(iniFile + (len - 4), L".ini") == 0)
|
||||||
{
|
{
|
||||||
len -= 4;
|
len -= 4;
|
||||||
}
|
}
|
||||||
@ -1222,33 +1222,24 @@ void CRainmeter::ReloadSettings()
|
|||||||
|
|
||||||
void CRainmeter::EditSettings()
|
void CRainmeter::EditSettings()
|
||||||
{
|
{
|
||||||
std::wstring command = m_ConfigEditor + L" \"";
|
RunFile(m_ConfigEditor.c_str(), m_IniFile.c_str());
|
||||||
command += m_IniFile;
|
|
||||||
command += L'"';
|
|
||||||
RunCommand(m_Window, command.c_str(), SW_SHOWNORMAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRainmeter::EditSkinFile(const std::wstring& name, const std::wstring& iniFile)
|
void CRainmeter::EditSkinFile(const std::wstring& name, const std::wstring& iniFile)
|
||||||
{
|
{
|
||||||
std::wstring command = m_SkinPath + name;
|
std::wstring args = m_SkinPath + name;
|
||||||
command += L'\\';
|
args += L'\\';
|
||||||
command += iniFile;
|
args += iniFile;
|
||||||
bool writable = CSystem::IsFileWritable(command.c_str());
|
bool writable = CSystem::IsFileWritable(args.c_str());
|
||||||
|
|
||||||
command.insert(0, L" \"");
|
|
||||||
command.insert(0, m_ConfigEditor);
|
|
||||||
command += L'"';
|
|
||||||
|
|
||||||
// Execute as admin if in protected location
|
// Execute as admin if in protected location
|
||||||
RunCommand(m_Window, command.c_str(), SW_SHOWNORMAL, !writable);
|
RunFile(m_ConfigEditor.c_str(), args.c_str(), !writable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRainmeter::OpenSkinFolder(const std::wstring& name)
|
void CRainmeter::OpenSkinFolder(const std::wstring& name)
|
||||||
{
|
{
|
||||||
std::wstring command = L'"' + m_SkinPath;
|
std::wstring folder = m_SkinPath + name;
|
||||||
if (!name.empty()) command += name;
|
RunFile(folder.c_str());
|
||||||
command += L'"';
|
|
||||||
RunCommand(m_Window, command.c_str(), SW_SHOWNORMAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRainmeter::ActivateActiveConfigs()
|
void CRainmeter::ActivateActiveConfigs()
|
||||||
@ -2158,16 +2149,12 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run command
|
// Run command
|
||||||
|
std::wstring tmpSz = command;
|
||||||
if (meterWindow)
|
if (meterWindow)
|
||||||
{
|
{
|
||||||
std::wstring tmpSz = command;
|
|
||||||
meterWindow->GetParser().ReplaceMeasures(tmpSz);
|
meterWindow->GetParser().ReplaceMeasures(tmpSz);
|
||||||
RunCommand(NULL, tmpSz.c_str(), SW_SHOWNORMAL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RunCommand(NULL, command, SW_SHOWNORMAL);
|
|
||||||
}
|
}
|
||||||
|
RunCommand(tmpSz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2223,11 +2210,6 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
|
|||||||
HRESULT hr = AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, L".ini", L"open", buffer, &cchOut);
|
HRESULT hr = AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, L".ini", L"open", buffer, &cchOut);
|
||||||
m_ConfigEditor = (SUCCEEDED(hr) && cchOut > 0) ? buffer : L"Notepad";
|
m_ConfigEditor = (SUCCEEDED(hr) && cchOut > 0) ? buffer : L"Notepad";
|
||||||
}
|
}
|
||||||
if (!m_ConfigEditor.empty() && m_ConfigEditor[0] != L'"')
|
|
||||||
{
|
|
||||||
m_ConfigEditor.insert(0, 1, L'"');
|
|
||||||
m_ConfigEditor += L'"';
|
|
||||||
}
|
|
||||||
|
|
||||||
m_LogViewer = parser.ReadString(L"Rainmeter", L"LogViewer", L"");
|
m_LogViewer = parser.ReadString(L"Rainmeter", L"LogViewer", L"");
|
||||||
if (m_LogViewer.empty())
|
if (m_LogViewer.empty())
|
||||||
@ -2237,11 +2219,6 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
|
|||||||
HRESULT hr = AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, L".log", L"open", buffer, &cchOut);
|
HRESULT hr = AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, L".log", L"open", buffer, &cchOut);
|
||||||
m_LogViewer = (SUCCEEDED(hr) && cchOut > 0) ? buffer : L"Notepad";
|
m_LogViewer = (SUCCEEDED(hr) && cchOut > 0) ? buffer : L"Notepad";
|
||||||
}
|
}
|
||||||
if (!m_LogViewer.empty() && m_LogViewer[0] != L'"')
|
|
||||||
{
|
|
||||||
m_LogViewer.insert(0, 1, L'"');
|
|
||||||
m_LogViewer += L'"';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_Debug)
|
if (m_Debug)
|
||||||
{
|
{
|
||||||
@ -3099,24 +3076,22 @@ void CRainmeter::ChangeSkinIndex(HMENU menu, int index)
|
|||||||
void CRainmeter::StartLogging()
|
void CRainmeter::StartLogging()
|
||||||
{
|
{
|
||||||
// Check if the file exists
|
// Check if the file exists
|
||||||
if (_waccess(m_LogFile.c_str(), 0) == -1)
|
const WCHAR* logFile = m_LogViewer.c_str();
|
||||||
|
if (_waccess(logFile, 0) == -1)
|
||||||
{
|
{
|
||||||
// Create log file
|
// Create log file
|
||||||
HANDLE file = CreateFile(m_LogFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
|
HANDLE file = CreateFile(logFile, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (file != INVALID_HANDLE_VALUE)
|
if (file != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
CloseHandle(file);
|
CloseHandle(file);
|
||||||
SetLogging(true);
|
SetLogging(true);
|
||||||
|
|
||||||
// std::wstring text = GetFormattedString(ID_STR_LOGFILECREATED, m_LogFile.c_str());
|
|
||||||
// MessageBox(NULL, text.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONINFORMATION);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Disable logging
|
// Disable logging
|
||||||
SetLogging(false);
|
SetLogging(false);
|
||||||
|
|
||||||
std::wstring text = GetFormattedString(ID_STR_LOGFILECREATEFAIL, m_LogFile.c_str());
|
std::wstring text = GetFormattedString(ID_STR_LOGFILECREATEFAIL, logFile);
|
||||||
MessageBox(NULL, text.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR);
|
MessageBox(NULL, text.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3134,20 +3109,20 @@ void CRainmeter::StopLogging()
|
|||||||
void CRainmeter::ShowLogFile()
|
void CRainmeter::ShowLogFile()
|
||||||
{
|
{
|
||||||
// Check if the file exists
|
// Check if the file exists
|
||||||
if (_waccess(m_LogFile.c_str(), 0) != -1)
|
const WCHAR* logFile = m_LogViewer.c_str();
|
||||||
|
if (_waccess(logFile, 0) != -1)
|
||||||
{
|
{
|
||||||
std::wstring command = m_LogViewer + L" ";
|
RunFile(m_LogViewer.c_str(), logFile);
|
||||||
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
|
||||||
if (_waccess(m_LogFile.c_str(), 0) != -1)
|
const WCHAR* logFile = m_LogViewer.c_str();
|
||||||
|
if (_waccess(logFile, 0) != -1)
|
||||||
{
|
{
|
||||||
std::wstring text = GetFormattedString(ID_STR_LOGFILEDELETE, m_LogFile.c_str());
|
std::wstring text = GetFormattedString(ID_STR_LOGFILEDELETE, logFile);
|
||||||
int res = MessageBox(NULL, text.c_str(), APPNAME, MB_YESNO | MB_TOPMOST | MB_ICONQUESTION);
|
int res = MessageBox(NULL, text.c_str(), APPNAME, MB_YESNO | MB_TOPMOST | MB_ICONQUESTION);
|
||||||
if (res == IDYES)
|
if (res == IDYES)
|
||||||
{
|
{
|
||||||
|
@ -440,11 +440,11 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
|||||||
}
|
}
|
||||||
else if (wParam == IDM_SHOW_HELP)
|
else if (wParam == IDM_SHOW_HELP)
|
||||||
{
|
{
|
||||||
RunCommand(NULL, RAINMETER_HELP, SW_SHOWNORMAL);
|
RunFile(RAINMETER_HELP);
|
||||||
}
|
}
|
||||||
else if (wParam == IDM_NEW_VERSION)
|
else if (wParam == IDM_NEW_VERSION)
|
||||||
{
|
{
|
||||||
RunCommand(NULL, RAINMETER_OFFICIAL, SW_SHOWNORMAL);
|
RunFile(RAINMETER_OFFICIAL);
|
||||||
}
|
}
|
||||||
else if (wParam == IDM_REFRESH)
|
else if (wParam == IDM_REFRESH)
|
||||||
{
|
{
|
||||||
@ -574,7 +574,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
|||||||
}
|
}
|
||||||
else if (tray->m_Notification == TRAY_NOTIFICATION_UPDATE)
|
else if (tray->m_Notification == TRAY_NOTIFICATION_UPDATE)
|
||||||
{
|
{
|
||||||
RunCommand(NULL, RAINMETER_OFFICIAL, SW_SHOWNORMAL);
|
RunFile(RAINMETER_OFFICIAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
tray->m_Notification = TRAY_NOTIFICATION_NONE;
|
tray->m_Notification = TRAY_NOTIFICATION_NONE;
|
||||||
|
Loading…
Reference in New Issue
Block a user