Disable 'Roster' and 'Window' menus as appropriate
This commit is contained in:
parent
0abdd9e0f9
commit
c339587b06
|
@ -391,6 +391,7 @@ MainWindow::RemoveConversation(Conversation* chat)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fListView->SelectConversation(index);
|
fListView->SelectConversation(index);
|
||||||
|
_ToggleMenuItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -488,16 +489,27 @@ void
|
||||||
MainWindow::_ToggleMenuItems()
|
MainWindow::_ToggleMenuItems()
|
||||||
{
|
{
|
||||||
BMenuItem* chatMenuItem = fMenuBar->FindItem(B_TRANSLATE("Chat"));
|
BMenuItem* chatMenuItem = fMenuBar->FindItem(B_TRANSLATE("Chat"));
|
||||||
|
BMenuItem* rosterMenuItem = fMenuBar->FindItem(B_TRANSLATE("Roster"));
|
||||||
BMenu* chatMenu = chatMenuItem->Submenu();
|
BMenu* chatMenu = chatMenuItem->Submenu();
|
||||||
if (chatMenuItem == NULL || chatMenu == NULL)
|
BMenu* rosterMenu = rosterMenuItem->Submenu();
|
||||||
|
|
||||||
|
if (chatMenu == NULL || rosterMenu == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool enabled = false;
|
bool enabled = (fServer != NULL && fServer->GetAccounts().CountItems() > 0);
|
||||||
if (fServer != NULL && fServer->GetAccounts().CountItems() > 0)
|
|
||||||
enabled = true;
|
|
||||||
|
|
||||||
for (int i = 0; i < chatMenu->CountItems(); i++)
|
for (int i = 0; i < chatMenu->CountItems(); i++)
|
||||||
chatMenu->ItemAt(i)->SetEnabled(enabled);
|
chatMenu->ItemAt(i)->SetEnabled(enabled);
|
||||||
|
|
||||||
|
for (int i = 0; i < rosterMenu->CountItems(); i++)
|
||||||
|
rosterMenu->ItemAt(i)->SetEnabled(enabled);
|
||||||
|
|
||||||
|
BMenuItem* windowMenuItem = fMenuBar->FindItem(B_TRANSLATE("Window"));
|
||||||
|
BMenu* windowMenu = windowMenuItem->Submenu();
|
||||||
|
enabled = (fListView->CountConversations() > 0);
|
||||||
|
|
||||||
|
for (int i = 0; i < windowMenu->CountItems(); i++)
|
||||||
|
windowMenu->ItemAt(i)->SetEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -513,8 +525,10 @@ MainWindow::_EnsureConversationItem(BMessage* msg)
|
||||||
if (chat != NULL) {
|
if (chat != NULL) {
|
||||||
if (fListView->HasItem(item))
|
if (fListView->HasItem(item))
|
||||||
fListView->InvalidateItem(fListView->IndexOf(item));
|
fListView->InvalidateItem(fListView->IndexOf(item));
|
||||||
else if (item != NULL)
|
else if (item != NULL) {
|
||||||
fListView->AddConversation(chat);
|
fListView->AddConversation(chat);
|
||||||
|
_ToggleMenuItems();
|
||||||
|
}
|
||||||
|
|
||||||
if (fListView->CountConversations() == 1)
|
if (fListView->CountConversations() == 1)
|
||||||
fListView->SelectConversation(0);
|
fListView->SelectConversation(0);
|
||||||
|
|
Ŝarĝante…
Reference in New Issue