Exemplo n.º 1
0
        public ConversationWidget(QWidget parent) : base(parent)
        {
            m_JSWindowObject  = new SynapseJSObject(this);
            this.m_TimeOpened = DateTime.Now;

            this.DateFormat           = "t";
            this.ShowUserIcons        = true;
            this.ShowHeader           = true;
            this.AllowTextBackgrounds = true;
            this.ShowIncomingFont     = true;
            this.ShowIncomingColors   = true;
        }
Exemplo n.º 2
0
        public ConversationWidget(QWidget parent)
            : base(parent)
        {
            m_JSWindowObject = new SynapseJSObject(this);
            this.m_TimeOpened = DateTime.Now;

            this.DateFormat = "t";
            this.ShowUserIcons = true;
            this.ShowHeader = true;
            this.AllowTextBackgrounds = true;
            this.ShowIncomingFont = true;
            this.ShowIncomingColors = true;
        }
Exemplo n.º 3
0
        public RosterWidget(QWidget parent)
            : base(parent)
        {
            SetupUi();

            m_RosterModel = new RosterAvatarGridModel();
            rosterGrid.Model = m_RosterModel;
            rosterGrid.ItemActivated += HandleItemActivated;
            rosterGrid.ShowGroupCounts = true;
            rosterGrid.InstallEventFilter(new KeyPressEater(delegate (QKeyEvent evnt) {
                if (!String.IsNullOrEmpty(evnt.Text())) {
                    rosterSearchButton.Checked = true;
                    friendSearchLineEdit.Text += evnt.Text();
                    friendSearchLineEdit.SetFocus();
                    return true;
                }
                return false;
            }, this));

            var accountService = ServiceManager.Get<AccountService>();
            accountService.AccountAdded += HandleAccountAdded;
            accountService.AccountRemoved += HandleAccountRemoved;
            foreach (Account account in accountService.Accounts) {
                HandleAccountAdded(account);
            }

            m_ActivityFeedItems = new Dictionary<string, IActivityFeedItem>();

            rosterGrid.ContextMenuPolicy = Qt.ContextMenuPolicy.CustomContextMenu;

            m_RosterMenu = new QMenu(this);
            QObject.Connect<QAction>(m_RosterMenu, Qt.SIGNAL("triggered(QAction*)"), HandleRosterMenuTriggered);

            var rosterViewActionGroup = new QActionGroup(this);
            QObject.Connect<QAction>(rosterViewActionGroup, Qt.SIGNAL("triggered(QAction *)"), RosterViewActionGroupTriggered);

            m_GridModeAction = new QAction("View as Grid", this);
            m_GridModeAction.SetActionGroup(rosterViewActionGroup);
            m_GridModeAction.Checkable = true;
            m_GridModeAction.Checked = true;
            m_RosterMenu.AddAction(m_GridModeAction);

            m_ListModeAction = new QAction("View as List", this);
            m_ListModeAction.SetActionGroup(rosterViewActionGroup);
            m_ListModeAction.Checkable = true;
            m_RosterMenu.AddAction(m_ListModeAction);

            m_RosterMenu.AddSeparator();

            m_ShowOfflineAction = new QAction("Show Offline Friends", this);
            m_ShowOfflineAction.Checkable = true;
            m_RosterMenu.AddAction(m_ShowOfflineAction);

            m_ShowTransportsAction = new QAction("Show Transports", this);
            m_ShowTransportsAction.Checkable = true;
            m_RosterMenu.AddAction(m_ShowTransportsAction);

            m_RosterMenu.AddSeparator();

            var sliderAction = new AvatarGridZoomAction<Synapse.UI.RosterItem>(rosterGrid);
            m_RosterMenu.AddAction(sliderAction);

            m_InviteActions = new List<QAction>();

            m_InviteMenu = new QMenu(this);
            m_InviteMenu.MenuAction().Text = "Invite To";
            m_InviteMenu.AddAction("New Conference...");

            m_RosterItemMenu = new QMenu(this);
            QObject.Connect<QAction>(m_RosterItemMenu, Qt.SIGNAL("triggered(QAction*)"), HandleRosterItemMenuTriggered);
            QObject.Connect(m_RosterItemMenu, Qt.SIGNAL("aboutToShow()"), RosterItemMenuAboutToShow);
            QObject.Connect(m_RosterItemMenu, Qt.SIGNAL("aboutToHide()"), RosterItemMenuAboutToHide);

            m_ViewProfileAction = new QAction("View Profile", m_RosterItemMenu);
            m_RosterItemMenu.AddAction(m_ViewProfileAction);

            m_IMAction = new QAction("IM", m_RosterItemMenu);
            m_RosterItemMenu.AddAction(m_IMAction);

            m_RosterItemMenu.AddAction("Send File...");
            m_RosterItemMenu.AddMenu(m_InviteMenu);
            m_RosterItemMenu.AddAction("View History");

            foreach (IActionCodon node in AddinManager.GetExtensionNodes("/Synapse/QtClient/Roster/FriendActions")) {
                m_RosterItemMenu.AddAction((QAction)node.CreateInstance(this));
            }

            m_RosterItemMenu.AddSeparator();

            m_EditGroupsAction = new QAction("Edit Groups", m_RosterItemMenu);
            m_RosterItemMenu.AddAction(m_EditGroupsAction);

            m_RemoveAction = new QAction("Remove", m_RosterItemMenu);
            m_RosterItemMenu.AddAction(m_RemoveAction);

            friendSearchLineEdit.InstallEventFilter(new KeyPressEater(delegate (QKeyEvent evnt) {
                if (evnt.Key() == (int)Key.Key_Escape) {
                    friendSearchLineEdit.Clear();
                    rosterSearchButton.Checked = false;
                    rosterGrid.SetFocus();
                    return true;
                }
                return false;
            }, this));

            //QSizeGrip grip = new QSizeGrip(tabWidget);
            //tabWidget.SetCornerWidget(grip, Qt.Corner.BottomRightCorner);

            0.UpTo(9).ForEach(num => {
                QAction action = new QAction(this);
                action.Shortcut = new QKeySequence("Alt+" + num.ToString());
                QObject.Connect(action, Qt.SIGNAL("triggered(bool)"), delegate {
                    tabWidget.CurrentIndex = num - 1;
                });
                this.AddAction(action);
            });

            var jsWindowObject = new SynapseJSObject(this);
            m_ActivityWebView.Page().linkDelegationPolicy = QWebPage.LinkDelegationPolicy.DelegateAllLinks;
            QObject.Connect<QUrl>(m_ActivityWebView, Qt.SIGNAL("linkClicked(QUrl)"), HandleActivityLinkClicked);
            QObject.Connect<bool>(m_ActivityWebView.Page(), Qt.SIGNAL("loadFinished(bool)"), HandleActivityPageLoadFinished);
            QObject.Connect(m_ActivityWebView.Page().MainFrame(), Qt.SIGNAL("javaScriptWindowObjectCleared()"), delegate {
                m_ActivityWebView.Page().MainFrame().AddToJavaScriptWindowObject("Synapse", jsWindowObject);
            });
            m_ActivityWebView.Page().MainFrame().Load("resource:/feed.html");

            //friendMucListWebView.Page().MainFrame().Load("resource:/friend-muclist.html");

            //quickJoinMucContainer.Hide();
            shoutContainer.Hide();

            QObject.Connect(shoutLineEdit, Qt.SIGNAL("textChanged(const QString &)"), delegate {
                shoutCharsLabel.Text = (140 - shoutLineEdit.Text.Length).ToString();
            });

            QObject.Connect(shoutLineEdit, Qt.SIGNAL("returnPressed()"), delegate {
                SendShout();
            });

            QVBoxLayout layout = new QVBoxLayout(m_AccountsContainer);
            layout.Margin = 0;
            m_AccountsContainer.SetLayout(layout);

            m_MucModel = new BookmarkedMUCsModel();
            mucTree.SetModel(m_MucModel);

            friendSearchContainer.Hide();

            rosterViewButton.icon  = new QIcon(new QPixmap("resource:/view-grid.png"));
            rosterSearchButton.icon = new QIcon(new QPixmap("resource:/simple-search.png"));
            addFriendButton.icon = new QIcon(new QPixmap("resource:/simple-add.png"));
            addMucBookmarkButton.icon = new QIcon(new QPixmap("resource:/simple-add.png"));
            feedFilterButton.icon = new QIcon(new QPixmap("resource:/simple-search.png"));

            m_CollapseIcon = new QIcon(new QPixmap("resource:/collapse.png"));
            m_ExpandIcon = new QIcon(new QPixmap("resource:/expand.png"));
            toggleJoinMucButton.icon = m_CollapseIcon;

            UpdateOnlineCount();

            var shoutService = ServiceManager.Get<ShoutService>();
            shoutService.HandlerAdded += HandleShoutHandlerAdded;
            shoutService.HandlerRemoved += HandleShoutHandlerRemoved;
            if (shoutService.Handlers.Count() > 0) {
                foreach (IShoutHandler handler in shoutService.Handlers) {
                    HandleShoutHandlerAdded(handler);
                }
            } else {
                shoutHandlersBox.Hide();
            }

            m_FeedFilterMenu = new QMenu(this);

            QObject.Connect(m_FeedFilterMenu, Qt.SIGNAL("triggered(QAction*)"), delegate (QAction action) {
                string js = Util.CreateJavascriptCall("ActivityFeed.setCategoryVisibility", action.Text.ToLower().Replace(" ", "-"), action.Checked);
                m_ActivityWebView.Page().MainFrame().EvaluateJavaScript(js);
            });

            var feedService = ServiceManager.Get<ActivityFeedService>();
            feedService.NewItem += delegate (IActivityFeedItem item) {
                lock (m_FeedItemQueue) {
                    if (!m_FeedIsLoaded) {
                        m_FeedItemQueue.Enqueue(item);
                    } else {
                        AddActivityFeedItem(item);
                    }
                }
            };
            feedService.CategoryAdded += delegate (string category) {
                QApplication.Invoke(delegate {
                    HandleCategoryAdded(category);
                });
            };
            foreach (string category in feedService.Categories) {
                HandleCategoryAdded(category);
            }
        }
Exemplo n.º 4
0
        public RosterWidget(QWidget parent) : base(parent)
        {
            SetupUi();

            var settingsService = ServiceManager.Get <SettingsService>();

            m_RosterModel = new RosterAvatarGridModel();
            m_RosterModel.ShowTransports = settingsService.Get <bool>("RosterShowTransports");
            m_RosterModel.ShowOffline    = settingsService.Get <bool>("RosterShowOffline");
            rosterGrid.Model             = m_RosterModel;
            rosterGrid.ItemActivated    += HandleItemActivated;
            rosterGrid.ShowGroupCounts   = true;
            rosterGrid.InstallEventFilter(new KeyPressEater(delegate(QKeyEvent evnt) {
                if (!String.IsNullOrEmpty(evnt.Text()))
                {
                    rosterSearchButton.Checked = true;
                    friendSearchLineEdit.Text += evnt.Text();
                    friendSearchLineEdit.SetFocus();
                    return(true);
                }
                return(false);
            }, this));

            if (settingsService.Has("RosterIconSize"))
            {
                rosterGrid.IconSize = settingsService.Get <int>("RosterIconSize");
            }

            var accountService = ServiceManager.Get <AccountService>();

            accountService.AccountAdded   += HandleAccountAdded;
            accountService.AccountRemoved += HandleAccountRemoved;
            foreach (Account account in accountService.Accounts)
            {
                HandleAccountAdded(account);
            }

            m_ActivityFeedItems = new Dictionary <string, IActivityFeedItem>();

            rosterGrid.ContextMenuPolicy = Qt.ContextMenuPolicy.CustomContextMenu;

            m_RosterMenu = new QMenu(this);
            QObject.Connect <QAction>(m_RosterMenu, Qt.SIGNAL("triggered(QAction*)"), HandleRosterMenuTriggered);

            var rosterViewActionGroup = new QActionGroup(this);

            QObject.Connect <QAction>(rosterViewActionGroup, Qt.SIGNAL("triggered(QAction *)"), RosterViewActionGroupTriggered);

            m_GridModeAction = new QAction("View as Grid", this);
            m_GridModeAction.SetActionGroup(rosterViewActionGroup);
            m_GridModeAction.Checkable = true;
            m_RosterMenu.AddAction(m_GridModeAction);

            m_ListModeAction = new QAction("View as List", this);
            m_ListModeAction.SetActionGroup(rosterViewActionGroup);
            m_ListModeAction.Checkable = true;
            m_RosterMenu.AddAction(m_ListModeAction);

            if (settingsService.Get <bool>("RosterListMode"))
            {
                rosterGrid.ListMode      = true;
                m_ListModeAction.Checked = true;
            }
            else
            {
                rosterGrid.ListMode      = false;
                m_GridModeAction.Checked = true;
            }

            m_RosterMenu.AddSeparator();

            m_ShowOfflineAction           = new QAction("Show Offline Friends", this);
            m_ShowOfflineAction.Checkable = true;
            m_RosterMenu.AddAction(m_ShowOfflineAction);

            m_ShowTransportsAction           = new QAction("Show Transports", this);
            m_ShowTransportsAction.Checkable = true;
            m_RosterMenu.AddAction(m_ShowTransportsAction);

            m_RosterMenu.AddSeparator();

            var sliderAction = new AvatarGridZoomAction <Synapse.UI.RosterItem>(rosterGrid);

            sliderAction.ValueChanged += delegate(int value) {
                rosterGrid.IconSize = value;
                settingsService.Set("RosterIconSize", value);
            };
            m_RosterMenu.AddAction(sliderAction);

            m_InviteActions = new List <QAction>();

            m_InviteMenu = new QMenu(this);
            m_InviteMenu.MenuAction().Text = "Invite To";
            m_InviteMenu.AddAction("New Conference...");

            m_RosterItemMenu = new QMenu(this);
            QObject.Connect <QAction>(m_RosterItemMenu, Qt.SIGNAL("triggered(QAction*)"), HandleRosterItemMenuTriggered);
            QObject.Connect(m_RosterItemMenu, Qt.SIGNAL("aboutToShow()"), RosterItemMenuAboutToShow);
            QObject.Connect(m_RosterItemMenu, Qt.SIGNAL("aboutToHide()"), RosterItemMenuAboutToHide);

            m_ViewProfileAction = new QAction("View Profile", m_RosterItemMenu);
            m_RosterItemMenu.AddAction(m_ViewProfileAction);

            m_IMAction = new QAction("IM", m_RosterItemMenu);
            m_RosterItemMenu.AddAction(m_IMAction);

            m_RosterItemMenu.AddAction("Send File...");
            m_RosterItemMenu.AddMenu(m_InviteMenu);
            m_RosterItemMenu.AddAction("View History");

            foreach (IActionCodon node in AddinManager.GetExtensionNodes("/Synapse/QtClient/Roster/FriendActions"))
            {
                m_RosterItemMenu.AddAction((QAction)node.CreateInstance(this));
            }

            m_RosterItemMenu.AddSeparator();

            m_EditGroupsAction = new QAction("Edit Groups", m_RosterItemMenu);
            m_RosterItemMenu.AddAction(m_EditGroupsAction);

            m_RemoveAction = new QAction("Remove", m_RosterItemMenu);
            m_RosterItemMenu.AddAction(m_RemoveAction);

            friendSearchLineEdit.InstallEventFilter(new KeyPressEater(delegate(QKeyEvent evnt) {
                if (evnt.Key() == (int)Key.Key_Escape)
                {
                    friendSearchLineEdit.Clear();
                    rosterSearchButton.Checked = false;
                    rosterGrid.SetFocus();
                    return(true);
                }
                return(false);
            }, this));

            //QSizeGrip grip = new QSizeGrip(tabWidget);
            //tabWidget.SetCornerWidget(grip, Qt.Corner.BottomRightCorner);

            0.UpTo(9).ForEach(num => {
                QAction action  = new QAction(this);
                action.Shortcut = new QKeySequence("Alt+" + num.ToString());
                QObject.Connect(action, Qt.SIGNAL("triggered(bool)"), delegate {
                    tabWidget.CurrentIndex = num - 1;
                });
                this.AddAction(action);
            });

            var jsWindowObject = new SynapseJSObject(this);

            m_ActivityWebView.Page().linkDelegationPolicy = QWebPage.LinkDelegationPolicy.DelegateAllLinks;
            QObject.Connect <QUrl>(m_ActivityWebView, Qt.SIGNAL("linkClicked(QUrl)"), HandleActivityLinkClicked);
            QObject.Connect <bool>(m_ActivityWebView.Page(), Qt.SIGNAL("loadFinished(bool)"), HandleActivityPageLoadFinished);
            QObject.Connect(m_ActivityWebView.Page().MainFrame(), Qt.SIGNAL("javaScriptWindowObjectCleared()"), delegate {
                m_ActivityWebView.Page().MainFrame().AddToJavaScriptWindowObject("Synapse", jsWindowObject);
            });
            m_ActivityWebView.Page().MainFrame().Load("resource:/feed.html");

            //friendMucListWebView.Page().MainFrame().Load("resource:/friend-muclist.html");

            //quickJoinMucContainer.Hide();
            shoutContainer.Hide();

            QObject.Connect(shoutLineEdit, Qt.SIGNAL("textChanged(const QString &)"), delegate {
                shoutCharsLabel.Text = (140 - shoutLineEdit.Text.Length).ToString();
            });

            QObject.Connect(shoutLineEdit, Qt.SIGNAL("returnPressed()"), delegate {
                SendShout();
            });

            QVBoxLayout layout = new QVBoxLayout(m_AccountsContainer);

            layout.Margin = 0;
            m_AccountsContainer.SetLayout(layout);

            m_MucModel = new BookmarkedMUCsModel();
            mucTree.SetModel(m_MucModel);

            friendSearchContainer.Hide();

            rosterViewButton.icon     = new QIcon(new QPixmap("resource:/view-grid.png"));
            rosterSearchButton.icon   = new QIcon(new QPixmap("resource:/simple-search.png"));
            addFriendButton.icon      = new QIcon(new QPixmap("resource:/simple-add.png"));
            addMucBookmarkButton.icon = new QIcon(new QPixmap("resource:/simple-add.png"));
            feedFilterButton.icon     = new QIcon(new QPixmap("resource:/simple-search.png"));

            m_CollapseIcon           = new QIcon(new QPixmap("resource:/collapse.png"));
            m_ExpandIcon             = new QIcon(new QPixmap("resource:/expand.png"));
            toggleJoinMucButton.icon = m_CollapseIcon;

            UpdateOnlineCount();

            var shoutService = ServiceManager.Get <ShoutService>();

            shoutService.HandlerAdded   += HandleShoutHandlerAdded;
            shoutService.HandlerRemoved += HandleShoutHandlerRemoved;
            if (shoutService.Handlers.Count() > 0)
            {
                foreach (IShoutHandler handler in shoutService.Handlers)
                {
                    HandleShoutHandlerAdded(handler);
                }
            }
            else
            {
                shoutHandlersBox.Hide();
            }

            m_FeedFilterMenu = new QMenu(this);

            QObject.Connect(m_FeedFilterMenu, Qt.SIGNAL("triggered(QAction*)"), delegate(QAction action) {
                string js = Util.CreateJavascriptCall("ActivityFeed.setCategoryVisibility", action.Text.ToLower().Replace(" ", "-"), action.Checked);
                m_ActivityWebView.Page().MainFrame().EvaluateJavaScript(js);
            });

            var feedService = ServiceManager.Get <ActivityFeedService>();

            feedService.NewItem += delegate(IActivityFeedItem item) {
                lock (m_FeedItemQueue) {
                    if (!m_FeedIsLoaded)
                    {
                        m_FeedItemQueue.Enqueue(item);
                    }
                    else
                    {
                        AddActivityFeedItem(item);
                    }
                }
            };
            feedService.CategoryAdded += delegate(string category) {
                QApplication.Invoke(delegate {
                    HandleCategoryAdded(category);
                });
            };
            foreach (string category in feedService.Categories)
            {
                HandleCategoryAdded(category);
            }
        }