-rw-r--r-- | core/applets/screenshotapplet/screenshot.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp index 2af860a..f2cc2c5 100644 --- a/core/applets/screenshotapplet/screenshot.cpp +++ b/core/applets/screenshotapplet/screenshot.cpp | |||
@@ -1,506 +1,522 @@ | |||
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 | #include <stdlib.h> | 18 | #include <stdlib.h> |
19 | #include <sys/socket.h> | 19 | #include <sys/socket.h> |
20 | #include <netinet/in.h> | 20 | #include <netinet/in.h> |
21 | #include <netdb.h> | 21 | #include <netdb.h> |
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | 26 | ||
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 | #include <qimage.h> | 36 | #include <qimage.h> |
37 | 37 | ||
38 | 38 | ||
39 | /* XPM */ | 39 | /* XPM */ |
40 | static char * snapshot_xpm[] = { | 40 | static char * snapshot_xpm[] = { |
41 | "32 32 177 2", | 41 | "32 32 177 2", |
42 | " c None", | 42 | " c None", |
43 | ". c #042045", | 43 | ". c #042045", |
44 | "+ c #0D2B47", | 44 | "+ c #0D2B47", |
45 | "@ c #0E325E", | 45 | "@ c #0E325E", |
46 | "# c #0D2E50", | 46 | "# c #0D2E50", |
47 | "$ c #0A1C32", | 47 | "$ c #0A1C32", |
48 | "% c #0F3A69", | 48 | "% c #0F3A69", |
49 | "& c #164680", | 49 | "& c #164680", |
50 | "* c #165EAE", | 50 | "* c #165EAE", |
51 | "= c #134D89", | 51 | "= c #134D89", |
52 | "- c #0A3A6E", | 52 | "- c #0A3A6E", |
53 | "; c #031024", | 53 | "; c #031024", |
54 | "> c #031B36", | 54 | "> c #031B36", |
55 | ", c #1A5EA3", | 55 | ", c #1A5EA3", |
56 | "' c #1862B1", | 56 | "' c #1862B1", |
57 | ") c #1866B9", | 57 | ") c #1866B9", |
58 | "! c #0F5AAC", | 58 | "! c #0F5AAC", |
59 | "~ c #0F56A8", | 59 | "~ c #0F56A8", |
60 | "{ c #0C4C96", | 60 | "{ c #0C4C96", |
61 | "] c #030918", | 61 | "] c #030918", |
62 | "^ c #060206", | 62 | "^ c #060206", |
63 | "/ c #20242C", | 63 | "/ c #20242C", |
64 | "( c #3E3B3B", | 64 | "( c #3E3B3B", |
65 | "_ c #186ABD", | 65 | "_ c #186ABD", |
66 | ": c #115EB3", | 66 | ": c #115EB3", |
67 | "< c #082644", | 67 | "< c #082644", |
68 | "[ c #222C38", | 68 | "[ c #222C38", |
69 | "} c #5A5859", | 69 | "} c #5A5859", |
70 | "| c #091921", | 70 | "| c #091921", |
71 | "1 c #1E7EDE", | 71 | "1 c #1E7EDE", |
72 | "2 c #1A7ADA", | 72 | "2 c #1A7ADA", |
73 | "3 c #1970CD", | 73 | "3 c #1970CD", |
74 | "4 c #1758A1", | 74 | "4 c #1758A1", |
75 | "5 c #0E529A", | 75 | "5 c #0E529A", |
76 | "6 c #094388", | 76 | "6 c #094388", |
77 | "7 c #22364E", | 77 | "7 c #22364E", |
78 | "8 c #384454", | 78 | "8 c #384454", |
79 | "9 c #04162C", | 79 | "9 c #04162C", |
80 | "0 c #123451", | 80 | "0 c #123451", |
81 | "a c #3296B4", | 81 | "a c #3296B4", |
82 | "b c #298AB1", | 82 | "b c #298AB1", |
83 | "c c #2484AC", | 83 | "c c #2484AC", |
84 | "d c #033D86", | 84 | "d c #033D86", |
85 | "e c #033677", | 85 | "e c #033677", |
86 | "f c #072C58", | 86 | "f c #072C58", |
87 | "g c #525862", | 87 | "g c #525862", |
88 | "h c #5E5E5E", | 88 | "h c #5E5E5E", |
89 | "i c #23492A", | 89 | "i c #23492A", |
90 | "j c #4FBD3F", | 90 | "j c #4FBD3F", |
91 | "k c #50B24C", | 91 | "k c #50B24C", |
92 | "l c #51C72E", | 92 | "l c #51C72E", |
93 | "m c #42C64A", | 93 | "m c #42C64A", |
94 | "n c #2686CA", | 94 | "n c #2686CA", |
95 | "o c #0B52A4", | 95 | "o c #0B52A4", |
96 | "p c #054A9A", | 96 | "p c #054A9A", |
97 | "q c #053B7C", | 97 | "q c #053B7C", |
98 | "r c #2B2325", | 98 | "r c #2B2325", |
99 | "s c #6E7070", | 99 | "s c #6E7070", |
100 | "t c #0D240E", | 100 | "t c #0D240E", |
101 | "u c #1E423E", | 101 | "u c #1E423E", |
102 | "v c #468ABE", | 102 | "v c #468ABE", |
103 | "w c #6A8AC2", | 103 | "w c #6A8AC2", |
104 | "x c #7EAA8E", | 104 | "x c #7EAA8E", |
105 | "y c #84BE4E", | 105 | "y c #84BE4E", |
106 | "z c #65C639", | 106 | "z c #65C639", |
107 | "A c #064EA0", | 107 | "A c #064EA0", |
108 | "B c #0A4DA0", | 108 | "B c #0A4DA0", |
109 | "C c #4E5242", | 109 | "C c #4E5242", |
110 | "D c #62362E", | 110 | "D c #62362E", |
111 | "E c #721A1A", | 111 | "E c #721A1A", |
112 | "F c #6E0A0A", | 112 | "F c #6E0A0A", |
113 | "G c #3E0E0E", | 113 | "G c #3E0E0E", |
114 | "H c #6AB85E", | 114 | "H c #6AB85E", |
115 | "I c #7E8ECA", | 115 | "I c #7E8ECA", |
116 | "J c #929CD4", | 116 | "J c #929CD4", |
117 | "K c #9EAECA", | 117 | "K c #9EAECA", |
118 | "L c #9EBEAE", | 118 | "L c #9EBEAE", |
119 | "M c #8EC26A", | 119 | "M c #8EC26A", |
120 | "N c #32A276", | 120 | "N c #32A276", |
121 | "O c #20518C", | 121 | "O c #20518C", |
122 | "P c #46566E", | 122 | "P c #46566E", |
123 | "Q c #614A51", | 123 | "Q c #614A51", |
124 | "R c #AE2A26", | 124 | "R c #AE2A26", |
125 | "S c #C41C1A", | 125 | "S c #C41C1A", |
126 | "T c #CE0A0A", | 126 | "T c #CE0A0A", |
127 | "U c #A60606", | 127 | "U c #A60606", |
128 | "V c #921616", | 128 | "V c #921616", |
129 | "W c #863735", | 129 | "W c #863735", |
130 | "X c #866A66", | 130 | "X c #866A66", |
131 | "Y c #9E9EA2", | 131 | "Y c #9E9EA2", |
132 | "Z c #1E5212", | 132 | "Z c #1E5212", |
133 | "` c #7EC652", | 133 | "` c #7EC652", |
134 | " .c #B2B2F2", | 134 | " .c #B2B2F2", |
135 | "..c #CACAF6", | 135 | "..c #CACAF6", |
136 | "+.c #AECEC6", | 136 | "+.c #AECEC6", |
137 | "@.c #92CE72", | 137 | "@.c #92CE72", |
138 | "#.c #42AA86", | 138 | "#.c #42AA86", |
139 | "$.c #365E96", | 139 | "$.c #365E96", |
140 | "%.c #B82420", | 140 | "%.c #B82420", |
141 | "&.c #E20E0E", | 141 | "&.c #E20E0E", |
142 | "*.c #EF0E0B", | 142 | "*.c #EF0E0B", |
143 | "=.c #566A86", | 143 | "=.c #566A86", |
144 | "-.c #92929A", | 144 | "-.c #92929A", |
145 | ";.c #16260E", | 145 | ";.c #16260E", |
146 | ">.c #2E571A", | 146 | ">.c #2E571A", |
147 | ",.c #7ED64E", | 147 | ",.c #7ED64E", |
148 | "'.c #9ECEB2", | 148 | "'.c #9ECEB2", |
149 | ").c #C6D5EF", | 149 | ").c #C6D5EF", |
150 | "!.c #E2E0FE", | 150 | "!.c #E2E0FE", |
151 | "~.c #A2DE8A", | 151 | "~.c #A2DE8A", |
152 | "{.c #4AAA5B", | 152 | "{.c #4AAA5B", |
153 | "].c #2A6AB2", | 153 | "].c #2A6AB2", |
154 | "^.c #9A7A6E", | 154 | "^.c #9A7A6E", |
155 | "/.c #D25A52", | 155 | "/.c #D25A52", |
156 | "(.c #F62626", | 156 | "(.c #F62626", |
157 | "_.c #FA0206", | 157 | "_.c #FA0206", |
158 | ":.c #DE1E16", | 158 | ":.c #DE1E16", |
159 | "<.c #B63A26", | 159 | "<.c #B63A26", |
160 | "[.c #865A2E", | 160 | "[.c #865A2E", |
161 | "}.c #26568E", | 161 | "}.c #26568E", |
162 | "|.c #435F7D", | 162 | "|.c #435F7D", |
163 | "1.c #7AE246", | 163 | "1.c #7AE246", |
164 | "2.c #96EA6E", | 164 | "2.c #96EA6E", |
165 | "3.c #BEEAAE", | 165 | "3.c #BEEAAE", |
166 | "4.c #D0EADC", | 166 | "4.c #D0EADC", |
167 | "5.c #B6CEFE", | 167 | "5.c #B6CEFE", |
168 | "6.c #9ADE8A", | 168 | "6.c #9ADE8A", |
169 | "7.c #2A609A", | 169 | "7.c #2A609A", |
170 | "8.c #7E623E", | 170 | "8.c #7E623E", |
171 | "9.c #CA7A72", | 171 | "9.c #CA7A72", |
172 | "0.c #F26E6E", | 172 | "0.c #F26E6E", |
173 | "a.c #FE5252", | 173 | "a.c #FE5252", |
174 | "b.c #FA3638", | 174 | "b.c #FA3638", |
175 | "c.c #DA2E28", | 175 | "c.c #DA2E28", |
176 | "d.c #9E3E3A", | 176 | "d.c #9E3E3A", |
177 | "e.c #3E7656", | 177 | "e.c #3E7656", |
178 | "f.c #76CB3A", | 178 | "f.c #76CB3A", |
179 | "g.c #90DE44", | 179 | "g.c #90DE44", |
180 | "h.c #A2EE6A", | 180 | "h.c #A2EE6A", |
181 | "i.c #9EEA9A", | 181 | "i.c #9EEA9A", |
182 | "j.c #92BEDE", | 182 | "j.c #92BEDE", |
183 | "k.c #7ADA7E", | 183 | "k.c #7ADA7E", |
184 | "l.c #5ECE52", | 184 | "l.c #5ECE52", |
185 | "m.c #6A5E52", | 185 | "m.c #6A5E52", |
186 | "n.c #A83238", | 186 | "n.c #A83238", |
187 | "o.c #FA5656", | 187 | "o.c #FA5656", |
188 | "p.c #F29A92", | 188 | "p.c #F29A92", |
189 | "q.c #D29E92", | 189 | "q.c #D29E92", |
190 | "r.c #8A7A62", | 190 | "r.c #8A7A62", |
191 | "s.c #05336B", | 191 | "s.c #05336B", |
192 | "t.c #59C631", | 192 | "t.c #59C631", |
193 | "u.c #8AD23A", | 193 | "u.c #8AD23A", |
194 | "v.c #66E242", | 194 | "v.c #66E242", |
195 | "w.c #1D6FC1", | 195 | "w.c #1D6FC1", |
196 | "x.c #E61212", | 196 | "x.c #E61212", |
197 | "y.c #CA261E", | 197 | "y.c #CA261E", |
198 | "z.c #5A763E", | 198 | "z.c #5A763E", |
199 | "A.c #1E6E9A", | 199 | "A.c #1E6E9A", |
200 | "B.c #023272", | 200 | "B.c #023272", |
201 | "C.c #329696", | 201 | "C.c #329696", |
202 | "D.c #2074B6", | 202 | "D.c #2074B6", |
203 | "E.c #3E4E76", | 203 | "E.c #3E4E76", |
204 | "F.c #5A525E", | 204 | "F.c #5A525E", |
205 | "G.c #425868", | 205 | "G.c #425868", |
206 | "H.c #04448E", | 206 | "H.c #04448E", |
207 | "I.c #28828A", | 207 | "I.c #28828A", |
208 | "J.c #2D8593", | 208 | "J.c #2D8593", |
209 | "K.c #12427A", | 209 | "K.c #12427A", |
210 | "L.c #054696", | 210 | "L.c #054696", |
211 | "M.c #042B5E", | 211 | "M.c #042B5E", |
212 | "N.c #134F95", | 212 | "N.c #134F95", |
213 | "O.c #1E6ABB", | 213 | "O.c #1E6ABB", |
214 | "P.c #1A5E96", | 214 | "P.c #1A5E96", |
215 | "Q.c #022E67", | 215 | "Q.c #022E67", |
216 | "R.c #0C3E7C", | 216 | "R.c #0C3E7C", |
217 | "S.c #023E8A", | 217 | "S.c #023E8A", |
218 | "T.c #021A3E", | 218 | "T.c #021A3E", |
219 | " ", | 219 | " ", |
220 | " ", | 220 | " ", |
221 | " ", | 221 | " ", |
222 | " . + @ # + ", | 222 | " . + @ # + ", |
223 | " $ # % & * * = - # $ ", | 223 | " $ # % & * * = - # $ ", |
224 | "; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", | 224 | "; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", |
225 | "; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", | 225 | "; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", |
226 | "| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ", | 226 | "| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ", |
227 | "9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ", | 227 | "9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ", |
228 | "| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ", | 228 | "| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ", |
229 | "t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ", | 229 | "t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ", |
230 | "| 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 ", | 230 | "| 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 ", |
231 | "| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ", | 231 | "| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ", |
232 | ";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ", | 232 | ";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ", |
233 | ";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ", | 233 | ";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ", |
234 | ";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ", | 234 | ";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ", |
235 | "t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ", | 235 | "t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ", |
236 | "| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ", | 236 | "| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ", |
237 | "; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ", | 237 | "; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ", |
238 | "9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ", | 238 | "9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ", |
239 | "9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ", | 239 | "9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ", |
240 | "; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ", | 240 | "; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ", |
241 | "; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ", | 241 | "; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ", |
242 | " ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ", | 242 | " ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ", |
243 | " # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ", | 243 | " # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ", |
244 | " + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ", | 244 | " + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ", |
245 | " < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ", | 245 | " < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ", |
246 | " $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ", | 246 | " $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ", |
247 | " ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ", | 247 | " ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ", |
248 | " | > e L.d L.H.e M.. ; ] ] ", | 248 | " | > e L.d L.H.e M.. ; ] ] ", |
249 | " > 9 . S.Q.. ; ] ", | 249 | " > 9 . S.Q.. ; ] ", |
250 | " T.; ] "}; | 250 | " T.; ] "}; |
251 | 251 | ||
252 | static const char *SCAP_hostname = "www.handhelds.org"; | 252 | static const char *SCAP_hostname = "www.handhelds.org"; |
253 | static const int SCAP_port = 80; | 253 | static const int SCAP_port = 80; |
254 | 254 | ||
255 | 255 | ||
256 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) | 256 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) |
257 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 257 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
258 | { | 258 | { |
259 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 259 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
260 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); | 260 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); |
261 | QHBoxLayout *hbox; | 261 | QHBoxLayout *hbox; |
262 | 262 | ||
263 | hbox = new QHBoxLayout ( vbox ); | 263 | hbox = new QHBoxLayout ( vbox ); |
264 | 264 | ||
265 | QLabel *l = new QLabel ( tr( "Delay" ), this ); | 265 | QLabel *l = new QLabel ( tr( "Delay" ), this ); |
266 | hbox-> addWidget ( l ); | 266 | hbox-> addWidget ( l ); |
267 | 267 | ||
268 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); | 268 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); |
269 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 269 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
270 | delaySpin-> setSuffix ( tr( "sec" )); | 270 | delaySpin-> setSuffix ( tr( "sec" )); |
271 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); | 271 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); |
272 | delaySpin-> setValue ( 1 ); | 272 | delaySpin-> setValue ( 1 ); |
273 | hbox-> addWidget ( delaySpin ); | 273 | hbox-> addWidget ( delaySpin ); |
274 | 274 | ||
275 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); | 275 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); |
276 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); | 276 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); |
277 | vbox->addWidget( saveNamedCheck); | 277 | vbox->addWidget( saveNamedCheck); |
278 | 278 | ||
279 | vbox-> addSpacing ( 3 ); | 279 | vbox-> addSpacing ( 3 ); |
280 | 280 | ||
281 | l = new QLabel ( tr( "Save screenshot as..." ), this ); | 281 | l = new QLabel ( tr( "Save screenshot as..." ), this ); |
282 | vbox-> addWidget ( l, AlignCenter ); | 282 | vbox-> addWidget ( l, AlignCenter ); |
283 | 283 | ||
284 | hbox = new QHBoxLayout ( vbox ); | 284 | hbox = new QHBoxLayout ( vbox ); |
285 | 285 | ||
286 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); | 286 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); |
287 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); | 287 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); |
288 | hbox-> addWidget ( grabItButton ); | 288 | hbox-> addWidget ( grabItButton ); |
289 | 289 | ||
290 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); | 290 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); |
291 | scapButton ->setFocusPolicy( QWidget::TabFocus ); | 291 | scapButton ->setFocusPolicy( QWidget::TabFocus ); |
292 | hbox-> addWidget ( scapButton ); | 292 | hbox-> addWidget ( scapButton ); |
293 | 293 | ||
294 | setFixedSize ( sizeHint ( )); | 294 | setFixedSize ( sizeHint ( )); |
295 | setFocusPolicy ( QWidget::NoFocus ); | 295 | setFocusPolicy ( QWidget::NoFocus ); |
296 | 296 | ||
297 | 297 | ||
298 | grabTimer = new QTimer ( this, "grab timer"); | 298 | grabTimer = new QTimer ( this, "grab timer"); |
299 | 299 | ||
300 | connect ( grabTimer, SIGNAL( timeout ( )), this, SLOT( performGrab ( ))); | 300 | connect ( grabTimer, SIGNAL( timeout ( )), this, SLOT( performGrab ( ))); |
301 | connect ( grabItButton, SIGNAL( clicked ( )), SLOT( slotGrab ( ))); | 301 | connect ( grabItButton, SIGNAL( clicked ( )), SLOT( slotGrab ( ))); |
302 | connect ( scapButton, SIGNAL( clicked ( )), SLOT( slotScap ( ))); | 302 | connect ( scapButton, SIGNAL( clicked ( )), SLOT( slotScap ( ))); |
303 | } | 303 | } |
304 | 304 | ||
305 | void ScreenshotControl::slotGrab() | 305 | void ScreenshotControl::slotGrab() |
306 | { | 306 | { |
307 | buttonPushed = 1; | 307 | buttonPushed = 1; |
308 | hide(); | 308 | hide(); |
309 | 309 | ||
310 | setFileName = FALSE; | 310 | setFileName = FALSE; |
311 | if ( saveNamedCheck->isChecked()) { | 311 | if ( saveNamedCheck->isChecked()) { |
312 | setFileName = TRUE; | 312 | setFileName = TRUE; |
313 | InputDialog *fileDlg; | 313 | InputDialog *fileDlg; |
314 | 314 | ||
315 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); | 315 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); |
316 | fileDlg->exec(); | 316 | fileDlg->exec(); |
317 | fileDlg->raise(); | 317 | fileDlg->raise(); |
318 | QString fileName, list; | 318 | QString fileName, list; |
319 | if ( fileDlg->result() == 1 ) { | 319 | if ( fileDlg->result() == 1 ) { |
320 | fileName = fileDlg->LineEdit1->text(); | 320 | fileName = fileDlg->LineEdit1->text(); |
321 | 321 | ||
322 | if (fileName.find("/", 0, TRUE) == -1) | 322 | if (fileName.find("/", 0, TRUE) == -1) |
323 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; | 323 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; |
324 | else | 324 | else |
325 | FileNamePath = fileName; | 325 | FileNamePath = fileName; |
326 | 326 | ||
327 | } | 327 | } |
328 | delete fileDlg; | 328 | delete fileDlg; |
329 | } | 329 | } |
330 | 330 | ||
331 | if ( delaySpin->value() ) | 331 | if ( delaySpin->value() ) |
332 | grabTimer->start( delaySpin->value() * 1000, true ); | 332 | grabTimer->start( delaySpin->value() * 1000, true ); |
333 | else | 333 | else |
334 | show(); | 334 | show(); |
335 | } | 335 | } |
336 | 336 | ||
337 | void ScreenshotControl::slotScap() | 337 | void ScreenshotControl::slotScap() |
338 | { | 338 | { |
339 | buttonPushed = 2; | 339 | buttonPushed = 2; |
340 | hide(); | 340 | hide(); |
341 | 341 | ||
342 | if ( delaySpin->value() ) | 342 | if ( delaySpin->value() ) |
343 | grabTimer->start( delaySpin->value() * 1000, true ); | 343 | grabTimer->start( delaySpin->value() * 1000, true ); |
344 | else | 344 | else |
345 | show(); | 345 | show(); |
346 | } | 346 | } |
347 | 347 | ||
348 | 348 | ||
349 | void ScreenshotControl::savePixmap() | 349 | void ScreenshotControl::savePixmap() |
350 | { | 350 | { |
351 | DocLnk lnk; | 351 | DocLnk lnk; |
352 | QString fileName; | 352 | QString fileName; |
353 | 353 | ||
354 | if ( setFileName) { | 354 | if ( setFileName) { |
355 | fileName = FileNamePath; | 355 | fileName = FileNamePath; |
356 | //not sure why this is needed here, but it forgets fileName | 356 | //not sure why this is needed here, but it forgets fileName |
357 | // if this is below the braces | 357 | // if this is below the braces |
358 | 358 | ||
359 | if (fileName.right(3) != "png") | 359 | if (fileName.right(3) != "png") |
360 | fileName = fileName + ".png"; | 360 | fileName = fileName + ".png"; |
361 | lnk.setFile(fileName); //sets File property | 361 | lnk.setFile(fileName); //sets File property |
362 | qDebug("saving file " + fileName); | 362 | qDebug("saving file " + fileName); |
363 | snapshot.save( fileName, "PNG"); | 363 | snapshot.save( fileName, "PNG"); |
364 | QFileInfo fi( fileName); | 364 | QFileInfo fi( fileName); |
365 | lnk.setName( fi.fileName()); //sets file name | 365 | lnk.setName( fi.fileName()); //sets file name |
366 | 366 | ||
367 | if (!lnk.writeLink()) | 367 | if (!lnk.writeLink()) |
368 | qDebug("Writing doclink did not work"); | 368 | qDebug("Writing doclink did not work"); |
369 | } | 369 | } |
370 | else { | 370 | else { |
371 | 371 | ||
372 | fileName = "sc_" + QDateTime::currentDateTime().toString(); | 372 | fileName = "sc_" + QDateTime::currentDateTime().toString(); |
373 | fileName.replace(QRegExp("'"), ""); | 373 | fileName.replace(QRegExp("'"), ""); |
374 | fileName.replace(QRegExp(" "), "_"); | 374 | fileName.replace(QRegExp(" "), "_"); |
375 | fileName.replace(QRegExp(":"), "."); | 375 | fileName.replace(QRegExp(":"), "."); |
376 | fileName.replace(QRegExp(","), ""); | 376 | fileName.replace(QRegExp(","), ""); |
377 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; | 377 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; |
378 | 378 | ||
379 | if ( !QDir( dirName).exists() ) { | 379 | if ( !QDir( dirName).exists() ) { |
380 | qDebug("making dir " + dirName); | 380 | qDebug("making dir " + dirName); |
381 | QString msg = "mkdir -p " + dirName; | 381 | QString msg = "mkdir -p " + dirName; |
382 | system(msg.latin1()); | 382 | system(msg.latin1()); |
383 | } | 383 | } |
384 | fileName = dirName + fileName; | 384 | fileName = dirName + fileName; |
385 | if (fileName.right(3) != "png") | 385 | if (fileName.right(3) != "png") |
386 | fileName = fileName + ".png"; | 386 | fileName = fileName + ".png"; |
387 | lnk.setFile(fileName); //sets File property | 387 | lnk.setFile(fileName); //sets File property |
388 | qDebug("saving file " + fileName); | 388 | qDebug("saving file " + fileName); |
389 | snapshot.save( fileName, "PNG"); | 389 | snapshot.save( fileName, "PNG"); |
390 | QFileInfo fi( fileName); | 390 | QFileInfo fi( fileName); |
391 | lnk.setName( fi.fileName()); //sets file name | 391 | lnk.setName( fi.fileName()); //sets file name |
392 | 392 | ||
393 | if (!lnk.writeLink()) | 393 | if (!lnk.writeLink()) |
394 | qDebug("Writing doclink did not work"); | 394 | qDebug("Writing doclink did not work"); |
395 | 395 | ||
396 | } | 396 | } |
397 | 397 | ||
398 | QPEApplication::beep(); | 398 | QPEApplication::beep(); |
399 | } | 399 | } |
400 | 400 | ||
401 | void ScreenshotControl::performGrab() | 401 | void ScreenshotControl::performGrab() |
402 | { | 402 | { |
403 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); | 403 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); |
404 | 404 | ||
405 | if (buttonPushed == 1) { | 405 | if (buttonPushed == 1) { |
406 | qDebug("grabbing screen"); | 406 | qDebug("grabbing screen"); |
407 | grabTimer->stop(); | 407 | grabTimer->stop(); |
408 | show(); | 408 | show(); |
409 | qApp->processEvents(); | 409 | qApp->processEvents(); |
410 | savePixmap(); | 410 | savePixmap(); |
411 | } | 411 | } |
412 | else { | 412 | else { |
413 | grabTimer->stop(); | 413 | grabTimer->stop(); |
414 | 414 | ||
415 | struct sockaddr_in raddr; | 415 | struct sockaddr_in raddr; |
416 | struct hostent *rhost_info; | 416 | struct hostent *rhost_info; |
417 | int sock = -1; | 417 | int sock = -1; |
418 | bool ok = false; | 418 | bool ok = false; |
419 | 419 | ||
420 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { | 420 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { |
421 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); | 421 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); |
422 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); | 422 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); |
423 | raddr. sin_family = rhost_info-> h_addrtype; | 423 | raddr. sin_family = rhost_info-> h_addrtype; |
424 | raddr. sin_port = htons ( SCAP_port ); | 424 | raddr. sin_port = htons ( SCAP_port ); |
425 | 425 | ||
426 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) | 426 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) |
427 | { | 427 | { |
428 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { | 428 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { |
429 | QString header; | 429 | QString header; |
430 | 430 | ||
431 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user | 431 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user |
432 | "Content-length: 153600\n" | 432 | "Content-length: 153600\n" |
433 | "Content-Type: image/gif\n" | 433 | "Content-Type: image/gif\n" |
434 | "Host: %4\n" // 3: scap host | 434 | "Host: %4\n" // 3: scap host |
435 | "\n"; | 435 | "\n"; |
436 | 436 | ||
437 | header = header. arg ( "" ). arg ( ::getenv ( "USER" )). arg ( SCAP_hostname ); | 437 | header = header. arg ( "" ). arg ( ::getenv ( "USER" )). arg ( SCAP_hostname ); |
438 | 438 | ||
439 | QPixmap pix; | 439 | QPixmap pix; |
440 | 440 | ||
441 | if ( snapshot. width ( ) == 320 && snapshot. height ( ) == 240 ) | 441 | if ( snapshot. width ( ) == 320 && snapshot. height ( ) == 240 ) |
442 | { | 442 | { |
443 | pix = snapshot; | 443 | pix = snapshot; |
444 | } | 444 | } |
445 | else if ( snapshot. width ( ) == 240 && snapshot. height ( ) == 320 ) | 445 | else if ( snapshot. width ( ) == 240 && snapshot. height ( ) == 320 ) |
446 | { | 446 | { |
447 | pix = snapshot. xForm ( QWMatrix ( ). rotate ( 90 )); | 447 | pix = snapshot. xForm ( QWMatrix ( ). rotate ( 90 )); |
448 | } | 448 | } |
449 | 449 | ||
450 | if ( !pix. isNull ( )) | 450 | if ( !pix. isNull ( )) |
451 | { | 451 | { |
452 | const char *ascii = header. latin1 ( ); | 452 | const char *ascii = header. latin1 ( ); |
453 | uint ascii_len = ::strlen ( ascii ); | 453 | uint ascii_len = ::strlen ( ascii ); |
454 | 454 | ||
455 | ::write ( sock, ascii, ascii_len ); | 455 | ::write ( sock, ascii, ascii_len ); |
456 | 456 | ||
457 | QImage img = pix. convertToImage ( ). convertDepth ( 16 ); | 457 | QImage img = pix. convertToImage ( ). convertDepth ( 16 ); |
458 | ::write ( sock, img. bits ( ), img.numBytes ( )); | 458 | ::write ( sock, img. bits ( ), img.numBytes ( )); |
459 | 459 | ||
460 | ok = true; | 460 | ok = true; |
461 | } | 461 | } |
462 | } | 462 | } |
463 | ::close ( sock ); | 463 | ::close ( sock ); |
464 | } | 464 | } |
465 | } | 465 | } |
466 | if ( ok ) | 466 | if ( ok ) |
467 | QMessageBox::information ( 0, tr( "Success" ), QString ( "<p>%1</p>" ). arg ( tr( "Screenshot was uploaded to %1" )). arg ( SCAP_hostname )); | 467 | QMessageBox::information ( 0, tr( "Success" ), QString ( "<p>%1</p>" ). arg ( tr( "Screenshot was uploaded to %1" )). arg ( SCAP_hostname )); |
468 | else | 468 | else |
469 | QMessageBox::warning ( 0, tr( "Error" ), QString ( "<p>%1</p>" ). arg ( tr( "Connection to %1 failed." )). arg ( SCAP_hostname )); | 469 | QMessageBox::warning ( 0, tr( "Error" ), QString ( "<p>%1</p>" ). arg ( tr( "Connection to %1 failed." )). arg ( SCAP_hostname )); |
470 | } | 470 | } |
471 | 471 | ||
472 | } | 472 | } |
473 | 473 | ||
474 | 474 | ||
475 | 475 | ||
476 | //=========================================================================== | 476 | //=========================================================================== |
477 | 477 | ||
478 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) | 478 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) |
479 | : QWidget( parent, name ) | 479 | : QWidget( parent, name ) |
480 | { | 480 | { |
481 | setFixedWidth( AppLnk::smallIconSize()); | 481 | setFixedWidth( AppLnk::smallIconSize()); |
482 | 482 | ||
483 | QImage img = (const char **)snapshot_xpm; | 483 | QImage img = (const char **)snapshot_xpm; |
484 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); | 484 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); |
485 | m_icon.convertFromImage(img); | 485 | m_icon.convertFromImage(img); |
486 | } | 486 | } |
487 | 487 | ||
488 | ScreenshotApplet::~ScreenshotApplet() | 488 | ScreenshotApplet::~ScreenshotApplet() |
489 | { | 489 | { |
490 | } | 490 | } |
491 | 491 | ||
492 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) | 492 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) |
493 | { | 493 | { |
494 | ScreenshotControl *sc = new ScreenshotControl ( ); | 494 | ScreenshotControl *sc = new ScreenshotControl ( ); |
495 | QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); | 495 | QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); |
496 | sc-> move ( curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2, | 496 | |
497 | curPos. y ( ) - sc-> sizeHint ( ). height ( )); | 497 | // windowPosX is the windows position centered above the applets icon. |
498 | sc-> show ( ); | 498 | // If the icon is near the edge of the screen, the window would leave the visible area |
499 | // so we check the position against the screen width and correct the difference if needed | ||
500 | |||
501 | int screenWidth = qApp->desktop()->width(); | ||
502 | int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; | ||
503 | int ZwindowPosX, XwindowPosX; | ||
504 | |||
505 | // the window would be placed beyond the screen wich doesn't look tooo good | ||
506 | if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { | ||
507 | XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; | ||
508 | ZwindowPosX = windowPosX - XwindowPosX - 1; | ||
509 | } else { | ||
510 | ZwindowPosX = windowPosX; | ||
511 | } | ||
512 | |||
513 | sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); | ||
514 | sc-> show ( ); | ||
499 | } | 515 | } |
500 | 516 | ||
501 | void ScreenshotApplet::paintEvent( QPaintEvent* ) | 517 | void ScreenshotApplet::paintEvent( QPaintEvent* ) |
502 | { | 518 | { |
503 | QPainter p ( this ); | 519 | QPainter p ( this ); |
504 | p.drawPixmap( 0,0, m_icon ); | 520 | p.drawPixmap( 0,0, m_icon ); |
505 | } | 521 | } |
506 | 522 | ||