Serial Studio 1.1.6
A dashboard software for your embedded projects
Widgets::Terminal Class Reference

#include <Terminal.h>

Inheritance diagram for Widgets::Terminal:
Inheritance graph
Collaboration diagram for Widgets::Terminal:
Collaboration graph

Public Slots

void copy ()
 
void clear ()
 
void selectAll ()
 
void clearSelection ()
 
void setReadOnly (const bool ro)
 
void setFont (const QFont &font)
 
void append (const QString &text)
 
void setText (const QString &text)
 
void insertText (const QString &text)
 
void setWordWrapMode (const int mode)
 
void setAutoscroll (const bool enabled)
 
void setScrollbarWidth (const int width)
 
void setPalette (const QPalette &palette)
 
void setWidgetEnabled (const bool enabled)
 
void setCenterOnScroll (const bool enabled)
 
void setVt100Emulation (const bool enabled)
 
void setUndoRedoEnabled (const bool enabled)
 
void setPlaceholderText (const QString &text)
 
void scrollToBottom (const bool repaint=false)
 
void setMaximumBlockCount (const int maxBlockCount)
 
- Public Slots inherited from UI::DeclarativeWidget
void resizeWidget ()
 
void setWidget (QWidget *widget)
 

Signals

void textChanged ()
 
void fontChanged ()
 
void readOnlyChanged ()
 
void autoscrollChanged ()
 
void colorPaletteChanged ()
 
void wordWrapModeChanged ()
 
void copyAvailableChanged ()
 
void widgetEnabledChanged ()
 
void scrollbarWidthChanged ()
 
void centerOnScrollChanged ()
 
void vt100EmulationChanged ()
 
void placeholderTextChanged ()
 
void undoRedoEnabledChanged ()
 
void maximumBlockCountChanged ()
 
- Signals inherited from UI::DeclarativeWidget
void widgetChanged ()
 

Public Member Functions

 Terminal (QQuickItem *parent=0)
 
QFont font () const
 
QString text () const
 
bool empty () const
 
bool readOnly () const
 
bool autoscroll () const
 
QPalette palette () const
 
int wordWrapMode () const
 
int scrollbarWidth () const
 
bool copyAvailable () const
 
bool widgetEnabled () const
 
bool centerOnScroll () const
 
bool vt100emulation () const
 
bool undoRedoEnabled () const
 
int maximumBlockCount () const
 
QString placeholderText () const
 
QTextDocument * document () const
 
- Public Member Functions inherited from UI::DeclarativeWidget
 DeclarativeWidget (QQuickItem *parent=0)
 
QWidget * widget ()
 
void update (const QRect &rect=QRect())
 
virtual void paint (QPainter *painter) override
 
virtual void keyPressEvent (QKeyEvent *event) override
 
virtual void keyReleaseEvent (QKeyEvent *event) override
 
virtual void inputMethodEvent (QInputMethodEvent *event) override
 
virtual void focusInEvent (QFocusEvent *event) override
 
virtual void focusOutEvent (QFocusEvent *event) override
 
virtual void mousePressEvent (QMouseEvent *event) override
 
virtual void mouseMoveEvent (QMouseEvent *event) override
 
virtual void mouseReleaseEvent (QMouseEvent *event) override
 
virtual void mouseDoubleClickEvent (QMouseEvent *event) override
 
virtual void wheelEvent (QWheelEvent *event) override
 
virtual void dragEnterEvent (QDragEnterEvent *event) override
 
virtual void dragMoveEvent (QDragMoveEvent *event) override
 
virtual void dragLeaveEvent (QDragLeaveEvent *event) override
 
virtual void dropEvent (QDropEvent *event) override
 

Properties

QFont font
 
QString text
 
bool autoscroll
 
QString placeholderText
 
bool undoRedoEnabled
 
int wordWrapMode
 
bool readOnly
 
bool centerOnScroll
 
bool widgetEnabled
 
QPalette palette
 
int maximumBlockCount
 
bool copyAvailable
 
bool empty
 
int scrollbarWidth
 
bool vt100emulation
 
- Properties inherited from UI::DeclarativeWidget
QWidget * widget
 

Private Slots

void repaint ()
 
void updateScrollbarVisibility ()
 
void setCopyAvailable (const bool yes)
 
void addText (const QString &text, const bool enableVt100)
 

Private Member Functions

QString vt100Processing (const QString &data)
 
void requestRepaint (const bool textChanged=false)
 

Private Attributes

bool m_repaint
 
bool m_autoscroll
 
bool m_textChanged
 
bool m_emulateVt100
 
bool m_copyAvailable
 
QPlainTextEdit m_textEdit
 
AnsiEscapeCodeHandler m_escapeCodeHandler
 

Constructor & Destructor Documentation

◆ Terminal()

Widgets::Terminal::Terminal ( QQuickItem *  parent = 0)

Constructor function

Member Function Documentation

◆ addText

void Widgets::Terminal::addText ( const QString &  text,
const bool  enableVt100 
)
privateslot

Inserts the given text directly, no additional line breaks added.

◆ append

void Widgets::Terminal::append ( const QString &  text)
slot

Appends a new paragraph with text to the end of the text edit.

If autoscroll() is enabled, this function shall also update the scrollbar position to scroll to the bottom of the text.

◆ autoscroll()

bool Widgets::Terminal::autoscroll ( ) const

Returns true if the widget shall scroll automatically to the bottom when new text is appended to the widget.

◆ autoscrollChanged

void Widgets::Terminal::autoscrollChanged ( )
signal

◆ centerOnScroll()

bool Widgets::Terminal::centerOnScroll ( ) const

If set to true, the plain text edit scrolls the document vertically to make the cursor visible at the center of the viewport. This also allows the text edit to scroll below the end of the document. Otherwise, if set to false, the plain text edit scrolls the smallest amount possible to ensure the cursor is visible.

◆ centerOnScrollChanged

void Widgets::Terminal::centerOnScrollChanged ( )
signal

◆ clear

void Widgets::Terminal::clear ( )
slot

Deletes all the text in the text edit.

◆ clearSelection

void Widgets::Terminal::clearSelection ( )
slot

Clears the text selection

◆ colorPaletteChanged

void Widgets::Terminal::colorPaletteChanged ( )
signal

◆ copy

void Widgets::Terminal::copy ( )
slot

Copies any selected text to the clipboard.

◆ copyAvailable()

bool Widgets::Terminal::copyAvailable ( ) const

Returns true if the user is able to copy any text from the document. This value is updated through the copyAvailable() signal sent by the QPlainTextEdit.

◆ copyAvailableChanged

void Widgets::Terminal::copyAvailableChanged ( )
signal

◆ document()

QTextDocument * Widgets::Terminal::document ( ) const

Returns the pointer to the text document

◆ empty()

bool Widgets::Terminal::empty ( ) const

Returns true if the text document is empty

◆ font()

QFont Widgets::Terminal::font ( ) const

Returns the font used by the QPlainTextEdit widget

◆ fontChanged

void Widgets::Terminal::fontChanged ( )
signal

◆ insertText

void Widgets::Terminal::insertText ( const QString &  text)
slot

Inserts the given text directly, no additional line breaks added.

◆ maximumBlockCount()

int Widgets::Terminal::maximumBlockCount ( ) const

This property holds the limit for blocks in the document.

Specifies the maximum number of blocks the document may have. If there are more blocks in the document that specified with this property blocks are removed from the beginning of the document.

A negative or zero value specifies that the document may contain an unlimited amount of blocks.

◆ maximumBlockCountChanged

void Widgets::Terminal::maximumBlockCountChanged ( )
signal

◆ palette()

QPalette Widgets::Terminal::palette ( ) const

Returns the palette used by the QPlainTextEdit widget

◆ placeholderText()

QString Widgets::Terminal::placeholderText ( ) const

This property holds the editor placeholder text.

Setting this property makes the editor display a grayed-out placeholder text as long as the document is empty.

◆ placeholderTextChanged

void Widgets::Terminal::placeholderTextChanged ( )
signal

◆ readOnly()

bool Widgets::Terminal::readOnly ( ) const

Returns true if the widget is set to read-only

◆ readOnlyChanged

void Widgets::Terminal::readOnlyChanged ( )
signal

◆ repaint

void Widgets::Terminal::repaint ( )
privateslot

Redraws the widget. This function is called by a timer to reduce the number of paint requests (and thus avoid considerable slow-downs).

◆ requestRepaint()

void Widgets::Terminal::requestRepaint ( const bool  textChanged = false)
private

Enables the re-paint flag, which is later used by the repaint() function to know if the widget shall be repainted.

◆ scrollbarWidth()

int Widgets::Terminal::scrollbarWidth ( ) const

Returns the width of the vertical scrollbar

◆ scrollbarWidthChanged

void Widgets::Terminal::scrollbarWidthChanged ( )
signal

◆ scrollToBottom

void Widgets::Terminal::scrollToBottom ( const bool  repaint = false)
slot

Moves the position of the vertical scrollbar to the end of the document.

◆ selectAll

void Widgets::Terminal::selectAll ( )
slot

Selects all the text of the text edit.

◆ setAutoscroll

void Widgets::Terminal::setAutoscroll ( const bool  enabled)
slot

Enables/disable automatic scrolling. If automatic scrolling is enabled, then the vertical scrollbar shall automatically scroll to the end of the document when the text of the text editor is changed.

◆ setCenterOnScroll

void Widgets::Terminal::setCenterOnScroll ( const bool  enabled)
slot

If set to true, the plain text edit scrolls the document vertically to make the cursor visible at the center of the viewport. This also allows the text edit to scroll below the end of the document. Otherwise, if set to false, the plain text edit scrolls the smallest amount possible to ensure the cursor is visible.

◆ setCopyAvailable

void Widgets::Terminal::setCopyAvailable ( const bool  yes)
privateslot

Updates the value of copy-available. This function is automatically called by the text editor widget when the user makes any text selection/deselection.

◆ setFont

void Widgets::Terminal::setFont ( const QFont &  font)
slot

Changes the font used to display the text of the text edit.

◆ setMaximumBlockCount

void Widgets::Terminal::setMaximumBlockCount ( const int  maxBlockCount)
slot

Specifies the maximum number of blocks the document may have. If there are more blocks in the document that specified with this property blocks are removed from the beginning of the document.

A negative or zero value specifies that the document may contain an unlimited amount of blocks.

◆ setPalette

void Widgets::Terminal::setPalette ( const QPalette &  palette)
slot

Changes the QPalette of the text editor widget and its children.

◆ setPlaceholderText

void Widgets::Terminal::setPlaceholderText ( const QString &  text)
slot

Changes the placeholder text of the text editor. The placeholder text is only displayed when the document is empty.

◆ setReadOnly

void Widgets::Terminal::setReadOnly ( const bool  ro)
slot

Changes the read-only state of the text edit.

In a read-only text edit the user can only navigate through the text and select text; modifying the text is not possible.

◆ setScrollbarWidth

void Widgets::Terminal::setScrollbarWidth ( const int  width)
slot

Changes the width of the vertical scrollbar

◆ setText

void Widgets::Terminal::setText ( const QString &  text)
slot

Replaces the text of the text editor with text.

If autoscroll() is enabled, this function shall also update the scrollbar position to scroll to the bottom of the text.

◆ setUndoRedoEnabled

void Widgets::Terminal::setUndoRedoEnabled ( const bool  enabled)
slot

Enables/disables undo/redo history support.

◆ setVt100Emulation

void Widgets::Terminal::setVt100Emulation ( const bool  enabled)
slot

Enables/disables interpretation of VT-100 escape secuences. This can be useful when interfacing through network ports or interfacing with a MCU that implements some kind of shell.

◆ setWidgetEnabled

void Widgets::Terminal::setWidgetEnabled ( const bool  enabled)
slot

Enables or disables the text editor widget.

◆ setWordWrapMode

void Widgets::Terminal::setWordWrapMode ( const int  mode)
slot

Changes the word wrap mode of the text editor.

This property holds the mode QPlainTextEdit will use when wrapping text by words.

◆ text()

QString Widgets::Terminal::text ( ) const

Returns the plain text of the QPlainTextEdit widget

◆ textChanged

void Widgets::Terminal::textChanged ( )
signal

◆ undoRedoEnabled()

bool Widgets::Terminal::undoRedoEnabled ( ) const

This property holds whether undo and redo are enabled. Users are only able to undo or redo actions if this property is true, and if there is an action that can be undone (or redone).

◆ undoRedoEnabledChanged

void Widgets::Terminal::undoRedoEnabledChanged ( )
signal

◆ updateScrollbarVisibility

void Widgets::Terminal::updateScrollbarVisibility ( )
privateslot

Hides or shows the scrollbar

◆ vt100emulation()

bool Widgets::Terminal::vt100emulation ( ) const

Returns true if the control shall parse basic VT-100 escape secuences. This can be useful if you need to interface with a shell/CLI from Serial Studio.

◆ vt100EmulationChanged

void Widgets::Terminal::vt100EmulationChanged ( )
signal

◆ vt100Processing()

QString Widgets::Terminal::vt100Processing ( const QString &  data)
private

Processes the given data to remove the escape sequences from the text using code from Qt Creator output terminal. Check the next code block for more info.

◆ widgetEnabled()

bool Widgets::Terminal::widgetEnabled ( ) const

Returns true if the QPlainTextEdit widget is enabled

◆ widgetEnabledChanged

void Widgets::Terminal::widgetEnabledChanged ( )
signal

◆ wordWrapMode()

int Widgets::Terminal::wordWrapMode ( ) const

Returns the wrap mode of the QPlainTextEdit casted to an integer type (so that it can be used from the QML interface).

◆ wordWrapModeChanged

void Widgets::Terminal::wordWrapModeChanged ( )
signal

Member Data Documentation

◆ m_autoscroll

bool Widgets::Terminal::m_autoscroll
private

◆ m_copyAvailable

bool Widgets::Terminal::m_copyAvailable
private

◆ m_emulateVt100

bool Widgets::Terminal::m_emulateVt100
private

◆ m_escapeCodeHandler

AnsiEscapeCodeHandler Widgets::Terminal::m_escapeCodeHandler
private

◆ m_repaint

bool Widgets::Terminal::m_repaint
private

◆ m_textChanged

bool Widgets::Terminal::m_textChanged
private

◆ m_textEdit

QPlainTextEdit Widgets::Terminal::m_textEdit
private

Property Documentation

◆ autoscroll

bool Widgets::Terminal::autoscroll
readwrite

◆ centerOnScroll

bool Widgets::Terminal::centerOnScroll
readwrite

◆ copyAvailable

bool Widgets::Terminal::copyAvailable
read

◆ empty

bool Widgets::Terminal::empty
read

◆ font

QFont Widgets::Terminal::font
readwrite

◆ maximumBlockCount

int Widgets::Terminal::maximumBlockCount
readwrite

◆ palette

QPalette Widgets::Terminal::palette
readwrite

◆ placeholderText

QString Widgets::Terminal::placeholderText
readwrite

◆ readOnly

bool Widgets::Terminal::readOnly
readwrite

◆ scrollbarWidth

int Widgets::Terminal::scrollbarWidth
readwrite

◆ text

QString Widgets::Terminal::text
readwrite

◆ undoRedoEnabled

bool Widgets::Terminal::undoRedoEnabled
readwrite

◆ vt100emulation

bool Widgets::Terminal::vt100emulation
readwrite

◆ widgetEnabled

bool Widgets::Terminal::widgetEnabled
readwrite

◆ wordWrapMode

int Widgets::Terminal::wordWrapMode
readwrite

The documentation for this class was generated from the following files: