public MainWindow() { SetupUi(); base.WindowFlags = (uint)Qt.WindowType.FramelessWindowHint; closeButton.icon = new QIcon(new QPixmap("resource:/stock-close_12.png")); menuButton.icon = new QIcon(new QPixmap("resource:/menu-icon.png")); // FIXME: Add a global "Application Icon" somewhere that contains multiple sizes. QPixmap pixmap = new QPixmap("resource:/octy-22.png"); base.WindowIcon = new QIcon(pixmap); m_NoAccountsStyleSheet = Util.ReadResource("mainwindow-noaccounts.qss"); m_StyleSheet = Util.ReadResource("mainwindow.qss"); containerWidget.SetStyleSheet(m_StyleSheet); QVBoxLayout layout = new QVBoxLayout(); layout.SetContentsMargins(0, 0, 0, 0); contentWidget.SetLayout(layout); m_RosterWidget = new RosterWidget(contentWidget); contentWidget.Layout().AddWidget(m_RosterWidget); m_NoAccountsWidget = new NoAccountsWidget(contentWidget); contentWidget.Layout().AddWidget(m_NoAccountsWidget); // This makes the shortcut work. base.AddAction(Gui.GlobalActions.QuitAction); m_MainMenu = new QMenu(this); m_MainMenu.AddAction(Gui.GlobalActions.NewMessageAction); m_MainMenu.AddAction(Gui.GlobalActions.JoinConferenceAction); m_MainMenu.AddAction(Gui.GlobalActions.ShowBrowserAction); m_MainMenu.AddAction(Gui.GlobalActions.EditProfileAction); m_MainMenu.AddAction(Gui.GlobalActions.ChangeStatusAction); m_MainMenu.AddSeparator(); m_MainMenu.AddAction(Gui.GlobalActions.ShowPreferencesAction); m_MainMenu.AddSeparator(); m_MainMenu.AddAction(Gui.GlobalActions.AboutAction); m_MainMenu.AddAction(Gui.GlobalActions.SendFeedbackAction); m_MainMenu.AddSeparator(); m_MainMenu.AddAction(Gui.GlobalActions.QuitAction); Gui.CenterWidgetOnScreen(this); headerLabel.InstallEventFilter(new WindowMover(this)); AccountService accountService = ServiceManager.Get<AccountService>(); accountService.AccountAdded += AddAccount; accountService.AccountRemoved += RemoveAccount; foreach (Account account in accountService.Accounts) { AddAccount(account); } }
public AccountStatusWidget(Account account, RosterWidget parent, MainWindow parentWindow) : base(parent) { SetupUi(); m_ParentWindow = parentWindow; m_EditProfileDialog = new EditProfileDialog(account, this.TopLevelWidget()); m_AvatarLabel.Cursor = new QCursor(CursorShape.PointingHandCursor); m_AvatarLabel.Clicked += delegate { if (m_Account.ConnectionState == AccountConnectionState.Connected) { m_EditProfileDialog.Show(2); m_EditProfileDialog.ActivateWindow(); } else { // FIXME: It really wouldn't be so hard to make this work. // On connect, check to see if it was changed and update server. QMessageBox.Warning(this.TopLevelWidget(), "Synapse", "Cannot edit avatar when you're not connected."); } }; m_Account = account; m_Account.ConnectionStateChanged += OnAccountStateChanged; m_Account.StatusChanged += OnAccountStateChanged; m_Account.MyVCardUpdated += HandleMyVCardUpdated; m_Account.AvatarManager.AvatarUpdated += HandleAvatarUpdated; OnAccountStateChanged(account); HandleAvatarUpdated(m_Account.Jid.Bare, null); HandleMyVCardUpdated(null, EventArgs.Empty); m_NameLabel.TextFormat = TextFormat.RichText; HandleAvatarUpdated(m_Account.Jid.Bare, m_Account.GetProperty("AvatarHash")); m_PresenceMenu = new QMenu(this); QObject.Connect(m_PresenceMenu, Qt.SIGNAL("aboutToShow()"), HandlePresenceMenuAboutToShow); QObject.Connect<QAction>(m_PresenceMenu, Qt.SIGNAL("triggered(QAction*)"), HandlePresenceMenuTriggered); QActionGroup group = new QActionGroup(this); group.Exclusive = true; m_AvailableAction = m_PresenceMenu.AddAction("Available"); group.AddAction(m_AvailableAction); m_AvailableAction.Checkable = true; m_FreeToChatAction = m_PresenceMenu.AddAction("Free To Chat"); group.AddAction(m_FreeToChatAction); m_FreeToChatAction.Checkable = true; m_AwayAction = m_PresenceMenu.AddAction("Away"); group.AddAction(m_AwayAction); m_AwayAction.Checkable = true; m_ExtendedAwayAction = m_PresenceMenu.AddAction("Extended Away"); group.AddAction(m_ExtendedAwayAction); m_ExtendedAwayAction.Checkable = true; m_DoNotDisturbAction = m_PresenceMenu.AddAction("Do Not Disturb"); group.AddAction(m_DoNotDisturbAction); m_DoNotDisturbAction.Checkable = true; m_PresenceMenu.AddSeparator(); m_OfflineAction = m_PresenceMenu.AddAction("Offline"); group.AddAction(m_OfflineAction); m_OfflineAction.Checkable = true; }
public AccountStatusWidget(Account account, RosterWidget parent, MainWindow parentWindow) : base(parent) { SetupUi(); m_ParentWindow = parentWindow; m_EditProfileDialog = new EditProfileDialog(account, this.TopLevelWidget()); m_AvatarLabel.Cursor = new QCursor(CursorShape.PointingHandCursor); m_AvatarLabel.Clicked += delegate { if (m_Account.ConnectionState == AccountConnectionState.Connected) { m_EditProfileDialog.Show(2); m_EditProfileDialog.ActivateWindow(); } else { // FIXME: It really wouldn't be so hard to make this work. // On connect, check to see if it was changed and update server. QMessageBox.Warning(this.TopLevelWidget(), "Synapse", "Cannot edit avatar when you're not connected."); } }; m_Account = account; m_Account.ConnectionStateChanged += OnAccountStateChanged; m_Account.StatusChanged += OnAccountStateChanged; m_Account.MyVCardUpdated += HandleMyVCardUpdated; m_Account.AvatarManager.AvatarUpdated += HandleAvatarUpdated; OnAccountStateChanged(account); HandleAvatarUpdated(m_Account.Jid.Bare, null); HandleMyVCardUpdated(null, EventArgs.Empty); m_NameLabel.TextFormat = TextFormat.RichText; HandleAvatarUpdated(m_Account.Jid.Bare, m_Account.GetProperty("AvatarHash")); m_PresenceMenu = new QMenu(this); QObject.Connect(m_PresenceMenu, Qt.SIGNAL("aboutToShow()"), HandlePresenceMenuAboutToShow); QObject.Connect <QAction>(m_PresenceMenu, Qt.SIGNAL("triggered(QAction*)"), HandlePresenceMenuTriggered); QActionGroup group = new QActionGroup(this); group.Exclusive = true; m_AvailableAction = m_PresenceMenu.AddAction("Available"); group.AddAction(m_AvailableAction); m_AvailableAction.Checkable = true; m_FreeToChatAction = m_PresenceMenu.AddAction("Free To Chat"); group.AddAction(m_FreeToChatAction); m_FreeToChatAction.Checkable = true; m_AwayAction = m_PresenceMenu.AddAction("Away"); group.AddAction(m_AwayAction); m_AwayAction.Checkable = true; m_ExtendedAwayAction = m_PresenceMenu.AddAction("Extended Away"); group.AddAction(m_ExtendedAwayAction); m_ExtendedAwayAction.Checkable = true; m_DoNotDisturbAction = m_PresenceMenu.AddAction("Do Not Disturb"); group.AddAction(m_DoNotDisturbAction); m_DoNotDisturbAction.Checkable = true; m_PresenceMenu.AddSeparator(); m_OfflineAction = m_PresenceMenu.AddAction("Offline"); group.AddAction(m_OfflineAction); m_OfflineAction.Checkable = true; }