Example #1
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);
            }
        }
Example #2
0
    public void SetupUi(QMainWindow MainWindow)
    {
    if (MainWindow.ObjectName == "")
        MainWindow.ObjectName = "MainWindow";
    QSize Size = new QSize(631, 570);
    Size = Size.ExpandedTo(MainWindow.MinimumSizeHint());
    MainWindow.Size = Size;
    MainWindow.MinimumSize = new QSize(600, 450);
    MainWindow.WindowIcon = new QIcon(":/main/resources/monosim_128.png");
    MenuFileNew = new QAction(MainWindow);
    MenuFileNew.ObjectName = "MenuFileNew";
    MenuFileNew.icon = new QIcon(":/toolbar/resources/qt/document-new.png");
    MenuFileOpen = new QAction(MainWindow);
    MenuFileOpen.ObjectName = "MenuFileOpen";
    MenuFileOpen.icon = new QIcon(":/toolbar/resources/qt/document-open.png");
    MenuFileSaveFile = new QAction(MainWindow);
    MenuFileSaveFile.ObjectName = "MenuFileSaveFile";
    MenuFileSaveFile.Enabled = false;
    MenuFileSaveFile.icon = new QIcon(":/toolbar/resources/qt/document-save.png");
    MenuFileSaveSim = new QAction(MainWindow);
    MenuFileSaveSim.ObjectName = "MenuFileSaveSim";
    MenuFileSaveSim.Enabled = false;
    MenuFileSaveSim.icon = new QIcon(":/main/resources/chip_32.png");
    MenuFileClose = new QAction(MainWindow);
    MenuFileClose.ObjectName = "MenuFileClose";
    MenuFileClose.Enabled = false;
    MenuFileClose.icon = new QIcon(":/toolbar/resources/qt/document-close.png");
    MenuFileSettings = new QAction(MainWindow);
    MenuFileSettings.ObjectName = "MenuFileSettings";
    MenuFileSettings.icon = new QIcon(":/toolbar/resources/qt/configure.png");
    MenuFileExit = new QAction(MainWindow);
    MenuFileExit.ObjectName = "MenuFileExit";
    MenuFileExit.icon = new QIcon(":/toolbar/resources/qt/application-exit.png");
    MenuSimConnect = new QAction(MainWindow);
    MenuSimConnect.ObjectName = "MenuSimConnect";
    MenuSimConnect.icon = new QIcon(":/toolbar/resources/qt/network-connect.png");
    MenuSimPin = new QAction(MainWindow);
    MenuSimPin.ObjectName = "MenuSimPin";
    MenuSimPin.Enabled = false;
    MenuSimPin.icon = new QIcon(":/toolbar/resources/qt/document-encrypt.png");
    MenuSimSaveFile = new QAction(MainWindow);
    MenuSimSaveFile.ObjectName = "MenuSimSaveFile";
    MenuSimSaveFile.Enabled = false;
    MenuSimSaveFile.icon = new QIcon(":/toolbar/resources/qt/document-save.png");
    MenuSimSaveSim = new QAction(MainWindow);
    MenuSimSaveSim.ObjectName = "MenuSimSaveSim";
    MenuSimSaveSim.Enabled = false;
    MenuSimSaveSim.icon = new QIcon(":/main/resources/chip_32.png");
    MenuSimDeleteAll = new QAction(MainWindow);
    MenuSimDeleteAll.ObjectName = "MenuSimDeleteAll";
    MenuSimDeleteAll.Enabled = false;
    MenuSimDeleteAll.icon = new QIcon(":/toolbar/resources/qt/edit-delete.png");
    MenuSimDisconnect = new QAction(MainWindow);
    MenuSimDisconnect.ObjectName = "MenuSimDisconnect";
    MenuSimDisconnect.Enabled = false;
    MenuSimDisconnect.icon = new QIcon(":/toolbar/resources/qt/network-disconnect.png");
    MenuAboutInfo = new QAction(MainWindow);
    MenuAboutInfo.ObjectName = "MenuAboutInfo";
    MenuAboutInfo.icon = new QIcon(":/toolbar/resources/qt/dialog-information.png");
    centralwidget = new QWidget(MainWindow);
    centralwidget.ObjectName = "centralwidget";
    gridLayout = new QGridLayout(centralwidget);
    gridLayout.ObjectName = "gridLayout";
    splitter = new QSplitter(centralwidget);
    splitter.ObjectName = "splitter";
    splitter.Orientation = Qt.Orientation.Vertical;
    splitter.ChildrenCollapsible = false;
    FrameFile = new QGroupBox(splitter);
    FrameFile.ObjectName = "FrameFile";
    FrameFile.MinimumSize = new QSize(0, 100);
    gridLayout1 = new QGridLayout(FrameFile);
    gridLayout1.ObjectName = "gridLayout1";
    LstFileContacts = new QTreeWidget(FrameFile);
    LstFileContacts.ObjectName = "LstFileContacts";
    LstFileContacts.Enabled = false;
    LstFileContacts.EditTriggers = Qyoto.Qyoto.GetCPPEnumValue("QAbstractItemView", "NoEditTriggers");
    LstFileContacts.selectionMode = QAbstractItemView.SelectionMode.ExtendedSelection;
    LstFileContacts.ItemsExpandable = false;
    LstFileContacts.ExpandsOnDoubleClick = false;

    gridLayout1.AddWidget(LstFileContacts, 0, 0, 1, 1);

    splitter.AddWidget(FrameFile);
    FrameSim = new QGroupBox(splitter);
    FrameSim.ObjectName = "FrameSim";
    FrameSim.MinimumSize = new QSize(0, 100);
    gridLayout2 = new QGridLayout(FrameSim);
    gridLayout2.ObjectName = "gridLayout2";
    LstSimContacts = new QTreeWidget(FrameSim);
    LstSimContacts.ObjectName = "LstSimContacts";
    LstSimContacts.Enabled = false;
    LstSimContacts.EditTriggers = Qyoto.Qyoto.GetCPPEnumValue("QAbstractItemView", "NoEditTriggers");
    LstSimContacts.selectionMode = QAbstractItemView.SelectionMode.ExtendedSelection;
    LstSimContacts.ItemsExpandable = false;
    LstSimContacts.ExpandsOnDoubleClick = false;

    gridLayout2.AddWidget(LstSimContacts, 0, 0, 1, 1);

    splitter.AddWidget(FrameSim);

    gridLayout.AddWidget(splitter, 0, 0, 1, 1);

    MainWindow.SetCentralWidget(centralwidget);
    MainMenu = new QMenuBar(MainWindow);
    MainMenu.ObjectName = "MainMenu";
    MainMenu.Geometry = new QRect(0, 0, 631, 24);
    MenuFileItem = new QMenu(MainMenu);
    MenuFileItem.ObjectName = "MenuFileItem";
    MenuReaderItem = new QMenu(MainMenu);
    MenuReaderItem.ObjectName = "MenuReaderItem";
    MenuAboutItem = new QMenu(MainMenu);
    MenuAboutItem.ObjectName = "MenuAboutItem";
    MenuSimItem = new QMenu(MainMenu);
    MenuSimItem.ObjectName = "MenuSimItem";
    MainWindow.SetMenuBar(MainMenu);
    StatusBar = new QStatusBar(MainWindow);
    StatusBar.ObjectName = "StatusBar";
    MainWindow.SetStatusBar(StatusBar);
    TopToolBar = new QToolBar(MainWindow);
    TopToolBar.ObjectName = "TopToolBar";
    TopToolBar.Movable = false;
    TopToolBar.Floatable = false;
    MainWindow.AddToolBar(Qt.ToolBarArea.TopToolBarArea, TopToolBar);

    MainMenu.AddAction(MenuFileItem.MenuAction());
    MainMenu.AddAction(MenuReaderItem.MenuAction());
    MainMenu.AddAction(MenuSimItem.MenuAction());
    MainMenu.AddAction(MenuAboutItem.MenuAction());
    MenuFileItem.AddAction(MenuFileNew);
    MenuFileItem.AddAction(MenuFileOpen);
    MenuFileItem.AddAction(MenuFileSaveFile);
    MenuFileItem.AddAction(MenuFileSaveSim);
    MenuFileItem.AddAction(MenuFileClose);
    MenuFileItem.AddSeparator();
    MenuFileItem.AddAction(MenuFileSettings);
    MenuFileItem.AddSeparator();
    MenuFileItem.AddAction(MenuFileExit);
    MenuAboutItem.AddAction(MenuAboutInfo);
    MenuSimItem.AddAction(MenuSimConnect);
    MenuSimItem.AddAction(MenuSimPin);
    MenuSimItem.AddSeparator();
    MenuSimItem.AddAction(MenuSimSaveFile);
    MenuSimItem.AddAction(MenuSimSaveSim);
    MenuSimItem.AddAction(MenuSimDeleteAll);
    MenuSimItem.AddSeparator();
    MenuSimItem.AddAction(MenuSimDisconnect);
    TopToolBar.AddAction(MenuFileNew);
    TopToolBar.AddAction(MenuFileOpen);
    TopToolBar.AddAction(MenuFileSaveFile);
    TopToolBar.AddAction(MenuFileSaveSim);
    TopToolBar.AddAction(MenuFileClose);
    TopToolBar.AddSeparator();
    TopToolBar.AddAction(MenuFileSettings);
    TopToolBar.AddAction(MenuSimConnect);
    TopToolBar.AddAction(MenuSimPin);
    TopToolBar.AddAction(MenuSimSaveFile);
    TopToolBar.AddAction(MenuSimSaveSim);
    TopToolBar.AddAction(MenuSimDisconnect);
    TopToolBar.AddSeparator();
    TopToolBar.AddAction(MenuAboutInfo);
    TopToolBar.AddAction(MenuFileExit);

    RetranslateUi(MainWindow);

    QMetaObject.ConnectSlotsByName(MainWindow);
    } // SetupUi