diff --git a/applets/notes/package/contents/ui/main.qml b/applets/notes/package/contents/ui/main.qml --- a/applets/notes/package/contents/ui/main.qml +++ b/applets/notes/package/contents/ui/main.qml @@ -310,6 +310,18 @@ text: i18nc("@info:tooltip", "Strikethrough") } } + QQC2.ToolButton { + icon.name: "edit-clear-all" + icon.color: textIconColor + icon.width: units.iconSizes.smallMedium + icon.height: icon.width + onClicked: documentHandler.clearFormatting() + Accessible.name: clearFormattingTooltip.text + QQC2.ToolTip { + id: clearFormattingTooltip + text: i18nc("@info:tooltip", "Clear formatting") + } + } } Item { // spacer diff --git a/applets/notes/plugin/documenthandler.h b/applets/notes/plugin/documenthandler.h --- a/applets/notes/plugin/documenthandler.h +++ b/applets/notes/plugin/documenthandler.h @@ -115,6 +115,7 @@ void setFontSize(int arg); void setTextColor(const QColor &arg); void setFontFamily(const QString &arg); + void clearFormatting(); void setText(const QString &arg); diff --git a/applets/notes/plugin/documenthandler.cpp b/applets/notes/plugin/documenthandler.cpp --- a/applets/notes/plugin/documenthandler.cpp +++ b/applets/notes/plugin/documenthandler.cpp @@ -300,6 +300,24 @@ emit fontFamilyChanged(); } +void DocumentHandler::clearFormatting() +{ + QTextCursor cursor = textCursor(); + if (cursor.isNull()) + return; + + QTextCharFormat fmt; + fmt.setFontWeight(QFont::Normal); + fmt.setFont(m_doc->defaultFont()); + fmt.clearBackground(); + + if (!cursor.hasSelection()) + cursor.select(QTextCursor::WordUnderCursor); + cursor.setCharFormat(fmt); + + reset(); +} + QStringList DocumentHandler::defaultFontSizes() const { // uhm... this is quite ugly