When sending invites, filter the roster window

This commit is contained in:
Jaidyn Ann 2021-06-19 00:11:02 -05:00
parent fdeb533d6e
commit 3d8942af60
2 changed files with 26 additions and 5 deletions

View File

@ -149,9 +149,11 @@ MainWindow::MessageReceived(BMessage* message)
invite->AddInt32("im_what", IM_ROOM_SEND_INVITE); invite->AddInt32("im_what", IM_ROOM_SEND_INVITE);
invite->AddString("chat_id", chat_id); invite->AddString("chat_id", chat_id);
BLooper* looper = (BLooper*)fConversation->GetProtocolLooper(); ProtocolLooper* plooper = fConversation->GetProtocolLooper();
BLooper* looper = (BLooper*)plooper;
fRosterWindow = new RosterWindow("Invite contact to chat" fRosterWindow = new RosterWindow("Invite contact to chat"
B_UTF8_ELLIPSIS, invite, new BMessenger(looper), fServer); B_UTF8_ELLIPSIS, invite, new BMessenger(looper), fServer,
plooper->GetInstance());
fRosterWindow->Show(); fRosterWindow->Show();
break; break;

View File

@ -45,9 +45,28 @@ RosterWindow::RosterWindow(const char* title, BMessage* selectMsg,
fRosterView->SetInvocationMessage(new BMessage(kSendMessage)); fRosterView->SetInvocationMessage(new BMessage(kSendMessage));
fOkButton = new BButton("OK", new BMessage(kSendMessage)); fOkButton = new BButton("OK", new BMessage(kSendMessage));
fAccountField = new BMenuField("accountMenuField", NULL,
CreateAccountMenu(fAccounts, BMessage(kSelAccount), BMenu* accountMenu;
new BMessage(kSelNoAccount)));
// If a specific instance is given, disallow selecting other accounts
if (instance > -1) {
accountMenu = new BMenu("accountMenu");
BString name = "N/A";
for (int i = 0; i < fAccounts.CountItems(); i++)
if (fAccounts.ValueAt(i) == instance) {
name = fAccounts.KeyAt(i);
break;
}
accountMenu->AddItem(new BMenuItem(name.String(), NULL));
accountMenu->SetLabelFromMarked(true);
accountMenu->ItemAt(0)->SetMarked(true);
accountMenu->SetEnabled(false);
}
else
accountMenu = CreateAccountMenu(fAccounts, BMessage(kSelAccount),
new BMessage(kSelNoAccount));
fAccountField = new BMenuField("accountMenuField", NULL, accountMenu);
BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f) BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f)
.SetInsets(B_USE_DEFAULT_SPACING) .SetInsets(B_USE_DEFAULT_SPACING)