MGR: If not connected to client, disable snooze menu items in task bar icon menu

This commit is contained in:
Charlie Fenton 2015-04-07 22:48:59 -07:00
parent 03f398844b
commit c64adb6e30
1 changed files with 6 additions and 18 deletions

View File

@ -569,6 +569,7 @@ void CTaskBarIcon::AdjustMenuItems(wxMenu* pMenu) {
wxFont font = wxNullFont; wxFont font = wxNullFont;
size_t loc = 0; size_t loc = 0;
bool is_dialog_detected = false; bool is_dialog_detected = false;
bool enableSnoozeItems = false;
wxASSERT(pDoc); wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument)); wxASSERT(wxDynamicCast(pDoc, CMainDocument));
@ -583,6 +584,8 @@ void CTaskBarIcon::AdjustMenuItems(wxMenu* pMenu) {
if (wxGetApp().IsModalDialogDisplayed()) { if (wxGetApp().IsModalDialogDisplayed()) {
is_dialog_detected = true; is_dialog_detected = true;
} }
enableSnoozeItems = (!is_dialog_detected) && pDoc->IsConnected();
for (loc = 0; loc < pMenu->GetMenuItemCount(); loc++) { for (loc = 0; loc < pMenu->GetMenuItemCount(); loc++) {
pMenuItem = pMenu->FindItemByPosition(loc); pMenuItem = pMenu->FindItemByPosition(loc);
@ -625,25 +628,18 @@ void CTaskBarIcon::AdjustMenuItems(wxMenu* pMenu) {
case RUN_MODE_NEVER: case RUN_MODE_NEVER:
m_SnoozeMenuItem->SetItemLabel(_("Resume")); m_SnoozeMenuItem->SetItemLabel(_("Resume"));
m_SnoozeMenuItem->Check(false); m_SnoozeMenuItem->Check(false);
if (!is_dialog_detected) { m_SnoozeMenuItem->Enable(enableSnoozeItems);
m_SnoozeMenuItem->Enable(true);
}
break; break;
default: default:
m_SnoozeMenuItem->SetItemLabel(_("Snooze")); m_SnoozeMenuItem->SetItemLabel(_("Snooze"));
m_SnoozeMenuItem->Check(true); m_SnoozeMenuItem->Check(true);
if (!is_dialog_detected) {
m_SnoozeMenuItem->Enable(true);
}
} }
break; break;
default: default:
m_SnoozeMenuItem->SetItemLabel(_("Snooze")); m_SnoozeMenuItem->SetItemLabel(_("Snooze"));
m_SnoozeMenuItem->Check(false); m_SnoozeMenuItem->Check(false);
if (!is_dialog_detected) {
m_SnoozeMenuItem->Enable(true);
}
} }
m_SnoozeMenuItem->Enable(enableSnoozeItems);
if (pDoc->state.have_gpu()) { if (pDoc->state.have_gpu()) {
switch (status.gpu_mode) { switch (status.gpu_mode) {
@ -652,30 +648,22 @@ void CTaskBarIcon::AdjustMenuItems(wxMenu* pMenu) {
case RUN_MODE_NEVER: case RUN_MODE_NEVER:
m_SnoozeGPUMenuItem->SetItemLabel(_("Resume GPU")); m_SnoozeGPUMenuItem->SetItemLabel(_("Resume GPU"));
m_SnoozeGPUMenuItem->Check(false); m_SnoozeGPUMenuItem->Check(false);
if (!is_dialog_detected) {
m_SnoozeGPUMenuItem->Enable(true);
}
break; break;
default: default:
m_SnoozeGPUMenuItem->SetItemLabel(_("Snooze GPU")); m_SnoozeGPUMenuItem->SetItemLabel(_("Snooze GPU"));
m_SnoozeGPUMenuItem->Check(true); m_SnoozeGPUMenuItem->Check(true);
if (!is_dialog_detected) {
m_SnoozeGPUMenuItem->Enable(true);
}
} }
break; break;
default: default:
m_SnoozeGPUMenuItem->SetItemLabel(_("Snooze GPU")); m_SnoozeGPUMenuItem->SetItemLabel(_("Snooze GPU"));
m_SnoozeGPUMenuItem->Check(false); m_SnoozeGPUMenuItem->Check(false);
if (!is_dialog_detected) {
m_SnoozeGPUMenuItem->Enable(true);
}
break; break;
} }
if (status.task_mode == RUN_MODE_NEVER) { if (status.task_mode == RUN_MODE_NEVER) {
m_SnoozeGPUMenuItem->Check(false); m_SnoozeGPUMenuItem->Check(false);
m_SnoozeGPUMenuItem->Enable(false); m_SnoozeGPUMenuItem->Enable(false);
} }
m_SnoozeGPUMenuItem->Enable(enableSnoozeItems);
} }
} }