From 79f67f66f47d0ca54eea43cb339c9b54dad21819 Mon Sep 17 00:00:00 2001 From: Anthony Alves Date: Thu, 25 Aug 2016 20:43:51 -0400 Subject: [PATCH] Send clipboard content to chat Users can now set a shortcut to send the content in their clipboard to the channel they are in. Works when mumble is not in the foreground. --- src/mumble/MainWindow.cpp | 14 ++++++++++++++ src/mumble/MainWindow.h | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index 5bad5b246..2a8cf1760 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -231,6 +231,10 @@ void MainWindow::createActions() { gsSendTextMessage=new GlobalShortcut(this, idx++, tr("Send Text Message", "Global Shortcut"), true, QVariant(QString())); gsSendTextMessage->setObjectName(QLatin1String("gsSendTextMessage")); + gsSendClipboardTextMessage=new GlobalShortcut(this, idx++, tr("Send Clipboard Text Message", "Global Shortcut")); + gsSendClipboardTextMessage->setObjectName(QLatin1String("gsSendClipboardTextMessage")); + gsSendClipboardTextMessage->qsWhatsThis = tr("This will send your Clipboard content to the channel you are currently in.", "Global Shortcut"); + #ifndef Q_OS_MAC qstiIcon->show(); #endif @@ -2694,6 +2698,16 @@ void MainWindow::on_gsSendTextMessage_triggered(bool down, QVariant scdata) { g.l->log(Log::TextMessage, tr("To %1: %2").arg(Log::formatChannel(c), qsText), tr("Message to channel %1").arg(c->qsName), true); } +void MainWindow::on_gsSendClipboardTextMessage_triggered(bool down, QVariant) { + if (!down) { + return; + } + + // call sendChatbarMessage() instead of on_gsSendTextMessage_triggered() to handle + // formatting of the content in the clipboard, i.e., href. + sendChatbarMessage(QApplication::clipboard()->text()); +} + void MainWindow::whisperReleased(QVariant scdata) { if (g.iPushToTalk <= 0) return; diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index a9947977d..af301987e 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -77,7 +77,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin GlobalShortcut *gsUnlink, *gsPushMute, *gsJoinChannel, *gsToggleOverlay; GlobalShortcut *gsMinimal, *gsVolumeUp, *gsVolumeDown, *gsWhisper, *gsLinkChannel; GlobalShortcut *gsCycleTransmitMode; - GlobalShortcut *gsSendTextMessage; + GlobalShortcut *gsSendTextMessage, *gsSendClipboardTextMessage; DockTitleBar *dtbLogDockTitle, *dtbChatDockTitle; ACLEditor *aclEdit; @@ -256,6 +256,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin void removeTarget(ShortcutTarget *); void on_gsCycleTransmitMode_triggered(bool, QVariant); void on_gsSendTextMessage_triggered(bool, QVariant); + void on_gsSendClipboardTextMessage_triggered(bool, QVariant); void on_Reconnect_timeout(); void on_Icon_messageClicked(); void on_Icon_activated(QSystemTrayIcon::ActivationReason);