Plugin links pt 2: Link::InsertText (#6527)
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
||||
- Minor: Badges now link to their home page like emotes in the context menu. (#6437)
|
||||
- Minor: Fixed usercard resizing improperly without recent messages. (#6496)
|
||||
- Minor: Added setting for character limit of deleted messages. (#6491)
|
||||
- Minor: Added link support to plugin message API. (#6386)
|
||||
- Minor: Added link support to plugin message API. (#6386, #6527)
|
||||
- Minor: Added a description for the logging option under moderation tab. (#6514)
|
||||
- Minor: Fixed "edit hotkey" dialog opening like a normal window. (#6540)
|
||||
- Bugfix: Expose the "Extra extension IDs" setting on non-Windows systems too. (#6509)
|
||||
|
||||
Vendored
+1
@@ -255,6 +255,7 @@ declare namespace c2 {
|
||||
JumpToChannel,
|
||||
CopyToClipboard,
|
||||
JumpToMessage,
|
||||
InsertText,
|
||||
}
|
||||
|
||||
enum MessageFlag {
|
||||
|
||||
@@ -354,6 +354,7 @@ c2.LinkType = {
|
||||
JumpToChannel = {}, ---@type c2.LinkType.JumpToChannel
|
||||
CopyToClipboard = {}, ---@type c2.LinkType.CopyToClipboard
|
||||
JumpToMessage = {}, ---@type c2.LinkType.JumpToMessage
|
||||
InsertText = {}, ---@type c2.LinkType.InsertText
|
||||
}
|
||||
|
||||
-- Begin src/singletons/Fonts.hpp
|
||||
|
||||
@@ -621,6 +621,7 @@ This table describes links available to plugins.
|
||||
| `JumpToChannel` | [Channel name](#channelget_name) | Go to already open split with given channel | `#pajlada` |
|
||||
| `CopyToClipboard` | Any Unicode text | Copy value to clipboard | n/a |
|
||||
| `JumpToMessage` | ID of the message | Highlight the message with given ID in current split, do nothing if it was not found | n/a |
|
||||
| `InsertText` | Any text, command or emote | Insert text into split input | n/a |
|
||||
|
||||
### Input/Output API
|
||||
|
||||
|
||||
@@ -190,6 +190,7 @@ std::unique_ptr<MessageElement> elementFromTable(const sol::table &tbl)
|
||||
break;
|
||||
|
||||
// these links should be safe to click as they don't have any immediate action associated with them
|
||||
case Link::InsertText:
|
||||
case Link::JumpToChannel:
|
||||
case Link::JumpToMessage:
|
||||
case Link::UserInfo:
|
||||
@@ -201,7 +202,6 @@ std::unique_ptr<MessageElement> elementFromTable(const sol::table &tbl)
|
||||
case Link::None:
|
||||
case Link::AutoModAllow:
|
||||
case Link::AutoModDeny:
|
||||
case Link::InsertText:
|
||||
case Link::OpenAccountsPage:
|
||||
case Link::Reconnect:
|
||||
throw std::runtime_error(
|
||||
|
||||
@@ -102,6 +102,7 @@ enum class ExposedLinkType : std::uint8_t {
|
||||
JumpToChannel = Link::Type::JumpToChannel,
|
||||
CopyToClipboard = Link::Type::CopyToClipboard,
|
||||
JumpToMessage = Link::Type::JumpToMessage,
|
||||
InsertText = Link::Type::InsertText,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -2423,6 +2423,15 @@ void ChannelView::handleMouseClick(QMouseEvent *event,
|
||||
if (link.type == Link::InsertText)
|
||||
{
|
||||
this->linkClicked.invoke(link);
|
||||
|
||||
if (this->context_ == Context::None)
|
||||
{
|
||||
auto *split = dynamic_cast<Split *>(this->parentWidget());
|
||||
if (split)
|
||||
{
|
||||
split->insertTextToInput(link.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user