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)
|
||||
{
|
||||
case NM_CLICK:
|
||||
RunCommand(NULL, ((PNMLINK)lParam)->item.szUrl, SW_SHOWNORMAL);
|
||||
RunFile(((PNMLINK)lParam)->item.szUrl);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1497,12 +1497,11 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
|
||||
int sel = ListBox_GetCurSel(item);
|
||||
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
|
||||
|
||||
std::wstring command = Rainmeter->GetConfigEditor() + L" \"";
|
||||
command += Rainmeter->GetSettingsPath();
|
||||
command += L"Themes\\";
|
||||
command += themes[sel];
|
||||
command += L"\\Rainmeter.thm\"";
|
||||
RunCommand(NULL, command.c_str(), SW_SHOWNORMAL);
|
||||
std::wstring args = Rainmeter->GetSettingsPath();
|
||||
args += L"Themes\\";
|
||||
args += themes[sel];
|
||||
args += L"\\Rainmeter.thm";
|
||||
RunFile(Rainmeter->GetConfigEditor().c_str(), args.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1546,9 +1545,8 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case IDC_MANAGETHEMES_BACKUP_BUTTON:
|
||||
{
|
||||
std::wstring command = L'"' + Rainmeter->GetPath();
|
||||
command += L"SkinInstaller.exe\" /BACKUP";
|
||||
RunCommand(NULL, command.c_str(), SW_SHOWNORMAL);
|
||||
std::wstring file = Rainmeter->GetPath() + L"SkinInstaller.exe";
|
||||
RunFile(file.c_str(), L"/BACKUP");
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -45,17 +45,12 @@ UINT GetUniqueID()
|
||||
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 command = szCommand;
|
||||
|
||||
size_t notwhite = command.find_first_not_of(L" \t\r\n");
|
||||
command.erase(0, notwhite);
|
||||
if (command.empty()) return;
|
||||
|
||||
size_t quotePos = command.find(L'"');
|
||||
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";
|
||||
DWORD type = GetFileAttributes(command.c_str());
|
||||
if (type & FILE_ATTRIBUTE_DIRECTORY && type != 0xFFFFFFFF)
|
||||
{
|
||||
ShellExecute(Owner, szVerb, command.c_str(), NULL, NULL, nShowCmd ? nShowCmd : SW_SHOWNORMAL);
|
||||
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();
|
||||
ShellExecute(si.hwnd, si.lpVerb, si.lpFile, NULL, NULL, si.nShow);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring dir = CRainmeter::ExtractPath(file);
|
||||
si.lpDirectory = dir.c_str();
|
||||
si.nShow = nShowCmd ? nShowCmd : SW_SHOWNORMAL;
|
||||
si.lpParameters = args;
|
||||
si.fMask = SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI;
|
||||
ShellExecuteEx(&si);
|
||||
}
|
||||
|
@ -49,7 +49,8 @@ void Log(int nLevel, const WCHAR* message);
|
||||
void LogWithArgs(int nLevel, const WCHAR* format, ...);
|
||||
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);
|
||||
std::wstring GetFormattedString(UINT id, ...);
|
||||
|
@ -811,7 +811,7 @@ int CRainmeter::Initialize(LPCWSTR iniPath)
|
||||
// Set file locations
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -1222,33 +1222,24 @@ void CRainmeter::ReloadSettings()
|
||||
|
||||
void CRainmeter::EditSettings()
|
||||
{
|
||||
std::wstring command = m_ConfigEditor + L" \"";
|
||||
command += m_IniFile;
|
||||
command += L'"';
|
||||
RunCommand(m_Window, command.c_str(), SW_SHOWNORMAL);
|
||||
RunFile(m_ConfigEditor.c_str(), m_IniFile.c_str());
|
||||
}
|
||||
|
||||
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'"';
|
||||
std::wstring args = m_SkinPath + name;
|
||||
args += L'\\';
|
||||
args += iniFile;
|
||||
bool writable = CSystem::IsFileWritable(args.c_str());
|
||||
|
||||
// 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)
|
||||
{
|
||||
std::wstring command = L'"' + m_SkinPath;
|
||||
if (!name.empty()) command += name;
|
||||
command += L'"';
|
||||
RunCommand(m_Window, command.c_str(), SW_SHOWNORMAL);
|
||||
std::wstring folder = m_SkinPath + name;
|
||||
RunFile(folder.c_str());
|
||||
}
|
||||
|
||||
void CRainmeter::ActivateActiveConfigs()
|
||||
@ -2158,16 +2149,12 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow,
|
||||
}
|
||||
|
||||
// Run command
|
||||
std::wstring tmpSz = command;
|
||||
if (meterWindow)
|
||||
{
|
||||
std::wstring tmpSz = command;
|
||||
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);
|
||||
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"");
|
||||
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);
|
||||
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)
|
||||
{
|
||||
@ -3099,24 +3076,22 @@ void CRainmeter::ChangeSkinIndex(HMENU menu, int index)
|
||||
void CRainmeter::StartLogging()
|
||||
{
|
||||
// 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
|
||||
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)
|
||||
{
|
||||
CloseHandle(file);
|
||||
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
|
||||
{
|
||||
// Disable logging
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -3134,20 +3109,20 @@ void CRainmeter::StopLogging()
|
||||
void CRainmeter::ShowLogFile()
|
||||
{
|
||||
// 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" ";
|
||||
command += m_LogFile;
|
||||
RunCommand(m_Window, command.c_str(), SW_SHOWNORMAL);
|
||||
RunFile(m_LogViewer.c_str(), logFile);
|
||||
}
|
||||
}
|
||||
|
||||
void CRainmeter::DeleteLogFile()
|
||||
{
|
||||
// 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);
|
||||
if (res == IDYES)
|
||||
{
|
||||
|
@ -440,11 +440,11 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
}
|
||||
else if (wParam == IDM_SHOW_HELP)
|
||||
{
|
||||
RunCommand(NULL, RAINMETER_HELP, SW_SHOWNORMAL);
|
||||
RunFile(RAINMETER_HELP);
|
||||
}
|
||||
else if (wParam == IDM_NEW_VERSION)
|
||||
{
|
||||
RunCommand(NULL, RAINMETER_OFFICIAL, SW_SHOWNORMAL);
|
||||
RunFile(RAINMETER_OFFICIAL);
|
||||
}
|
||||
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)
|
||||
{
|
||||
RunCommand(NULL, RAINMETER_OFFICIAL, SW_SHOWNORMAL);
|
||||
RunFile(RAINMETER_OFFICIAL);
|
||||
}
|
||||
|
||||
tray->m_Notification = TRAY_NOTIFICATION_NONE;
|
||||
|
Loading…
Reference in New Issue
Block a user