예제 #1
0
    } // SetupUi

    public void RetranslateUi(QDialog SettingsDialog)
    {
        SettingsDialog.WindowTitle = QApplication.Translate("SettingsDialog", "Dialog", null, QApplication.Encoding.UnicodeUTF8);
        FrameSettings.Title        = QApplication.Translate("SettingsDialog", "GroupBox", null, QApplication.Encoding.UnicodeUTF8);
        LblPortSpeedReset.Text     = QApplication.Translate("SettingsDialog", "Reset Baud", null, QApplication.Encoding.UnicodeUTF8);
        CmbPortSpeedReset.Clear();
        CmbPortSpeedReset.AddItem(QApplication.Translate("SettingsDialog", "110", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeedReset.AddItem(QApplication.Translate("SettingsDialog", "300", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeedReset.AddItem(QApplication.Translate("SettingsDialog", "600", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeedReset.AddItem(QApplication.Translate("SettingsDialog", "1200", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeedReset.AddItem(QApplication.Translate("SettingsDialog", "2400", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeedReset.AddItem(QApplication.Translate("SettingsDialog", "4800", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeedReset.AddItem(QApplication.Translate("SettingsDialog", "9600", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeedReset.AddItem(QApplication.Translate("SettingsDialog", "14400", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeedReset.AddItem(QApplication.Translate("SettingsDialog", "19200", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeedReset.AddItem(QApplication.Translate("SettingsDialog", "38400", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeedReset.AddItem(QApplication.Translate("SettingsDialog", "56000", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeedReset.AddItem(QApplication.Translate("SettingsDialog", "57600", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeedReset.AddItem(QApplication.Translate("SettingsDialog", "115200", null, QApplication.Encoding.UnicodeUTF8));
        LblPortSpeed.Text = QApplication.Translate("SettingsDialog", "Data Baud", null, QApplication.Encoding.UnicodeUTF8);
        CmbPortSpeed.Clear();
        CmbPortSpeed.AddItem(QApplication.Translate("SettingsDialog", "110", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeed.AddItem(QApplication.Translate("SettingsDialog", "300", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeed.AddItem(QApplication.Translate("SettingsDialog", "600", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeed.AddItem(QApplication.Translate("SettingsDialog", "1200", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeed.AddItem(QApplication.Translate("SettingsDialog", "2400", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeed.AddItem(QApplication.Translate("SettingsDialog", "4800", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeed.AddItem(QApplication.Translate("SettingsDialog", "9600", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeed.AddItem(QApplication.Translate("SettingsDialog", "14400", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeed.AddItem(QApplication.Translate("SettingsDialog", "19200", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeed.AddItem(QApplication.Translate("SettingsDialog", "38400", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeed.AddItem(QApplication.Translate("SettingsDialog", "56000", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeed.AddItem(QApplication.Translate("SettingsDialog", "57600", null, QApplication.Encoding.UnicodeUTF8));
        CmbPortSpeed.AddItem(QApplication.Translate("SettingsDialog", "115200", null, QApplication.Encoding.UnicodeUTF8));
        LblDataBits.Text = QApplication.Translate("SettingsDialog", "Data bits", null, QApplication.Encoding.UnicodeUTF8);
        CmbDataBits.Clear();
        CmbDataBits.AddItem(QApplication.Translate("SettingsDialog", "7", null, QApplication.Encoding.UnicodeUTF8));
        CmbDataBits.AddItem(QApplication.Translate("SettingsDialog", "8", null, QApplication.Encoding.UnicodeUTF8));
        LblStopBits.Text = QApplication.Translate("SettingsDialog", "Stop bits", null, QApplication.Encoding.UnicodeUTF8);
        CmbStopBits.Clear();
        CmbStopBits.AddItem(QApplication.Translate("SettingsDialog", "1", null, QApplication.Encoding.UnicodeUTF8));
        CmbStopBits.AddItem(QApplication.Translate("SettingsDialog", "1.5", null, QApplication.Encoding.UnicodeUTF8));
        CmbStopBits.AddItem(QApplication.Translate("SettingsDialog", "2", null, QApplication.Encoding.UnicodeUTF8));
        LblParity.Text = QApplication.Translate("SettingsDialog", "Parity", null, QApplication.Encoding.UnicodeUTF8);
        CmbParity.Clear();
        CmbParity.AddItem(QApplication.Translate("SettingsDialog", "Odd", null, QApplication.Encoding.UnicodeUTF8));
        CmbParity.AddItem(QApplication.Translate("SettingsDialog", "Even", null, QApplication.Encoding.UnicodeUTF8));
        CmbParity.AddItem(QApplication.Translate("SettingsDialog", "None", null, QApplication.Encoding.UnicodeUTF8));
        LblConvention.Text = QApplication.Translate("SettingsDialog", "Convention", null, QApplication.Encoding.UnicodeUTF8);
        CmbConvention.Clear();
        CmbConvention.AddItem(QApplication.Translate("SettingsDialog", "Direct", null, QApplication.Encoding.UnicodeUTF8));
        CmbConvention.AddItem(QApplication.Translate("SettingsDialog", "Inverse", null, QApplication.Encoding.UnicodeUTF8));
    } // RetranslateUi
예제 #2
0
        private QGroupBox InitQComboBox()
        {
            var         groupBox = new QGroupBox("QComboBox", this);
            QVBoxLayout vBox     = new QVBoxLayout();
            QComboBox   comboBox = new QComboBox(this);
            QLabel      label    = new QLabel("Silence is a source of great strength.", this);

            comboBox.AddItem("Silence is a source of great strength.");
            comboBox.AddItem("From caring comes courage.");
            comboBox.AddItem("Mastering yourself is true power.");
            comboBox.AddItem("To the mind that is still, the whole universe surrenders.");
            comboBox.AddItem("Be the chief but never the lord.");
            comboBox.AddItem("He who is contented is rich.");
            comboBox.AddItem("He who knows himself is enlightened.");

            comboBox.ActivatedText += (string obj) => {
                label.Text = obj;
            };

            vBox.AddWidget(comboBox);
            vBox.AddWidget(label);

            groupBox.Layout = vBox;
            return(groupBox);
        }
예제 #3
0
        //public ComboBoxDemo()
        //{
        //	WindowTitle = "ComboBox Demo";

        //	InitUI();

        //	Resize(250, 200);
        //	Move(100, 100);
        //	Show();
        //}

        public override void InitUI()
        {
            var layout = new QVBoxLayout(this);

            label = new QLabel("Selected");
            label.AdjustSize();

            layout.AddWidget(label);

            var combo = new QComboBox(this);

            combo.AddItem("Ubuntu");
            combo.AddItem("Arch");
            combo.AddItem("Fedora");
            combo.AddItem("Red Hat");
            combo.AddItem("Gentoo");

            layout.AddWidget(combo);

            combo.ActivatedText += OnActivated;
        }
예제 #4
0
        internal ChatWindow(IChatHandler handler)
        {
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }
            m_Handler = handler;

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

            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;

                participantsGrid.ListMode = settingsService.Get <bool>("MucListMode");
                if (settingsService.Has("MucIconSize"))
                {
                    participantsGrid.IconSize = settingsService.Get <int>("MucIconSize");
                }

                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;
                listModeAction.Checked   = participantsGrid.ListMode;
                m_ParticipantsMenu.AddAction(listModeAction);

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

                var sliderAction = new AvatarGridZoomAction <jabber.connection.RoomParticipant>(participantsGrid);
                sliderAction.ValueChanged += delegate(int value) {
                    participantsGrid.IconSize = value;
                    settingsService.Set("MucIconSize", value);
                };
                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);

            if (settingsService.Has("MucSplitterState"))
            {
                byte[] state = settingsService.Get <byte[]>("MucSplitterState");
                splitter_2.RestoreState(QByteArrayConverter.FromArray(state));
            }

            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("preferences-desktop-font",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-x-generic",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("user-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"));
        }
예제 #5
0
        private QGroupBox InitQComboBox()
        {
            var groupBox = new QGroupBox ("QComboBox", this);
            QVBoxLayout vBox = new QVBoxLayout ();
            QComboBox comboBox = new QComboBox (this);
            QLabel label = new QLabel ("Silence is a source of great strength.", this);

            comboBox.AddItem ("Silence is a source of great strength.");
            comboBox.AddItem ("From caring comes courage.");
            comboBox.AddItem ("Mastering yourself is true power.");
            comboBox.AddItem ("To the mind that is still, the whole universe surrenders.");
            comboBox.AddItem ("Be the chief but never the lord.");
            comboBox.AddItem ("He who is contented is rich.");
            comboBox.AddItem ("He who knows himself is enlightened.");

            comboBox.ActivatedText += (string obj) => {
                label.Text = obj;
            };

            vBox.AddWidget (comboBox);
            vBox.AddWidget (label);

            groupBox.Layout = vBox;
            return groupBox;
        }
예제 #6
0
        private void InitUI()
        {
            QLabel labelCode = new QLabel("Code",this);
            QLabel labelName = new QLabel("Name", this);
            QLabel labelUnit = new QLabel("Price", this);
            QLabel labelPrice = new QLabel("Unit Price", this);

            labelErrorCode = new QLabel("", this);
            labelErrorCode.ObjectName = "errorCode";

            labelErrorName = new QLabel("", this);
            labelErrorName.ObjectName = "errorName";

            labelErrorUnit = new QLabel("", this);
            labelErrorUnit.ObjectName = "errorUnit";

            labelErrorPrice = new QLabel("", this);
            labelErrorPrice.ObjectName = "errorPrice";

            StyleSheet = @"QLabel#errorCode{color:#ff0000}
                QLabel#errorName{color:#ff0000}
                QLabel#errorUnit{color:#ff0000}
                QLabel#errorPrice{color:#ff0000}
            ";

            txtCode = new QLineEdit(this);
            txtName = new QLineEdit(this);
            cmbUnit = new QComboBox(this);
            txtPrice = new QLineEdit(this);

            txtCode.TextEdited += OnTextCodeEdited;
            txtName.TextEdited += OnTextNameEdited;
            txtPrice.TextEdited += OnTextPriceEdited;

            txtCode.FocusOutEvent += OnTextCodeFocusOut;
            txtName.FocusOutEvent += OnTextNameFocusOut;
            txtPrice.FocusOutEvent += OnTextPriceFocusOut;

            QPushButton btnSave = new QPushButton("Save", this);
            QPushButton btnReset = new QPushButton("Reset", this);

            btnSave.Clicked += OnBtnSaveClicked;
            btnReset.Clicked += OnBtnResetClicked;

            //Layouts
            QVBoxLayout topVLayout = new QVBoxLayout(this);
            QHBoxLayout topHLayout = new QHBoxLayout();

            QFormLayout formLayout = new QFormLayout();

            QVBoxLayout vBoxCode = new QVBoxLayout();
            QVBoxLayout vBoxName = new QVBoxLayout();
            QVBoxLayout vBoxUnit = new QVBoxLayout();
            QVBoxLayout vBoxPrice = new QVBoxLayout();

            QHBoxLayout btnHLayout = new QHBoxLayout();

            QGroupBox groupBox = new QGroupBox("Product",this);
            groupBox.MinimumWidth = 250;

            QVBoxLayout grpBoxVLayout = new QVBoxLayout();

            vBoxCode.AddWidget(txtCode);
            vBoxCode.AddWidget(labelErrorCode);

            vBoxName.AddWidget(txtName);
            vBoxName.AddWidget(labelErrorName);

            vBoxUnit.AddWidget(cmbUnit);
            vBoxUnit.AddWidget(labelErrorUnit);

            vBoxPrice.AddWidget(txtPrice);
            vBoxPrice.AddWidget(labelErrorPrice);

            formLayout.HorizontalSpacing = 5;
            formLayout.VerticalSpacing = 10;
            formLayout.AddRow(labelCode, vBoxCode);
            formLayout.AddRow(labelName, vBoxName);
            formLayout.AddRow(labelUnit, vBoxUnit);
            formLayout.AddRow(labelPrice, vBoxPrice);

            btnHLayout.AddStretch(1);
            btnHLayout.AddWidget(btnSave);
            btnHLayout.AddWidget(btnReset);

            grpBoxVLayout.AddItem(formLayout);
            grpBoxVLayout.AddItem(btnHLayout);

            cmbUnit.AddItem("Litre", "L");
            cmbUnit.AddItem("Kilogram","K");
            cmbUnit.AddItem("Gram", "G");
            cmbUnit.AddItem("Packet", "P");

            groupBox.Layout = grpBoxVLayout;

            topHLayout.AddStretch(1);
            topHLayout.AddWidget(groupBox);
            topHLayout.AddStretch(1);

            topVLayout.AddStretch(1);
            topVLayout.AddItem(topHLayout);
            topVLayout.AddStretch(1);
        }