コード例 #1
0
ファイル: RosterWidget.cs プロジェクト: goto/synapse
        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);
            }
        }
コード例 #2
0
ファイル: ChatWindow.cs プロジェクト: goto/synapse
        internal ChatWindow(IChatHandler handler)
        {
            if (handler == null)
                throw new ArgumentNullException("handler");
            m_Handler = handler;

            SetupUi();

            if (handler is MucHandler) {
                m_ParticipantsMenu = new QMenu(this);
                QObject.Connect(m_ParticipantsMenu, Qt.SIGNAL("aboutToShow()"), HandleMenuAboutToShow);
                QObject.Connect(m_ParticipantsMenu, Qt.SIGNAL("aboutToHide()"), HandleMenuAboutToHide);

                var mucHandler = (MucHandler)handler;
                participantsGrid.Model = mucHandler.GridModel;
                participantsGrid.ContextMenuPolicy = Qt.ContextMenuPolicy.CustomContextMenu;
                participantsGrid.ItemActivated += HandleItemActivated;

                var group = new QActionGroup(this);

                var gridModeAction = new QAction("View as Grid", this);
                QObject.Connect(gridModeAction, Qt.SIGNAL("triggered()"), HandleGridModeActionTriggered);
                gridModeAction.SetActionGroup(group);
                gridModeAction.Checkable = true;
                gridModeAction.Checked = true;
                m_ParticipantsMenu.AddAction(gridModeAction);

                var listModeAction = new QAction("View as List", this);
                QObject.Connect(listModeAction, Qt.SIGNAL("triggered()"), HandleListModeActionTriggered);
                listModeAction.SetActionGroup(group);
                listModeAction.Checkable = true;
                m_ParticipantsMenu.AddAction(listModeAction);

                var separatorAction = new QAction(participantsGrid);
                separatorAction.SetSeparator(true);
                m_ParticipantsMenu.AddAction(separatorAction);

                var sliderAction = new AvatarGridZoomAction<jabber.connection.RoomParticipant>(participantsGrid);
                m_ParticipantsMenu.AddAction(sliderAction);

                m_ParticipantItemMenu = new QMenu(this);
                QObject.Connect(m_ParticipantItemMenu, Qt.SIGNAL("aboutToShow()"), HandleMenuAboutToShow);
                QObject.Connect(m_ParticipantItemMenu, Qt.SIGNAL("aboutToHide()"), HandleMenuAboutToHide);

                var mucViewProfileAction = new QAction("View Profile", this);
                QObject.Connect(mucViewProfileAction, Qt.SIGNAL("triggered()"), HandleMucViewProfileActionTriggered);
                m_ParticipantItemMenu.AddAction(mucViewProfileAction);

                var mucPrivateMessageAction = new QAction("IM", this);
                QObject.Connect(mucPrivateMessageAction, Qt.SIGNAL("triggered()"), HandleMucPrivateMessageTriggered);
                m_ParticipantItemMenu.AddAction(mucPrivateMessageAction);

                var mucSendFileAction = new QAction("Send File...", this);
                QObject.Connect(mucSendFileAction, Qt.SIGNAL("triggered()"), HandleMucSendFileActionTriggered);
                m_ParticipantItemMenu.AddAction(mucSendFileAction);

                var mucViewHistoryAction = new QAction("View History", this);
                QObject.Connect(mucViewHistoryAction, Qt.SIGNAL("triggered()"), HandleMucViewHistoryActionTriggered);
                m_ParticipantItemMenu.AddAction(mucViewHistoryAction);

                m_ModeratorActionsMenu = new QMenu("Moderator Actions", this);

                var roomRoleActionGroup = new QActionGroup(this);
                QObject.Connect(roomRoleActionGroup, Qt.SIGNAL("triggered(QAction*)"), this, Qt.SLOT("HandleRoomRoleActionGroupTriggered(QAction*)"));

                m_ModeratorAction = new QAction("Moderator", this);
                roomRoleActionGroup.AddAction(m_ModeratorAction);
                m_ModeratorAction.Checkable = true;
                m_ModeratorActionsMenu.AddAction(m_ModeratorAction);

                m_ParticipantAction = new QAction("Participant", this);
                roomRoleActionGroup.AddAction(m_ParticipantAction);
                m_ParticipantAction.Checkable = true;
                m_ModeratorActionsMenu.AddAction(m_ParticipantAction);

                m_VisitorAction = new QAction("Visitor", this);
                roomRoleActionGroup.AddAction(m_VisitorAction);
                m_VisitorAction.Checkable = true;
                m_ModeratorActionsMenu.AddAction(m_VisitorAction);

                m_ModeratorActionsMenu.AddSeparator();

                var mucKickAction = new QAction("Kick...", this);
                QObject.Connect(mucKickAction, Qt.SIGNAL("triggered()"), HandleMucKickActionTriggered);
                m_ModeratorActionsMenu.AddAction(mucKickAction);

                var mucBanAction = new QAction("Ban...", this);
                QObject.Connect(mucBanAction, Qt.SIGNAL("triggered()"), HandleMucBanActionTriggered);
                m_ModeratorActionsMenu.AddAction(mucBanAction);

                m_ModeratorActionsMenu.AddSeparator();

                m_ChangeAffiliationAction = new QAction("Change Affiliation...", this);
                QObject.Connect(m_ChangeAffiliationAction, Qt.SIGNAL("triggered()"), HandleChangeAffiliationTriggered);
                m_ModeratorActionsMenu.AddAction(m_ChangeAffiliationAction);

                m_ParticipantItemMenu.AddSeparator();
                m_ParticipantItemMenu.AddMenu(m_ModeratorActionsMenu);

                m_ParticipantItemMenu.AddSeparator();

                m_AddAsFriendAction = new QAction("Add as Friend", this);
                m_ParticipantItemMenu.AddAction(m_AddAsFriendAction);

                this.WindowTitle = mucHandler.Room.JID.User; // FIXME: Show only "user" in tab, show full room jid in title?
                this.WindowIcon = Gui.LoadIcon("internet-group-chat");
            } else {
                var chatHandler = (ChatHandler)handler;
                rightContainer.Hide();

                if (((ChatHandler)handler).IsMucMessage) {
                    this.WindowTitle = chatHandler.Jid.Resource;
                } else {
                    this.WindowTitle = chatHandler.Account.GetDisplayName(chatHandler.Jid);
                }
                this.WindowIcon = new QIcon((QPixmap)Synapse.Xmpp.AvatarManager.GetAvatar(chatHandler.Jid));
            }

            m_ConversationWidget.ChatHandler = handler;

            handler.ReadyChanged += HandleReadyChanged;

            splitter.SetStretchFactor(1, 0);
            splitter_2.SetStretchFactor(1, 0);

            KeyPressEater eater = new KeyPressEater(this);
            eater.KeyEvent += HandleKeyEvent;
            textEdit.InstallEventFilter(eater);

            QToolBar toolbar = new QToolBar(this);
            toolbar.IconSize = new QSize(16, 16);

            var formatMenuButton = new QToolButton(this);

            var formatMenu = new QMenu(this);
            QObject.Connect<QAction>(formatMenu, Qt.SIGNAL("triggered(QAction*)"), HandleFormatMenuActionTriggered);
            formatMenuButton.ToolButtonStyle = ToolButtonStyle.ToolButtonTextBesideIcon;
            formatMenuButton.Text = "Format";
            formatMenuButton.icon = Gui.LoadIcon("fonts", 16);
            formatMenuButton.PopupMode = QToolButton.ToolButtonPopupMode.InstantPopup;
            formatMenuButton.SetMenu(formatMenu);
            toolbar.AddWidget(formatMenuButton);

            m_BoldAction = new QAction(Gui.LoadIcon("format-text-bold", 16), "Bold", this);
            m_BoldAction.Shortcut = "Ctrl+B";
            m_BoldAction.Checkable = true;
            formatMenu.AddAction(m_BoldAction);

            m_ItalicAction = new QAction(Gui.LoadIcon("format-text-italic", 16), "Italic", this);
            m_ItalicAction.Shortcut = "Ctrl+I";
            m_ItalicAction.Checkable = true;
            formatMenu.AddAction(m_ItalicAction);

            m_UnderlineAction = new QAction(Gui.LoadIcon("format-text-underline", 16), "Underline", this);
            m_UnderlineAction.Shortcut = "Ctrl+U";
            m_UnderlineAction.Checkable = true;
            formatMenu.AddAction(m_UnderlineAction);

            m_StrikethroughAction = new QAction(Gui.LoadIcon("format-text-strikethrough", 16), "Strikethrough", this);
            m_StrikethroughAction.Shortcut = "Ctrl+S";
            m_StrikethroughAction.Checkable = true;
            formatMenu.AddAction(m_StrikethroughAction);

            formatMenu.AddSeparator();

            m_ClearFormattingAction = new QAction(Gui.LoadIcon("edit-clear", 16), "Clear Formatting", this);
            formatMenu.AddAction(m_ClearFormattingAction);

            var insertMenu = new QMenu(this);
            var insertMenuButton = new QToolButton(this);
            insertMenuButton.ToolButtonStyle = ToolButtonStyle.ToolButtonTextBesideIcon;
            insertMenuButton.Text = "Insert";
            insertMenuButton.icon = Gui.LoadIcon("image", 16);
            insertMenuButton.PopupMode = QToolButton.ToolButtonPopupMode.InstantPopup;
            insertMenuButton.SetMenu(insertMenu);
            toolbar.AddWidget(insertMenuButton);

            m_InsertPhotoAction = new QAction(Gui.LoadIcon("insert-image", 16), "Photo...", this);
            QObject.Connect(m_InsertPhotoAction, Qt.SIGNAL("triggered()"), HandleInsertImageActionTriggered);
            insertMenu.AddAction(m_InsertPhotoAction);

            m_InsertLinkAction = new QAction(Gui.LoadIcon("insert-link", 16), "Link...", this);
            QObject.Connect(m_InsertLinkAction, Qt.SIGNAL("triggered()"), HandleInsertLinkActionTriggered);
            insertMenu.AddAction(m_InsertLinkAction);

            foreach (IActionCodon node in AddinManager.GetExtensionNodes("/Synapse/QtClient/ChatWindow/InsertActions")) {
                insertMenu.AddAction((QAction)node.CreateInstance(this));
            }

            toolbar.AddSeparator();

            var activitiesMenu = new QMenu(this);
            var activitiesMenuButton = new QToolButton(this);
            activitiesMenuButton.ToolButtonStyle = ToolButtonStyle.ToolButtonTextBesideIcon;
            activitiesMenuButton.Text = "Activities";
            activitiesMenuButton.icon = Gui.LoadIcon("applications-games", 16); // FIXME: Not a good icon.
            activitiesMenuButton.PopupMode = QToolButton.ToolButtonPopupMode.InstantPopup;
            activitiesMenuButton.SetMenu(activitiesMenu);
            toolbar.AddWidget(activitiesMenuButton);

            m_InviteToMucAction = new QAction(Gui.LoadIcon("internet-group-chat", 16), "Invite to Conference...", this);
            QObject.Connect(m_InviteToMucAction, Qt.SIGNAL("triggered()"), HandleInviteToMucActionTriggered);
            activitiesMenu.AddAction(m_InviteToMucAction);
            activitiesMenu.AddSeparator();

            activitiesMenu.AddAction(Gui.LoadIcon("applications-graphics", 16), "Launch Whiteboard...");
            activitiesMenu.AddAction(Gui.LoadIcon("desktop", 16), "Share Desktop...");

            var spacerWidget = new QWidget(toolbar);
            spacerWidget.SetSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed);
            toolbar.AddWidget(spacerWidget);

            var toContainer = new QWidget(toolbar);
            var layout = new QHBoxLayout(toContainer);
            layout.SetContentsMargins(0, 0, 4, 0);

            m_ToComboBox = new QComboBox(toContainer);

            layout.AddWidget(new QLabel("To:", toContainer));
            layout.AddWidget(m_ToComboBox);

            QAction toWidgetAction = (QWidgetAction)toolbar.AddWidget(toContainer);

            m_ToComboBox.AddItem("Automatic", "auto");
            m_ToComboBox.InsertSeparator(1);

            ((QVBoxLayout)bottomContainer.Layout()).InsertWidget(0, toolbar);

            if (handler is ChatHandler) {
                var chatHandler = (ChatHandler)handler;
                handler.Account.Client.OnPresence += delegate(object sender, Presence pres) {
                    if (pres.From.Bare != chatHandler.Jid.Bare || pres.Priority == "-1") {
                        return;
                    }
                    QApplication.Invoke(delegate {
                        if (!String.IsNullOrEmpty(pres.From.Resource)) {
                            if (pres.Type == PresenceType.available) {
                                string text = String.Format("{0} ({1})", Helper.GetResourceDisplay(pres), Helper.GetPresenceDisplay(pres));
                                int i = m_ToComboBox.FindData(pres.From.Resource);
                                if (i == -1) {
                                    m_ToComboBox.AddItem(text, pres.From.Resource);
                                } else {
                                    m_ToComboBox.SetItemText(i, text);
                                }
                            } else if (pres.Type == PresenceType.unavailable) {
                                int i = m_ToComboBox.FindData(pres.From.Resource);
                                if (i > -1) {
                                    m_ToComboBox.RemoveItem(i);
                                    m_ToComboBox.CurrentIndex = 0;
                                }
                            }
                        }

                        if (chatHandler.IsMucMessage) {
                            toWidgetAction.Visible = false;
                        } else {
                            string title = null;
                            if (handler.Account.PresenceManager[pres.From.BareJID] == null) {
                                title = String.Format("{0} (Offline)", chatHandler.Account.GetDisplayName(chatHandler.Jid));
                            } else {
                                title = chatHandler.Account.GetDisplayName(chatHandler.Jid);
                            }
                            Gui.TabbedChatsWindow.SetTabTitle(this, title);
                        }
                    });
                };

                foreach (var presence in chatHandler.Account.PresenceManager.GetAll(chatHandler.Jid)) {
                    if (presence.Priority != "-1" && !String.IsNullOrEmpty(presence.From.Resource)) {
                        string text = String.Format("{0} ({1})", Helper.GetResourceDisplay(presence), Helper.GetPresenceDisplay(presence));
                        m_ToComboBox.AddItem(text, presence.From.Resource);
                    }
                }

                // FIXME: Make this a menu with "View Profile" and "View History".
                var viewProfileAction = new QAction(Gui.LoadIcon("info", 16), "View Profile", this);
                QObject.Connect(viewProfileAction, Qt.SIGNAL("triggered()"), HandleViewProfileActionTriggered);
                toolbar.AddAction(viewProfileAction);
            } else {
                toWidgetAction.Visible = false;
            }

            QObject.Connect<bool>(m_ConversationWidget.Page(), Qt.SIGNAL("loadFinished(bool)"), delegate (bool ok) {
                if (!ok) {
                    throw new Exception("Failed to load chat html.");
                }
                handler.NewContent += HandleNewContent;
                m_Handler.FireQueued();
            });

            var settings = ServiceManager.Get<SettingsService>();
            m_ConversationWidget.ShowHeader = settings.Get<bool>("MessageShowHeader");
            m_ConversationWidget.ShowUserIcons = settings.Get<bool>("MessageShowAvatars");
            m_ConversationWidget.LoadTheme(settings.Get<string>("MessageTheme"), settings.Get<string>("MessageThemeVariant"));
        }
コード例 #3
0
		/// <summary>
		/// Update graphic objects with language file values
		/// </summary>
		private void UpdateGraphicObjects()
		{
			// Main Window Title
			this.WindowTitle = MainClass.AppNameVer + " [" + GlobalObj.AppNameVer + "]";
			
			// Update menu and toolbar 
			mainwindow_Ui.menu_File.Title = GlobalObj.LMan.GetString("filemenulbl").Replace("_", "&");
			mainwindow_Ui.action_Open.Text = GlobalObj.LMan.GetString("openmenulbl").Replace("_", "&");
			mainwindow_Ui.action_Open.IconText = GlobalObj.LMan.GetString("openlbl");
			
			mainwindow_Ui.action_Close.Text = GlobalObj.LMan.GetString("closemenulbl").Replace("_", "&");
			mainwindow_Ui.action_Close.IconText = GlobalObj.LMan.GetString("closelbl");
			
			mainwindow_Ui.action_SerialSettings.Text = GlobalObj.LMan.GetString("settingsmenulbl");
			mainwindow_Ui.action_SerialSettings.IconText = GlobalObj.LMan.GetString("settingslbl");
			
			mainwindow_Ui.action_Exit.Text = GlobalObj.LMan.GetString("exitmenulbl").Replace("_", "&");
			mainwindow_Ui.action_Exit.IconText = GlobalObj.LMan.GetString("exitlbl");
			
			mainwindow_Ui.menu_Reader.Title = GlobalObj.LMan.GetString("readermenulbl").Replace("_", "&");
			mainwindow_Ui.menu_About.Title = GlobalObj.LMan.GetString("helpmenulbl").Replace("_", "&");
			mainwindow_Ui.action_Info.Text = GlobalObj.LMan.GetString("infomenulbl").Replace("_", "&");
			mainwindow_Ui.action_Info.IconText = GlobalObj.LMan.GetString("infolbl");
			
			mainwindow_Ui.action_ATR.IconText = GlobalObj.LMan.GetString("atrlbl");
			
			mainwindow_Ui.FrameATR.Title = GlobalObj.LMan.GetString("atrframelbl");
			mainwindow_Ui.FrameFile.Title = GlobalObj.LMan.GetString("commandfilelbl");
			mainwindow_Ui.FrameExchange.Title = GlobalObj.LMan.GetString("cardframelbl");
			
			mainwindow_Ui.LblCommand.Text = GlobalObj.LMan.GetString("cmdlbl");
			mainwindow_Ui.LblResponse.Text = GlobalObj.LMan.GetString("resplbl");
			mainwindow_Ui.BtnSend.Text = GlobalObj.LMan.GetString("sendlbl");
			
			
			// Update font for command list
			if (GlobalObj.IsWindows())
			{
				mainwindow_Ui.LstCommands.Font = new QFont("Courier New", 10);
			}
			else
			{
				mainwindow_Ui.LstCommands.Font = new QFont("Fixed", 10);				
			}
			
			
			// loop for each managed readers type
			foreach(IReader rdr in GlobalObj.ReaderManager.Values)
			{
				allReaders.AddRange(rdr.Readers);
			}
			
			// Update readers list on gui			
			QAction action_Reader;
			QActionGroup readersGrp = new QActionGroup(this);
			
			for (int r=0; r<allReaders.Count; r++)
			{
				action_Reader = new QAction(allReaders[r], mainwindow_Ui.menu_Reader);
				action_Reader.ObjectName = "action_Reader_" + r.ToString();
				action_Reader.SetVisible(true);
				action_Reader.IconVisibleInMenu = false;
				action_Reader.Checkable = true;
				action_Reader.SetActionGroup(readersGrp);
				
				if (r==0)
				{
					action_Reader.SetChecked(true);
				}
				else
				{
					action_Reader.SetChecked(false);
				}
				mainwindow_Ui.menu_Reader.AddAction(action_Reader);
				
				Connect( action_Reader, SIGNAL("activated()"), this, SLOT("ActionChangeReader()"));
				
			}
			
			// check for available readers
			if (allReaders.Count > 0)
			{
				// select first reader
				GlobalObj.SelectedReader = allReaders[0];
			}


			// LANGUAGE STATUS TIP
			// mainwindow_Ui.action_Open.StatusTip = "";  // status bar desc
				
			// LANGUAGE TOOL TIP
			// mainwindow_Ui.action_Open.ToolTip = ""; // tool tip text
			
		}
コード例 #4
0
		/// <summary>
		/// Update graphic objects with language file values
		/// </summary>
		private void UpdateGraphicObjects()
		{
			// Main Window Title
			this.WindowTitle = MainClass.AppNameVer + " [" + GlobalObj.AppNameVer + "]";
			
			// Set tool tip text for toolbutton
			mainwindow_Ui.MenuFileItem.Title = GlobalObjUI.LMan.GetString("filemenulbl").Replace("_", "&");
			mainwindow_Ui.MenuFileNew.ToolTip = GlobalObjUI.LMan.GetString("newfileact").Replace("_", "");
			mainwindow_Ui.MenuFileNew.Text = GlobalObjUI.LMan.GetString("newfileact").Replace("_", "&");
			mainwindow_Ui.MenuFileOpen.ToolTip = GlobalObjUI.LMan.GetString("openfileact").Replace("_", "");
			mainwindow_Ui.MenuFileOpen.Text = GlobalObjUI.LMan.GetString("openfileact").Replace("_", "&");
			mainwindow_Ui.MenuFileSaveFile.ToolTip = GlobalObjUI.LMan.GetString("savefileact").Replace("_", "");
			mainwindow_Ui.MenuFileSaveFile.Text = GlobalObjUI.LMan.GetString("savefileact").Replace("_", "&");
			mainwindow_Ui.MenuFileSaveSim.ToolTip = GlobalObjUI.LMan.GetString("savefilesimact").Replace("_", "");
			mainwindow_Ui.MenuFileSaveSim.Text = GlobalObjUI.LMan.GetString("savefilesimact").Replace("_", "&");
			mainwindow_Ui.MenuFileClose.ToolTip = GlobalObjUI.LMan.GetString("closefileact").Replace("_", "");
			mainwindow_Ui.MenuFileClose.Text = GlobalObjUI.LMan.GetString("closefileact").Replace("_", "&");
			mainwindow_Ui.MenuFileSettings.ToolTip = GlobalObjUI.LMan.GetString("settingsact").Replace("_", "");
			mainwindow_Ui.MenuFileSettings.Text = GlobalObjUI.LMan.GetString("settingsact").Replace("_", "&");
			mainwindow_Ui.MenuFileExit.ToolTip = GlobalObjUI.LMan.GetString("exitact").Replace("_", "");
			mainwindow_Ui.MenuFileExit.Text = GlobalObjUI.LMan.GetString("exitact").Replace("_", "&");
			
			mainwindow_Ui.MenuSimItem.Title = GlobalObjUI.LMan.GetString("simmenulbl").Replace("_", "&");
			mainwindow_Ui.MenuSimConnect.ToolTip = GlobalObjUI.LMan.GetString("opensimact").Replace("_", "");
			mainwindow_Ui.MenuSimConnect.Text = GlobalObjUI.LMan.GetString("opensimact").Replace("_", "&");
			mainwindow_Ui.MenuSimPin.ToolTip = GlobalObjUI.LMan.GetString("pinsimact").Replace("_", "");
			mainwindow_Ui.MenuSimPin.Text = GlobalObjUI.LMan.GetString("pinsimact").Replace("_", "&");
			mainwindow_Ui.MenuSimSaveFile.ToolTip = GlobalObjUI.LMan.GetString("savesimfileact").Replace("_", "");
			mainwindow_Ui.MenuSimSaveFile.Text = GlobalObjUI.LMan.GetString("savesimfileact").Replace("_", "&");
			mainwindow_Ui.MenuSimSaveSim.ToolTip = GlobalObjUI.LMan.GetString("savesimact").Replace("_", "");
			mainwindow_Ui.MenuSimSaveSim.Text = GlobalObjUI.LMan.GetString("savesimact").Replace("_", "&");
			mainwindow_Ui.MenuSimDeleteAll.Text = GlobalObjUI.LMan.GetString("deletesimact").Replace("_", "&");
			mainwindow_Ui.MenuSimDisconnect.ToolTip = GlobalObjUI.LMan.GetString("closesimact").Replace("_", "");
			mainwindow_Ui.MenuSimDisconnect.Text = GlobalObjUI.LMan.GetString("closesimact").Replace("_", "&");
			
			mainwindow_Ui.MenuReaderItem.Title = GlobalObjUI.LMan.GetString("readermenulbl").Replace("_", "&");
			
			mainwindow_Ui.MenuAboutItem.Title = GlobalObjUI.LMan.GetString("helpmenulbl").Replace("_", "&");
			mainwindow_Ui.MenuAboutInfo.ToolTip = GlobalObjUI.LMan.GetString("infoact").Replace("_", "");
			mainwindow_Ui.MenuAboutInfo.Text = GlobalObjUI.LMan.GetString("infoact").Replace("_", "&");
			
			// Frame labels
			mainwindow_Ui.FrameFile.Title = GlobalObjUI.LMan.GetString("framefile"); 
			mainwindow_Ui.FrameSim.Title =  GlobalObjUI.LMan.GetString("framesim");
			
			
			// Setup column headers
			List<string> columnHeaders = new List<string>();
			columnHeaders.Add(" ");
			columnHeaders.Add(GlobalObjUI.LMan.GetString("descnumber"));
			columnHeaders.Add(GlobalObjUI.LMan.GetString("phonenumber"));
			
			mainwindow_Ui.LstFileContacts.SetHeaderLabels(columnHeaders);
			mainwindow_Ui.LstFileContacts.SetColumnWidth(1, 150);
			mainwindow_Ui.LstFileContacts.SetColumnWidth(2, 150);
			
			mainwindow_Ui.LstSimContacts.SetHeaderLabels(columnHeaders);
			mainwindow_Ui.LstSimContacts.SetColumnWidth(1, 150);
			mainwindow_Ui.LstSimContacts.SetColumnWidth(2, 150);
			
			mainwindow_Ui.LstFileContacts.HideColumn(0);
			mainwindow_Ui.LstSimContacts.HideColumn(0);
			
			
			// loop for each managed readers type
			foreach(IReader rdr in GlobalObj.ReaderManager.Values)
			{
				allReaders.AddRange(rdr.Readers);
			}
			
			// Update readers list on gui			
			QAction action_Reader;
			QActionGroup readersGrp = new QActionGroup(this);
			
			for (int r=0; r<allReaders.Count; r++)
			{
				action_Reader = new QAction(allReaders[r], mainwindow_Ui.MenuReaderItem);
				action_Reader.ObjectName = "action_Reader_" + r.ToString();
				action_Reader.SetVisible(true);
				action_Reader.IconVisibleInMenu = false;
				action_Reader.Checkable = true;
				action_Reader.SetActionGroup(readersGrp);
				
				if (r==0)
				{
					action_Reader.SetChecked(true);
				}
				else
				{
					action_Reader.SetChecked(false);
				}
				mainwindow_Ui.MenuReaderItem.AddAction(action_Reader);
				
				Connect( action_Reader, SIGNAL("activated()"), this, SLOT("ActionChangeReader()"));
				
			}
			
			// check for available readers
			if (allReaders.Count > 0)
			{
				// select first reader
				GlobalObj.SelectedReader = allReaders[0];
			}
			
			// Add progressbar to statusbar
			PBar = new QProgressBar(mainwindow_Ui.StatusBar);
			PBar.SetFixedWidth(180);
			PBar.SetFixedHeight(20);
			PBar.SetVisible(false);
			mainwindow_Ui.StatusBar.AddPermanentWidget(PBar);

			CreateFileMenu();
			CreateSimMenu();
		}