From kde-commits Fri Nov 26 17:37:09 2004 From: Esben Mose Hansen Date: Fri, 26 Nov 2004 17:37:09 +0000 To: kde-commits Subject: kdebase/klipper Message-Id: <20041126173709.BD64817A2B () office ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=110149064610189 CVS commit by esben: The wrong clipboard/selection was set by the prevent-empty-clipboard feature Image items were not set correctly if a text item was current set in the clipboard. M +17 -5 toplevel.cpp 1.167 M +9 -2 toplevel.h 1.58 --- kdebase/klipper/toplevel.cpp #1.166:1.167 @@ -720,5 +720,5 @@ void KlipperWidget::checkClipData( bool const HistoryItem* top = history()->first(); if ( top ) { - setClipboard( *top, selectionMode ); + setClipboard( *top, selectionMode ? Selection : Clipboard); } return; @@ -748,5 +748,5 @@ void KlipperWidget::checkClipData( bool << "\nserialNo=" << clip->data()->serialNumber() << " (sel,cli)=(" << m_lastSelection << "," << m_lastClipboard << ")" << "\nowning (sel,cli)=(" << clip->ownsSelection() << "," << clip->ownsClipboard() << ")" - << "\ntext=" << clip->text() << endl; + << "\ntext=" << clip->text( selectionMode ? QClipboard::Selection : QClipboard::Clipboard) << endl; #endif @@ -773,6 +773,10 @@ void KlipperWidget::checkClipData( bool if ( top ) { // keep old clipboard after someone set it to null - setClipboard( *top, selectionMode ); +#ifdef NOISY_KLIPPER + kdDebug() << "Resetting clipboard (Prevent empty clipboard)" << endl; +#endif + setClipboard( *top, selectionMode ? Selection : Clipboard ); } + return; } @@ -820,6 +824,11 @@ void KlipperWidget::setClipboard( const Ignore lock( locklevel ); + Q_ASSERT( ( mode & 1 ) == 0 ); // Warn if trying to pass a boolean as a mode. + if ( mode & Selection ) { - if ( clip->image().isNull() ) { +#ifdef NOSIY_KLIPPER + kdDebug() << "Setting selection to <" << item.text() << ">" << endl; +#endif + if ( item.image().isNull() ) { clip->setText( item.text(), QClipboard::Selection ); } else { @@ -829,5 +838,8 @@ void KlipperWidget::setClipboard( const } if ( mode & Clipboard ) { - if ( clip->image().isNull() ) { +#ifdef NOSIY_KLIPPER + kdDebug() << "Setting clipboard to <" << item.text() << ">" << endl; +#endif + if ( item.image().isNull() ) { clip->setText( item.text(), QClipboard::Clipboard ); } else { --- kdebase/klipper/toplevel.h #1.57:1.58 @@ -78,4 +78,12 @@ public slots: protected: + /** + * The selection modes + * + * Don't use 1, as I use that as a guard against passing + * a boolean true as a mode. + */ + enum SelectionMode { Clipboard = 2, Selection = 4 }; + void paintEvent(QPaintEvent *); void mousePressEvent(QMouseEvent *); @@ -148,5 +156,4 @@ private slots: private: - enum SelectionMode { Clipboard = 1, Selection = 2 }; QClipboard *clip;