diff --git a/src/messages/layouts/messagelayout.hpp b/src/messages/layouts/messagelayout.hpp index 76878c07..b6f045a8 100644 --- a/src/messages/layouts/messagelayout.hpp +++ b/src/messages/layouts/messagelayout.hpp @@ -50,7 +50,7 @@ public: const MessageLayoutElement *getElementAt(QPoint point); int getLastCharacterIndex() const; int getSelectionIndex(QPoint position); - void addSelectionText(QString &str, int from, int to); + void addSelectionText(QString &str, int from = 0, int to = INT_MAX); // Misc bool isDisabled() const; diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index 79c7a3ef..b4644498 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -938,12 +938,13 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) const auto &creator = hoverLayoutElement->getCreator(); auto creatorFlags = creator.getFlags(); - if ((creatorFlags & (MessageElement::Flags::EmoteImages | MessageElement::Flags::EmojiImage)) != - 0) { - if (event->button() == Qt::RightButton) { - static QMenu *menu = new QMenu; - menu->clear(); + if (event->button() == Qt::RightButton) { + static QMenu *menu = new QMenu; + menu->clear(); + // Emote actions + if ((creatorFlags & + (MessageElement::Flags::EmoteImages | MessageElement::Flags::EmojiImage)) != 0) { const auto &emoteElement = static_cast(creator); // TODO: We might want to add direct "Open image" variants alongside the Copy actions @@ -977,12 +978,30 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) QApplication::clipboard()->setText(emotePageLink); // }); } - - menu->move(QCursor::pos()); - menu->show(); - - return; } + + // add seperator + if (!menu->actions().empty()) + menu->addSeparator(); + + // Message actions + menu->addAction("Copy message", [layout] { + QString copyString; + layout->addSelectionText(copyString); + + QGuiApplication::clipboard()->setText(copyString); + }); + // menu->addAction("Quote message", [layout] { + // QString copyString; + // layout->addSelectionText(copyString); + + // // insert into input + // }); + + menu->move(QCursor::pos()); + menu->show(); + + return; } auto &link = hoverLayoutElement->getLink();