summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-03-09 10:05:26 (UTC)
committer harlekin <harlekin>2003-03-09 10:05:26 (UTC)
commitc45c38135a5bdc5acf2a73b5086a21e5331fcbbf (patch) (unidiff)
tree6b247100b120d993c237b890202e4dbb490416bf
parent8357b1104375ea0cb6b9d6ed1b8975f090745d60 (diff)
downloadopie-c45c38135a5bdc5acf2a73b5086a21e5331fcbbf.zip
opie-c45c38135a5bdc5acf2a73b5086a21e5331fcbbf.tar.gz
opie-c45c38135a5bdc5acf2a73b5086a21e5331fcbbf.tar.bz2
new inlined icon
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/clipboardapplet/clipboard.cpp315
1 files changed, 209 insertions, 106 deletions
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp
index 3099a84..b83e16e 100644
--- a/core/applets/clipboardapplet/clipboard.cpp
+++ b/core/applets/clipboardapplet/clipboard.cpp
@@ -12,244 +12,347 @@
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 <qpe/resource.h> 23#include <qpe/resource.h>
24 24
25#include <qpainter.h> 25#include <qpainter.h>
26#include <qpopupmenu.h> 26#include <qpopupmenu.h>
27#include <qwindowsystem_qws.h> 27#include <qwindowsystem_qws.h>
28#include <qapplication.h> 28#include <qapplication.h>
29#include <qclipboard.h> 29#include <qclipboard.h>
30#include <qtimer.h> 30#include <qtimer.h>
31 31
32//=========================================================================== 32//===========================================================================
33 33
34/* XPM */ 34/* XPM */
35static const char * paste_xpm[] = { 35static const char * paste_xpm[] = {
36"14 16 64 1", 36"14 16 167 2",
37 " c None", 37 " c None",
38 ".c #020202", 38 ". c #96A0AC",
39 "+c #867616", 39 "+ c #9BB0D4",
40 "@c #A69A42", 40 "@ c #5E7095",
41 "#c #BAB676", 41 "# c #F1CA79",
42 "$c #060606", 42 "$ c #EFC56D",
43 "%c #EAD2AA", 43 "% c #C9AF76",
44 "&c #F6F6DA", 44 "& c #9FABBA",
45 "*c #222212", 45 "* c #AEBFDD",
46 "=c #86761E", 46 "= c #8899BA",
47 "-c #868686", 47 "- c #726E68",
48 ";c #5A5202", 48 "; c #D19A33",
49 ">c #8A7E2E", 49 "> c #DA9524",
50 ",c #2C2C2C", 50 ", c #EFC065",
51 "'c #9A9A9A", 51 "' c #F3DDA6",
52 ")c #F6EADA", 52 ") c #E9D192",
53 "!c #AAA262", 53 "! c #ADA895",
54 "~c #323232", 54 "~ c #9AA8BF",
55 "{c #726A32", 55 "{ c #B4C2D8",
56 "]c #6E6E6E", 56 "] c #AEBED7",
57 "^c #C2B69E", 57 "^ c #797E8A",
58 "/c #9E9E9E", 58 "/ c #B78534",
59 "(c #EED6BA", 59 "( c #DE8516",
60 "_c #F2DEC2", 60 "_ c #8A4308",
61 ":c #D2CE8E", 61 ": c #F0C470",
62 "<c #3A3A3A", 62 "< c #F5EFD3",
63 "[c #EACAA2", 63 "[ c #DFD7B4",
64 "}c #3E3E3E", 64 "} c #8F9BA6",
65 "|c #727272", 65 "| c #7C8BA3",
66 "1c #CECECE", 66 "1 c #808A9A",
67 "2c #929292", 67 "2 c #828892",
68 "3c #4A462A", 68 "3 c #727582",
69 "4c #424242", 69 "4 c #9A6435",
70 "5c #666666", 70 "5 c #F37004",
71 "6c #C2AE96", 71 "6 c #A24104",
72 "7c #767676", 72 "7 c #F0C36E",
73 "8c #D6D6D6", 73 "8 c #F4EBCC",
74 "9c #C2C2C2", 74 "9 c #ECDCAF",
75 "0c #BFA681", 75 "0 c #CDC29B",
76 "ac #1E1E1E", 76 "a c #C1B486",
77 "bc #FAF6F3", 77 "b c #C3A86B",
78 "cc #AEAEAE", 78 "c c #B8924A",
79 "dc #C29A6A", 79 "d c #B17B31",
80 "ec #FEFEFE", 80 "e c #C66C1C",
81 "fc #B6B6B6", 81 "f c #DE6610",
82 "gc #7E7E7E", 82 "g c #944311",
83 "hc #FAF2E6", 83 "h c #F3E8C6",
84 "ic #8E8E8E", 84 "i c #F3E0AB",
85 "jc #C6BCAE", 85 "j c #F2DB9B",
86 "kc #DEDEDE", 86 "k c #F1D382",
87 "lc #BEBEBE", 87 "l c #F0C056",
88 "mc #464646", 88 "m c #CCA354",
89 "nc #BEAE92", 89 "n c #B7B09D",
90 "oc #262626", 90 "o c #C2A898",
91 "pc #F2E2CE", 91 "p c #BCA298",
92 "qc #C2A175", 92 "q c #9A959F",
93 "rc #CACACA", 93 "r c #526C8F",
94 "sc #969696", 94 "s c #F3E4B9",
95 "tc #8A8A8A", 95 "t c #F3DA99",
96 "uc #828282", 96 "u c #F4D78A",
97 "vc #6A6A6A", 97 "v c #F5CA6A",
98 "wc #BEB6AE", 98 "w c #F4B032",
99 "xc #E2E0E0", 99 "x c #C19A56",
100 "yc #7A7A7A", 100 "y c #C2D7EA",
101" *{>; ", 101 "z c #C0D0E7",
102" }}}@e:!;}}} ", 102 "A c #B0C6E8",
103"<x8=&:#@+;ll, ", 103 "B c #A6C1EB",
104"}k/=;;3}337|o ", 104 "C c #6AA1E3",
105"<k's24444m45o ", 105 "D c #F0C36D",
106"}8'ss4xkkk]}a ", 106 "E c #F3E2B0",
107"<1s224keee|b4 ", 107 "F c #F3D891",
108"}r2itmkeee]]44", 108 "G c #F3CF7A",
109"<9iitmkeeehkw.", 109 "H c #F4BC4C",
110"<lt-u4keeb)pn.", 110 "I c #F3A51C",
111"<fu-umkebhp(0.", 111 "J c #BC9758",
112"<cugg4kbh)_(q.", 112 "K c #CAE4FE",
113"<cyyymk))p(%q.", 113 "L c #C5DDFB",
114",5vvv4k)p_%[q.", 114 "M c #B5D3FB",
115" ...$mljnn0qd.", 115 "N c #A8CCFC",
116" 4.......,"}; 116 "O c #63A6F6",
117 "P c #2180E3",
118 "Q c #F3E1AE",
119 "R c #F3D488",
120 "S c #F3C664",
121 "T c #F4B63C",
122 "U c #F2A61C",
123 "V c #BC9A5C",
124 "W c #CCE6FE",
125 "X c #C8DEFB",
126 "Y c #B9D6FB",
127 "Z c #B2D0FC",
128 "` c #84B6FB",
129 " .c #479DFB",
130 "..c #F3DFAC",
131 "+.c #F3CC76",
132 "@.c #F3BE52",
133 "#.c #F4B53A",
134 "$.c #F2AB24",
135 "%.c #BC9D61",
136 "&.c #CBE5FE",
137 "*.c #C3DBFB",
138 "=.c #B0D0FB",
139 "-.c #ACCBFC",
140 ";.c #A0C3FD",
141 ">.c #6EB1FF",
142 ",.c #F3DCA4",
143 "'.c #F3C35F",
144 ").c #F3BC4A",
145 "!.c #F3AC26",
146 "~.c #BC9E63",
147 "{.c #CAE4FF",
148 "].c #BCD7FB",
149 "^.c #A3C7FB",
150 "/.c #94BCFB",
151 "(.c #92BAFB",
152 "_.c #74B4FE",
153 ":.c #F1C46D",
154 "<.c #F4D99A",
155 "[.c #F4BE52",
156 "}.c #F4BB47",
157 "|.c #F4B63D",
158 "1.c #F4AD27",
159 "2.c #BC9E64",
160 "3.c #CAE5FF",
161 "4.c #BAD6FB",
162 "5.c #A1C5FB",
163 "6.c #9AC1FB",
164 "7.c #9DC1FC",
165 "8.c #7CBAFE",
166 "9.c #F5C870",
167 "0.c #F8DC9B",
168 "a.c #F8C65C",
169 "b.c #F8C252",
170 "c.c #F8BE49",
171 "d.c #F7B534",
172 "e.c #BFA46C",
173 "f.c #CBE4FF",
174 "g.c #B7D3FB",
175 "h.c #A4C6FB",
176 "i.c #A0C4FB",
177 "j.c #A2C4FC",
178 "k.c #80BDFF",
179 "l.c #BC9250",
180 "m.c #BF9461",
181 "n.c #BD8944",
182 "o.c #BD863D",
183 "p.c #BD8438",
184 "q.c #BC7C2C",
185 "r.c #988269",
186 "s.c #C5E7FF",
187 "t.c #C0DDFE",
188 "u.c #B2D4FE",
189 "v.c #ACD1FE",
190 "w.c #ACD0FE",
191 "x.c #7DC0FF",
192 "y.c #805835",
193 "z.c #754D26",
194 "A.c #754C22",
195 "B.c #754B20",
196 "C.c #75471A",
197 "D.c #534D4F",
198 "E.c #619BCE",
199 "F.c #6295C8",
200 "G.c #5C91C8",
201 "H.c #598FC8",
202 "I.c #588FC8",
203 "J.c #3E87CD",
204" . + @ ",
205" # $ % & * = - ; > ",
206", ' ) ! ~ { ] ^ / ( _ ",
207": < [ } | 1 2 3 4 5 6 ",
208"7 8 9 0 a b c d e f g ",
209"7 h i j k l m n o p q r ",
210"7 s t u v w x y z A B C ",
211"D E F G H I J K L M N O P ",
212"D Q R S T U V W X Y Z ` . ",
213"D ..+.@.#.$.%.&.*.=.-.;.>. ",
214"7 ,.'.).T !.~.{.].^./.(._. ",
215":.<.[.}.|.1.2.3.4.5.6.7.8. ",
216"9.0.a.b.c.d.e.f.g.h.i.j.k. ",
217"l.m.n.o.p.q.r.s.t.u.v.w.x. ",
218" y.z.A.B.C.D.E.F.G.H.I.J. ",
219" "};
117 220
118 221
119ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) 222ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name )
120{ 223{
121 setFixedWidth ( 14 ); 224 setFixedWidth ( 14 );
122 setFixedHeight ( 18 ); 225 setFixedHeight ( 18 );
123 m_clipboardPixmap = QPixmap ( paste_xpm ); 226 m_clipboardPixmap = QPixmap ( paste_xpm );
124 227
125 m_timer = new QTimer ( this ); 228 m_timer = new QTimer ( this );
126 229
127 connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( ))); 230 connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( )));
128 connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( newData ( ))); 231 connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( newData ( )));
129 connect ( qApp, SIGNAL( aboutToQuit ( )), this, SLOT( shutdown ( ))); 232 connect ( qApp, SIGNAL( aboutToQuit ( )), this, SLOT( shutdown ( )));
130 233
131 m_menu = 0; 234 m_menu = 0;
132 m_dirty = true; 235 m_dirty = true;
133 m_lasttext = QString::null; 236 m_lasttext = QString::null;
134 237
135 m_timer-> start ( 0, true ); 238 m_timer-> start ( 0, true );
136} 239}
137 240
138ClipboardApplet::~ClipboardApplet ( ) 241ClipboardApplet::~ClipboardApplet ( )
139{ 242{
140} 243}
141 244
142void ClipboardApplet::shutdown ( ) 245void ClipboardApplet::shutdown ( )
143{ 246{
144 // the timer has to be stopped, or Qt/E will hang on quit() 247 // the timer has to be stopped, or Qt/E will hang on quit()
145 // see launcher/desktop.cpp 248 // see launcher/desktop.cpp
146 249
147 m_timer-> stop ( ); 250 m_timer-> stop ( );
148} 251}
149 252
150void ClipboardApplet::mousePressEvent ( QMouseEvent *) 253void ClipboardApplet::mousePressEvent ( QMouseEvent *)
151{ 254{
152 if ( m_dirty ) { 255 if ( m_dirty ) {
153 delete m_menu; 256 delete m_menu;
154 257
155 m_menu = new QPopupMenu ( this ); 258 m_menu = new QPopupMenu ( this );
156 m_menu-> setCheckable ( true ); 259 m_menu-> setCheckable ( true );
157 260
158 if ( m_history. count ( )) { 261 if ( m_history. count ( )) {
159 for ( unsigned int i = 0; i < m_history. count ( ); i++ ) { 262 for ( unsigned int i = 0; i < m_history. count ( ); i++ ) {
160 QString str = m_history [i]; 263 QString str = m_history [i];
161 264
162 if ( str. length ( ) > 20 ) 265 if ( str. length ( ) > 20 )
163 str = str. left ( 20 ) + "..."; 266 str = str. left ( 20 ) + "...";
164 267
165 m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i ); 268 m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i );
166 m_menu-> setItemChecked ( i, false ); 269 m_menu-> setItemChecked ( i, false );
167 } 270 }
168 m_menu-> setItemChecked ( m_history. count ( ) - 1, true ); 271 m_menu-> setItemChecked ( m_history. count ( ) - 1, true );
169 m_menu-> insertSeparator ( ); 272 m_menu-> insertSeparator ( );
170 } 273 }
171 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 ); 274 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 );
172 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 ); 275 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 );
173 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 ); 276 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 );
174 277
175 connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int ))); 278 connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int )));
176 279
177 m_dirty = false; 280 m_dirty = false;
178 } 281 }
179 QPoint p = mapToGlobal ( QPoint ( 0, 0 )); 282 QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
180 QSize s = m_menu-> sizeHint ( ); 283 QSize s = m_menu-> sizeHint ( );
181 284
182 m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); 285 m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )));
183} 286}
184 287
185void ClipboardApplet::action(int id) 288void ClipboardApplet::action(int id)
186{ 289{
187 ushort unicode = 0; 290 ushort unicode = 0;
188 int scan = 0; 291 int scan = 0;
189 292
190 switch ( id ) { 293 switch ( id ) {
191 case 100: 294 case 100:
192 unicode = 'X' - '@'; 295 unicode = 'X' - '@';
193 scan = Key_X; // Cut 296 scan = Key_X; // Cut
194 break; 297 break;
195 case 101: 298 case 101:
196 unicode = 'C' - '@'; 299 unicode = 'C' - '@';
197 scan = Key_C; // Copy 300 scan = Key_C; // Copy
198 break; 301 break;
199 case 102: 302 case 102:
200 unicode = 'V' - '@'; 303 unicode = 'V' - '@';
201 scan = Key_V; // Paste 304 scan = Key_V; // Paste
202 break; 305 break;
203 306
204 default: 307 default:
205 if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) { 308 if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) {
206 QApplication::clipboard ( )-> setText ( m_history [id] ); 309 QApplication::clipboard ( )-> setText ( m_history [id] );
207 310
208 for ( uint i = 0; i < m_history. count ( ); i++ ) 311 for ( uint i = 0; i < m_history. count ( ); i++ )
209 m_menu-> setItemChecked ( i, i == uint( id )); 312 m_menu-> setItemChecked ( i, i == uint( id ));
210 313
211 unicode = 'V' - '@'; 314 unicode = 'V' - '@';
212 scan = Key_V; 315 scan = Key_V;
213 } 316 }
214 break; 317 break;
215 } 318 }
216 319
217 if ( scan ) { 320 if ( scan ) {
218 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false ); 321 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false );
219 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false ); 322 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false );
220 } 323 }
221} 324}
222 325
223void ClipboardApplet::paintEvent ( QPaintEvent* ) 326void ClipboardApplet::paintEvent ( QPaintEvent* )
224{ 327{
225 QPainter p ( this ); 328 QPainter p ( this );
226 p. drawPixmap ( 0, 1, m_clipboardPixmap ); 329 p. drawPixmap ( 0, 1, m_clipboardPixmap );
227} 330}
228 331
229void ClipboardApplet::newData ( ) 332void ClipboardApplet::newData ( )
230{ 333{
231 static bool excllock = false; 334 static bool excllock = false;
232 335
233 if ( excllock ) 336 if ( excllock )
234 return; 337 return;
235 else 338 else
236 excllock = true; 339 excllock = true;
237 340
238 m_timer-> stop ( ); 341 m_timer-> stop ( );
239 342
240 QCString type = "plain"; 343 QCString type = "plain";
241 QString txt = QApplication::clipboard ( )-> text ( type ); 344 QString txt = QApplication::clipboard ( )-> text ( type );
242 345
243 if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) { 346 if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) {
244 m_history. append ( txt ); 347 m_history. append ( txt );
245 348
246 if ( m_history. count ( ) > 5 ) 349 if ( m_history. count ( ) > 5 )
247 m_history. remove ( m_history. begin ( )); 350 m_history. remove ( m_history. begin ( ));
248 351
249 m_dirty = true; 352 m_dirty = true;
250 } 353 }
251 354
252 m_timer-> start ( 1500, true ); 355 m_timer-> start ( 1500, true );
253 356
254 excllock = false; 357 excllock = false;
255} 358}