- Fixed that the selected skin isn't loaded when clicking "Load" button or menu.
- Fixed that the selected skin tab isn't disabled correctly when unloading the skin via the skin context menu.
This commit is contained in:
spx 2011-09-08 23:10:41 +00:00
parent 2e128c75be
commit 3518dbf07e
3 changed files with 27 additions and 21 deletions

View File

@ -411,7 +411,7 @@ void CDialogManage::CTabSkins::Update(CMeterWindow* meterWindow, bool deleted)
{
if (meterWindow)
{
if (m_IgnoreUpdate)
if (!deleted && m_IgnoreUpdate)
{
// Changed setting from dialog, no need to update
m_IgnoreUpdate = false;
@ -881,10 +881,10 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
{
if (!m_SkinWindow)
{
CMeterWindow* mw = Rainmeter->GetMeterWindow(m_SkinName);
if (mw)
// Skin not active, load
std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(m_SkinName, m_FileName);
if (indexes.first != -1 && indexes.second != -1)
{
std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(mw);
Rainmeter->ActivateConfig(indexes.first, indexes.second);
// Fake selection change to update controls
@ -984,19 +984,22 @@ INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
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)
if (indexes.first != -1)
{
CMeterWindow* mw = (*iter).second;
mw->ChangeZPos(mw->GetWindowZPosition(), true);
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);
}
}
}
}

View File

@ -2325,11 +2325,11 @@ void CRainmeter::ClearDeleteLaterList()
if ((*iter).second == meterWindow)
{
m_Meters.erase(iter);
CDialogManage::UpdateSkins(meterWindow, true);
break;
}
}
CDialogManage::UpdateSkins(meterWindow, true);
delete meterWindow;
}
while (!m_DelayDeleteList.empty());
@ -2422,24 +2422,26 @@ CMeterWindow* CRainmeter::GetMeterWindowByINI(const std::wstring& ini_searching)
return NULL;
}
std::pair<int, int> CRainmeter::GetMeterWindowIndex(CMeterWindow* meterWindow)
std::pair<int, int> CRainmeter::GetMeterWindowIndex(const std::wstring& config, const std::wstring& iniFile)
{
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)
if (_wcsicmp(m_ConfigStrings[i].config.c_str(), config.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)
if (_wcsicmp(m_ConfigStrings[i].iniFiles[j].c_str(), iniFile.c_str()) == 0)
{
indexes = std::make_pair(i, j);
return indexes;
}
}
}
}
indexes = std::make_pair(-1, -1); // error
return indexes;
}

View File

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