Improve the style picker
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "chatdocumenthandler.h"
|
||||
#include "enums/chatbartype.h"
|
||||
#include "enums/messagecomponenttype.h"
|
||||
#include "enums/textstyle.h"
|
||||
#include "messagecontentmodel.h"
|
||||
|
||||
ChatBarMessageContentModel::ChatBarMessageContentModel(QObject *parent)
|
||||
@@ -277,11 +278,28 @@ ChatBarMessageContentModel::insertComponent(int row, MessageComponentType::Type
|
||||
return it;
|
||||
}
|
||||
|
||||
void ChatBarMessageContentModel::insertStyleAtCursor(TextStyle::Style style)
|
||||
{
|
||||
switch (style) {
|
||||
case TextStyle::Paragraph:
|
||||
insertComponentAtCursor(MessageComponentType::Text);
|
||||
return;
|
||||
case TextStyle::Code:
|
||||
insertComponentAtCursor(MessageComponentType::Code);
|
||||
return;
|
||||
case TextStyle::Quote:
|
||||
insertComponentAtCursor(MessageComponentType::Quote);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ChatBarMessageContentModel::insertComponentAtCursor(MessageComponentType::Type type)
|
||||
{
|
||||
if (m_components[m_currentFocusComponent.row()].type == type) {
|
||||
if (type == MessageComponentType::Text && focusedDocumentHandler()) {
|
||||
focusedDocumentHandler()->setStyle(ChatDocumentHandler::Paragraph);
|
||||
focusedDocumentHandler()->setStyle(TextStyle::Paragraph);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "chatdocumenthandler.h"
|
||||
#include "enums/messagecomponenttype.h"
|
||||
#include "enums/textstyle.h"
|
||||
#include "messagecomponent.h"
|
||||
#include "models/messagecontentmodel.h"
|
||||
|
||||
@@ -55,6 +56,8 @@ public:
|
||||
Q_INVOKABLE void refocusCurrentComponent() const;
|
||||
ChatDocumentHandler *focusedDocumentHandler() const;
|
||||
|
||||
Q_INVOKABLE void insertStyleAtCursor(TextStyle::Style style);
|
||||
|
||||
Q_INVOKABLE void insertComponentAtCursor(MessageComponentType::Type type);
|
||||
|
||||
Q_INVOKABLE void addAttachment(const QUrl &path);
|
||||
|
||||
Reference in New Issue
Block a user