Update the look of the chatbar to be floating with the rich text controls on top and send buttons inline

This commit is contained in:
James Graham
2026-01-17 15:46:00 +00:00
parent 79de8a792c
commit 6b318ec754
25 changed files with 945 additions and 806 deletions

View File

@@ -77,6 +77,21 @@ void CompletionModel::setTextItem(ChatTextItemHelper *textItem)
Q_EMIT textItemChanged();
}
bool CompletionModel::isCompleting() const
{
if (!m_textItem) {
return false;
}
return m_textItem->isCompleting;
}
void CompletionModel::ignoreCurrentCompletion()
{
m_ignoreCurrentCompletion = true;
m_textItem->isCompleting = false;
Q_EMIT isCompletingChanged();
}
void CompletionModel::updateTextStart()
{
auto cursor = m_textItem->textCursor();
@@ -193,6 +208,15 @@ void CompletionModel::updateCompletion()
if (cursor.isNull()) {
return;
}
if (m_ignoreCurrentCompletion) {
cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor);
if (cursor.selectedText() == u' ') {
m_ignoreCurrentCompletion = false;
}
return;
}
cursor.setPosition(m_textStart);
while (!cursor.selectedText().endsWith(u' ') && !cursor.atBlockEnd()) {
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
@@ -242,6 +266,7 @@ void CompletionModel::updateCompletion()
endResetModel();
m_textItem->isCompleting = rowCount() > 0;
Q_EMIT isCompletingChanged();
}
CompletionModel::AutoCompletionType CompletionModel::autoCompletionType() const

View File

@@ -62,6 +62,11 @@ class CompletionModel : public QAbstractListModel
*/
Q_PROPERTY(UserListModel *userListModel READ userListModel WRITE setUserListModel NOTIFY userListModelChanged)
/**
* @brief The UserListModel to be used for room completions.
*/
Q_PROPERTY(bool isCompleting READ isCompleting NOTIFY isCompletingChanged)
public:
/**
* @brief Defines the different types of completion available.
@@ -98,6 +103,10 @@ public:
ChatTextItemHelper *textItem() const;
void setTextItem(ChatTextItemHelper *textItem);
bool isCompleting() const;
Q_INVOKABLE void ignoreCurrentCompletion();
/**
* @brief Get the given role value at the given index.
*
@@ -137,12 +146,14 @@ Q_SIGNALS:
void autoCompletionTypeChanged();
void roomListModelChanged();
void userListModelChanged();
void isCompletingChanged();
private:
QPointer<NeoChatRoom> m_room;
ChatBarType::Type m_type = ChatBarType::None;
QPointer<ChatTextItemHelper> m_textItem;
bool m_ignoreCurrentCompletion = false;
int m_textStart = 0;
void updateTextStart();