X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Finputwidget.cpp;fp=src%2Fqtui%2Finputwidget.cpp;h=699867245fd246462cdf7ec36828c5713c3a9633;hp=ad8371669bc8869e212d03bd6ebd3cd287f42bba;hb=de6ee9a2a3389ebf62f181b12632e58d2ffb8879;hpb=d6ac048d75fcc19f5577077d7ae625d41dbbf726 diff --git a/src/qtui/inputwidget.cpp b/src/qtui/inputwidget.cpp index ad837166..69986724 100644 --- a/src/qtui/inputwidget.cpp +++ b/src/qtui/inputwidget.cpp @@ -68,6 +68,7 @@ InputWidget::InputWidget(QWidget* parent) ui.boldButton->setIcon(icon::get("format-text-bold")); ui.italicButton->setIcon(icon::get("format-text-italic")); ui.underlineButton->setIcon(icon::get("format-text-underline")); + ui.strikethroughButton->setIcon(icon::get("format-text-strikethrough")); ui.clearButton->setIcon(icon::get("edit-clear")); ui.encryptionIconLabel->hide(); @@ -374,6 +375,11 @@ void InputWidget::toggleFormatUnderline() setFormatUnderline(!ui.underlineButton->isChecked()); } +void InputWidget::toggleFormatStrikethrough() +{ + setFormatStrikethrough(!ui.strikethroughButton->isChecked()); +} + void InputWidget::clearFormat() { // Clear all formatting for selection (not global) @@ -511,6 +517,7 @@ void InputWidget::setFormatClear(const bool global) QTextCharFormat fmt; fmt.setFontWeight(QFont::Normal); fmt.setFontUnderline(false); + fmt.setFontStrikeOut(false); fmt.setFontItalic(false); fmt.clearForeground(); fmt.clearBackground(); @@ -525,6 +532,7 @@ void InputWidget::setFormatClear(const bool global) ui.boldButton->setChecked(false); ui.italicButton->setChecked(false); ui.underlineButton->setChecked(false); + ui.strikethroughButton->setChecked(false); } void InputWidget::setFormatBold(const bool bold) @@ -557,6 +565,16 @@ void InputWidget::setFormatUnderline(const bool underline) ui.underlineButton->setChecked(underline); } +void InputWidget::setFormatStrikethrough(const bool strike) +{ + // Apply formatting + QTextCharFormat fmt; + fmt.setFontStrikeOut(strike); + mergeFormatOnSelection(fmt); + // Make sure UI state follows + ui.strikethroughButton->setChecked(strike); +} + void InputWidget::mergeFormatOnSelection(const QTextCharFormat& format) { QTextCursor cursor = inputLine()->textCursor(); @@ -605,6 +623,11 @@ void InputWidget::on_underlineButton_clicked(bool checked) setFormatUnderline(checked); } +void InputWidget::on_strikethroughButton_clicked(bool checked) +{ + setFormatStrikethrough(checked); +} + void InputWidget::on_italicButton_clicked(bool checked) { setFormatItalic(checked); @@ -615,6 +638,7 @@ void InputWidget::fontChanged(const QFont& f) ui.boldButton->setChecked(f.bold()); ui.italicButton->setChecked(f.italic()); ui.underlineButton->setChecked(f.underline()); + ui.strikethroughButton->setChecked(f.strikeOut()); } void InputWidget::colorChosen(QAction* action)