- Manage Skins: Load order can now be changed

- Fixed that the PLAY/PLAYLOOP commands didn't work with relative paths
- Errors that used to display in a messagebox are now logged and shown in the About Log dialog (which is opened when an error occurs)
- Some minor tweaks
This commit is contained in:
Birunthan Mohanathas 2011-09-08 14:39:25 +00:00
parent d598c56b76
commit f17602ee1d
13 changed files with 177 additions and 184 deletions

View File

@ -103,8 +103,7 @@ void CDialogManage::OpenSkin(CMeterWindow* meterWindow)
if (c_Dialog && c_Dialog->m_TabSkins)
{
std::wstring name = meterWindow->GetSkinName();
name += L"\\";
std::wstring name = meterWindow->GetSkinName() + L"\\";
name += meterWindow->GetSkinIniFile();
HWND item = GetDlgItem(c_Dialog->m_TabSkins->GetWindow(), IDC_MANAGESKINS_SKINS_TREEVIEW);
@ -523,6 +522,7 @@ void CDialogManage::CTabSkins::SetControls()
ComboBox_SetCurSel(item, m_SkinWindow->GetWindowZPosition() + 2);
item = GetDlgItem(m_Window, IDC_MANAGESKINS_LOADORDER_TEXT);
EnableWindow(item, TRUE);
_itow(Rainmeter->GetLoadOrder(m_SkinName), buffer, 10);
SetWindowText(item, buffer);
@ -619,6 +619,7 @@ void CDialogManage::CTabSkins::DisableControls(bool clear)
item = GetDlgItem(m_Window, IDC_MANAGESKINS_LOADORDER_TEXT);
SetWindowText(item, L"");
EnableWindow(item, FALSE);
item = GetDlgItem(m_Window, IDC_MANAGESKINS_ONHOVER_COMBOBOX);
EnableWindow(item, FALSE);
@ -636,8 +637,7 @@ void CDialogManage::CTabSkins::ReadSkin()
item = GetDlgItem(m_Window, IDC_MANAGESKINS_EDIT_BUTTON);
EnableWindow(item, TRUE);
std::wstring file = Rainmeter->GetSkinPath();
file += m_SkinName;
std::wstring file = Rainmeter->GetSkinPath() + m_SkinName;
file += L"\\";
file += m_FileName;
m_SkinWindow = Rainmeter->GetMeterWindowByINI(file);
@ -831,6 +831,12 @@ INT_PTR CALLBACK CDialogManage::CTabSkins::DlgProc(HWND hWnd, UINT uMsg, WPARAM
INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
{
if (!m_HandleCommands)
{
// Values are being changed/reset, no need to apply changes
return FALSE;
}
switch (LOWORD(wParam))
{
case IDC_MANAGESKINS_ACTIVESKINS_BUTTON:
@ -842,8 +848,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
int index = 0;
for ( ; iter != Rainmeter->GetAllMeterWindows().end(); ++iter)
{
std::wstring name = ((*iter).second)->GetSkinName();
name += L"\\";
std::wstring name = ((*iter).second)->GetSkinName() + L"\\";
name += ((*iter).second)->GetSkinIniFile();
InsertMenu(menu, index, MF_BYPOSITION, ID_CONFIG_FIRST + index, name.c_str());
++index;
@ -876,18 +881,11 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
{
if (!m_SkinWindow)
{
// Skin not active, load
const std::vector<CRainmeter::CONFIG>& configs = Rainmeter->GetAllConfigs();
for (int i = 0, isize = (int)configs.size(); i < isize; ++i)
CMeterWindow* mw = Rainmeter->GetMeterWindow(m_SkinName);
if (mw)
{
if (_wcsicmp(configs[i].config.c_str(), m_SkinName.c_str()) == 0)
{
for (int j = 0, jsize = (int)configs[i].iniFiles.size(); j < jsize; ++j)
{
if (_wcsicmp(configs[i].iniFiles[j].c_str(), m_FileName.c_str()) == 0)
{
Rainmeter->ActivateConfig(i, j);
std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(mw);
Rainmeter->ActivateConfig(indexes.first, indexes.second);
// Fake selection change to update controls
NMHDR nm;
@ -897,9 +895,6 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
OnNotify(0, (LPARAM)&nm);
}
}
}
}
}
else
{
m_HandleCommands = false;
@ -937,10 +932,8 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
if (HIWORD(wParam) == EN_CHANGE)
{
WCHAR buffer[32];
if (GetWindowText((HWND)lParam, buffer, 32) > 0)
{
m_IgnoreUpdate = true;
int x = _wtoi(buffer);
int x = (GetWindowText((HWND)lParam, buffer, 32) > 0) ? _wtoi(buffer) : 0;
m_SkinWindow->MoveWindow(x, m_SkinWindow->GetY());
if (x > m_SkinWindow->GetX())
@ -949,17 +942,14 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
Edit_SetText((HWND)lParam, buffer);
}
}
}
break;
case IDC_MANAGESKINS_Y_TEXT:
if (HIWORD(wParam) == EN_CHANGE)
{
WCHAR buffer[32];
if (GetWindowText((HWND)lParam, buffer, 32) > 0)
{
m_IgnoreUpdate = true;
int y = _wtoi(buffer);
int y = (GetWindowText((HWND)lParam, buffer, 32) > 0) ? _wtoi(buffer) : 0;
m_SkinWindow->MoveWindow(m_SkinWindow->GetX(), y);
if (y > m_SkinWindow->GetY())
@ -968,6 +958,47 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
Edit_SetText((HWND)lParam, buffer);
}
}
break;
case IDC_MANAGESKINS_LOADORDER_TEXT:
if (HIWORD(wParam) == EN_CHANGE)
{
if (m_IgnoreUpdate)
{
// To avoid infinite loop after setting value below
m_IgnoreUpdate = false;
}
else
{
m_IgnoreUpdate = true;
// Convert text to number and set it to get rid of extra chars
int value = GetDlgItemInt(m_Window, IDC_MANAGESKINS_LOADORDER_TEXT, NULL, TRUE);
SetDlgItemInt(m_Window, IDC_MANAGESKINS_LOADORDER_TEXT, value, TRUE);
// Move caret to end
Edit_SetSel((HWND)lParam, 32, 32);
WCHAR buffer[32];
_itow(value, buffer, 10);
WritePrivateProfileString(m_SkinName.c_str(), L"LoadOrder", buffer, Rainmeter->GetIniFile().c_str());
std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(m_SkinWindow);
Rainmeter->SetLoadOrder(indexes.first, value);
std::multimap<int, CMeterWindow*> windows;
Rainmeter->GetMeterWindowsByLoadOrder(windows);
CSystem::PrepareHelperWindow();
// Reorder window z-position to reflect load order
std::multimap<int, CMeterWindow*>::const_iterator iter = windows.begin();
for ( ; iter != windows.end(); ++iter)
{
CMeterWindow* mw = (*iter).second;
mw->ChangeZPos(mw->GetWindowZPosition(), true);
}
}
}
break;
@ -1081,8 +1112,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
{
if (i == index)
{
std::wstring name = ((*iter).second)->GetSkinName();
name += L"\\";
std::wstring name = ((*iter).second)->GetSkinName() + L"\\";
name += ((*iter).second)->GetSkinIniFile();
HWND item = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW);
@ -1115,8 +1145,7 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam)
case NM_CLICK:
if (nm->idFrom == IDC_MANAGESKINS_ADDMETADATA_LINK)
{
std::wstring file = Rainmeter->GetSkinPath();
file += m_SkinName;
std::wstring file = Rainmeter->GetSkinPath() + m_SkinName;
file += L"\\";
file += m_FileName;
WritePrivateProfileString(L"Rainmeter", L"\r\n[Metadata]\r\nName=\r\nInformation=\r\nLicense=\r\nVersion", L"", file.c_str());
@ -1271,8 +1300,7 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam)
** Constructor.
**
*/
CDialogManage::CTabThemes::CTabThemes(HWND wnd) : CTab(wnd),
m_LoadTheme(false)
CDialogManage::CTabThemes::CTabThemes(HWND wnd) : CTab(wnd)
{
}
@ -1619,8 +1647,7 @@ INT_PTR CDialogManage::CTabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
case IDC_MANAGESETTINGS_SHOWLOGFILE_BUTTON:
{
std::wstring command = Rainmeter->GetLogViewer();
command += Rainmeter->GetLogFile();
std::wstring command = Rainmeter->GetLogViewer() + Rainmeter->GetLogFile();
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);
}
break;

View File

@ -39,7 +39,6 @@ public:
static void OpenSkin(CMeterWindow* meterWindow);
static void UpdateSkins(CMeterWindow* meterWindow, bool deleted = false);
static void UpdateThemes();
static WINDOWPLACEMENT c_WindowPlacement;
static CDialogManage* c_Dialog;
@ -86,13 +85,6 @@ private:
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
void Update();
private:
void PreserveSetting(const std::wstring& backupFile, LPCTSTR key, bool replace = true);
bool m_LoadTheme;
};
// Settings tab

View File

@ -19,15 +19,6 @@
#include "StdAfx.h"
#include "Error.h"
const WCHAR* CError::c_ErrorStrings[] =
{
L"User defined error",
L"Out of memory",
L"Null parameter",
L"Unable to register windowclass",
L"Unable to create window"
};
/*
** GetString
**
@ -36,22 +27,5 @@ const WCHAR* CError::c_ErrorStrings[] =
*/
const std::wstring& CError::GetString()
{
// static WCHAR Buffer[16];
if (m_Error != ERROR_USER)
{
m_String = c_ErrorStrings[m_Error];
// if (m_File)
// {
// _snwprintf_s(Buffer, _TRUNCATE, L"%i", m_Line);
//
// m_String += L"\n(";
// m_String += m_File;
// m_String += L" : ";
// m_String += Buffer;
// m_String += L")";
// }
}
return m_String;
}

View File

@ -25,22 +25,10 @@
class CError
{
public:
// Few predefined errors
enum RAINERROR
{
ERROR_USER,
ERROR_OUT_OF_MEM,
ERROR_NULL_PARAMETER,
ERROR_REGISTER_WINDOWCLASS,
ERROR_CREATE_WINDOW
};
CError(const std::wstring& String) : m_Error(ERROR_USER), m_String(String), m_File(NULL) {}
CError(const WCHAR* String ) : m_Error(ERROR_USER), m_String(String), m_File(NULL) {}
CError(const std::wstring& String, int Line, const char* File) : m_Error(ERROR_USER), m_String(String), m_Line(Line), m_File(File) {}
CError(const WCHAR* String, int Line, const char* File) : m_Error(ERROR_USER), m_String(String), m_Line(Line), m_File(File) {}
CError(RAINERROR Error) : m_Error(Error), m_File(NULL) {}
CError(RAINERROR Error, int Line, const char* File) : m_Error(Error), m_Line(Line), m_File(File) {}
CError(const std::wstring& String) : m_String(String), m_File(NULL) {}
CError(const WCHAR* String ) : m_String(String), m_File(NULL) {}
CError(const std::wstring& String, int Line, const char* File) : m_String(String), m_Line(Line), m_File(File) {}
CError(const WCHAR* String, int Line, const char* File) : m_String(String), m_Line(Line), m_File(File) {}
const std::wstring& GetString();
@ -48,9 +36,6 @@ private:
std::wstring m_String;
int m_Line;
const char* m_File;
RAINERROR m_Error;
static const WCHAR* c_ErrorStrings[];
};
#endif

View File

@ -285,7 +285,7 @@ BEGIN
LTEXT "Position:", IDC_STATIC, 165, 190, 80, 9
COMBOBOX IDC_MANAGESKINS_ZPOSITION_COMBOBOX, 230, 187, 70, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | WS_DISABLED
LTEXT "Load order:", IDC_STATIC, 165, 208, 80, 9
EDITTEXT IDC_MANAGESKINS_LOADORDER_TEXT, 230, 205, 70, 14, ES_NUMBER | WS_BORDER | WS_TABSTOP | WS_DISABLED
EDITTEXT IDC_MANAGESKINS_LOADORDER_TEXT, 230, 205, 70, 14, WS_BORDER | WS_TABSTOP | WS_DISABLED
LTEXT "Transparency:", IDC_STATIC, 165, 229, 80, 9
COMBOBOX IDC_MANAGESKINS_TRANSPARENCY_COMBOBOX, 230, 226, 70, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | WS_DISABLED
LTEXT "On hover:", IDC_STATIC, 165, 247, 80, 9

View File

@ -147,8 +147,8 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
if (m_Plugin == NULL)
{
std::wstring error = L"Rainmeter plugin " + m_PluginName;
error += L" not found!";
std::wstring error = L"Plugin: \"" + m_PluginName;
error += L"\" not found!";
throw CError(error, __LINE__, __FILE__);
}
}
@ -164,8 +164,8 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
FreeLibrary(m_Plugin);
std::wstring error = L"Rainmeter plugin " + m_PluginName;
error += L" doesn't export Update or GetString function!";
std::wstring error = L"Plugin: \"" + m_PluginName;
error += L"\" doesn't export Update() or GetString()!";
throw CError(error, __LINE__, __FILE__);
}

View File

@ -447,7 +447,7 @@ void CMeter::BindMeasure(const std::list<CMeasure*>& measures)
if (m_MeasureName.empty())
{
std::wstring error = L"The meter [" + m_Name;
error += L"] is not bound to anything!";
error += L"] is unbound!";
throw CError(error, __LINE__, __FILE__);
}

View File

@ -836,7 +836,7 @@ void CMeterString::EnumerateInstalledFontFamilies()
}
else
{
Log(LOG_ERROR, L"Failed to enumerate installed font families: GetFamilies() failed.");
Log(LOG_ERROR, L"Font family enumeration: GetFamilies() failed.");
}
delete [] fontFamilies;
@ -848,6 +848,6 @@ void CMeterString::EnumerateInstalledFontFamilies()
}
else
{
Log(LOG_ERROR, L"Failed to enumerate installed font families: InstalledFontCollection() failed.");
Log(LOG_ERROR, L"Font family enumeration: InstalledFontCollection() failed.");
}
}

View File

@ -247,7 +247,7 @@ int CMeterWindow::Initialize(CRainmeter& Rainmeter)
if (err != 0 && ERROR_CLASS_ALREADY_EXISTS != err)
{
throw CError(CError::ERROR_REGISTER_WINDOWCLASS, __LINE__, __FILE__);
throw CError(L"Unable to register class!", __LINE__, __FILE__);
}
}
@ -266,7 +266,7 @@ int CMeterWindow::Initialize(CRainmeter& Rainmeter)
if (m_Window == NULL)
{
throw CError(CError::ERROR_CREATE_WINDOW, __LINE__, __FILE__);
throw CError(L"Unable to register window!", __LINE__, __FILE__);
}
#ifndef _WIN64
@ -421,13 +421,13 @@ void CMeterWindow::Refresh(bool init, bool all)
{
if (0 == SetTimer(m_Window, METERTIMER, m_WindowUpdate, NULL))
{
throw CError(L"Unable to create a timer!", __LINE__, __FILE__);
throw CError(L"Unable to set timer!", __LINE__, __FILE__);
}
}
if (0 == SetTimer(m_Window, MOUSETIMER, 500, NULL)) // Mouse position is checked twice per sec
{
throw CError(L"Unable to create a timer!", __LINE__, __FILE__);
throw CError(L"Unable to set timer!", __LINE__, __FILE__);
}
UpdateTransparency(m_AlphaValue, true);
@ -2315,7 +2315,7 @@ bool CMeterWindow::ReadSkin()
{
delete measure;
measure = NULL;
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
Log(LOG_ERROR, error.GetString().c_str());
}
}
else if (meterName.length() > 0)
@ -2345,7 +2345,7 @@ bool CMeterWindow::ReadSkin()
{
delete meter;
meter = NULL;
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
Log(LOG_ERROR, error.GetString().c_str());
}
}
// If it's not a meter or measure it will be ignored
@ -2384,7 +2384,7 @@ bool CMeterWindow::ReadSkin()
}
catch (CError& error)
{
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
Log(LOG_ERROR, error.GetString().c_str());
}
}
}
@ -2410,7 +2410,7 @@ void CMeterWindow::InitializeMeasures()
}
catch (CError& error)
{
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
Log(LOG_ERROR, error.GetString().c_str());
}
}
}
@ -2433,7 +2433,7 @@ void CMeterWindow::InitializeMeters()
}
catch (CError& error)
{
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
Log(LOG_ERROR, error.GetString().c_str());
}
if (!(*j)->GetToolTipText().empty())
@ -2897,7 +2897,7 @@ bool CMeterWindow::UpdateMeasure(CMeasure* measure, bool force)
}
catch (CError& error)
{
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
Log(LOG_ERROR, error.GetString().c_str());
}
}
@ -2937,7 +2937,7 @@ bool CMeterWindow::UpdateMeter(CMeter* meter, bool& bActiveTransition, bool forc
}
catch (CError& error)
{
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
Log(LOG_ERROR, error.GetString().c_str());
}
}
@ -3828,7 +3828,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
catch (CError& error)
{
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
Log(LOG_ERROR, error.GetString().c_str());
}
return 0;
@ -5024,7 +5024,7 @@ LRESULT CMeterWindow::OnDelayedRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
catch (CError& error)
{
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
Log(LOG_ERROR, error.GetString().c_str());
}
return 0;
}

View File

@ -145,7 +145,7 @@ std::vector<std::wstring> CRainmeter::ParseString(LPCTSTR str)
*/
int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath)
{
int Result=1;
int result = 1;
try
{
@ -153,16 +153,15 @@ int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath)
if (Rainmeter)
{
Result=Rainmeter->Initialize(ParentWnd, dllInst, szPath);
result = Rainmeter->Initialize(ParentWnd, dllInst, szPath);
}
}
catch (CError& error)
{
MessageBox(ParentWnd, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
}
return Result;
return result;
}
/*
@ -1303,22 +1302,13 @@ void RainmeterActivateConfigWide(const WCHAR* arg)
if (subStrings.size() > 1)
{
const std::vector<CRainmeter::CONFIG>& configs = Rainmeter->GetAllConfigs();
for (int i = 0, isize = (int)configs.size(); i < isize; ++i)
CMeterWindow* mw = Rainmeter->GetMeterWindow(subStrings[0]);
if (mw)
{
if (_wcsicmp(configs[i].config.c_str(), subStrings[0].c_str()) == 0)
{
for (int j = 0, jsize = (int)configs[i].iniFiles.size(); j < jsize; ++j)
{
if (_wcsicmp(configs[i].iniFiles[j].c_str(), subStrings[1].c_str()) == 0)
{
Rainmeter->ActivateConfig(i, j);
std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(mw);
Rainmeter->ActivateConfig(indexes.first, indexes.second);
return;
}
}
}
}
LogWithArgs(LOG_NOTICE, L"No such config: \"%s\" \"%s\"", subStrings[0].c_str(), subStrings[1].c_str());
}
else
@ -1789,11 +1779,11 @@ CRainmeter::~CRainmeter()
*/
int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
{
int Result=0;
int result = 0;
if (Parent == NULL || Instance == NULL)
{
throw CError(CError::ERROR_NULL_PARAMETER, __LINE__, __FILE__);
throw CError(L"Null parameter", __LINE__, __FILE__);
}
m_Instance = Instance;
@ -2151,7 +2141,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
// Create meter windows for active configs
ActivateActiveConfigs();
return Result; // Alles OK
return result; // Alles OK
}
/*
@ -2249,7 +2239,7 @@ void CRainmeter::ActivateConfig(int configIndex, int iniIndex)
}
catch (CError& error)
{
MessageBox(NULL, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
Log(LOG_ERROR, error.GetString().c_str());
}
}
}
@ -2423,6 +2413,27 @@ CMeterWindow* CRainmeter::GetMeterWindowByINI(const std::wstring& ini_searching)
return NULL;
}
std::pair<int, int> CRainmeter::GetMeterWindowIndex(CMeterWindow* meterWindow)
{
std::pair<int, int> indexes;
for (int i = 0, isize = (int)m_ConfigStrings.size(); i < isize; ++i)
{
if (_wcsicmp(m_ConfigStrings[i].config.c_str(), meterWindow->GetSkinName().c_str()) == 0)
{
for (int j = 0, jsize = (int)m_ConfigStrings[i].iniFiles.size(); j < jsize; ++j)
{
if (_wcsicmp(m_ConfigStrings[i].iniFiles[j].c_str(), meterWindow->GetSkinIniFile().c_str()) == 0)
{
indexes = std::make_pair(i, j);
}
}
}
}
return indexes;
}
CMeterWindow* CRainmeter::GetMeterWindow(HWND hwnd)
{
std::map<std::wstring, CMeterWindow*>::const_iterator iter = m_Meters.begin();
@ -2483,7 +2494,7 @@ int CRainmeter::GetLoadOrder(const std::wstring& config)
}
}
// LoadOrder not exists
// LoadOrder not specified
return 0;
}
@ -3067,7 +3078,6 @@ BOOL CRainmeter::ExecuteBang(const std::wstring& bang, const std::wstring& arg,
return TRUE;
}
/*
** ParseCommand
**
@ -3212,6 +3222,11 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
strCommand.assign(strCommand, 1, len);
}
if (meterWindow)
{
meterWindow->MakePathAbsolute(strCommand);
}
PlaySound(strCommand.c_str(), NULL, flags);
}
return;
@ -3481,13 +3496,13 @@ void CRainmeter::RefreshAll()
{
// Verify whether the cached information is valid
int found = 0;
std::wstring skinConfig = mw->GetSkinName();
const std::wstring& skinConfig = mw->GetSkinName();
for (int i = 0, isize = (int)m_ConfigStrings.size(); i < isize; ++i)
{
if (_wcsicmp(skinConfig.c_str(), m_ConfigStrings[i].config.c_str()) == 0)
{
found = 1;
std::wstring skinIniFile = mw->GetSkinIniFile();
const std::wstring& skinIniFile = mw->GetSkinIniFile();
for (int j = 0, jsize = (int)m_ConfigStrings[i].iniFiles.size(); j < jsize; ++j)
{
if (_wcsicmp(skinIniFile.c_str(), m_ConfigStrings[i].iniFiles[j].c_str()) == 0)
@ -3538,7 +3553,7 @@ void CRainmeter::RefreshAll()
}
catch (CError& error)
{
MessageBox(mw->GetWindow(), error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
Log(LOG_ERROR, error.GetString().c_str());
}
}
}
@ -3626,7 +3641,7 @@ void CRainmeter::UpdateDesktopWorkArea(bool reset)
std::wstring format = L"Resetting WorkArea@%i: L=%i, T=%i, R=%i, B=%i (W=%i, H=%i)";
if (!result)
{
format += L" => FAIL.";
format += L" => FAIL";
}
LogWithArgs(LOG_NOTICE, format.c_str(), (int)i + 1, r.left, r.top, r.right, r.bottom, r.right - r.left, r.bottom - r.top);
}
@ -3700,7 +3715,7 @@ void CRainmeter::UpdateDesktopWorkArea(bool reset)
format += L": L=%i, T=%i, R=%i, B=%i (W=%i, H=%i)";
if (!result)
{
format += L" => FAIL.";
format += L" => FAIL";
}
LogWithArgs(LOG_NOTICE, format.c_str(), r.left, r.top, r.right, r.bottom, r.right - r.left, r.bottom - r.top);
}
@ -4326,6 +4341,12 @@ void CRainmeter::DeleteLogFile()
void CRainmeter::AddAboutLogInfo(int level, LPCWSTR time, LPCWSTR message)
{
if (level == LOG_ERROR)
{
// Open About Log window for errors
CDialogAbout::Open();
}
// Store 20 last items
LOG_INFO logInfo = {level, time, message};
m_LogData.push_back(logInfo);
@ -4375,39 +4396,33 @@ void CRainmeter::TestSettingsFile(bool bDefaultIniLocation)
}
if (!bSuccess)
{
Log(LOG_WARNING, L"The Rainmeter.ini file is NOT writable.");
Log(LOG_WARNING, L"Rainmeter.ini is NOT writable.");
std::wstring error = L"The Rainmeter.ini file is not writable. This means that the\n"
L"application will not be able to save any settings permanently.\n\n";
std::wstring error = L"Rainmeter.ini is not writable. Rainmeter will not\n"
L"be able to save any settings permanently.\n\n";
if (!bDefaultIniLocation)
{
std::wstring strTarget = L"%APPDATA%\\Rainmeter\\";
ExpandEnvironmentVariables(strTarget);
error += L"You should quit Rainmeter and move the settings file from\n\n";
error += L"You should quit Rainmeter and move the settings file from\n";
error += m_IniFile;
error += L"\n\nto\n\n";
error += L"\n\nto\n";
error += strTarget;
error += L"\n\nAlternatively you can simply remove the file and\n"
L"it will be automatically recreated in the correct location\n"
L"when Rainmeter is restarted the next time (you\'ll lose your\n"
L"current settings though).\n";
error += L"\n\nAlternatively, simply remove the file and it will\n"
L"be automatically recreated in the correct location on\n"
L"next launch (current settings will be lost).";
}
else
{
error += L"Make sure that the settings file is not set as read-only and\n"
L"that it is located in a folder where you have write permissions.\n\n"
L"The settings file is located at:\n";
error += L"Make sure that the settings file is not set as read-only and that\n"
L"the folder is writable. The file is located at:\n";
error += m_IniFile;
}
MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_ICONERROR);
}
else
{
Log(LOG_NOTICE, L"The Rainmeter.ini file is writable.");
}
}
std::wstring CRainmeter::ExtractPath(const std::wstring& strFilePath)

View File

@ -179,6 +179,7 @@ public:
CMeterWindow* GetMeterWindow(const std::wstring& config);
CMeterWindow* GetMeterWindowByINI(const std::wstring& ini_searching);
std::pair<int, int> GetMeterWindowIndex(CMeterWindow* meterWindow);
CMeterWindow* GetMeterWindow(HWND hwnd);
void GetMeterWindowsByLoadOrder(std::multimap<int, CMeterWindow*>& windows, const std::wstring& group = L"");

View File

@ -315,7 +315,7 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
{
delete m_Measure;
m_Measure = NULL;
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
Log(LOG_ERROR, error.GetString().c_str());
}
Rainmeter->SetCurrentParser(oldParser);
@ -445,8 +445,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
const std::wstring& log = Rainmeter->GetLogFile();
if (_waccess(log.c_str(), 0) != -1)
{
std::wstring command = Rainmeter->GetLogViewer();
command += log;
std::wstring command = Rainmeter->GetLogViewer() + log;
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
}
}