summaryrefslogtreecommitdiff
path: root/core/applets/clipboardapplet/clipboard.cpp
Unidiff
Diffstat (limited to 'core/applets/clipboardapplet/clipboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/clipboardapplet/clipboard.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp
index 34d151e..4fc8076 100644
--- a/core/applets/clipboardapplet/clipboard.cpp
+++ b/core/applets/clipboardapplet/clipboard.cpp
@@ -1,150 +1,150 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "clipboard.h" 21#include "clipboard.h"
22 22
23#include <opie2/otaskbarapplet.h> 23#include <opie2/otaskbarapplet.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26 26
27#include <qpainter.h> 27#include <qpainter.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qwindowsystem_qws.h> 29#include <qwindowsystem_qws.h>
30#include <qapplication.h> 30#include <qapplication.h>
31#include <qclipboard.h> 31#include <qclipboard.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34//=========================================================================== 34//===========================================================================
35 35
36 36
37ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) 37ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name )
38{ 38{
39 setFixedWidth ( AppLnk::smallIconSize() ); 39 setFixedWidth ( AppLnk::smallIconSize() );
40 setFixedHeight ( AppLnk::smallIconSize() ); 40 setFixedHeight ( AppLnk::smallIconSize() );
41 41
42 QImage img = Resource::loadImage( "paste"); 42 QImage img = Resource::loadImage( "paste");
43 img = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 43 img = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
44 44
45 m_clipboardPixmap.convertFromImage( img ); 45 m_clipboardPixmap.convertFromImage( img );
46 46
47 m_timer = new QTimer ( this ); 47 m_timer = new QTimer ( this );
48 48
49 connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( ))); 49 connect ( QApplication::clipboard ( ), SIGNAL( dataChanged()), this, SLOT( newData()));
50 connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( newData ( ))); 50 connect ( m_timer, SIGNAL( timeout()), this, SLOT( newData()));
51 connect ( qApp, SIGNAL( aboutToQuit ( )), this, SLOT( shutdown ( ))); 51 connect ( qApp, SIGNAL( aboutToQuit()), this, SLOT( shutdown()));
52 52
53 m_menu = 0; 53 m_menu = 0;
54 m_dirty = true; 54 m_dirty = true;
55 m_lasttext = QString::null; 55 m_lasttext = QString::null;
56 56
57 m_timer-> start ( 0, true ); 57 m_timer-> start ( 0, true );
58} 58}
59 59
60ClipboardApplet::~ClipboardApplet ( ) 60ClipboardApplet::~ClipboardApplet ( )
61{ 61{
62} 62}
63 63
64int ClipboardApplet::position() 64int ClipboardApplet::position()
65{ 65{
66 return 6; 66 return 6;
67} 67}
68 68
69void ClipboardApplet::shutdown ( ) 69void ClipboardApplet::shutdown ( )
70{ 70{
71 // the timer has to be stopped, or Qt/E will hang on quit() 71 // the timer has to be stopped, or Qt/E will hang on quit()
72 // see launcher/desktop.cpp 72 // see launcher/desktop.cpp
73 73
74 m_timer-> stop ( ); 74 m_timer-> stop ( );
75} 75}
76 76
77void ClipboardApplet::mousePressEvent ( QMouseEvent *) 77void ClipboardApplet::mousePressEvent ( QMouseEvent *)
78{ 78{
79 if ( m_dirty ) { 79 if ( m_dirty ) {
80 delete m_menu; 80 delete m_menu;
81 81
82 m_menu = new QPopupMenu ( this ); 82 m_menu = new QPopupMenu ( this );
83 m_menu-> setCheckable ( true ); 83 m_menu-> setCheckable ( true );
84 84
85 if ( m_history. count ( )) { 85 if ( m_history. count ( )) {
86 for ( unsigned int i = 0; i < m_history. count ( ); i++ ) { 86 for ( unsigned int i = 0; i < m_history. count ( ); i++ ) {
87 QString str = m_history [i]; 87 QString str = m_history [i];
88 88
89 if ( str. length ( ) > 20 ) 89 if ( str. length ( ) > 20 )
90 str = str. left ( 20 ) + "..."; 90 str = str. left ( 20 ) + "...";
91 91
92 m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i ); 92 m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i );
93 m_menu-> setItemChecked ( i, false ); 93 m_menu-> setItemChecked ( i, false );
94 } 94 }
95 m_menu-> setItemChecked ( m_history. count ( ) - 1, true ); 95 m_menu-> setItemChecked ( m_history. count ( ) - 1, true );
96 m_menu-> insertSeparator ( ); 96 m_menu-> insertSeparator ( );
97 } 97 }
98 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 ); 98 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 );
99 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 ); 99 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 );
100 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 ); 100 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 );
101 101
102 connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int ))); 102 connect ( m_menu, SIGNAL( activated(int)), this, SLOT( action(int)));
103 103
104 m_dirty = false; 104 m_dirty = false;
105 } 105 }
106 QPoint p = mapToGlobal ( QPoint ( 0, 0 )); 106 QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
107 QSize s = m_menu-> sizeHint ( ); 107 QSize s = m_menu-> sizeHint ( );
108 108
109 m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); 109 m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )));
110} 110}
111 111
112void ClipboardApplet::action(int id) 112void ClipboardApplet::action(int id)
113{ 113{
114 ushort unicode = 0; 114 ushort unicode = 0;
115 int scan = 0; 115 int scan = 0;
116 116
117 switch ( id ) { 117 switch ( id ) {
118 case 100: 118 case 100:
119 unicode = 'X' - '@'; 119 unicode = 'X' - '@';
120 scan = Key_X; // Cut 120 scan = Key_X; // Cut
121 break; 121 break;
122 case 101: 122 case 101:
123 unicode = 'C' - '@'; 123 unicode = 'C' - '@';
124 scan = Key_C; // Copy 124 scan = Key_C; // Copy
125 break; 125 break;
126 case 102: 126 case 102:
127 unicode = 'V' - '@'; 127 unicode = 'V' - '@';
128 scan = Key_V; // Paste 128 scan = Key_V; // Paste
129 break; 129 break;
130 130
131 default: 131 default:
132 if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) { 132 if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) {
133 QApplication::clipboard ( )-> setText ( m_history [id] ); 133 QApplication::clipboard ( )-> setText ( m_history [id] );
134 134
135 for ( uint i = 0; i < m_history. count ( ); i++ ) 135 for ( uint i = 0; i < m_history. count ( ); i++ )
136 m_menu-> setItemChecked ( i, i == uint( id )); 136 m_menu-> setItemChecked ( i, i == uint( id ));
137 137
138 unicode = 'V' - '@'; 138 unicode = 'V' - '@';
139 scan = Key_V; 139 scan = Key_V;
140 } 140 }
141 break; 141 break;
142 } 142 }
143 143
144 if ( scan ) { 144 if ( scan ) {
145 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false ); 145 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false );
146 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false ); 146 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false );
147 } 147 }
148} 148}
149 149
150void ClipboardApplet::paintEvent ( QPaintEvent* ) 150void ClipboardApplet::paintEvent ( QPaintEvent* )