-rw-r--r-- | core/applets/screenshotapplet/screenshot.cpp | 27 | ||||
-rw-r--r-- | core/applets/screenshotapplet/screenshot.h | 11 |
2 files changed, 31 insertions, 7 deletions
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp index 938ea0c..042f390 100644 --- a/core/applets/screenshotapplet/screenshot.cpp +++ b/core/applets/screenshotapplet/screenshot.cpp | |||
@@ -1,120 +1,120 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com | 2 | ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | 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/odebug.h> |
20 | #include <opie2/otaskbarapplet.h> | 20 | #include <opie2/otaskbarapplet.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/applnk.h> | 22 | #include <qpe/applnk.h> |
23 | using namespace Opie::Core; | 23 | #include <qpe/qcopenvelope_qws.h> |
24 | using namespace Opie::Ui; | 24 | |
25 | 25 | ||
26 | /* QT */ | 26 | /* QT */ |
27 | #include <qlineedit.h> | 27 | #include <qlineedit.h> |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qpainter.h> | 31 | #include <qpainter.h> |
32 | #include <qspinbox.h> | 32 | #include <qspinbox.h> |
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | 36 | ||
37 | /* STD */ | 37 | /* STD */ |
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | #include <sys/socket.h> | 39 | #include <sys/socket.h> |
40 | #include <netinet/in.h> | 40 | #include <netinet/in.h> |
41 | #include <netdb.h> | 41 | #include <netdb.h> |
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | 43 | ||
44 | /* XPM */ | 44 | /* XPM */ |
45 | static char * snapshot_xpm[] = { | 45 | static char * snapshot_xpm[] = { |
46 | "32 32 177 2", | 46 | "32 32 177 2", |
47 | " c None", | 47 | " c None", |
48 | ". c #042045", | 48 | ". c #042045", |
49 | "+ c #0D2B47", | 49 | "+ c #0D2B47", |
50 | "@ c #0E325E", | 50 | "@ c #0E325E", |
51 | "# c #0D2E50", | 51 | "# c #0D2E50", |
52 | "$ c #0A1C32", | 52 | "$ c #0A1C32", |
53 | "% c #0F3A69", | 53 | "% c #0F3A69", |
54 | "& c #164680", | 54 | "& c #164680", |
55 | "* c #165EAE", | 55 | "* c #165EAE", |
56 | "= c #134D89", | 56 | "= c #134D89", |
57 | "- c #0A3A6E", | 57 | "- c #0A3A6E", |
58 | "; c #031024", | 58 | "; c #031024", |
59 | "> c #031B36", | 59 | "> c #031B36", |
60 | ", c #1A5EA3", | 60 | ", c #1A5EA3", |
61 | "' c #1862B1", | 61 | "' c #1862B1", |
62 | ") c #1866B9", | 62 | ") c #1866B9", |
63 | "! c #0F5AAC", | 63 | "! c #0F5AAC", |
64 | "~ c #0F56A8", | 64 | "~ c #0F56A8", |
65 | "{ c #0C4C96", | 65 | "{ c #0C4C96", |
66 | "] c #030918", | 66 | "] c #030918", |
67 | "^ c #060206", | 67 | "^ c #060206", |
68 | "/ c #20242C", | 68 | "/ c #20242C", |
69 | "( c #3E3B3B", | 69 | "( c #3E3B3B", |
70 | "_ c #186ABD", | 70 | "_ c #186ABD", |
71 | ": c #115EB3", | 71 | ": c #115EB3", |
72 | "< c #082644", | 72 | "< c #082644", |
73 | "[ c #222C38", | 73 | "[ c #222C38", |
74 | "} c #5A5859", | 74 | "} c #5A5859", |
75 | "| c #091921", | 75 | "| c #091921", |
76 | "1 c #1E7EDE", | 76 | "1 c #1E7EDE", |
77 | "2 c #1A7ADA", | 77 | "2 c #1A7ADA", |
78 | "3 c #1970CD", | 78 | "3 c #1970CD", |
79 | "4 c #1758A1", | 79 | "4 c #1758A1", |
80 | "5 c #0E529A", | 80 | "5 c #0E529A", |
81 | "6 c #094388", | 81 | "6 c #094388", |
82 | "7 c #22364E", | 82 | "7 c #22364E", |
83 | "8 c #384454", | 83 | "8 c #384454", |
84 | "9 c #04162C", | 84 | "9 c #04162C", |
85 | "0 c #123451", | 85 | "0 c #123451", |
86 | "a c #3296B4", | 86 | "a c #3296B4", |
87 | "b c #298AB1", | 87 | "b c #298AB1", |
88 | "c c #2484AC", | 88 | "c c #2484AC", |
89 | "d c #033D86", | 89 | "d c #033D86", |
90 | "e c #033677", | 90 | "e c #033677", |
91 | "f c #072C58", | 91 | "f c #072C58", |
92 | "g c #525862", | 92 | "g c #525862", |
93 | "h c #5E5E5E", | 93 | "h c #5E5E5E", |
94 | "i c #23492A", | 94 | "i c #23492A", |
95 | "j c #4FBD3F", | 95 | "j c #4FBD3F", |
96 | "k c #50B24C", | 96 | "k c #50B24C", |
97 | "l c #51C72E", | 97 | "l c #51C72E", |
98 | "m c #42C64A", | 98 | "m c #42C64A", |
99 | "n c #2686CA", | 99 | "n c #2686CA", |
100 | "o c #0B52A4", | 100 | "o c #0B52A4", |
101 | "p c #054A9A", | 101 | "p c #054A9A", |
102 | "q c #053B7C", | 102 | "q c #053B7C", |
103 | "r c #2B2325", | 103 | "r c #2B2325", |
104 | "s c #6E7070", | 104 | "s c #6E7070", |
105 | "t c #0D240E", | 105 | "t c #0D240E", |
106 | "u c #1E423E", | 106 | "u c #1E423E", |
107 | "v c #468ABE", | 107 | "v c #468ABE", |
108 | "w c #6A8AC2", | 108 | "w c #6A8AC2", |
109 | "x c #7EAA8E", | 109 | "x c #7EAA8E", |
110 | "y c #84BE4E", | 110 | "y c #84BE4E", |
111 | "z c #65C639", | 111 | "z c #65C639", |
112 | "A c #064EA0", | 112 | "A c #064EA0", |
113 | "B c #0A4DA0", | 113 | "B c #0A4DA0", |
114 | "C c #4E5242", | 114 | "C c #4E5242", |
115 | "D c #62362E", | 115 | "D c #62362E", |
116 | "E c #721A1A", | 116 | "E c #721A1A", |
117 | "F c #6E0A0A", | 117 | "F c #6E0A0A", |
118 | "G c #3E0E0E", | 118 | "G c #3E0E0E", |
119 | "H c #6AB85E", | 119 | "H c #6AB85E", |
120 | "I c #7E8ECA", | 120 | "I c #7E8ECA", |
@@ -161,351 +161,374 @@ static char * snapshot_xpm[] = { | |||
161 | "(. c #F62626", | 161 | "(. c #F62626", |
162 | "_. c #FA0206", | 162 | "_. c #FA0206", |
163 | ":. c #DE1E16", | 163 | ":. c #DE1E16", |
164 | "<. c #B63A26", | 164 | "<. c #B63A26", |
165 | "[. c #865A2E", | 165 | "[. c #865A2E", |
166 | "}. c #26568E", | 166 | "}. c #26568E", |
167 | "|. c #435F7D", | 167 | "|. c #435F7D", |
168 | "1. c #7AE246", | 168 | "1. c #7AE246", |
169 | "2. c #96EA6E", | 169 | "2. c #96EA6E", |
170 | "3. c #BEEAAE", | 170 | "3. c #BEEAAE", |
171 | "4. c #D0EADC", | 171 | "4. c #D0EADC", |
172 | "5. c #B6CEFE", | 172 | "5. c #B6CEFE", |
173 | "6. c #9ADE8A", | 173 | "6. c #9ADE8A", |
174 | "7. c #2A609A", | 174 | "7. c #2A609A", |
175 | "8. c #7E623E", | 175 | "8. c #7E623E", |
176 | "9. c #CA7A72", | 176 | "9. c #CA7A72", |
177 | "0. c #F26E6E", | 177 | "0. c #F26E6E", |
178 | "a. c #FE5252", | 178 | "a. c #FE5252", |
179 | "b. c #FA3638", | 179 | "b. c #FA3638", |
180 | "c. c #DA2E28", | 180 | "c. c #DA2E28", |
181 | "d. c #9E3E3A", | 181 | "d. c #9E3E3A", |
182 | "e. c #3E7656", | 182 | "e. c #3E7656", |
183 | "f. c #76CB3A", | 183 | "f. c #76CB3A", |
184 | "g. c #90DE44", | 184 | "g. c #90DE44", |
185 | "h. c #A2EE6A", | 185 | "h. c #A2EE6A", |
186 | "i. c #9EEA9A", | 186 | "i. c #9EEA9A", |
187 | "j. c #92BEDE", | 187 | "j. c #92BEDE", |
188 | "k. c #7ADA7E", | 188 | "k. c #7ADA7E", |
189 | "l. c #5ECE52", | 189 | "l. c #5ECE52", |
190 | "m. c #6A5E52", | 190 | "m. c #6A5E52", |
191 | "n. c #A83238", | 191 | "n. c #A83238", |
192 | "o. c #FA5656", | 192 | "o. c #FA5656", |
193 | "p. c #F29A92", | 193 | "p. c #F29A92", |
194 | "q. c #D29E92", | 194 | "q. c #D29E92", |
195 | "r. c #8A7A62", | 195 | "r. c #8A7A62", |
196 | "s. c #05336B", | 196 | "s. c #05336B", |
197 | "t. c #59C631", | 197 | "t. c #59C631", |
198 | "u. c #8AD23A", | 198 | "u. c #8AD23A", |
199 | "v. c #66E242", | 199 | "v. c #66E242", |
200 | "w. c #1D6FC1", | 200 | "w. c #1D6FC1", |
201 | "x. c #E61212", | 201 | "x. c #E61212", |
202 | "y. c #CA261E", | 202 | "y. c #CA261E", |
203 | "z. c #5A763E", | 203 | "z. c #5A763E", |
204 | "A. c #1E6E9A", | 204 | "A. c #1E6E9A", |
205 | "B. c #023272", | 205 | "B. c #023272", |
206 | "C. c #329696", | 206 | "C. c #329696", |
207 | "D. c #2074B6", | 207 | "D. c #2074B6", |
208 | "E. c #3E4E76", | 208 | "E. c #3E4E76", |
209 | "F. c #5A525E", | 209 | "F. c #5A525E", |
210 | "G. c #425868", | 210 | "G. c #425868", |
211 | "H. c #04448E", | 211 | "H. c #04448E", |
212 | "I. c #28828A", | 212 | "I. c #28828A", |
213 | "J. c #2D8593", | 213 | "J. c #2D8593", |
214 | "K. c #12427A", | 214 | "K. c #12427A", |
215 | "L. c #054696", | 215 | "L. c #054696", |
216 | "M. c #042B5E", | 216 | "M. c #042B5E", |
217 | "N. c #134F95", | 217 | "N. c #134F95", |
218 | "O. c #1E6ABB", | 218 | "O. c #1E6ABB", |
219 | "P. c #1A5E96", | 219 | "P. c #1A5E96", |
220 | "Q. c #022E67", | 220 | "Q. c #022E67", |
221 | "R. c #0C3E7C", | 221 | "R. c #0C3E7C", |
222 | "S. c #023E8A", | 222 | "S. c #023E8A", |
223 | "T. c #021A3E", | 223 | "T. c #021A3E", |
224 | " ", | 224 | " ", |
225 | " ", | 225 | " ", |
226 | " ", | 226 | " ", |
227 | " . + @ # + ", | 227 | " . + @ # + ", |
228 | " $ # % & * * = - # $ ", | 228 | " $ # % & * * = - # $ ", |
229 | "; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", | 229 | "; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", |
230 | "; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", | 230 | "; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", |
231 | "| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ", | 231 | "| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ", |
232 | "9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ", | 232 | "9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ", |
233 | "| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ", | 233 | "| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ", |
234 | "t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ", | 234 | "t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ", |
235 | "| u H I J K L M H k N 3 3 : ~ o o 5 O P Q R S T T U V W X Y ", | 235 | "| u H I J K L M H k N 3 3 : ~ o o 5 O P Q R S T T U V W X Y ", |
236 | "| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ", | 236 | "| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ", |
237 | ";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ", | 237 | ";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ", |
238 | ";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ", | 238 | ";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ", |
239 | ";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ", | 239 | ";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ", |
240 | "t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ", | 240 | "t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ", |
241 | "| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ", | 241 | "| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ", |
242 | "; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ", | 242 | "; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ", |
243 | "9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ", | 243 | "9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ", |
244 | "9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ", | 244 | "9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ", |
245 | "; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ", | 245 | "; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ", |
246 | "; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ", | 246 | "; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ", |
247 | " ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ", | 247 | " ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ", |
248 | " # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ", | 248 | " # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ", |
249 | " + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ", | 249 | " + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ", |
250 | " < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ", | 250 | " < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ", |
251 | " $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ", | 251 | " $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ", |
252 | " ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ", | 252 | " ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ", |
253 | " | > e L.d L.H.e M.. ; ] ] ", | 253 | " | > e L.d L.H.e M.. ; ] ] ", |
254 | " > 9 . S.Q.. ; ] ", | 254 | " > 9 . S.Q.. ; ] ", |
255 | " T.; ] "}; | 255 | " T.; ] "}; |
256 | 256 | ||
257 | |||
258 | using namespace Opie::Core; | ||
259 | using namespace Opie::Ui; | ||
260 | |||
257 | static const char *SCAP_hostname = "www.handhelds.org"; | 261 | static const char *SCAP_hostname = "www.handhelds.org"; |
258 | static const int SCAP_port = 80; | 262 | static const int SCAP_port = 80; |
259 | 263 | ||
260 | 264 | ||
261 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) | 265 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) |
262 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 266 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
263 | { | 267 | { |
264 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 268 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
265 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); | 269 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); |
266 | QHBoxLayout *hbox; | 270 | QHBoxLayout *hbox; |
267 | 271 | ||
268 | hbox = new QHBoxLayout ( vbox ); | 272 | hbox = new QHBoxLayout ( vbox ); |
269 | 273 | ||
270 | QLabel *l = new QLabel ( tr( "Delay" ), this ); | 274 | QLabel *l = new QLabel ( tr( "Delay" ), this ); |
271 | hbox-> addWidget ( l ); | 275 | hbox-> addWidget ( l ); |
272 | 276 | ||
273 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); | 277 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); |
274 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 278 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
275 | delaySpin-> setSuffix ( tr( "sec" )); | 279 | delaySpin-> setSuffix ( tr( "sec" )); |
276 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); | 280 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); |
277 | delaySpin-> setValue ( 1 ); | 281 | delaySpin-> setValue ( 1 ); |
278 | hbox-> addWidget ( delaySpin ); | 282 | hbox-> addWidget ( delaySpin ); |
279 | 283 | ||
280 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); | 284 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); |
281 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); | 285 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); |
282 | vbox->addWidget( saveNamedCheck); | 286 | vbox->addWidget( saveNamedCheck); |
283 | 287 | ||
284 | vbox-> addSpacing ( 3 ); | 288 | vbox-> addSpacing ( 3 ); |
285 | 289 | ||
286 | l = new QLabel ( tr( "Save screenshot as..." ), this ); | 290 | l = new QLabel ( tr( "Save screenshot as..." ), this ); |
287 | vbox-> addWidget ( l, AlignCenter ); | 291 | vbox-> addWidget ( l, AlignCenter ); |
288 | 292 | ||
289 | hbox = new QHBoxLayout ( vbox ); | 293 | hbox = new QHBoxLayout ( vbox ); |
290 | 294 | ||
291 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); | 295 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); |
292 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); | 296 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); |
293 | hbox-> addWidget ( grabItButton ); | 297 | hbox-> addWidget ( grabItButton ); |
294 | 298 | ||
299 | QPushButton* drawPadButton = new QPushButton( tr("Opie drawpad"), this, "DrawPadButton" ); | ||
300 | drawPadButton->setFocusPolicy( QWidget::TabFocus ); | ||
301 | hbox->addWidget( drawPadButton ); | ||
302 | |||
295 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); | 303 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); |
296 | scapButton ->setFocusPolicy( QWidget::TabFocus ); | 304 | scapButton ->setFocusPolicy( QWidget::TabFocus ); |
297 | hbox-> addWidget ( scapButton ); | 305 | hbox-> addWidget ( scapButton ); |
298 | 306 | ||
299 | setFixedSize ( sizeHint ( )); | 307 | setFixedSize ( sizeHint ( )); |
300 | setFocusPolicy ( QWidget::NoFocus ); | 308 | setFocusPolicy ( QWidget::NoFocus ); |
301 | 309 | ||
302 | 310 | ||
303 | grabTimer = new QTimer ( this, "grab timer"); | 311 | grabTimer = new QTimer ( this, "grab timer"); |
304 | 312 | ||
305 | connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab())); | 313 | connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab())); |
306 | connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab())); | 314 | connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab())); |
307 | connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap())); | 315 | connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap())); |
316 | connect ( drawPadButton, SIGNAL(clicked()), SLOT(slotDrawpad()) ); | ||
308 | } | 317 | } |
309 | 318 | ||
310 | void ScreenshotControl::slotGrab() | 319 | void ScreenshotControl::slotGrab() |
311 | { | 320 | { |
312 | buttonPushed = 1; | 321 | buttonPushed = 1; |
313 | hide(); | 322 | hide(); |
314 | 323 | ||
315 | setFileName = FALSE; | 324 | setFileName = FALSE; |
316 | if ( saveNamedCheck->isChecked()) { | 325 | if ( saveNamedCheck->isChecked()) { |
317 | setFileName = TRUE; | 326 | setFileName = TRUE; |
318 | InputDialog *fileDlg; | 327 | InputDialog *fileDlg; |
319 | 328 | ||
320 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); | 329 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); |
321 | fileDlg->exec(); | 330 | fileDlg->exec(); |
322 | fileDlg->raise(); | 331 | fileDlg->raise(); |
323 | QString fileName, list; | 332 | QString fileName, list; |
324 | if ( fileDlg->result() == 1 ) { | 333 | if ( fileDlg->result() == 1 ) { |
325 | fileName = fileDlg->LineEdit1->text(); | 334 | fileName = fileDlg->LineEdit1->text(); |
326 | 335 | ||
327 | if (fileName.find("/", 0, TRUE) == -1) | 336 | if (fileName.find("/", 0, TRUE) == -1) |
328 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; | 337 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; |
329 | else | 338 | else |
330 | FileNamePath = fileName; | 339 | FileNamePath = fileName; |
331 | 340 | ||
332 | } | 341 | } |
333 | delete fileDlg; | 342 | delete fileDlg; |
334 | } | 343 | } |
335 | 344 | ||
336 | if ( delaySpin->value() ) | 345 | if ( delaySpin->value() ) |
337 | grabTimer->start( delaySpin->value() * 1000, true ); | 346 | grabTimer->start( delaySpin->value() * 1000, true ); |
338 | else | 347 | else |
339 | show(); | 348 | show(); |
340 | } | 349 | } |
341 | 350 | ||
342 | void ScreenshotControl::slotScap() | 351 | void ScreenshotControl::slotScap() |
343 | { | 352 | { |
344 | buttonPushed = 2; | 353 | buttonPushed = 2; |
345 | hide(); | 354 | hide(); |
346 | 355 | ||
347 | if ( delaySpin->value() ) | 356 | if ( delaySpin->value() ) |
348 | grabTimer->start( delaySpin->value() * 1000, true ); | 357 | grabTimer->start( delaySpin->value() * 1000, true ); |
349 | else | 358 | else |
350 | show(); | 359 | show(); |
351 | } | 360 | } |
352 | 361 | ||
362 | void ScreenshotControl::slotDrawpad() | ||
363 | { | ||
364 | buttonPushed = 3; | ||
365 | hide(); | ||
366 | if ( delaySpin->value() ) | ||
367 | grabTimer->start( delaySpin->value()*1000, true ); | ||
368 | else | ||
369 | show(); | ||
370 | } | ||
353 | 371 | ||
354 | void ScreenshotControl::savePixmap() | 372 | void ScreenshotControl::savePixmap() |
355 | { | 373 | { |
356 | DocLnk lnk; | 374 | DocLnk lnk; |
357 | QString fileName; | 375 | QString fileName; |
358 | 376 | ||
359 | if ( setFileName) { | 377 | if ( setFileName) { |
360 | fileName = FileNamePath; | 378 | fileName = FileNamePath; |
361 | //not sure why this is needed here, but it forgets fileName | 379 | //not sure why this is needed here, but it forgets fileName |
362 | // if this is below the braces | 380 | // if this is below the braces |
363 | 381 | ||
364 | if (fileName.right(3) != "png") | 382 | if (fileName.right(3) != "png") |
365 | fileName = fileName + ".png"; | 383 | fileName = fileName + ".png"; |
366 | lnk.setFile(fileName); //sets File property | 384 | lnk.setFile(fileName); //sets File property |
367 | odebug << "saving file " + fileName << oendl; | 385 | odebug << "saving file " + fileName << oendl; |
368 | snapshot.save( fileName, "PNG"); | 386 | snapshot.save( fileName, "PNG"); |
369 | QFileInfo fi( fileName); | 387 | QFileInfo fi( fileName); |
370 | lnk.setName( fi.fileName()); //sets file name | 388 | lnk.setName( fi.fileName()); //sets file name |
371 | 389 | ||
372 | if (!lnk.writeLink()) | 390 | if (!lnk.writeLink()) |
373 | odebug << "Writing doclink did not work" << oendl; | 391 | odebug << "Writing doclink did not work" << oendl; |
374 | } | 392 | } |
375 | else { | 393 | else { |
376 | 394 | ||
377 | fileName = "sc_" + QDateTime::currentDateTime().toString(); | 395 | fileName = "sc_" + QDateTime::currentDateTime().toString(); |
378 | fileName.replace(QRegExp("'"), ""); | 396 | fileName.replace(QRegExp("'"), ""); |
379 | fileName.replace(QRegExp(" "), "_"); | 397 | fileName.replace(QRegExp(" "), "_"); |
380 | fileName.replace(QRegExp(":"), "."); | 398 | fileName.replace(QRegExp(":"), "."); |
381 | fileName.replace(QRegExp(","), ""); | 399 | fileName.replace(QRegExp(","), ""); |
382 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; | 400 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; |
383 | 401 | ||
384 | if ( !QDir( dirName).exists() ) { | 402 | if ( !QDir( dirName).exists() ) { |
385 | odebug << "making dir " + dirName << oendl; | 403 | odebug << "making dir " + dirName << oendl; |
386 | QString msg = "mkdir -p " + dirName; | 404 | QString msg = "mkdir -p " + dirName; |
387 | system(msg.latin1()); | 405 | system(msg.latin1()); |
388 | } | 406 | } |
389 | fileName = dirName + fileName; | 407 | fileName = dirName + fileName; |
390 | if (fileName.right(3) != "png") | 408 | if (fileName.right(3) != "png") |
391 | fileName = fileName + ".png"; | 409 | fileName = fileName + ".png"; |
392 | lnk.setFile(fileName); //sets File property | 410 | lnk.setFile(fileName); //sets File property |
393 | odebug << "saving file " + fileName << oendl; | 411 | odebug << "saving file " + fileName << oendl; |
394 | snapshot.save( fileName, "PNG"); | 412 | snapshot.save( fileName, "PNG"); |
395 | QFileInfo fi( fileName); | 413 | QFileInfo fi( fileName); |
396 | lnk.setName( fi.fileName()); //sets file name | 414 | lnk.setName( fi.fileName()); //sets file name |
397 | 415 | ||
398 | if (!lnk.writeLink()) | 416 | if (!lnk.writeLink()) |
399 | odebug << "Writing doclink did not work" << oendl; | 417 | odebug << "Writing doclink did not work" << oendl; |
400 | 418 | ||
401 | } | 419 | } |
402 | 420 | ||
403 | QPEApplication::beep(); | 421 | QPEApplication::beep(); |
404 | } | 422 | } |
405 | 423 | ||
406 | void ScreenshotControl::performGrab() | 424 | void ScreenshotControl::performGrab() |
407 | { | 425 | { |
408 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); | 426 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); |
409 | 427 | ||
410 | if (buttonPushed == 1) { | 428 | if (buttonPushed == 1) { |
411 | odebug << "grabbing screen" << oendl; | 429 | odebug << "grabbing screen" << oendl; |
412 | grabTimer->stop(); | 430 | grabTimer->stop(); |
413 | show(); | 431 | show(); |
414 | qApp->processEvents(); | 432 | qApp->processEvents(); |
415 | savePixmap(); | 433 | savePixmap(); |
434 | }else if ( buttonPushed == 3 ) { | ||
435 | grabTimer->stop(); | ||
436 | show(); | ||
437 | QCopEnvelope env("QPE/Application/drawpad", "importPixmap(QPixmap)" ); | ||
438 | env << snapshot; | ||
416 | } else { | 439 | } else { |
417 | grabTimer->stop(); | 440 | grabTimer->stop(); |
418 | 441 | ||
419 | struct sockaddr_in raddr; | 442 | struct sockaddr_in raddr; |
420 | struct hostent *rhost_info; | 443 | struct hostent *rhost_info; |
421 | int sock = -1; | 444 | int sock = -1; |
422 | bool ok = false; | 445 | bool ok = false; |
423 | 446 | ||
424 | QString displayEnv = getenv("QWS_DISPLAY"); | 447 | QString displayEnv = getenv("QWS_DISPLAY"); |
425 | odebug << displayEnv << oendl; | 448 | odebug << displayEnv << oendl; |
426 | 449 | ||
427 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { | 450 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { |
428 | 451 | ||
429 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { | 452 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { |
430 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); | 453 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); |
431 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); | 454 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); |
432 | raddr. sin_family = rhost_info-> h_addrtype; | 455 | raddr. sin_family = rhost_info-> h_addrtype; |
433 | raddr. sin_port = htons ( SCAP_port ); | 456 | raddr. sin_port = htons ( SCAP_port ); |
434 | 457 | ||
435 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { | 458 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { |
436 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { | 459 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { |
437 | 460 | ||
438 | QString header; | 461 | QString header; |
439 | 462 | ||
440 | QPixmap pix; | 463 | QPixmap pix; |
441 | 464 | ||
442 | QString SCAP_model=""; | 465 | QString SCAP_model=""; |
443 | #warning FIXME: model string should be filled with actual device model | 466 | #warning FIXME: model string should be filled with actual device model |
444 | if( snapshot.width() > 320) | 467 | if( snapshot.width() > 320) |
445 | SCAP_model ="Corgi"; | 468 | SCAP_model ="Corgi"; |
446 | 469 | ||
447 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! | 470 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! |
448 | pix = snapshot.xForm(QWMatrix().rotate(90)); | 471 | pix = snapshot.xForm(QWMatrix().rotate(90)); |
449 | } else | 472 | } else |
450 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); | 473 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); |
451 | 474 | ||
452 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it | 475 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it |
453 | 476 | ||
454 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user | 477 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user |
455 | "Content-length: %3\n" // 3: content length | 478 | "Content-length: %3\n" // 3: content length |
456 | "Content-Type: image/png\n" | 479 | "Content-Type: image/png\n" |
457 | "Host: %4\n" // 4: scap host | 480 | "Host: %4\n" // 4: scap host |
458 | "\n"; | 481 | "\n"; |
459 | 482 | ||
460 | 483 | ||
461 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); | 484 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); |
462 | odebug << header << oendl; | 485 | odebug << header << oendl; |
463 | 486 | ||
464 | if ( !pix.isNull() ) { | 487 | if ( !pix.isNull() ) { |
465 | const char *ascii = header.latin1( ); | 488 | const char *ascii = header.latin1( ); |
466 | uint ascii_len = ::strlen( ascii ); | 489 | uint ascii_len = ::strlen( ascii ); |
467 | ::write ( sock, ascii, ascii_len ); | 490 | ::write ( sock, ascii, ascii_len ); |
468 | ::write ( sock, img.bits(), img.numBytes() ); | 491 | ::write ( sock, img.bits(), img.numBytes() ); |
469 | 492 | ||
470 | ok = true; | 493 | ok = true; |
471 | } | 494 | } |
472 | } | 495 | } |
473 | ::close ( sock ); | 496 | ::close ( sock ); |
474 | } | 497 | } |
475 | } | 498 | } |
476 | if ( ok ) { | 499 | if ( ok ) { |
477 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); | 500 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); |
478 | } else { | 501 | } else { |
479 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); | 502 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); |
480 | } | 503 | } |
481 | } else { | 504 | } else { |
482 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); | 505 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); |
483 | } | 506 | } |
484 | } | 507 | } |
485 | 508 | ||
486 | } | 509 | } |
487 | 510 | ||
488 | 511 | ||
489 | 512 | ||
490 | //=========================================================================== | 513 | //=========================================================================== |
491 | 514 | ||
492 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) | 515 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) |
493 | : QWidget( parent, name ) | 516 | : QWidget( parent, name ) |
494 | { | 517 | { |
495 | setFixedWidth( AppLnk::smallIconSize()); | 518 | setFixedWidth( AppLnk::smallIconSize()); |
496 | 519 | ||
497 | QImage img = (const char **)snapshot_xpm; | 520 | QImage img = (const char **)snapshot_xpm; |
498 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); | 521 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); |
499 | m_icon.convertFromImage(img); | 522 | m_icon.convertFromImage(img); |
500 | } | 523 | } |
501 | 524 | ||
502 | ScreenshotApplet::~ScreenshotApplet() | 525 | ScreenshotApplet::~ScreenshotApplet() |
503 | { | 526 | { |
504 | } | 527 | } |
505 | 528 | ||
506 | int ScreenshotApplet::position() | 529 | int ScreenshotApplet::position() |
507 | { | 530 | { |
508 | return 6; | 531 | return 6; |
509 | } | 532 | } |
510 | 533 | ||
511 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) | 534 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) |
diff --git a/core/applets/screenshotapplet/screenshot.h b/core/applets/screenshotapplet/screenshot.h index b753583..e7b6040 100644 --- a/core/applets/screenshotapplet/screenshot.h +++ b/core/applets/screenshotapplet/screenshot.h | |||
@@ -1,71 +1,72 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com | 2 | ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | 14 | ||
15 | #ifndef __SCREENSHOT_APPLET_H__ | 15 | #ifndef SCREENSHOT_APPLET_H__ |
16 | #define __SCREENSHOT_APPLET_H__ | 16 | #define SCREENSHOT_APPLET_H__ |
17 | 17 | ||
18 | 18 | ||
19 | 19 | ||
20 | #include <qwidget.h> | 20 | #include <qwidget.h> |
21 | #include <qframe.h> | 21 | #include <qframe.h> |
22 | #include <qpixmap.h> | 22 | #include <qpixmap.h> |
23 | #include <qguardedptr.h> | 23 | #include <qguardedptr.h> |
24 | #include <qtimer.h> | 24 | #include <qtimer.h> |
25 | 25 | ||
26 | class QComboBox; | 26 | class QComboBox; |
27 | class QCheckBox; | 27 | class QCheckBox; |
28 | class QSpinBox; | 28 | class QSpinBox; |
29 | class QPushButton; | 29 | class QPushButton; |
30 | //class QImage; | 30 | //class QImage; |
31 | 31 | ||
32 | class ScreenshotControl : public QFrame | 32 | class ScreenshotControl : public QFrame |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | ScreenshotControl( QWidget *parent=0, const char *name=0 ); | 36 | ScreenshotControl( QWidget *parent=0, const char *name=0 ); |
37 | 37 | ||
38 | private: | 38 | private: |
39 | QPushButton *grabItButton, *scapButton; | 39 | QPushButton *grabItButton, *scapButton; |
40 | QPixmap snapshot; | 40 | QPixmap snapshot; |
41 | QTimer* grabTimer; | 41 | QTimer* grabTimer; |
42 | QCheckBox *saveNamedCheck; | 42 | QCheckBox *saveNamedCheck; |
43 | QString FileNamePath; | 43 | QString FileNamePath; |
44 | bool setFileName; | 44 | bool setFileName; |
45 | QSpinBox *delaySpin; | 45 | QSpinBox *delaySpin; |
46 | int buttonPushed; | 46 | int buttonPushed; |
47 | 47 | ||
48 | private slots: | 48 | private slots: |
49 | void slotGrab(); | 49 | void slotGrab(); |
50 | void slotScap(); | 50 | void slotScap(); |
51 | void slotDrawpad(); | ||
51 | void savePixmap(); | 52 | void savePixmap(); |
52 | void performGrab(); | 53 | void performGrab(); |
53 | }; | 54 | }; |
54 | 55 | ||
55 | class ScreenshotApplet : public QWidget { | 56 | class ScreenshotApplet : public QWidget { |
56 | public: | 57 | public: |
57 | ScreenshotApplet( QWidget *parent = 0, const char *name=0 ); | 58 | ScreenshotApplet( QWidget *parent = 0, const char *name=0 ); |
58 | ~ScreenshotApplet(); | 59 | ~ScreenshotApplet(); |
59 | static int position(); | 60 | static int position(); |
60 | 61 | ||
61 | protected: | 62 | protected: |
62 | void mousePressEvent( QMouseEvent * ); | 63 | void mousePressEvent( QMouseEvent * ); |
63 | void paintEvent( QPaintEvent* ); | 64 | void paintEvent( QPaintEvent* ); |
64 | 65 | ||
65 | private: | 66 | private: |
66 | QPixmap m_icon; | 67 | QPixmap m_icon; |
67 | }; | 68 | }; |
68 | 69 | ||
69 | 70 | ||
70 | #endif // __SCREENSHOT_APPLET_H__ | 71 | #endif // __SCREENSHOT_APPLET_H__ |
71 | 72 | ||