Commit 3bd6ac34 authored by David Redondo's avatar David Redondo 🏎
Browse files

[Klipper] Always restore the last clipbboard item

D19852 intrdouced x-kde-force-image-copy hint for programs to specify that
images should be set to the clipboard even if should not be included in the
history. But when the program was closed the clipboard was restored to the first
item in history in which the image was not included. To fix this introduce a new
class member which holds the last clipboard item and restore it.
Credit goes to David Edumndson
Test Plan:
Try it with spectacle
@ngraham, @davidedmundson, #plasma
parent 69adf060
......@@ -612,6 +612,8 @@ HistoryItemPtr Klipper::applyClipChanges( const QMimeData* clipData )
saveHistory = false;
m_last = item;
if (saveHistory) {
history()->insert( item );
......@@ -693,7 +695,7 @@ void Klipper::checkClipData( bool selectionMode )
// This won't quite work, but it's close enough for now.
// The trouble is that the top selection =! top clipboard
// but we don't track that yet. We will....
auto top = history()->first();
auto top = m_last;
if ( top ) {
setClipboard( *top, selectionMode ? Selection : Clipboard);
......@@ -717,7 +719,7 @@ void Klipper::checkClipData( bool selectionMode )
if ( changed && clipEmpty && m_bNoNullClipboard ) {
auto top = history()->first();
auto top = m_last;
if ( top ) {
// keep old clipboard after someone set it to null
qCDebug(KLIPPER_LOG) << "Resetting clipboard (Prevent empty clipboard)";
......@@ -159,6 +159,8 @@ private:
QClipboard* m_clip;
QSharedPointer<HistoryItem> m_last;
QTime m_showTimer;
History* m_history;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment