The TextEditDialog class.
More...
#include <texteditdialog.h>
The TextEditDialog class.
A separate window for editing text. This window can be resized arbitrarily and also provides a toolbar for rich text editing (if rich text is enabled). This dialog can be run from anywhere. Once the dialog has closed (i.e. returned from exec() ), the text entered into it can be retrieved using get_string().
TODO: Add a live signal for updating the calling function.
TextEditDialog::TextEditDialog |
( |
QWidget * |
parent = nullptr , |
|
|
const QString & |
s = nullptr , |
|
|
bool |
rich_text = true |
|
) |
| |
TextEditDialog Constructor.
- Parameters
-
parent | QWidget parent. Usually MainWindow. |
s | The starting string when the dialog opens. It'll be read as rich text HTML or plain text based on the rich_text parameter (which defaults to rich text HTML). It can also be left empty to start blank. |
rich_text | Set the editing mode of the editor. If TRUE, the dialog will interpret the string in s as rich text HTML and also return rich text HTML through get_string(). It'll also show a toolbar with rich text options (i.e. font, italic, underline, size, etc.) If FALSE, the dialog will run in plain text mode interpreting the string in s as plain text and returning plain text through get_string(). It also will not show the rich text editing toolbar. |
void TextEditDialog::accept |
( |
| ) |
|
|
overrideprivatevirtualslot |
const QString & TextEditDialog::get_string |
( |
| ) |
|
Retrieve the current text in the dialog.
This function can be called after the user has accepted the dialog (i.e. made changes and clicked OK). This will return either plain text or rich text (HTML) depending on the mode it's running in (rich/plain text mode is set in the constructor). The value this returns only gets updated when the user clicks OK so it cannot be used to retrieve live text updates from the dialog.
- Returns
The text entered once the user accepted this dialog.
void TextEditDialog::SetAlignmentFromProperty |
( |
| ) |
|
|
privateslot |
Slot for text alignment buttons to set alignment based on their properties.
Intended slot for left_align_button, center_align_button, right_align_button, and justify_align_button. Pulls from their property("a") value which should be a member of the Qt::Alignment enum.
void TextEditDialog::SetFontWeight |
( |
int |
i | ) |
|
|
privateslot |
Slot for the font_weight combobox to set the font weight based on its data value.
- Parameters
-
i | Index of the font_weight to retrieve the desired font weight from |
void TextEditDialog::UpdateUIFromTextCursor |
( |
| ) |
|
|
privateslot |
Slot for when the text edit widget's cursor moves so the rich text toolbar can stay up to date.
In rich text mode, different parts of a text document can be formatted in different ways. As the user moves around the text, the UI buttons should be consistent with whatever text is currently selected. This slot should therefore be connected to QTextEdit::cursorPositionChanged() and will change the "checked" state of the formatting buttons and current index of the comboboxes to match the currently selected text.
QPushButton* TextEditDialog::center_align_button |
|
private |
Button for setting the current text row(s) to center alignment.
A color selector for setting the current text color.
QFontComboBox* TextEditDialog::font_list |
|
private |
ComboBox for the list of font families that the selected text can be set to.
A slider to set the current font size.
QComboBox* TextEditDialog::font_weight |
|
private |
ComboBox for the list of font weights that the selected text can be set to.
QPushButton* TextEditDialog::italic_button |
|
private |
Toggle button for setting the italic state of the currently selected text.
QPushButton* TextEditDialog::justify_align_button |
|
private |
Button for setting the current text row(s) to justified alignment.
QPushButton* TextEditDialog::left_align_button |
|
private |
Button for setting the current text row(s) to left alignment.
QString TextEditDialog::result_str |
|
private |
Internal storage of text entered, saved when the user clicks OK.
bool TextEditDialog::rich_text_ |
|
private |
Internal rich text mode value.
This is set in the constructor and cannot be changed during the lifetime of this dialog.
QPushButton* TextEditDialog::right_align_button |
|
private |
Button for setting the current text row(s) to right alignment.
QTextEdit* TextEditDialog::textEdit |
|
private |
Main text editing widget.
QPushButton* TextEditDialog::underline_button |
|
private |
Toggle button for setting the underlined state of the currently selected text.
The documentation for this class was generated from the following files: