Esempio n. 1
0
        void HandleFormatMenuActionTriggered(QAction action)
        {
            var cursor = textEdit.TextCursor();

            QTextCharFormat fmt = new QTextCharFormat();

            if (action == m_ClearFormattingAction)
            {
                cursor.SetCharFormat(fmt);
                textEdit.SetCurrentCharFormat(fmt);
                return;
            }

            if (action == m_BoldAction)
            {
                fmt.SetFontWeight(action.Checked ? (int)QFont.Weight.Bold : (int)QFont.Weight.Normal);
            }
            else if (action == m_ItalicAction)
            {
                fmt.SetFontItalic(action.Checked);
            }
            else if (action == m_UnderlineAction)
            {
                fmt.SetFontUnderline(action.Checked);
            }
            else if (action == m_StrikethroughAction)
            {
                fmt.SetFontStrikeOut(action.Checked);
            }

            cursor.MergeCharFormat(fmt);
            textEdit.MergeCurrentCharFormat(fmt);
        }
Esempio n. 2
0
        void on_textEdit_currentCharFormatChanged(QTextCharFormat format)
        {
            var font = format.Font();

            m_BoldAction.Checked          = font.Bold();
            m_ItalicAction.Checked        = font.Italic();
            m_UnderlineAction.Checked     = font.Underline();
            m_StrikethroughAction.Checked = font.StrikeOut();
        }