feature: paste image in chat #51
@ -51,7 +51,7 @@ Conversation::Conversation(bool muc, Models::Account* acc, Models::Element* el,
|
|||||||
delegate(new MessageDelegate(this)),
|
delegate(new MessageDelegate(this)),
|
||||||
manualSliderChange(false),
|
manualSliderChange(false),
|
||||||
tsb(QApplication::style()->styleHint(QStyle::SH_ScrollBar_Transient) == 1),
|
tsb(QApplication::style()->styleHint(QStyle::SH_ScrollBar_Transient) == 1),
|
||||||
pasteImageAction(nullptr),
|
pasteImageAction(new QAction(tr("Paste Image"), this)),
|
||||||
shadow(10, 1, Qt::black, this),
|
shadow(10, 1, Qt::black, this),
|
||||||
contextMenu(new QMenu())
|
contextMenu(new QMenu())
|
||||||
{
|
{
|
||||||
@ -88,21 +88,11 @@ Conversation::Conversation(bool muc, Models::Account* acc, Models::Element* el,
|
|||||||
this, &Conversation::onTextEditDocSizeChanged);
|
this, &Conversation::onTextEditDocSizeChanged);
|
||||||
|
|
||||||
m_ui->messageEditor->installEventFilter(&ker);
|
m_ui->messageEditor->installEventFilter(&ker);
|
||||||
|
m_ui->messageEditor->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
blue marked this conversation as resolved
|
|||||||
QAction* pasteImageAction = new QAction(tr("Paste Image"), this);
|
connect(m_ui->messageEditor, &QTextEdit::customContextMenuRequested, this, &Conversation::onMessageEditorContext);
|
||||||
connect(pasteImageAction, &QAction::triggered, this, &Conversation::onImagePasted);
|
connect(pasteImageAction, &QAction::triggered, this, &Conversation::onImagePasted);
|
||||||
|
|
||||||
m_ui->messageEditor->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
connect(m_ui->messageEditor, &QTextEdit::customContextMenuRequested, this, [this, pasteImageAction](const QPoint &pos) {
|
|
||||||
pasteImageAction->setEnabled(Conversation::checkClipboardImage());
|
|
||||||
|
|
||||||
QMenu *editorMenu = m_ui->messageEditor->createStandardContextMenu();
|
|
||||||
editorMenu->addSeparator();
|
|
||||||
editorMenu->addAction(pasteImageAction);
|
|
||||||
|
|
||||||
editorMenu->exec(this->m_ui->messageEditor->mapToGlobal(pos));
|
|
||||||
});
|
|
||||||
|
|
||||||
//line->setAutoFillBackground(false);
|
//line->setAutoFillBackground(false);
|
||||||
//if (testAttribute(Qt::WA_TranslucentBackground)) {
|
//if (testAttribute(Qt::WA_TranslucentBackground)) {
|
||||||
//m_ui->scrollArea->setAutoFillBackground(false);
|
//m_ui->scrollArea->setAutoFillBackground(false);
|
||||||
@ -486,3 +476,14 @@ void Conversation::onFeedContext(const QPoint& pos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Conversation::onMessageEditorContext(const QPoint& pos)
|
||||||
|
{
|
||||||
|
pasteImageAction->setEnabled(Conversation::checkClipboardImage());
|
||||||
|
|
||||||
|
QMenu *editorMenu = m_ui->messageEditor->createStandardContextMenu();
|
||||||
|
editorMenu->addSeparator();
|
||||||
|
editorMenu->addAction(pasteImageAction);
|
||||||
|
|
||||||
|
editorMenu->exec(this->m_ui->messageEditor->mapToGlobal(pos));
|
||||||
|
}
|
||||||
|
@ -114,6 +114,7 @@ protected slots:
|
|||||||
void onFeedMessage(const Shared::Message& msg);
|
void onFeedMessage(const Shared::Message& msg);
|
||||||
void positionShadow();
|
void positionShadow();
|
||||||
void onFeedContext(const QPoint &pos);
|
void onFeedContext(const QPoint &pos);
|
||||||
|
void onMessageEditorContext(const QPoint &pos);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const bool isMuc;
|
const bool isMuc;
|
||||||
|
Loading…
Reference in New Issue
Block a user
Do you mind if we better move it to initialization block? Cuz, since you declare here that variable again as QAction* it might be even considered like another variable rather than that one declared as a property...
How about this change?
52551c1ce0
That's good, thank you!