Skip to content

Commit

Permalink
Linux: Fix storing selection with disabled automatic commands
Browse files Browse the repository at this point in the history
Fixes storing selection when "Store text selected using mouse" option is
enabled but "Run automatic commands on selection" is disabled.

Fixes #2651
  • Loading branch information
hluk committed Apr 21, 2024
1 parent d1b4f28 commit 901934a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/app/clipboardmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions src/app/clipboardmonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions src/scriptable/scriptable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 901934a

Please sign in to comment.