modernize: Migrate action-related things to PMF connects
[quassel.git] / src / qtui / chatitem.cpp
index b88ac27..8063a97 100644 (file)
@@ -33,6 +33,7 @@
 #include <QTextLayout>
 #include <QMenu>
 
+#include "action.h"
 #include "buffermodel.h"
 #include "bufferview.h"
 #include "chatline.h"
@@ -297,7 +298,7 @@ QVector<QTextLayout::FormatRange> ChatItem::additionalFormats() const
     using Label = UiStyle::MessageLabel;
     using Format = UiStyle::Format;
 
-    Label itemLabel = data(ChatLineModel::MsgLabelRole).value<Label>();
+    auto itemLabel = data(ChatLineModel::MsgLabelRole).value<Label>();
     const auto &fmtList = formatList();
 
     struct LabelFormat {
@@ -660,7 +661,7 @@ void ContentsChatItem::clearCache()
 ContentsChatItemPrivate *ContentsChatItem::privateData() const
 {
     if (!_data) {
-        ContentsChatItem *that = const_cast<ContentsChatItem *>(this);
+        auto *that = const_cast<ContentsChatItem *>(this);
         that->_data = new ContentsChatItemPrivate(ClickableList::fromString(data(ChatLineModel::DisplayRole).toString()), that);
     }
     return _data;
@@ -869,10 +870,13 @@ void ContentsChatItem::addActionsToMenu(QMenu *menu, const QPointF &pos)
         Clickable click = privateData()->currentClickable;
         switch (click.type()) {
         case Clickable::Url:
+        {
             privateData()->activeClickable = click;
-            menu->addAction(icon::get("edit-copy"), tr("Copy Link Address"),
-                &_actionProxy, SLOT(copyLinkToClipboard()))->setData(QVariant::fromValue<void *>(this));
+            auto action = new Action{icon::get("edit-copy"), tr("Copy Link Address"), menu, &_actionProxy, &ActionProxy::copyLinkToClipboard};
+            action->setData(QVariant::fromValue<void *>(this));
+            menu->addAction(action);
             break;
+        }
         case Clickable::Channel:
         {
             // Remove existing menu actions, they confuse us when right-clicking on a clickable