X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Finputwidget.cpp;h=699867245fd246462cdf7ec36828c5713c3a9633;hb=4e51500401db3c85dbe5e92e5e5c15b6e3c87787;hp=dee4da7ec199ebe06c32568ff7d4f8ac80fa1f55;hpb=c1cf157116de7fc3da96203aa6f03c38c7ebb650;p=quassel.git diff --git a/src/qtui/inputwidget.cpp b/src/qtui/inputwidget.cpp index dee4da7e..69986724 100644 --- a/src/qtui/inputwidget.cpp +++ b/src/qtui/inputwidget.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * + * Copyright (C) 2005-2020 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -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)