Make sure that the style menu shows the right style name for code and quote.

Also when in quote mode the valid styles are now transformed to how they look in quote to show they are valid. Clicking quote style again in a quote block will return to paragrpah style from heading now
This commit is contained in:
James Graham
2026-02-07 17:18:26 +00:00
parent 7afce01a23
commit 13d7f9b322
11 changed files with 110 additions and 18 deletions

View File

@@ -47,6 +47,21 @@ QTextDocument *StyleDelegateHelper::document() const
return quickDocument ? quickDocument->textDocument() : nullptr;
}
bool StyleDelegateHelper::inQuote() const
{
return m_inQuote;
}
void StyleDelegateHelper::setInQuote(bool inQuote)
{
if (inQuote == m_inQuote) {
return;
}
m_inQuote = inQuote;
formatDocument();
Q_EMIT inQuoteChanged();
}
void StyleDelegateHelper::formatDocument()
{
if (!document()) {
@@ -62,7 +77,7 @@ void StyleDelegateHelper::formatDocument()
cursor.select(QTextCursor::Document);
cursor.removeSelectedText();
const auto style = static_cast<RichFormat::Format>(m_textItem->property("style").toInt());
const auto string = RichFormat::styleString(style);
const auto string = RichFormat::styleString(style, m_inQuote);
const auto sizeText = static_cast<RichFormat::Format>(m_textItem->property("sizeText").toBool());
const int headingLevel = style <= 6 && sizeText ? style : 0;
@@ -83,7 +98,7 @@ void StyleDelegateHelper::formatDocument()
chrfmt.setFontItalic(true);
}
cursor.mergeBlockCharFormat(chrfmt);
cursor.setBlockCharFormat(chrfmt);
cursor.insertText(string);
cursor.endEditBlock();
}