author | sandman <sandman> | 2002-07-20 22:34:42 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-07-20 22:34:42 (UTC) |
commit | 594dfd3535846a536cebdb3381f4858239404c49 (patch) (side-by-side diff) | |
tree | d813fa27d282e03b732fb79985beabd3aa190064 | |
parent | d7e4bedb202300254511ad5949cb6176bcf4f37f (diff) | |
download | opie-594dfd3535846a536cebdb3381f4858239404c49.zip opie-594dfd3535846a536cebdb3381f4858239404c49.tar.gz opie-594dfd3535846a536cebdb3381f4858239404c49.tar.bz2 |
Fix for a (obvious) bug that resulted in double pasting and/or hanging apps
-rw-r--r-- | core/applets/clipboardapplet/clipboard.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp index 181f4bf..5848d0f 100644 --- a/core/applets/clipboardapplet/clipboard.cpp +++ b/core/applets/clipboardapplet/clipboard.cpp @@ -114,120 +114,120 @@ static const char * paste_xpm[] = { ",5vvv4k)p_%[q.", " ...$mljnn0qd.", " 4.......,"}; ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { setFixedWidth ( 14 ); setFixedHeight ( 18 ); m_clipboardPixmap = QPixmap ( paste_xpm ); QTimer *timer = new QTimer ( this ); connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( ))); connect ( timer, SIGNAL( timeout ( )), this, SLOT( newData ( ))); timer-> start ( 1000 ); m_menu = 0; m_dirty = true; m_lasttext = QString::null; } ClipboardApplet::~ClipboardApplet ( ) { } void ClipboardApplet::mousePressEvent ( QMouseEvent *) { if ( m_dirty ) { delete m_menu; m_menu = new QPopupMenu ( this ); m_menu-> setCheckable ( true ); if ( m_history. count ( )) { for ( unsigned int i = 0; i < m_history. count ( ); i++ ) { QString str = m_history [i]; if ( str. length ( ) > 20 ) str = str. left ( 20 ) + "..."; m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i ); m_menu-> setItemChecked ( i, false ); } m_menu-> setItemChecked ( m_history. count ( ) - 1, true ); m_menu-> insertSeparator ( ); } m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 ); m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 ); m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 ); connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int ))); m_dirty = false; } QPoint p = mapToGlobal ( QPoint ( 0, 0 )); QSize s = m_menu-> sizeHint ( ); m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); } void ClipboardApplet::action(int id) { ushort unicode = 0; int scan = 0; switch ( id ) { case 100: unicode = 'X' - '@'; scan = Key_X; // Cut break; case 101: unicode = 'C' - '@'; scan = Key_C; // Copy break; case 102: unicode = 'V' - '@'; scan = Key_V; // Paste break; default: if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) { QApplication::clipboard ( )-> setText ( m_history [id] ); for ( uint i = 0; i < m_history. count ( ); i++ ) m_menu-> setItemChecked ( i, i == uint( id )); unicode = 'V' - '@'; scan = Key_V; } break; } if ( scan ) { qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false ); - qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false ); + qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false ); } } void ClipboardApplet::paintEvent ( QPaintEvent* ) { QPainter p ( this ); p. drawPixmap ( 0, 1, m_clipboardPixmap ); } void ClipboardApplet::newData ( ) { QCString type = "plain"; QString txt = QApplication::clipboard ( )-> text ( type ); if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) { m_history. append ( txt ); if ( m_history. count ( ) > 5 ) m_history. remove ( m_history. begin ( )); m_dirty = true; } } |