diff --git a/src/app/clipboardmonitor.cpp b/src/app/clipboardmonitor.cpp index 0d9b6accb8..3e59ca3e87 100644 --- a/src/app/clipboardmonitor.cpp +++ b/src/app/clipboardmonitor.cpp @@ -179,14 +179,20 @@ void ClipboardMonitor::onClipboardChanged(ClipboardMode mode) } // omit running run automatic commands when disabled - if ( !m_runSelection && mode == ClipboardMode::Selection ) + if ( !m_runSelection && mode == ClipboardMode::Selection ) { + if ( m_storeSelection && !m_clipboardTab.isEmpty() ) { + data.insert(mimeClipboardMode, QByteArrayLiteral("selection")); + setTextData(&data, m_clipboardTab, mimeOutputTab); + emit saveData(data); + } return; + } #endif if (mode != ClipboardMode::Clipboard) { const QString modeName = mode == ClipboardMode::Selection - ? "selection" - : "find buffer"; + ? QStringLiteral("selection") + : QStringLiteral("find buffer"); data.insert(mimeClipboardMode, modeName); } diff --git a/src/app/clipboardmonitor.h b/src/app/clipboardmonitor.h index bf91c6218d..1f0d6617b1 100644 --- a/src/app/clipboardmonitor.h +++ b/src/app/clipboardmonitor.h @@ -29,6 +29,7 @@ class ClipboardMonitor final : public QObject signals: void clipboardChanged(const QVariantMap &data, ClipboardOwnership ownership); void clipboardUnchanged(const QVariantMap &data); + void saveData(const QVariantMap &data); void synchronizeSelection(ClipboardMode sourceMode, uint sourceTextHash, uint targetTextHash); void fetchCurrentClipboardOwner(QString *title); diff --git a/src/scriptable/scriptable.cpp b/src/scriptable/scriptable.cpp index 03f3e7bc59..8f80d1fc48 100644 --- a/src/scriptable/scriptable.cpp +++ b/src/scriptable/scriptable.cpp @@ -2608,6 +2608,11 @@ void Scriptable::monitorClipboard() this, &Scriptable::onSynchronizeSelection ); connect( &monitor, &ClipboardMonitor::fetchCurrentClipboardOwner, this, &Scriptable::onFetchCurrentClipboardOwner ); + connect( &monitor, &ClipboardMonitor::saveData, + m_proxy, [this](const QVariantMap &data) { + m_data = data; + eval("saveData()"); + } ); monitor.startMonitoring(); setClipboardMonitorRunning(true);