public static Account ShowAccountSelectMenu(QWidget attachWidget) { AccountService accountService = ServiceManager.Get<AccountService>(); if (accountService.ConnectedAccounts.Count == 0) { var widget = (attachWidget != null) ? attachWidget.TopLevelWidget() : Gui.MainWindow; QMessageBox.Critical(widget, "Synapse", "You are not connected."); return null; } Account selectedAccount = null; if (accountService.ConnectedAccounts.Count > 1) { QMenu menu = new QMenu(); menu.AddAction("Select Account:").SetDisabled(true); foreach (Account account in accountService.ConnectedAccounts) { QAction action = menu.AddAction(account.Jid.ToString()); if (menu.ActiveAction() == null) menu.SetActiveAction(action); } var pos = (attachWidget != null) ? attachWidget.MapToGlobal(new QPoint(0, attachWidget.Height())) : QCursor.Pos(); QAction selectedAction = menu.Exec(pos); if (selectedAction != null) { selectedAccount = accountService.GetAccount(new jabber.JID(selectedAction.Text)); } } else { selectedAccount = accountService.ConnectedAccounts[0]; } return selectedAccount; }
public AvatarProviderTab(IAvatarProvider provider, QWidget parent) : base(parent) { m_Provider = provider; QObject.Connect(base.Page().MainFrame(), Qt.SIGNAL("javaScriptWindowObjectCleared()"), delegate { base.Page().MainFrame().AddToJavaScriptWindowObject("AvatarSelectDialog", parent.TopLevelWidget()); }); base.SetHtml(String.Empty); }