Changeset View
Changeset View
Standalone View
Standalone View
klipper/klipper.cpp
Context not available. | |||||
116 | m_history = new History( this ); | 116 | m_history = new History( this ); | ||
---|---|---|---|---|---|
117 | m_popup = new KlipperPopup(m_history); | 117 | m_popup = new KlipperPopup(m_history); | ||
118 | m_popup->setShowHelp(m_mode == KlipperMode::Standalone); | 118 | m_popup->setShowHelp(m_mode == KlipperMode::Standalone); | ||
119 | connect(m_history, &History::changed, this, &Klipper::slotHistoryChanged); | ||||
119 | connect(m_history, &History::changed, m_popup, &KlipperPopup::slotHistoryChanged); | 120 | connect(m_history, &History::changed, m_popup, &KlipperPopup::slotHistoryChanged); | ||
120 | connect(m_history, &History::topIsUserSelectedSet, m_popup, &KlipperPopup::slotTopIsUserSelectedSet); | 121 | connect(m_history, &History::topIsUserSelectedSet, m_popup, &KlipperPopup::slotTopIsUserSelectedSet); | ||
121 | 122 | | |||
Context not available. | |||||
288 | void Klipper::clearClipboardHistory() | 289 | void Klipper::clearClipboardHistory() | ||
289 | { | 290 | { | ||
290 | updateTimestamp(); | 291 | updateTimestamp(); | ||
291 | slotClearClipboard(); | | |||
292 | history()->slotClear(); | 292 | history()->slotClear(); | ||
293 | saveSession(); | 293 | saveSession(); | ||
294 | } | 294 | } | ||
Context not available. | |||||
330 | // this will cause it to loadSettings too | 330 | // this will cause it to loadSettings too | ||
331 | setURLGrabberEnabled(m_bURLGrabber); | 331 | setURLGrabberEnabled(m_bURLGrabber); | ||
332 | history()->setMaxSize( KlipperSettings::maxClipItems() ); | 332 | history()->setMaxSize( KlipperSettings::maxClipItems() ); | ||
333 | history()->model()->setDisplayImages(!m_bIgnoreImages); | ||||
334 | | ||||
333 | // Convert 4.3 settings | 335 | // Convert 4.3 settings | ||
334 | if (KlipperSettings::synchronize() != 3) { | 336 | if (KlipperSettings::synchronize() != 3) { | ||
335 | // 2 was the id of "Ignore selection" radiobutton | 337 | // 2 was the id of "Ignore selection" radiobutton | ||
Context not available. | |||||
604 | return HistoryItemPtr(); | 606 | return HistoryItemPtr(); | ||
605 | } | 607 | } | ||
606 | Ignore lock( m_locklevel ); | 608 | Ignore lock( m_locklevel ); | ||
607 | HistoryItemPtr item = HistoryItem::create( clipData ); | | |||
608 | 609 | | |||
609 | bool saveHistory = true; | 610 | if (!(history()->empty())) { | ||
610 | if (clipData->data(QStringLiteral("x-kde-passwordManagerHint")) == QByteArrayLiteral("secret")) { | 611 | if (m_bIgnoreImages && history()->first()->mimeData()->hasImage()) { | ||
611 | saveHistory = false; | 612 | history()->remove(history()->first()); | ||
612 | } | 613 | } | ||
613 | if (clipData->hasImage() && m_bIgnoreImages) { | | |||
614 | saveHistory = false; | | |||
615 | } | 614 | } | ||
616 | 615 | | |||
617 | m_last = item; | 616 | HistoryItemPtr item = HistoryItem::create( clipData ); | ||
618 | 617 | | |||
619 | if (saveHistory) { | 618 | bool saveToHistory = true; | ||
619 | if (clipData->data(QStringLiteral("x-kde-passwordManagerHint")) == QByteArrayLiteral("secret")) { | ||||
620 | saveToHistory = false; | ||||
621 | } | ||||
622 | if (saveToHistory) { | ||||
620 | history()->insert( item ); | 623 | history()->insert( item ); | ||
621 | } | 624 | } | ||
622 | return item; | | |||
623 | 625 | | |||
626 | return item; | ||||
624 | } | 627 | } | ||
625 | 628 | | |||
626 | void Klipper::newClipData( QClipboard::Mode mode ) | 629 | void Klipper::newClipData( QClipboard::Mode mode ) | ||
Context not available. | |||||
636 | 639 | | |||
637 | } | 640 | } | ||
638 | 641 | | |||
642 | void Klipper::slotHistoryChanged() | ||||
643 | { | ||||
644 | if (history()->empty()) { | ||||
645 | slotClearClipboard(); | ||||
646 | } | ||||
647 | } | ||||
648 | | ||||
639 | // Protection against too many clipboard data changes. Lyx responds to clipboard data | 649 | // Protection against too many clipboard data changes. Lyx responds to clipboard data | ||
640 | // requests with setting new clipboard data, so if Lyx takes over clipboard, | 650 | // requests with setting new clipboard data, so if Lyx takes over clipboard, | ||
641 | // Klipper notices, requests this data, this triggers "new" clipboard contents | 651 | // Klipper notices, requests this data, this triggers "new" clipboard contents | ||
Context not available. | |||||
697 | // This won't quite work, but it's close enough for now. | 707 | // This won't quite work, but it's close enough for now. | ||
698 | // The trouble is that the top selection =! top clipboard | 708 | // The trouble is that the top selection =! top clipboard | ||
699 | // but we don't track that yet. We will.... | 709 | // but we don't track that yet. We will.... | ||
700 | auto top = m_last; | 710 | auto top = history()->first(); | ||
701 | if ( top ) { | 711 | if ( top ) { | ||
702 | setClipboard( *top, selectionMode ? Selection : Clipboard); | 712 | setClipboard( *top, selectionMode ? Selection : Clipboard); | ||
703 | } | 713 | } | ||
Context not available. | |||||
721 | } | 731 | } | ||
722 | 732 | | |||
723 | if ( changed && clipEmpty && m_bNoNullClipboard ) { | 733 | if ( changed && clipEmpty && m_bNoNullClipboard ) { | ||
724 | auto top = m_last; | 734 | auto top = history()->first(); | ||
725 | if ( top ) { | 735 | if ( top ) { | ||
726 | // keep old clipboard after someone set it to null | 736 | // keep old clipboard after someone set it to null | ||
727 | qCDebug(KLIPPER_LOG) << "Resetting clipboard (Prevent empty clipboard)"; | 737 | qCDebug(KLIPPER_LOG) << "Resetting clipboard (Prevent empty clipboard)"; | ||
Context not available. | |||||
992 | KMessageBox::Dangerous); | 1002 | KMessageBox::Dangerous); | ||
993 | if (clearHist == KMessageBox::Yes) { | 1003 | if (clearHist == KMessageBox::Yes) { | ||
994 | history()->slotClear(); | 1004 | history()->slotClear(); | ||
995 | slotClearClipboard(); | | |||
996 | saveHistory(); | 1005 | saveHistory(); | ||
997 | } | 1006 | } | ||
998 | 1007 | | |||
Context not available. |