- 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) if (c_Dialog && c_Dialog->m_TabSkins)
{ {
std::wstring name = meterWindow->GetSkinName(); std::wstring name = meterWindow->GetSkinName() + L"\\";
name += L"\\";
name += meterWindow->GetSkinIniFile(); name += meterWindow->GetSkinIniFile();
HWND item = GetDlgItem(c_Dialog->m_TabSkins->GetWindow(), IDC_MANAGESKINS_SKINS_TREEVIEW); 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); ComboBox_SetCurSel(item, m_SkinWindow->GetWindowZPosition() + 2);
item = GetDlgItem(m_Window, IDC_MANAGESKINS_LOADORDER_TEXT); item = GetDlgItem(m_Window, IDC_MANAGESKINS_LOADORDER_TEXT);
EnableWindow(item, TRUE);
_itow(Rainmeter->GetLoadOrder(m_SkinName), buffer, 10); _itow(Rainmeter->GetLoadOrder(m_SkinName), buffer, 10);
SetWindowText(item, buffer); SetWindowText(item, buffer);
@ -619,6 +619,7 @@ void CDialogManage::CTabSkins::DisableControls(bool clear)
item = GetDlgItem(m_Window, IDC_MANAGESKINS_LOADORDER_TEXT); item = GetDlgItem(m_Window, IDC_MANAGESKINS_LOADORDER_TEXT);
SetWindowText(item, L""); SetWindowText(item, L"");
EnableWindow(item, FALSE);
item = GetDlgItem(m_Window, IDC_MANAGESKINS_ONHOVER_COMBOBOX); item = GetDlgItem(m_Window, IDC_MANAGESKINS_ONHOVER_COMBOBOX);
EnableWindow(item, FALSE); EnableWindow(item, FALSE);
@ -636,8 +637,7 @@ void CDialogManage::CTabSkins::ReadSkin()
item = GetDlgItem(m_Window, IDC_MANAGESKINS_EDIT_BUTTON); item = GetDlgItem(m_Window, IDC_MANAGESKINS_EDIT_BUTTON);
EnableWindow(item, TRUE); EnableWindow(item, TRUE);
std::wstring file = Rainmeter->GetSkinPath(); std::wstring file = Rainmeter->GetSkinPath() + m_SkinName;
file += m_SkinName;
file += L"\\"; file += L"\\";
file += m_FileName; file += m_FileName;
m_SkinWindow = Rainmeter->GetMeterWindowByINI(file); 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) 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)) switch (LOWORD(wParam))
{ {
case IDC_MANAGESKINS_ACTIVESKINS_BUTTON: case IDC_MANAGESKINS_ACTIVESKINS_BUTTON:
@ -842,8 +848,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
int index = 0; int index = 0;
for ( ; iter != Rainmeter->GetAllMeterWindows().end(); ++iter) for ( ; iter != Rainmeter->GetAllMeterWindows().end(); ++iter)
{ {
std::wstring name = ((*iter).second)->GetSkinName(); std::wstring name = ((*iter).second)->GetSkinName() + L"\\";
name += L"\\";
name += ((*iter).second)->GetSkinIniFile(); name += ((*iter).second)->GetSkinIniFile();
InsertMenu(menu, index, MF_BYPOSITION, ID_CONFIG_FIRST + index, name.c_str()); InsertMenu(menu, index, MF_BYPOSITION, ID_CONFIG_FIRST + index, name.c_str());
++index; ++index;
@ -876,28 +881,18 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
{ {
if (!m_SkinWindow) if (!m_SkinWindow)
{ {
// Skin not active, load CMeterWindow* mw = Rainmeter->GetMeterWindow(m_SkinName);
const std::vector<CRainmeter::CONFIG>& configs = Rainmeter->GetAllConfigs(); if (mw)
for (int i = 0, isize = (int)configs.size(); i < isize; ++i)
{ {
if (_wcsicmp(configs[i].config.c_str(), m_SkinName.c_str()) == 0) std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(mw);
{ Rainmeter->ActivateConfig(indexes.first, indexes.second);
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);
// Fake selection change to update controls // Fake selection change to update controls
NMHDR nm; NMHDR nm;
nm.code = TVN_SELCHANGED; nm.code = TVN_SELCHANGED;
nm.idFrom = IDC_MANAGESKINS_SKINS_TREEVIEW; nm.idFrom = IDC_MANAGESKINS_SKINS_TREEVIEW;
nm.hwndFrom = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW); nm.hwndFrom = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW);
OnNotify(0, (LPARAM)&nm); OnNotify(0, (LPARAM)&nm);
}
}
}
} }
} }
else else
@ -937,17 +932,14 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
if (HIWORD(wParam) == EN_CHANGE) if (HIWORD(wParam) == EN_CHANGE)
{ {
WCHAR buffer[32]; WCHAR buffer[32];
if (GetWindowText((HWND)lParam, buffer, 32) > 0) m_IgnoreUpdate = true;
{ int x = (GetWindowText((HWND)lParam, buffer, 32) > 0) ? _wtoi(buffer) : 0;
m_IgnoreUpdate = true; m_SkinWindow->MoveWindow(x, m_SkinWindow->GetY());
int x = _wtoi(buffer);
m_SkinWindow->MoveWindow(x, m_SkinWindow->GetY());
if (x > m_SkinWindow->GetX()) if (x > m_SkinWindow->GetX())
{ {
_itow(m_SkinWindow->GetX(), buffer, 10); _itow(m_SkinWindow->GetX(), buffer, 10);
Edit_SetText((HWND)lParam, buffer); Edit_SetText((HWND)lParam, buffer);
}
} }
} }
break; break;
@ -956,16 +948,55 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
if (HIWORD(wParam) == EN_CHANGE) if (HIWORD(wParam) == EN_CHANGE)
{ {
WCHAR buffer[32]; WCHAR buffer[32];
if (GetWindowText((HWND)lParam, buffer, 32) > 0) m_IgnoreUpdate = true;
int y = (GetWindowText((HWND)lParam, buffer, 32) > 0) ? _wtoi(buffer) : 0;
m_SkinWindow->MoveWindow(m_SkinWindow->GetX(), y);
if (y > m_SkinWindow->GetY())
{
_itow(m_SkinWindow->GetY(), buffer, 10);
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; m_IgnoreUpdate = true;
int y = _wtoi(buffer);
m_SkinWindow->MoveWindow(m_SkinWindow->GetX(), y);
if (y > m_SkinWindow->GetY()) // 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)
{ {
_itow(m_SkinWindow->GetY(), buffer, 10); CMeterWindow* mw = (*iter).second;
Edit_SetText((HWND)lParam, buffer); mw->ChangeZPos(mw->GetWindowZPosition(), true);
} }
} }
} }
@ -1081,8 +1112,7 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
{ {
if (i == index) if (i == index)
{ {
std::wstring name = ((*iter).second)->GetSkinName(); std::wstring name = ((*iter).second)->GetSkinName() + L"\\";
name += L"\\";
name += ((*iter).second)->GetSkinIniFile(); name += ((*iter).second)->GetSkinIniFile();
HWND item = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW); 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: case NM_CLICK:
if (nm->idFrom == IDC_MANAGESKINS_ADDMETADATA_LINK) if (nm->idFrom == IDC_MANAGESKINS_ADDMETADATA_LINK)
{ {
std::wstring file = Rainmeter->GetSkinPath(); std::wstring file = Rainmeter->GetSkinPath() + m_SkinName;
file += m_SkinName;
file += L"\\"; file += L"\\";
file += m_FileName; file += m_FileName;
WritePrivateProfileString(L"Rainmeter", L"\r\n[Metadata]\r\nName=\r\nInformation=\r\nLicense=\r\nVersion", L"", file.c_str()); 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. ** Constructor.
** **
*/ */
CDialogManage::CTabThemes::CTabThemes(HWND wnd) : CTab(wnd), CDialogManage::CTabThemes::CTabThemes(HWND wnd) : CTab(wnd)
m_LoadTheme(false)
{ {
} }
@ -1619,8 +1647,7 @@ INT_PTR CDialogManage::CTabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
case IDC_MANAGESETTINGS_SHOWLOGFILE_BUTTON: case IDC_MANAGESETTINGS_SHOWLOGFILE_BUTTON:
{ {
std::wstring command = Rainmeter->GetLogViewer(); std::wstring command = Rainmeter->GetLogViewer() + Rainmeter->GetLogFile();
command += Rainmeter->GetLogFile();
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL); LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);
} }
break; break;

View File

@ -39,7 +39,6 @@ public:
static void OpenSkin(CMeterWindow* meterWindow); static void OpenSkin(CMeterWindow* meterWindow);
static void UpdateSkins(CMeterWindow* meterWindow, bool deleted = false); static void UpdateSkins(CMeterWindow* meterWindow, bool deleted = false);
static void UpdateThemes();
static WINDOWPLACEMENT c_WindowPlacement; static WINDOWPLACEMENT c_WindowPlacement;
static CDialogManage* c_Dialog; static CDialogManage* c_Dialog;
@ -86,13 +85,6 @@ private:
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam); INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(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 // Settings tab

View File

@ -19,15 +19,6 @@
#include "StdAfx.h" #include "StdAfx.h"
#include "Error.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 ** GetString
** **
@ -36,22 +27,5 @@ const WCHAR* CError::c_ErrorStrings[] =
*/ */
const std::wstring& CError::GetString() 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; return m_String;
} }

View File

@ -25,32 +25,17 @@
class CError class CError
{ {
public: public:
// Few predefined errors CError(const std::wstring& String) : m_String(String), m_File(NULL) {}
enum RAINERROR 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) {}
ERROR_USER, CError(const WCHAR* String, int Line, const char* File) : m_String(String), m_Line(Line), m_File(File) {}
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) {} const std::wstring& GetString();
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) {}
const std::wstring& GetString();
private: private:
std::wstring m_String; std::wstring m_String;
int m_Line; int m_Line;
const char* m_File; const char* m_File;
RAINERROR m_Error;
static const WCHAR* c_ErrorStrings[];
}; };
#endif #endif

View File

@ -285,7 +285,7 @@ BEGIN
LTEXT "Position:", IDC_STATIC, 165, 190, 80, 9 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 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 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 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 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 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) if (m_Plugin == NULL)
{ {
std::wstring error = L"Rainmeter plugin " + m_PluginName; std::wstring error = L"Plugin: \"" + m_PluginName;
error += L" not found!"; error += L"\" not found!";
throw CError(error, __LINE__, __FILE__); throw CError(error, __LINE__, __FILE__);
} }
} }
@ -164,8 +164,8 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
{ {
FreeLibrary(m_Plugin); FreeLibrary(m_Plugin);
std::wstring error = L"Rainmeter plugin " + m_PluginName; std::wstring error = L"Plugin: \"" + m_PluginName;
error += L" doesn't export Update or GetString function!"; error += L"\" doesn't export Update() or GetString()!";
throw CError(error, __LINE__, __FILE__); throw CError(error, __LINE__, __FILE__);
} }

View File

@ -68,7 +68,7 @@ bool CMeasureRegistry::Update()
(LPBYTE)data, (LPBYTE)data,
(LPDWORD)&size) == ERROR_SUCCESS) (LPDWORD)&size) == ERROR_SUCCESS)
{ {
switch(type) switch (type)
{ {
case REG_DWORD: case REG_DWORD:
m_Value = *((LPDWORD)data); m_Value = *((LPDWORD)data);

View File

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

View File

@ -112,7 +112,7 @@ int CMeterString::GetX(bool abs)
if (!abs) if (!abs)
{ {
switch(m_Align) switch (m_Align)
{ {
case ALIGN_CENTER: case ALIGN_CENTER:
x = x - (m_W / 2); x = x - (m_W / 2);
@ -224,7 +224,7 @@ void CMeterString::Initialize()
FontStyle style = FontStyleRegular; FontStyle style = FontStyleRegular;
switch(m_Style) switch (m_Style)
{ {
case ITALIC: case ITALIC:
style = FontStyleItalic; style = FontStyleItalic;
@ -516,7 +516,7 @@ bool CMeterString::Update()
} }
if (!m_Postfix.empty()) m_String += m_Postfix; if (!m_Postfix.empty()) m_String += m_Postfix;
switch(m_textCase) switch (m_textCase)
{ {
case TEXTCASE_UPPER: case TEXTCASE_UPPER:
StringToUpper(m_String); StringToUpper(m_String);
@ -588,7 +588,7 @@ bool CMeterString::DrawString(Graphics& graphics, RectF* rect)
graphics.SetTextRenderingHint(TextRenderingHintSingleBitPerPixelGridFit); graphics.SetTextRenderingHint(TextRenderingHintSingleBitPerPixelGridFit);
} }
switch(m_Align) switch (m_Align)
{ {
case ALIGN_CENTER: case ALIGN_CENTER:
stringFormat.SetAlignment(StringAlignmentCenter); stringFormat.SetAlignment(StringAlignmentCenter);
@ -836,7 +836,7 @@ void CMeterString::EnumerateInstalledFontFamilies()
} }
else else
{ {
Log(LOG_ERROR, L"Failed to enumerate installed font families: GetFamilies() failed."); Log(LOG_ERROR, L"Font family enumeration: GetFamilies() failed.");
} }
delete [] fontFamilies; delete [] fontFamilies;
@ -848,6 +848,6 @@ void CMeterString::EnumerateInstalledFontFamilies()
} }
else 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) 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) if (m_Window == NULL)
{ {
throw CError(CError::ERROR_CREATE_WINDOW, __LINE__, __FILE__); throw CError(L"Unable to register window!", __LINE__, __FILE__);
} }
#ifndef _WIN64 #ifndef _WIN64
@ -421,13 +421,13 @@ void CMeterWindow::Refresh(bool init, bool all)
{ {
if (0 == SetTimer(m_Window, METERTIMER, m_WindowUpdate, NULL)) 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 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); UpdateTransparency(m_AlphaValue, true);
@ -2315,7 +2315,7 @@ bool CMeterWindow::ReadSkin()
{ {
delete measure; delete measure;
measure = NULL; 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) else if (meterName.length() > 0)
@ -2345,7 +2345,7 @@ bool CMeterWindow::ReadSkin()
{ {
delete meter; delete meter;
meter = NULL; 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 // If it's not a meter or measure it will be ignored
@ -2384,7 +2384,7 @@ bool CMeterWindow::ReadSkin()
} }
catch (CError& error) 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) 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) 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()) if (!(*j)->GetToolTipText().empty())
@ -2897,7 +2897,7 @@ bool CMeterWindow::UpdateMeasure(CMeasure* measure, bool force)
} }
catch (CError& error) 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) catch (CError& error)
{ {
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); Log(LOG_ERROR, error.GetString().c_str());
} }
} }
@ -3826,9 +3826,9 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
} }
} }
catch(CError& error) 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; return 0;
@ -5024,7 +5024,7 @@ LRESULT CMeterWindow::OnDelayedRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
catch (CError& error) 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; return 0;
} }

View File

@ -145,24 +145,23 @@ std::vector<std::wstring> CRainmeter::ParseString(LPCTSTR str)
*/ */
int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath) int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath)
{ {
int Result=1; int result = 1;
try try
{ {
Rainmeter=new CRainmeter; Rainmeter = new CRainmeter;
if (Rainmeter) if (Rainmeter)
{ {
Result=Rainmeter->Initialize(ParentWnd, dllInst, szPath); result = Rainmeter->Initialize(ParentWnd, dllInst, szPath);
} }
} }
catch(CError& error) catch (CError& error)
{ {
MessageBox(ParentWnd, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); MessageBox(ParentWnd, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
} }
return Result; return result;
} }
/* /*
@ -1303,21 +1302,12 @@ void RainmeterActivateConfigWide(const WCHAR* arg)
if (subStrings.size() > 1) if (subStrings.size() > 1)
{ {
const std::vector<CRainmeter::CONFIG>& configs = Rainmeter->GetAllConfigs(); CMeterWindow* mw = Rainmeter->GetMeterWindow(subStrings[0]);
if (mw)
for (int i = 0, isize = (int)configs.size(); i < isize; ++i)
{ {
if (_wcsicmp(configs[i].config.c_str(), subStrings[0].c_str()) == 0) std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(mw);
{ Rainmeter->ActivateConfig(indexes.first, indexes.second);
for (int j = 0, jsize = (int)configs[i].iniFiles.size(); j < jsize; ++j) return;
{
if (_wcsicmp(configs[i].iniFiles[j].c_str(), subStrings[1].c_str()) == 0)
{
Rainmeter->ActivateConfig(i, j);
return;
}
}
}
} }
LogWithArgs(LOG_NOTICE, L"No such config: \"%s\" \"%s\"", subStrings[0].c_str(), subStrings[1].c_str()); LogWithArgs(LOG_NOTICE, L"No such config: \"%s\" \"%s\"", subStrings[0].c_str(), subStrings[1].c_str());
} }
@ -1789,11 +1779,11 @@ CRainmeter::~CRainmeter()
*/ */
int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath) int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
{ {
int Result=0; int result = 0;
if (Parent==NULL || Instance==NULL) if (Parent == NULL || Instance == NULL)
{ {
throw CError(CError::ERROR_NULL_PARAMETER, __LINE__, __FILE__); throw CError(L"Null parameter", __LINE__, __FILE__);
} }
m_Instance = Instance; m_Instance = Instance;
@ -2151,7 +2141,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
// Create meter windows for active configs // Create meter windows for active configs
ActivateActiveConfigs(); ActivateActiveConfigs();
return Result; // Alles OK return result; // Alles OK
} }
/* /*
@ -2247,9 +2237,9 @@ void CRainmeter::ActivateConfig(int configIndex, int iniIndex)
{ {
CreateMeterWindow(skinPath, skinConfig, skinIniFile); CreateMeterWindow(skinPath, skinConfig, skinIniFile);
} }
catch(CError& error) 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; 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) CMeterWindow* CRainmeter::GetMeterWindow(HWND hwnd)
{ {
std::map<std::wstring, CMeterWindow*>::const_iterator iter = m_Meters.begin(); 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; return 0;
} }
@ -3067,7 +3078,6 @@ BOOL CRainmeter::ExecuteBang(const std::wstring& bang, const std::wstring& arg,
return TRUE; return TRUE;
} }
/* /*
** ParseCommand ** ParseCommand
** **
@ -3212,6 +3222,11 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
strCommand.assign(strCommand, 1, len); strCommand.assign(strCommand, 1, len);
} }
if (meterWindow)
{
meterWindow->MakePathAbsolute(strCommand);
}
PlaySound(strCommand.c_str(), NULL, flags); PlaySound(strCommand.c_str(), NULL, flags);
} }
return; return;
@ -3481,13 +3496,13 @@ void CRainmeter::RefreshAll()
{ {
// Verify whether the cached information is valid // Verify whether the cached information is valid
int found = 0; 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) for (int i = 0, isize = (int)m_ConfigStrings.size(); i < isize; ++i)
{ {
if (_wcsicmp(skinConfig.c_str(), m_ConfigStrings[i].config.c_str()) == 0) if (_wcsicmp(skinConfig.c_str(), m_ConfigStrings[i].config.c_str()) == 0)
{ {
found = 1; 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) 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) if (_wcsicmp(skinIniFile.c_str(), m_ConfigStrings[i].iniFiles[j].c_str()) == 0)
@ -3538,7 +3553,7 @@ void CRainmeter::RefreshAll()
} }
catch (CError& error) 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)"; std::wstring format = L"Resetting WorkArea@%i: L=%i, T=%i, R=%i, B=%i (W=%i, H=%i)";
if (!result) 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); 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)"; format += L": L=%i, T=%i, R=%i, B=%i (W=%i, H=%i)";
if (!result) 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); 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) 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 // Store 20 last items
LOG_INFO logInfo = {level, time, message}; LOG_INFO logInfo = {level, time, message};
m_LogData.push_back(logInfo); m_LogData.push_back(logInfo);
@ -4375,39 +4396,33 @@ void CRainmeter::TestSettingsFile(bool bDefaultIniLocation)
} }
if (!bSuccess) 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" std::wstring error = L"Rainmeter.ini is not writable. Rainmeter will not\n"
L"application will not be able to save any settings permanently.\n\n"; L"be able to save any settings permanently.\n\n";
if (!bDefaultIniLocation) if (!bDefaultIniLocation)
{ {
std::wstring strTarget = L"%APPDATA%\\Rainmeter\\"; std::wstring strTarget = L"%APPDATA%\\Rainmeter\\";
ExpandEnvironmentVariables(strTarget); 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 += m_IniFile;
error += L"\n\nto\n\n"; error += L"\n\nto\n";
error += strTarget; error += strTarget;
error += L"\n\nAlternatively you can simply remove the file and\n" error += L"\n\nAlternatively, simply remove the file and it will\n"
L"it will be automatically recreated in the correct location\n" L"be automatically recreated in the correct location on\n"
L"when Rainmeter is restarted the next time (you\'ll lose your\n" L"next launch (current settings will be lost).";
L"current settings though).\n";
} }
else else
{ {
error += L"Make sure that the settings file is not set as read-only and\n" error += L"Make sure that the settings file is not set as read-only and that\n"
L"that it is located in a folder where you have write permissions.\n\n" L"the folder is writable. The file is located at:\n";
L"The settings file is located at:\n";
error += m_IniFile; error += m_IniFile;
} }
MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_ICONERROR); 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) std::wstring CRainmeter::ExtractPath(const std::wstring& strFilePath)

View File

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

View File

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