author | mickeyl <mickeyl> | 2004-04-05 12:48:49 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-05 12:48:49 (UTC) |
commit | f1708be741dfb73ceaffb633b44093f2cb2b3d57 (patch) (unidiff) | |
tree | 0bdcab2ac6c5f0e5cac67eb58807a50bb79d82e0 /core/applets/screenshotapplet/screenshot.cpp | |
parent | 0b481957a2eebf28b05d9803780d05ad4232aa00 (diff) | |
download | opie-f1708be741dfb73ceaffb633b44093f2cb2b3d57.zip opie-f1708be741dfb73ceaffb633b44093f2cb2b3d57.tar.gz opie-f1708be741dfb73ceaffb633b44093f2cb2b3d57.tar.bz2 |
convert core/applets/* to Opie debug framework
Diffstat (limited to 'core/applets/screenshotapplet/screenshot.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/applets/screenshotapplet/screenshot.cpp | 522 |
1 files changed, 262 insertions, 260 deletions
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp index 9aa012a..938ea0c 100644 --- a/core/applets/screenshotapplet/screenshot.cpp +++ b/core/applets/screenshotapplet/screenshot.cpp | |||
@@ -15,11 +15,14 @@ | |||
15 | #include "screenshot.h" | 15 | #include "screenshot.h" |
16 | #include "inputDialog.h" | 16 | #include "inputDialog.h" |
17 | 17 | ||
18 | /* OPIE */ | 18 | /* OPIE */ |
19 | #include <opie2/odebug.h> | ||
19 | #include <opie2/otaskbarapplet.h> | 20 | #include <opie2/otaskbarapplet.h> |
20 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/applnk.h> | 22 | #include <qpe/applnk.h> |
23 | using namespace Opie::Core; | ||
24 | using namespace Opie::Ui; | ||
22 | 25 | ||
23 | /* QT */ | 26 | /* QT */ |
24 | #include <qlineedit.h> | 27 | #include <qlineedit.h> |
25 | #include <qdir.h> | 28 | #include <qdir.h> |
@@ -38,188 +41,187 @@ | |||
38 | #include <netdb.h> | 41 | #include <netdb.h> |
39 | #include <unistd.h> | 42 | #include <unistd.h> |
40 | 43 | ||
41 | /* XPM */ | 44 | /* XPM */ |
42 | using namespace Opie::Ui; | ||
43 | static char * snapshot_xpm[] = { | 45 | static char * snapshot_xpm[] = { |
44 | "32 32 177 2", | 46 | "32 32 177 2", |
45 | " c None", | 47 | " c None", |
46 | ". c #042045", | 48 | ". c #042045", |
47 | "+ c #0D2B47", | 49 | "+ c #0D2B47", |
48 | "@ c #0E325E", | 50 | "@ c #0E325E", |
49 | "# c #0D2E50", | 51 | "# c #0D2E50", |
50 | "$ c #0A1C32", | 52 | "$ c #0A1C32", |
51 | "% c #0F3A69", | 53 | "% c #0F3A69", |
52 | "& c #164680", | 54 | "& c #164680", |
53 | "* c #165EAE", | 55 | "* c #165EAE", |
54 | "= c #134D89", | 56 | "= c #134D89", |
55 | "- c #0A3A6E", | 57 | "- c #0A3A6E", |
56 | "; c #031024", | 58 | "; c #031024", |
57 | "> c #031B36", | 59 | "> c #031B36", |
58 | ", c #1A5EA3", | 60 | ", c #1A5EA3", |
59 | "' c #1862B1", | 61 | "' c #1862B1", |
60 | ") c #1866B9", | 62 | ") c #1866B9", |
61 | "! c #0F5AAC", | 63 | "! c #0F5AAC", |
62 | "~ c #0F56A8", | 64 | "~ c #0F56A8", |
63 | "{ c #0C4C96", | 65 | "{ c #0C4C96", |
64 | "] c #030918", | 66 | "] c #030918", |
65 | "^ c #060206", | 67 | "^ c #060206", |
66 | "/ c #20242C", | 68 | "/ c #20242C", |
67 | "( c #3E3B3B", | 69 | "( c #3E3B3B", |
68 | "_ c #186ABD", | 70 | "_ c #186ABD", |
69 | ": c #115EB3", | 71 | ": c #115EB3", |
70 | "< c #082644", | 72 | "< c #082644", |
71 | "[ c #222C38", | 73 | "[ c #222C38", |
72 | "} c #5A5859", | 74 | "} c #5A5859", |
73 | "| c #091921", | 75 | "| c #091921", |
74 | "1 c #1E7EDE", | 76 | "1 c #1E7EDE", |
75 | "2 c #1A7ADA", | 77 | "2 c #1A7ADA", |
76 | "3 c #1970CD", | 78 | "3 c #1970CD", |
77 | "4 c #1758A1", | 79 | "4 c #1758A1", |
78 | "5 c #0E529A", | 80 | "5 c #0E529A", |
79 | "6 c #094388", | 81 | "6 c #094388", |
80 | "7 c #22364E", | 82 | "7 c #22364E", |
81 | "8 c #384454", | 83 | "8 c #384454", |
82 | "9 c #04162C", | 84 | "9 c #04162C", |
83 | "0 c #123451", | 85 | "0 c #123451", |
84 | "a c #3296B4", | 86 | "a c #3296B4", |
85 | "b c #298AB1", | 87 | "b c #298AB1", |
86 | "c c #2484AC", | 88 | "c c #2484AC", |
87 | "d c #033D86", | 89 | "d c #033D86", |
88 | "e c #033677", | 90 | "e c #033677", |
89 | "f c #072C58", | 91 | "f c #072C58", |
90 | "g c #525862", | 92 | "g c #525862", |
91 | "h c #5E5E5E", | 93 | "h c #5E5E5E", |
92 | "i c #23492A", | 94 | "i c #23492A", |
93 | "j c #4FBD3F", | 95 | "j c #4FBD3F", |
94 | "k c #50B24C", | 96 | "k c #50B24C", |
95 | "l c #51C72E", | 97 | "l c #51C72E", |
96 | "m c #42C64A", | 98 | "m c #42C64A", |
97 | "n c #2686CA", | 99 | "n c #2686CA", |
98 | "o c #0B52A4", | 100 | "o c #0B52A4", |
99 | "p c #054A9A", | 101 | "p c #054A9A", |
100 | "q c #053B7C", | 102 | "q c #053B7C", |
101 | "r c #2B2325", | 103 | "r c #2B2325", |
102 | "s c #6E7070", | 104 | "s c #6E7070", |
103 | "t c #0D240E", | 105 | "t c #0D240E", |
104 | "u c #1E423E", | 106 | "u c #1E423E", |
105 | "v c #468ABE", | 107 | "v c #468ABE", |
106 | "w c #6A8AC2", | 108 | "w c #6A8AC2", |
107 | "x c #7EAA8E", | 109 | "x c #7EAA8E", |
108 | "y c #84BE4E", | 110 | "y c #84BE4E", |
109 | "z c #65C639", | 111 | "z c #65C639", |
110 | "A c #064EA0", | 112 | "A c #064EA0", |
111 | "B c #0A4DA0", | 113 | "B c #0A4DA0", |
112 | "C c #4E5242", | 114 | "C c #4E5242", |
113 | "D c #62362E", | 115 | "D c #62362E", |
114 | "E c #721A1A", | 116 | "E c #721A1A", |
115 | "F c #6E0A0A", | 117 | "F c #6E0A0A", |
116 | "G c #3E0E0E", | 118 | "G c #3E0E0E", |
117 | "H c #6AB85E", | 119 | "H c #6AB85E", |
118 | "I c #7E8ECA", | 120 | "I c #7E8ECA", |
119 | "J c #929CD4", | 121 | "J c #929CD4", |
120 | "K c #9EAECA", | 122 | "K c #9EAECA", |
121 | "L c #9EBEAE", | 123 | "L c #9EBEAE", |
122 | "M c #8EC26A", | 124 | "M c #8EC26A", |
123 | "N c #32A276", | 125 | "N c #32A276", |
124 | "O c #20518C", | 126 | "O c #20518C", |
125 | "P c #46566E", | 127 | "P c #46566E", |
126 | "Q c #614A51", | 128 | "Q c #614A51", |
127 | "R c #AE2A26", | 129 | "R c #AE2A26", |
128 | "S c #C41C1A", | 130 | "S c #C41C1A", |
129 | "T c #CE0A0A", | 131 | "T c #CE0A0A", |
130 | "U c #A60606", | 132 | "U c #A60606", |
131 | "V c #921616", | 133 | "V c #921616", |
132 | "W c #863735", | 134 | "W c #863735", |
133 | "X c #866A66", | 135 | "X c #866A66", |
134 | "Y c #9E9EA2", | 136 | "Y c #9E9EA2", |
135 | "Z c #1E5212", | 137 | "Z c #1E5212", |
136 | "` c #7EC652", | 138 | "` c #7EC652", |
137 | " .c #B2B2F2", | 139 | " . c #B2B2F2", |
138 | "..c #CACAF6", | 140 | ".. c #CACAF6", |
139 | "+.c #AECEC6", | 141 | "+. c #AECEC6", |
140 | "@.c #92CE72", | 142 | "@. c #92CE72", |
141 | "#.c #42AA86", | 143 | "#. c #42AA86", |
142 | "$.c #365E96", | 144 | "$. c #365E96", |
143 | "%.c #B82420", | 145 | "%. c #B82420", |
144 | "&.c #E20E0E", | 146 | "&. c #E20E0E", |
145 | "*.c #EF0E0B", | 147 | "*. c #EF0E0B", |
146 | "=.c #566A86", | 148 | "=. c #566A86", |
147 | "-.c #92929A", | 149 | "-. c #92929A", |
148 | ";.c #16260E", | 150 | ";. c #16260E", |
149 | ">.c #2E571A", | 151 | ">. c #2E571A", |
150 | ",.c #7ED64E", | 152 | ",. c #7ED64E", |
151 | "'.c #9ECEB2", | 153 | "'. c #9ECEB2", |
152 | ").c #C6D5EF", | 154 | "). c #C6D5EF", |
153 | "!.c #E2E0FE", | 155 | "!. c #E2E0FE", |
154 | "~.c #A2DE8A", | 156 | "~. c #A2DE8A", |
155 | "{.c #4AAA5B", | 157 | "{. c #4AAA5B", |
156 | "].c #2A6AB2", | 158 | "]. c #2A6AB2", |
157 | "^.c #9A7A6E", | 159 | "^. c #9A7A6E", |
158 | "/.c #D25A52", | 160 | "/. c #D25A52", |
159 | "(.c #F62626", | 161 | "(. c #F62626", |
160 | "_.c #FA0206", | 162 | "_. c #FA0206", |
161 | ":.c #DE1E16", | 163 | ":. c #DE1E16", |
162 | "<.c #B63A26", | 164 | "<. c #B63A26", |
163 | "[.c #865A2E", | 165 | "[. c #865A2E", |
164 | "}.c #26568E", | 166 | "}. c #26568E", |
165 | "|.c #435F7D", | 167 | "|. c #435F7D", |
166 | "1.c #7AE246", | 168 | "1. c #7AE246", |
167 | "2.c #96EA6E", | 169 | "2. c #96EA6E", |
168 | "3.c #BEEAAE", | 170 | "3. c #BEEAAE", |
169 | "4.c #D0EADC", | 171 | "4. c #D0EADC", |
170 | "5.c #B6CEFE", | 172 | "5. c #B6CEFE", |
171 | "6.c #9ADE8A", | 173 | "6. c #9ADE8A", |
172 | "7.c #2A609A", | 174 | "7. c #2A609A", |
173 | "8.c #7E623E", | 175 | "8. c #7E623E", |
174 | "9.c #CA7A72", | 176 | "9. c #CA7A72", |
175 | "0.c #F26E6E", | 177 | "0. c #F26E6E", |
176 | "a.c #FE5252", | 178 | "a. c #FE5252", |
177 | "b.c #FA3638", | 179 | "b. c #FA3638", |
178 | "c.c #DA2E28", | 180 | "c. c #DA2E28", |
179 | "d.c #9E3E3A", | 181 | "d. c #9E3E3A", |
180 | "e.c #3E7656", | 182 | "e. c #3E7656", |
181 | "f.c #76CB3A", | 183 | "f. c #76CB3A", |
182 | "g.c #90DE44", | 184 | "g. c #90DE44", |
183 | "h.c #A2EE6A", | 185 | "h. c #A2EE6A", |
184 | "i.c #9EEA9A", | 186 | "i. c #9EEA9A", |
185 | "j.c #92BEDE", | 187 | "j. c #92BEDE", |
186 | "k.c #7ADA7E", | 188 | "k. c #7ADA7E", |
187 | "l.c #5ECE52", | 189 | "l. c #5ECE52", |
188 | "m.c #6A5E52", | 190 | "m. c #6A5E52", |
189 | "n.c #A83238", | 191 | "n. c #A83238", |
190 | "o.c #FA5656", | 192 | "o. c #FA5656", |
191 | "p.c #F29A92", | 193 | "p. c #F29A92", |
192 | "q.c #D29E92", | 194 | "q. c #D29E92", |
193 | "r.c #8A7A62", | 195 | "r. c #8A7A62", |
194 | "s.c #05336B", | 196 | "s. c #05336B", |
195 | "t.c #59C631", | 197 | "t. c #59C631", |
196 | "u.c #8AD23A", | 198 | "u. c #8AD23A", |
197 | "v.c #66E242", | 199 | "v. c #66E242", |
198 | "w.c #1D6FC1", | 200 | "w. c #1D6FC1", |
199 | "x.c #E61212", | 201 | "x. c #E61212", |
200 | "y.c #CA261E", | 202 | "y. c #CA261E", |
201 | "z.c #5A763E", | 203 | "z. c #5A763E", |
202 | "A.c #1E6E9A", | 204 | "A. c #1E6E9A", |
203 | "B.c #023272", | 205 | "B. c #023272", |
204 | "C.c #329696", | 206 | "C. c #329696", |
205 | "D.c #2074B6", | 207 | "D. c #2074B6", |
206 | "E.c #3E4E76", | 208 | "E. c #3E4E76", |
207 | "F.c #5A525E", | 209 | "F. c #5A525E", |
208 | "G.c #425868", | 210 | "G. c #425868", |
209 | "H.c #04448E", | 211 | "H. c #04448E", |
210 | "I.c #28828A", | 212 | "I. c #28828A", |
211 | "J.c #2D8593", | 213 | "J. c #2D8593", |
212 | "K.c #12427A", | 214 | "K. c #12427A", |
213 | "L.c #054696", | 215 | "L. c #054696", |
214 | "M.c #042B5E", | 216 | "M. c #042B5E", |
215 | "N.c #134F95", | 217 | "N. c #134F95", |
216 | "O.c #1E6ABB", | 218 | "O. c #1E6ABB", |
217 | "P.c #1A5E96", | 219 | "P. c #1A5E96", |
218 | "Q.c #022E67", | 220 | "Q. c #022E67", |
219 | "R.c #0C3E7C", | 221 | "R. c #0C3E7C", |
220 | "S.c #023E8A", | 222 | "S. c #023E8A", |
221 | "T.c #021A3E", | 223 | "T. c #021A3E", |
222 | " ", | 224 | " ", |
223 | " ", | 225 | " ", |
224 | " ", | 226 | " ", |
225 | " . + @ # + ", | 227 | " . + @ # + ", |
@@ -298,9 +300,9 @@ ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) | |||
298 | setFocusPolicy ( QWidget::NoFocus ); | 300 | setFocusPolicy ( QWidget::NoFocus ); |
299 | 301 | ||
300 | 302 | ||
301 | grabTimer = new QTimer ( this, "grab timer"); | 303 | grabTimer = new QTimer ( this, "grab timer"); |
302 | 304 | ||
303 | connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab())); | 305 | connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab())); |
304 | connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab())); | 306 | connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab())); |
305 | connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap())); | 307 | connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap())); |
306 | } | 308 | } |
@@ -361,15 +363,15 @@ void ScreenshotControl::savePixmap() | |||
361 | 363 | ||
362 | if (fileName.right(3) != "png") | 364 | if (fileName.right(3) != "png") |
363 | fileName = fileName + ".png"; | 365 | fileName = fileName + ".png"; |
364 | lnk.setFile(fileName); //sets File property | 366 | lnk.setFile(fileName); //sets File property |
365 | qDebug("saving file " + fileName); | 367 | odebug << "saving file " + fileName << oendl; |
366 | snapshot.save( fileName, "PNG"); | 368 | snapshot.save( fileName, "PNG"); |
367 | QFileInfo fi( fileName); | 369 | QFileInfo fi( fileName); |
368 | lnk.setName( fi.fileName()); //sets file name | 370 | lnk.setName( fi.fileName()); //sets file name |
369 | 371 | ||
370 | if (!lnk.writeLink()) | 372 | if (!lnk.writeLink()) |
371 | qDebug("Writing doclink did not work"); | 373 | odebug << "Writing doclink did not work" << oendl; |
372 | } | 374 | } |
373 | else { | 375 | else { |
374 | 376 | ||
375 | fileName = "sc_" + QDateTime::currentDateTime().toString(); | 377 | fileName = "sc_" + QDateTime::currentDateTime().toString(); |
@@ -379,109 +381,109 @@ void ScreenshotControl::savePixmap() | |||
379 | fileName.replace(QRegExp(","), ""); | 381 | fileName.replace(QRegExp(","), ""); |
380 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; | 382 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; |
381 | 383 | ||
382 | if ( !QDir( dirName).exists() ) { | 384 | if ( !QDir( dirName).exists() ) { |
383 | qDebug("making dir " + dirName); | 385 | odebug << "making dir " + dirName << oendl; |
384 | QString msg = "mkdir -p " + dirName; | 386 | QString msg = "mkdir -p " + dirName; |
385 | system(msg.latin1()); | 387 | system(msg.latin1()); |
386 | } | 388 | } |
387 | fileName = dirName + fileName; | 389 | fileName = dirName + fileName; |
388 | if (fileName.right(3) != "png") | 390 | if (fileName.right(3) != "png") |
389 | fileName = fileName + ".png"; | 391 | fileName = fileName + ".png"; |
390 | lnk.setFile(fileName); //sets File property | 392 | lnk.setFile(fileName); //sets File property |
391 | qDebug("saving file " + fileName); | 393 | odebug << "saving file " + fileName << oendl; |
392 | snapshot.save( fileName, "PNG"); | 394 | snapshot.save( fileName, "PNG"); |
393 | QFileInfo fi( fileName); | 395 | QFileInfo fi( fileName); |
394 | lnk.setName( fi.fileName()); //sets file name | 396 | lnk.setName( fi.fileName()); //sets file name |
395 | 397 | ||
396 | if (!lnk.writeLink()) | 398 | if (!lnk.writeLink()) |
397 | qDebug("Writing doclink did not work"); | 399 | odebug << "Writing doclink did not work" << oendl; |
398 | 400 | ||
399 | } | 401 | } |
400 | 402 | ||
401 | QPEApplication::beep(); | 403 | QPEApplication::beep(); |
402 | } | 404 | } |
403 | 405 | ||
404 | void ScreenshotControl::performGrab() | 406 | void ScreenshotControl::performGrab() |
405 | { | 407 | { |
406 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); | 408 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); |
407 | 409 | ||
408 | if (buttonPushed == 1) { | 410 | if (buttonPushed == 1) { |
409 | qDebug("grabbing screen"); | 411 | odebug << "grabbing screen" << oendl; |
410 | grabTimer->stop(); | 412 | grabTimer->stop(); |
411 | show(); | 413 | show(); |
412 | qApp->processEvents(); | 414 | qApp->processEvents(); |
413 | savePixmap(); | 415 | savePixmap(); |
414 | } else { | 416 | } else { |
415 | grabTimer->stop(); | 417 | grabTimer->stop(); |
416 | 418 | ||
417 | struct sockaddr_in raddr; | 419 | struct sockaddr_in raddr; |
418 | struct hostent *rhost_info; | 420 | struct hostent *rhost_info; |
419 | int sock = -1; | 421 | int sock = -1; |
420 | bool ok = false; | 422 | bool ok = false; |
421 | 423 | ||
422 | QString displayEnv = getenv("QWS_DISPLAY"); | 424 | QString displayEnv = getenv("QWS_DISPLAY"); |
423 | qDebug(displayEnv); | 425 | odebug << displayEnv << oendl; |
424 | 426 | ||
425 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { | 427 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { |
426 | 428 | ||
427 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { | 429 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { |
428 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); | 430 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); |
429 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); | 431 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); |
430 | raddr. sin_family = rhost_info-> h_addrtype; | 432 | raddr. sin_family = rhost_info-> h_addrtype; |
431 | raddr. sin_port = htons ( SCAP_port ); | 433 | raddr. sin_port = htons ( SCAP_port ); |
432 | 434 | ||
433 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { | 435 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { |
434 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { | 436 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { |
435 | 437 | ||
436 | QString header; | 438 | QString header; |
437 | 439 | ||
438 | QPixmap pix; | 440 | QPixmap pix; |
439 | 441 | ||
440 | QString SCAP_model=""; | 442 | QString SCAP_model=""; |
441 | #warning FIXME: model string should be filled with actual device model | 443 | #warning FIXME: model string should be filled with actual device model |
442 | if( snapshot.width() > 320) | 444 | if( snapshot.width() > 320) |
443 | SCAP_model ="Corgi"; | 445 | SCAP_model ="Corgi"; |
444 | 446 | ||
445 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! | 447 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! |
446 | pix = snapshot.xForm(QWMatrix().rotate(90)); | 448 | pix = snapshot.xForm(QWMatrix().rotate(90)); |
447 | } else | 449 | } else |
448 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); | 450 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); |
449 | 451 | ||
450 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it | 452 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it |
451 | 453 | ||
452 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user | 454 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user |
453 | "Content-length: %3\n" // 3: content length | 455 | "Content-length: %3\n" // 3: content length |
454 | "Content-Type: image/png\n" | 456 | "Content-Type: image/png\n" |
455 | "Host: %4\n" // 4: scap host | 457 | "Host: %4\n" // 4: scap host |
456 | "\n"; | 458 | "\n"; |
457 | 459 | ||
458 | 460 | ||
459 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); | 461 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); |
460 | qDebug(header); | 462 | odebug << header << oendl; |
461 | 463 | ||
462 | if ( !pix.isNull() ) { | 464 | if ( !pix.isNull() ) { |
463 | const char *ascii = header.latin1( ); | 465 | const char *ascii = header.latin1( ); |
464 | uint ascii_len = ::strlen( ascii ); | 466 | uint ascii_len = ::strlen( ascii ); |
465 | ::write ( sock, ascii, ascii_len ); | 467 | ::write ( sock, ascii, ascii_len ); |
466 | ::write ( sock, img.bits(), img.numBytes() ); | 468 | ::write ( sock, img.bits(), img.numBytes() ); |
467 | 469 | ||
468 | ok = true; | 470 | ok = true; |
469 | } | 471 | } |
470 | } | 472 | } |
471 | ::close ( sock ); | 473 | ::close ( sock ); |
472 | } | 474 | } |
473 | } | 475 | } |
474 | if ( ok ) { | 476 | if ( ok ) { |
475 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); | 477 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); |
476 | } else { | 478 | } else { |
477 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); | 479 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); |
478 | } | 480 | } |
479 | } else { | 481 | } else { |
480 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); | 482 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); |
481 | } | 483 | } |
482 | } | 484 | } |
483 | 485 | ||
484 | } | 486 | } |
485 | 487 | ||
486 | 488 | ||
487 | 489 | ||
@@ -489,9 +491,9 @@ void ScreenshotControl::performGrab() | |||
489 | 491 | ||
490 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) | 492 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) |
491 | : QWidget( parent, name ) | 493 | : QWidget( parent, name ) |
492 | { | 494 | { |
493 | setFixedWidth( AppLnk::smallIconSize()); | 495 | setFixedWidth( AppLnk::smallIconSize()); |
494 | 496 | ||
495 | QImage img = (const char **)snapshot_xpm; | 497 | QImage img = (const char **)snapshot_xpm; |
496 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); | 498 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); |
497 | m_icon.convertFromImage(img); | 499 | m_icon.convertFromImage(img); |
@@ -513,29 +515,29 @@ void ScreenshotApplet::mousePressEvent( QMouseEvent *) | |||
513 | 515 | ||
514 | // windowPosX is the windows position centered above the applets icon. | 516 | // windowPosX is the windows position centered above the applets icon. |
515 | // If the icon is near the edge of the screen, the window would leave the visible area | 517 | // If the icon is near the edge of the screen, the window would leave the visible area |
516 | // so we check the position against the screen width and correct the difference if needed | 518 | // so we check the position against the screen width and correct the difference if needed |
517 | 519 | ||
518 | int screenWidth = qApp->desktop()->width(); | 520 | int screenWidth = qApp->desktop()->width(); |
519 | int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; | 521 | int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; |
520 | int ZwindowPosX, XwindowPosX; | 522 | int ZwindowPosX, XwindowPosX; |
521 | 523 | ||
522 | // the window would be placed beyond the screen wich doesn't look tooo good | 524 | // the window would be placed beyond the screen wich doesn't look tooo good |
523 | if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { | 525 | if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { |
524 | XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; | 526 | XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; |
525 | ZwindowPosX = windowPosX - XwindowPosX - 1; | 527 | ZwindowPosX = windowPosX - XwindowPosX - 1; |
526 | } else { | 528 | } else { |
527 | ZwindowPosX = windowPosX; | 529 | ZwindowPosX = windowPosX; |
528 | } | 530 | } |
529 | 531 | ||
530 | sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); | 532 | sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); |
531 | sc-> show ( ); | 533 | sc-> show ( ); |
532 | } | 534 | } |
533 | 535 | ||
534 | void ScreenshotApplet::paintEvent( QPaintEvent* ) | 536 | void ScreenshotApplet::paintEvent( QPaintEvent* ) |
535 | { | 537 | { |
536 | QPainter p ( this ); | 538 | QPainter p ( this ); |
537 | p.drawPixmap( 0,0, m_icon ); | 539 | p.drawPixmap( 0,0, m_icon ); |
538 | } | 540 | } |
539 | 541 | ||
540 | 542 | ||
541 | EXPORT_OPIE_APPLET_v1( ScreenshotApplet ) | 543 | EXPORT_OPIE_APPLET_v1( ScreenshotApplet ) |