Add more tests

This commit is contained in:
James Graham
2026-01-02 15:04:15 +00:00
parent 9ea76ca5d0
commit d10fe4a684
18 changed files with 822 additions and 221 deletions

View File

@@ -23,14 +23,6 @@ QQC2.ToolBar {
required property MessageContent.ChatBarMessageContentModel contentModel
Connections {
target: contentModel
function onFocusRowChanged() {
console.warn("focus changed", contentModel.focusRow, contentModel.focusType)
}
}
required property real maxAvailableWidth
readonly property real uncompressedImplicitWidth: textFormatRow.implicitWidth +

View File

@@ -87,7 +87,7 @@ QQC2.Popup {
radius: Kirigami.Units.cornerRadius
border {
width: 1
color: styleDelegate.hovered || root.chatButtonHelper.currentStyle === styleDelegate.index ?
color: styleDelegate.hovered || (root.chatButtonHelper.currentStyle === styleDelegate.index) ?
Kirigami.Theme.highlightColor :
Kirigami.ColorUtils.linearInterpolation(
Kirigami.Theme.backgroundColor,

View File

@@ -44,7 +44,11 @@ bool ChatButtonHelper::bold() const
if (!m_textItem) {
return false;
}
return m_textItem->formatsAtCursor().contains(RichFormat::Bold);
const auto cursor = m_textItem->textCursor();
if (cursor.isNull()) {
return false;
}
return RichFormat::formatsAtCursor(cursor).contains(RichFormat::Bold);
}
bool ChatButtonHelper::italic() const
@@ -52,7 +56,11 @@ bool ChatButtonHelper::italic() const
if (!m_textItem) {
return false;
}
return m_textItem->formatsAtCursor().contains(RichFormat::Italic);
const auto cursor = m_textItem->textCursor();
if (cursor.isNull()) {
return false;
}
return RichFormat::formatsAtCursor(cursor).contains(RichFormat::Italic);
}
bool ChatButtonHelper::underline() const
@@ -60,7 +68,11 @@ bool ChatButtonHelper::underline() const
if (!m_textItem) {
return false;
}
return m_textItem->formatsAtCursor().contains(RichFormat::Underline);
const auto cursor = m_textItem->textCursor();
if (cursor.isNull()) {
return false;
}
return RichFormat::formatsAtCursor(cursor).contains(RichFormat::Underline);
}
bool ChatButtonHelper::strikethrough() const
@@ -68,7 +80,11 @@ bool ChatButtonHelper::strikethrough() const
if (!m_textItem) {
return false;
}
return m_textItem->formatsAtCursor().contains(RichFormat::Strikethrough);
const auto cursor = m_textItem->textCursor();
if (cursor.isNull()) {
return false;
}
return RichFormat::formatsAtCursor(cursor).contains(RichFormat::Strikethrough);
}
bool ChatButtonHelper::unorderedList() const
@@ -76,7 +92,11 @@ bool ChatButtonHelper::unorderedList() const
if (!m_textItem) {
return false;
}
return m_textItem->formatsAtCursor().contains(RichFormat::UnorderedList);
const auto cursor = m_textItem->textCursor();
if (cursor.isNull()) {
return false;
}
return RichFormat::formatsAtCursor(cursor).contains(RichFormat::UnorderedList);
}
bool ChatButtonHelper::orderedList() const
@@ -84,7 +104,11 @@ bool ChatButtonHelper::orderedList() const
if (!m_textItem) {
return false;
}
return m_textItem->formatsAtCursor().contains(RichFormat::OrderedList);
const auto cursor = m_textItem->textCursor();
if (cursor.isNull()) {
return false;
}
return RichFormat::formatsAtCursor(cursor).contains(RichFormat::OrderedList);
}
RichFormat::Format ChatButtonHelper::currentStyle() const