diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-17 12:47:55 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-17 12:47:55 +0300 |
commit | ab32043a6046fcc8954c726a446a16a59bb71f04 (patch) | |
tree | 208147b21d1c0121f4717d42b91a7f1bd69c0c8c /plugins/TabSRMM | |
parent | 1d36871179fb325cd8a7363fa71fe187d0ddfc14 (diff) |
code cleaning
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r-- | plugins/TabSRMM/src/chat_window.cpp | 85 |
1 files changed, 41 insertions, 44 deletions
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp index a9561d8030..b05c8f492f 100644 --- a/plugins/TabSRMM/src/chat_window.cpp +++ b/plugins/TabSRMM/src/chat_window.cpp @@ -2064,53 +2064,50 @@ void CChatRoomDlg::UpdateStatusBar() if (m_pContainer->hwndActive != m_hwnd || m_pContainer->hwndStatus == 0 || CMimAPI::m_shutDown || m_wszStatusBar[0]) return; - if (m_si->pszModule != nullptr) { - wchar_t szFinalStatusBarText[512]; - - //Mad: strange rare crash here... - MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule); - if (!mi) - return; - - if (!mi->ptszModDispName) - return; - - int x = 12; - x += GetTextPixelSize(mi->ptszModDispName, (HFONT)SendMessage(m_pContainer->hwndStatus, WM_GETFONT, 0, 0), TRUE); - x += GetSystemMetrics(SM_CXSMICON); - - if (m_pPanel.isActive()) { - time_t now = time(0); - DWORD diff = (now - mi->idleTimeStamp) / 60; - - if ((diff >= 1 && diff != mi->lastIdleCheck)) { - mi->lastIdleCheck = diff; - if (diff == 0) - mi->tszIdleMsg[0] = 0; - else if (diff > 59) { - DWORD hours = diff / 60; - DWORD minutes = diff % 60; - mir_snwprintf(mi->tszIdleMsg, TranslateT(", %d %s, %d %s idle"), hours, hours > 1 ? - TranslateT("hours") : TranslateT("hour"), - minutes, minutes > 1 ? TranslateT("minutes") : TranslateT("minute")); - } - else mir_snwprintf(mi->tszIdleMsg, TranslateT(", %d %s idle"), diff, diff > 1 ? TranslateT("minutes") : TranslateT("minute")); + if (m_si->pszModule == nullptr) + return; + + //Mad: strange rare crash here... + MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule); + if (!mi) + return; + + if (!mi->ptszModDispName) + return; + + int x = 12; + x += GetTextPixelSize(mi->ptszModDispName, (HFONT)SendMessage(m_pContainer->hwndStatus, WM_GETFONT, 0, 0), TRUE); + x += GetSystemMetrics(SM_CXSMICON); + + wchar_t szFinalStatusBarText[512]; + if (m_pPanel.isActive()) { + time_t now = time(0); + DWORD diff = (now - mi->idleTimeStamp) / 60; + + if ((diff >= 1 && diff != mi->lastIdleCheck)) { + mi->lastIdleCheck = diff; + if (diff > 59) { + DWORD hours = diff / 60; + DWORD minutes = diff % 60; + mir_snwprintf(mi->tszIdleMsg, TranslateT(", %d %s, %d %s idle"), + hours, hours > 1 ? TranslateT("hours") : TranslateT("hour"), + minutes, minutes > 1 ? TranslateT("minutes") : TranslateT("minute")); } - mir_snwprintf(szFinalStatusBarText, TranslateT("%s on %s%s"), m_wszMyNickname, mi->ptszModDispName, mi->tszIdleMsg); + else mir_snwprintf(mi->tszIdleMsg, TranslateT(", %d %s idle"), diff, diff > 1 ? TranslateT("minutes") : TranslateT("minute")); } - else { - if (m_si->ptszStatusbarText) - mir_snwprintf(szFinalStatusBarText, L"%s %s", mi->ptszModDispName, m_si->ptszStatusbarText); - else - wcsncpy_s(szFinalStatusBarText, mi->ptszModDispName, _TRUNCATE); - } - SendMessage(m_pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)szFinalStatusBarText); - tabUpdateStatusBar(); - m_pPanel.Invalidate(); - if (m_pWnd) - m_pWnd->Invalidate(); - return; + mir_snwprintf(szFinalStatusBarText, TranslateT("%s on %s%s"), m_wszMyNickname, mi->ptszModDispName, mi->tszIdleMsg); + } + else { + if (m_si->ptszStatusbarText) + mir_snwprintf(szFinalStatusBarText, L"%s %s", mi->ptszModDispName, m_si->ptszStatusbarText); + else + wcsncpy_s(szFinalStatusBarText, mi->ptszModDispName, _TRUNCATE); } + SendMessage(m_pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)szFinalStatusBarText); + tabUpdateStatusBar(); + m_pPanel.Invalidate(); + if (m_pWnd) + m_pWnd->Invalidate(); } void CChatRoomDlg::UpdateTitle() |