Changeset View
Changeset View
Standalone View
Standalone View
klipper/klipper.cpp
Show First 20 Lines • Show All 606 Lines • ▼ Show 20 Line(s) | 600 | { | |||
---|---|---|---|---|---|
607 | bool saveHistory = true; | 607 | bool saveHistory = true; | ||
608 | if (clipData->data(QStringLiteral("x-kde-passwordManagerHint")) == QByteArrayLiteral("secret")) { | 608 | if (clipData->data(QStringLiteral("x-kde-passwordManagerHint")) == QByteArrayLiteral("secret")) { | ||
609 | saveHistory = false; | 609 | saveHistory = false; | ||
610 | } | 610 | } | ||
611 | if (clipData->hasImage() && m_bIgnoreImages) { | 611 | if (clipData->hasImage() && m_bIgnoreImages) { | ||
612 | saveHistory = false; | 612 | saveHistory = false; | ||
613 | } | 613 | } | ||
614 | 614 | | |||
615 | m_last = item; | ||||
616 | | ||||
615 | if (saveHistory) { | 617 | if (saveHistory) { | ||
616 | history()->insert( item ); | 618 | history()->insert( item ); | ||
617 | } | 619 | } | ||
618 | return item; | 620 | return item; | ||
619 | 621 | | |||
620 | } | 622 | } | ||
621 | 623 | | |||
622 | void Klipper::newClipData( QClipboard::Mode mode ) | 624 | void Klipper::newClipData( QClipboard::Mode mode ) | ||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | |||||
688 | void Klipper::checkClipData( bool selectionMode ) | 690 | void Klipper::checkClipData( bool selectionMode ) | ||
689 | { | 691 | { | ||
690 | if ( ignoreClipboardChanges() ) // internal to klipper, ignoring QSpinBox selections | 692 | if ( ignoreClipboardChanges() ) // internal to klipper, ignoring QSpinBox selections | ||
691 | { | 693 | { | ||
692 | // keep our old clipboard, thanks | 694 | // keep our old clipboard, thanks | ||
693 | // This won't quite work, but it's close enough for now. | 695 | // This won't quite work, but it's close enough for now. | ||
694 | // The trouble is that the top selection =! top clipboard | 696 | // The trouble is that the top selection =! top clipboard | ||
695 | // but we don't track that yet. We will.... | 697 | // but we don't track that yet. We will.... | ||
696 | auto top = history()->first(); | 698 | auto top = m_last; | ||
697 | if ( top ) { | 699 | if ( top ) { | ||
698 | setClipboard( *top, selectionMode ? Selection : Clipboard); | 700 | setClipboard( *top, selectionMode ? Selection : Clipboard); | ||
699 | } | 701 | } | ||
700 | return; | 702 | return; | ||
701 | } | 703 | } | ||
702 | 704 | | |||
703 | qCDebug(KLIPPER_LOG) << "Checking clip data"; | 705 | qCDebug(KLIPPER_LOG) << "Checking clip data"; | ||
704 | 706 | | |||
705 | const QMimeData* data = m_clip->mimeData( selectionMode ? QClipboard::Selection : QClipboard::Clipboard ); | 707 | const QMimeData* data = m_clip->mimeData( selectionMode ? QClipboard::Selection : QClipboard::Clipboard ); | ||
706 | if ( !data ) { | 708 | if ( !data ) { | ||
707 | qCWarning(KLIPPER_LOG) << "No data in clipboard. This not not supposed to happen."; | 709 | qCWarning(KLIPPER_LOG) << "No data in clipboard. This not not supposed to happen."; | ||
708 | return; | 710 | return; | ||
709 | } | 711 | } | ||
710 | 712 | | |||
711 | bool changed = true; // ### FIXME (only relevant under polling, might be better to simply remove polling and rely on XFixes) | 713 | bool changed = true; // ### FIXME (only relevant under polling, might be better to simply remove polling and rely on XFixes) | ||
712 | bool clipEmpty = data->formats().isEmpty(); | 714 | bool clipEmpty = data->formats().isEmpty(); | ||
713 | if (clipEmpty) { | 715 | if (clipEmpty) { | ||
714 | // Might be a timeout. Try again | 716 | // Might be a timeout. Try again | ||
715 | clipEmpty = data->formats().isEmpty(); | 717 | clipEmpty = data->formats().isEmpty(); | ||
716 | qCDebug(KLIPPER_LOG) << "was empty. Retried, now " << (clipEmpty?" still empty":" no longer empty"); | 718 | qCDebug(KLIPPER_LOG) << "was empty. Retried, now " << (clipEmpty?" still empty":" no longer empty"); | ||
717 | } | 719 | } | ||
718 | 720 | | |||
719 | if ( changed && clipEmpty && m_bNoNullClipboard ) { | 721 | if ( changed && clipEmpty && m_bNoNullClipboard ) { | ||
720 | auto top = history()->first(); | 722 | auto top = m_last; | ||
721 | if ( top ) { | 723 | if ( top ) { | ||
722 | // keep old clipboard after someone set it to null | 724 | // keep old clipboard after someone set it to null | ||
723 | qCDebug(KLIPPER_LOG) << "Resetting clipboard (Prevent empty clipboard)"; | 725 | qCDebug(KLIPPER_LOG) << "Resetting clipboard (Prevent empty clipboard)"; | ||
724 | setClipboard( *top, selectionMode ? Selection : Clipboard ); | 726 | setClipboard( *top, selectionMode ? Selection : Clipboard ); | ||
725 | } | 727 | } | ||
726 | return; | 728 | return; | ||
727 | } | 729 | } | ||
728 | 730 | | |||
▲ Show 20 Lines • Show All 323 Lines • Show Last 20 Lines |