Diffstat (limited to 'core/applets/screenshotapplet/screenshot.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/applets/screenshotapplet/screenshot.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp index 5d6bce4..20e1c9b 100644 --- a/core/applets/screenshotapplet/screenshot.cpp +++ b/core/applets/screenshotapplet/screenshot.cpp | |||
@@ -110,387 +110,387 @@ static char * snapshot_xpm[] = { | |||
110 | "B c #0A4DA0", | 110 | "B c #0A4DA0", |
111 | "C c #4E5242", | 111 | "C c #4E5242", |
112 | "D c #62362E", | 112 | "D c #62362E", |
113 | "E c #721A1A", | 113 | "E c #721A1A", |
114 | "F c #6E0A0A", | 114 | "F c #6E0A0A", |
115 | "G c #3E0E0E", | 115 | "G c #3E0E0E", |
116 | "H c #6AB85E", | 116 | "H c #6AB85E", |
117 | "I c #7E8ECA", | 117 | "I c #7E8ECA", |
118 | "J c #929CD4", | 118 | "J c #929CD4", |
119 | "K c #9EAECA", | 119 | "K c #9EAECA", |
120 | "L c #9EBEAE", | 120 | "L c #9EBEAE", |
121 | "M c #8EC26A", | 121 | "M c #8EC26A", |
122 | "N c #32A276", | 122 | "N c #32A276", |
123 | "O c #20518C", | 123 | "O c #20518C", |
124 | "P c #46566E", | 124 | "P c #46566E", |
125 | "Q c #614A51", | 125 | "Q c #614A51", |
126 | "R c #AE2A26", | 126 | "R c #AE2A26", |
127 | "S c #C41C1A", | 127 | "S c #C41C1A", |
128 | "T c #CE0A0A", | 128 | "T c #CE0A0A", |
129 | "U c #A60606", | 129 | "U c #A60606", |
130 | "V c #921616", | 130 | "V c #921616", |
131 | "W c #863735", | 131 | "W c #863735", |
132 | "X c #866A66", | 132 | "X c #866A66", |
133 | "Y c #9E9EA2", | 133 | "Y c #9E9EA2", |
134 | "Z c #1E5212", | 134 | "Z c #1E5212", |
135 | "` c #7EC652", | 135 | "` c #7EC652", |
136 | " .c #B2B2F2", | 136 | " .c #B2B2F2", |
137 | "..c #CACAF6", | 137 | "..c #CACAF6", |
138 | "+.c #AECEC6", | 138 | "+.c #AECEC6", |
139 | "@.c #92CE72", | 139 | "@.c #92CE72", |
140 | "#.c #42AA86", | 140 | "#.c #42AA86", |
141 | "$.c #365E96", | 141 | "$.c #365E96", |
142 | "%.c #B82420", | 142 | "%.c #B82420", |
143 | "&.c #E20E0E", | 143 | "&.c #E20E0E", |
144 | "*.c #EF0E0B", | 144 | "*.c #EF0E0B", |
145 | "=.c #566A86", | 145 | "=.c #566A86", |
146 | "-.c #92929A", | 146 | "-.c #92929A", |
147 | ";.c #16260E", | 147 | ";.c #16260E", |
148 | ">.c #2E571A", | 148 | ">.c #2E571A", |
149 | ",.c #7ED64E", | 149 | ",.c #7ED64E", |
150 | "'.c #9ECEB2", | 150 | "'.c #9ECEB2", |
151 | ").c #C6D5EF", | 151 | ").c #C6D5EF", |
152 | "!.c #E2E0FE", | 152 | "!.c #E2E0FE", |
153 | "~.c #A2DE8A", | 153 | "~.c #A2DE8A", |
154 | "{.c #4AAA5B", | 154 | "{.c #4AAA5B", |
155 | "].c #2A6AB2", | 155 | "].c #2A6AB2", |
156 | "^.c #9A7A6E", | 156 | "^.c #9A7A6E", |
157 | "/.c #D25A52", | 157 | "/.c #D25A52", |
158 | "(.c #F62626", | 158 | "(.c #F62626", |
159 | "_.c #FA0206", | 159 | "_.c #FA0206", |
160 | ":.c #DE1E16", | 160 | ":.c #DE1E16", |
161 | "<.c #B63A26", | 161 | "<.c #B63A26", |
162 | "[.c #865A2E", | 162 | "[.c #865A2E", |
163 | "}.c #26568E", | 163 | "}.c #26568E", |
164 | "|.c #435F7D", | 164 | "|.c #435F7D", |
165 | "1.c #7AE246", | 165 | "1.c #7AE246", |
166 | "2.c #96EA6E", | 166 | "2.c #96EA6E", |
167 | "3.c #BEEAAE", | 167 | "3.c #BEEAAE", |
168 | "4.c #D0EADC", | 168 | "4.c #D0EADC", |
169 | "5.c #B6CEFE", | 169 | "5.c #B6CEFE", |
170 | "6.c #9ADE8A", | 170 | "6.c #9ADE8A", |
171 | "7.c #2A609A", | 171 | "7.c #2A609A", |
172 | "8.c #7E623E", | 172 | "8.c #7E623E", |
173 | "9.c #CA7A72", | 173 | "9.c #CA7A72", |
174 | "0.c #F26E6E", | 174 | "0.c #F26E6E", |
175 | "a.c #FE5252", | 175 | "a.c #FE5252", |
176 | "b.c #FA3638", | 176 | "b.c #FA3638", |
177 | "c.c #DA2E28", | 177 | "c.c #DA2E28", |
178 | "d.c #9E3E3A", | 178 | "d.c #9E3E3A", |
179 | "e.c #3E7656", | 179 | "e.c #3E7656", |
180 | "f.c #76CB3A", | 180 | "f.c #76CB3A", |
181 | "g.c #90DE44", | 181 | "g.c #90DE44", |
182 | "h.c #A2EE6A", | 182 | "h.c #A2EE6A", |
183 | "i.c #9EEA9A", | 183 | "i.c #9EEA9A", |
184 | "j.c #92BEDE", | 184 | "j.c #92BEDE", |
185 | "k.c #7ADA7E", | 185 | "k.c #7ADA7E", |
186 | "l.c #5ECE52", | 186 | "l.c #5ECE52", |
187 | "m.c #6A5E52", | 187 | "m.c #6A5E52", |
188 | "n.c #A83238", | 188 | "n.c #A83238", |
189 | "o.c #FA5656", | 189 | "o.c #FA5656", |
190 | "p.c #F29A92", | 190 | "p.c #F29A92", |
191 | "q.c #D29E92", | 191 | "q.c #D29E92", |
192 | "r.c #8A7A62", | 192 | "r.c #8A7A62", |
193 | "s.c #05336B", | 193 | "s.c #05336B", |
194 | "t.c #59C631", | 194 | "t.c #59C631", |
195 | "u.c #8AD23A", | 195 | "u.c #8AD23A", |
196 | "v.c #66E242", | 196 | "v.c #66E242", |
197 | "w.c #1D6FC1", | 197 | "w.c #1D6FC1", |
198 | "x.c #E61212", | 198 | "x.c #E61212", |
199 | "y.c #CA261E", | 199 | "y.c #CA261E", |
200 | "z.c #5A763E", | 200 | "z.c #5A763E", |
201 | "A.c #1E6E9A", | 201 | "A.c #1E6E9A", |
202 | "B.c #023272", | 202 | "B.c #023272", |
203 | "C.c #329696", | 203 | "C.c #329696", |
204 | "D.c #2074B6", | 204 | "D.c #2074B6", |
205 | "E.c #3E4E76", | 205 | "E.c #3E4E76", |
206 | "F.c #5A525E", | 206 | "F.c #5A525E", |
207 | "G.c #425868", | 207 | "G.c #425868", |
208 | "H.c #04448E", | 208 | "H.c #04448E", |
209 | "I.c #28828A", | 209 | "I.c #28828A", |
210 | "J.c #2D8593", | 210 | "J.c #2D8593", |
211 | "K.c #12427A", | 211 | "K.c #12427A", |
212 | "L.c #054696", | 212 | "L.c #054696", |
213 | "M.c #042B5E", | 213 | "M.c #042B5E", |
214 | "N.c #134F95", | 214 | "N.c #134F95", |
215 | "O.c #1E6ABB", | 215 | "O.c #1E6ABB", |
216 | "P.c #1A5E96", | 216 | "P.c #1A5E96", |
217 | "Q.c #022E67", | 217 | "Q.c #022E67", |
218 | "R.c #0C3E7C", | 218 | "R.c #0C3E7C", |
219 | "S.c #023E8A", | 219 | "S.c #023E8A", |
220 | "T.c #021A3E", | 220 | "T.c #021A3E", |
221 | " ", | 221 | " ", |
222 | " ", | 222 | " ", |
223 | " ", | 223 | " ", |
224 | " . + @ # + ", | 224 | " . + @ # + ", |
225 | " $ # % & * * = - # $ ", | 225 | " $ # % & * * = - # $ ", |
226 | "; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", | 226 | "; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", |
227 | "; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", | 227 | "; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", |
228 | "| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ", | 228 | "| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ", |
229 | "9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ", | 229 | "9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ", |
230 | "| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ", | 230 | "| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ", |
231 | "t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ", | 231 | "t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ", |
232 | "| 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 ", | 232 | "| 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 ", |
233 | "| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ", | 233 | "| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ", |
234 | ";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ", | 234 | ";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ", |
235 | ";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ", | 235 | ";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ", |
236 | ";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ", | 236 | ";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ", |
237 | "t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ", | 237 | "t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ", |
238 | "| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ", | 238 | "| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ", |
239 | "; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ", | 239 | "; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ", |
240 | "9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ", | 240 | "9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ", |
241 | "9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ", | 241 | "9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ", |
242 | "; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ", | 242 | "; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ", |
243 | "; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ", | 243 | "; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ", |
244 | " ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ", | 244 | " ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ", |
245 | " # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ", | 245 | " # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ", |
246 | " + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ", | 246 | " + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ", |
247 | " < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ", | 247 | " < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ", |
248 | " $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ", | 248 | " $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ", |
249 | " ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ", | 249 | " ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ", |
250 | " | > e L.d L.H.e M.. ; ] ] ", | 250 | " | > e L.d L.H.e M.. ; ] ] ", |
251 | " > 9 . S.Q.. ; ] ", | 251 | " > 9 . S.Q.. ; ] ", |
252 | " T.; ] "}; | 252 | " T.; ] "}; |
253 | 253 | ||
254 | static const char *SCAP_hostname = "www.handhelds.org"; | 254 | static const char *SCAP_hostname = "www.handhelds.org"; |
255 | static const int SCAP_port = 80; | 255 | static const int SCAP_port = 80; |
256 | 256 | ||
257 | 257 | ||
258 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) | 258 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) |
259 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 259 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
260 | { | 260 | { |
261 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 261 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
262 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); | 262 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); |
263 | QHBoxLayout *hbox; | 263 | QHBoxLayout *hbox; |
264 | 264 | ||
265 | hbox = new QHBoxLayout ( vbox ); | 265 | hbox = new QHBoxLayout ( vbox ); |
266 | 266 | ||
267 | QLabel *l = new QLabel ( tr( "Delay" ), this ); | 267 | QLabel *l = new QLabel ( tr( "Delay" ), this ); |
268 | hbox-> addWidget ( l ); | 268 | hbox-> addWidget ( l ); |
269 | 269 | ||
270 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); | 270 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); |
271 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 271 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
272 | delaySpin-> setSuffix ( tr( "sec" )); | 272 | delaySpin-> setSuffix ( tr( "sec" )); |
273 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); | 273 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); |
274 | delaySpin-> setValue ( 1 ); | 274 | delaySpin-> setValue ( 1 ); |
275 | hbox-> addWidget ( delaySpin ); | 275 | hbox-> addWidget ( delaySpin ); |
276 | 276 | ||
277 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); | 277 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); |
278 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); | 278 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); |
279 | vbox->addWidget( saveNamedCheck); | 279 | vbox->addWidget( saveNamedCheck); |
280 | 280 | ||
281 | vbox-> addSpacing ( 3 ); | 281 | vbox-> addSpacing ( 3 ); |
282 | 282 | ||
283 | l = new QLabel ( tr( "Save screenshot as..." ), this ); | 283 | l = new QLabel ( tr( "Save screenshot as..." ), this ); |
284 | vbox-> addWidget ( l, AlignCenter ); | 284 | vbox-> addWidget ( l, AlignCenter ); |
285 | 285 | ||
286 | hbox = new QHBoxLayout ( vbox ); | 286 | hbox = new QHBoxLayout ( vbox ); |
287 | 287 | ||
288 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); | 288 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); |
289 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); | 289 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); |
290 | hbox-> addWidget ( grabItButton ); | 290 | hbox-> addWidget ( grabItButton ); |
291 | 291 | ||
292 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); | 292 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); |
293 | scapButton ->setFocusPolicy( QWidget::TabFocus ); | 293 | scapButton ->setFocusPolicy( QWidget::TabFocus ); |
294 | hbox-> addWidget ( scapButton ); | 294 | hbox-> addWidget ( scapButton ); |
295 | 295 | ||
296 | setFixedSize ( sizeHint ( )); | 296 | setFixedSize ( sizeHint ( )); |
297 | setFocusPolicy ( QWidget::NoFocus ); | 297 | setFocusPolicy ( QWidget::NoFocus ); |
298 | 298 | ||
299 | 299 | ||
300 | grabTimer = new QTimer ( this, "grab timer"); | 300 | grabTimer = new QTimer ( this, "grab timer"); |
301 | 301 | ||
302 | connect ( grabTimer, SIGNAL( timeout ( )), this, SLOT( performGrab ( ))); | 302 | connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab())); |
303 | connect ( grabItButton, SIGNAL( clicked ( )), SLOT( slotGrab ( ))); | 303 | connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab())); |
304 | connect ( scapButton, SIGNAL( clicked ( )), SLOT( slotScap ( ))); | 304 | connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap())); |
305 | } | 305 | } |
306 | 306 | ||
307 | void ScreenshotControl::slotGrab() | 307 | void ScreenshotControl::slotGrab() |
308 | { | 308 | { |
309 | buttonPushed = 1; | 309 | buttonPushed = 1; |
310 | hide(); | 310 | hide(); |
311 | 311 | ||
312 | setFileName = FALSE; | 312 | setFileName = FALSE; |
313 | if ( saveNamedCheck->isChecked()) { | 313 | if ( saveNamedCheck->isChecked()) { |
314 | setFileName = TRUE; | 314 | setFileName = TRUE; |
315 | InputDialog *fileDlg; | 315 | InputDialog *fileDlg; |
316 | 316 | ||
317 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); | 317 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); |
318 | fileDlg->exec(); | 318 | fileDlg->exec(); |
319 | fileDlg->raise(); | 319 | fileDlg->raise(); |
320 | QString fileName, list; | 320 | QString fileName, list; |
321 | if ( fileDlg->result() == 1 ) { | 321 | if ( fileDlg->result() == 1 ) { |
322 | fileName = fileDlg->LineEdit1->text(); | 322 | fileName = fileDlg->LineEdit1->text(); |
323 | 323 | ||
324 | if (fileName.find("/", 0, TRUE) == -1) | 324 | if (fileName.find("/", 0, TRUE) == -1) |
325 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; | 325 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; |
326 | else | 326 | else |
327 | FileNamePath = fileName; | 327 | FileNamePath = fileName; |
328 | 328 | ||
329 | } | 329 | } |
330 | delete fileDlg; | 330 | delete fileDlg; |
331 | } | 331 | } |
332 | 332 | ||
333 | if ( delaySpin->value() ) | 333 | if ( delaySpin->value() ) |
334 | grabTimer->start( delaySpin->value() * 1000, true ); | 334 | grabTimer->start( delaySpin->value() * 1000, true ); |
335 | else | 335 | else |
336 | show(); | 336 | show(); |
337 | } | 337 | } |
338 | 338 | ||
339 | void ScreenshotControl::slotScap() | 339 | void ScreenshotControl::slotScap() |
340 | { | 340 | { |
341 | buttonPushed = 2; | 341 | buttonPushed = 2; |
342 | hide(); | 342 | hide(); |
343 | 343 | ||
344 | if ( delaySpin->value() ) | 344 | if ( delaySpin->value() ) |
345 | grabTimer->start( delaySpin->value() * 1000, true ); | 345 | grabTimer->start( delaySpin->value() * 1000, true ); |
346 | else | 346 | else |
347 | show(); | 347 | show(); |
348 | } | 348 | } |
349 | 349 | ||
350 | 350 | ||
351 | void ScreenshotControl::savePixmap() | 351 | void ScreenshotControl::savePixmap() |
352 | { | 352 | { |
353 | DocLnk lnk; | 353 | DocLnk lnk; |
354 | QString fileName; | 354 | QString fileName; |
355 | 355 | ||
356 | if ( setFileName) { | 356 | if ( setFileName) { |
357 | fileName = FileNamePath; | 357 | fileName = FileNamePath; |
358 | //not sure why this is needed here, but it forgets fileName | 358 | //not sure why this is needed here, but it forgets fileName |
359 | // if this is below the braces | 359 | // if this is below the braces |
360 | 360 | ||
361 | if (fileName.right(3) != "png") | 361 | if (fileName.right(3) != "png") |
362 | fileName = fileName + ".png"; | 362 | fileName = fileName + ".png"; |
363 | lnk.setFile(fileName); //sets File property | 363 | lnk.setFile(fileName); //sets File property |
364 | qDebug("saving file " + fileName); | 364 | qDebug("saving file " + fileName); |
365 | snapshot.save( fileName, "PNG"); | 365 | snapshot.save( fileName, "PNG"); |
366 | QFileInfo fi( fileName); | 366 | QFileInfo fi( fileName); |
367 | lnk.setName( fi.fileName()); //sets file name | 367 | lnk.setName( fi.fileName()); //sets file name |
368 | 368 | ||
369 | if (!lnk.writeLink()) | 369 | if (!lnk.writeLink()) |
370 | qDebug("Writing doclink did not work"); | 370 | qDebug("Writing doclink did not work"); |
371 | } | 371 | } |
372 | else { | 372 | else { |
373 | 373 | ||
374 | fileName = "sc_" + QDateTime::currentDateTime().toString(); | 374 | fileName = "sc_" + QDateTime::currentDateTime().toString(); |
375 | fileName.replace(QRegExp("'"), ""); | 375 | fileName.replace(QRegExp("'"), ""); |
376 | fileName.replace(QRegExp(" "), "_"); | 376 | fileName.replace(QRegExp(" "), "_"); |
377 | fileName.replace(QRegExp(":"), "."); | 377 | fileName.replace(QRegExp(":"), "."); |
378 | fileName.replace(QRegExp(","), ""); | 378 | fileName.replace(QRegExp(","), ""); |
379 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; | 379 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; |
380 | 380 | ||
381 | if ( !QDir( dirName).exists() ) { | 381 | if ( !QDir( dirName).exists() ) { |
382 | qDebug("making dir " + dirName); | 382 | qDebug("making dir " + dirName); |
383 | QString msg = "mkdir -p " + dirName; | 383 | QString msg = "mkdir -p " + dirName; |
384 | system(msg.latin1()); | 384 | system(msg.latin1()); |
385 | } | 385 | } |
386 | fileName = dirName + fileName; | 386 | fileName = dirName + fileName; |
387 | if (fileName.right(3) != "png") | 387 | if (fileName.right(3) != "png") |
388 | fileName = fileName + ".png"; | 388 | fileName = fileName + ".png"; |
389 | lnk.setFile(fileName); //sets File property | 389 | lnk.setFile(fileName); //sets File property |
390 | qDebug("saving file " + fileName); | 390 | qDebug("saving file " + fileName); |
391 | snapshot.save( fileName, "PNG"); | 391 | snapshot.save( fileName, "PNG"); |
392 | QFileInfo fi( fileName); | 392 | QFileInfo fi( fileName); |
393 | lnk.setName( fi.fileName()); //sets file name | 393 | lnk.setName( fi.fileName()); //sets file name |
394 | 394 | ||
395 | if (!lnk.writeLink()) | 395 | if (!lnk.writeLink()) |
396 | qDebug("Writing doclink did not work"); | 396 | qDebug("Writing doclink did not work"); |
397 | 397 | ||
398 | } | 398 | } |
399 | 399 | ||
400 | QPEApplication::beep(); | 400 | QPEApplication::beep(); |
401 | } | 401 | } |
402 | 402 | ||
403 | void ScreenshotControl::performGrab() | 403 | void ScreenshotControl::performGrab() |
404 | { | 404 | { |
405 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); | 405 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); |
406 | 406 | ||
407 | if (buttonPushed == 1) { | 407 | if (buttonPushed == 1) { |
408 | qDebug("grabbing screen"); | 408 | qDebug("grabbing screen"); |
409 | grabTimer->stop(); | 409 | grabTimer->stop(); |
410 | show(); | 410 | show(); |
411 | qApp->processEvents(); | 411 | qApp->processEvents(); |
412 | savePixmap(); | 412 | savePixmap(); |
413 | } else { | 413 | } else { |
414 | grabTimer->stop(); | 414 | grabTimer->stop(); |
415 | 415 | ||
416 | struct sockaddr_in raddr; | 416 | struct sockaddr_in raddr; |
417 | struct hostent *rhost_info; | 417 | struct hostent *rhost_info; |
418 | int sock = -1; | 418 | int sock = -1; |
419 | bool ok = false; | 419 | bool ok = false; |
420 | 420 | ||
421 | QString displayEnv = getenv("QWS_DISPLAY"); | 421 | QString displayEnv = getenv("QWS_DISPLAY"); |
422 | qDebug(displayEnv); | 422 | qDebug(displayEnv); |
423 | 423 | ||
424 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { | 424 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { |
425 | 425 | ||
426 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { | 426 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { |
427 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); | 427 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); |
428 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); | 428 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); |
429 | raddr. sin_family = rhost_info-> h_addrtype; | 429 | raddr. sin_family = rhost_info-> h_addrtype; |
430 | raddr. sin_port = htons ( SCAP_port ); | 430 | raddr. sin_port = htons ( SCAP_port ); |
431 | 431 | ||
432 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { | 432 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { |
433 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { | 433 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { |
434 | 434 | ||
435 | QString header; | 435 | QString header; |
436 | 436 | ||
437 | QPixmap pix; | 437 | QPixmap pix; |
438 | 438 | ||
439 | QString SCAP_model=""; | 439 | QString SCAP_model=""; |
440 | #warning FIXME: model string should be filled with actual device model | 440 | #warning FIXME: model string should be filled with actual device model |
441 | if( snapshot.width() > 320) | 441 | if( snapshot.width() > 320) |
442 | SCAP_model ="Corgi"; | 442 | SCAP_model ="Corgi"; |
443 | 443 | ||
444 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! | 444 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! |
445 | pix = snapshot.xForm(QWMatrix().rotate(90)); | 445 | pix = snapshot.xForm(QWMatrix().rotate(90)); |
446 | } else | 446 | } else |
447 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); | 447 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); |
448 | 448 | ||
449 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it | 449 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it |
450 | 450 | ||
451 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user | 451 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user |
452 | "Content-length: %3\n" // 3: content length | 452 | "Content-length: %3\n" // 3: content length |
453 | "Content-Type: image/png\n" | 453 | "Content-Type: image/png\n" |
454 | "Host: %4\n" // 4: scap host | 454 | "Host: %4\n" // 4: scap host |
455 | "\n"; | 455 | "\n"; |
456 | 456 | ||
457 | 457 | ||
458 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); | 458 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); |
459 | qDebug(header); | 459 | qDebug(header); |
460 | 460 | ||
461 | if ( !pix.isNull() ) { | 461 | if ( !pix.isNull() ) { |
462 | const char *ascii = header.latin1( ); | 462 | const char *ascii = header.latin1( ); |
463 | uint ascii_len = ::strlen( ascii ); | 463 | uint ascii_len = ::strlen( ascii ); |
464 | ::write ( sock, ascii, ascii_len ); | 464 | ::write ( sock, ascii, ascii_len ); |
465 | ::write ( sock, img.bits(), img.numBytes() ); | 465 | ::write ( sock, img.bits(), img.numBytes() ); |
466 | 466 | ||
467 | ok = true; | 467 | ok = true; |
468 | } | 468 | } |
469 | } | 469 | } |
470 | ::close ( sock ); | 470 | ::close ( sock ); |
471 | } | 471 | } |
472 | } | 472 | } |
473 | if ( ok ) { | 473 | if ( ok ) { |
474 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); | 474 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); |
475 | } else { | 475 | } else { |
476 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); | 476 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); |
477 | } | 477 | } |
478 | } else { | 478 | } else { |
479 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); | 479 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); |
480 | } | 480 | } |
481 | } | 481 | } |
482 | 482 | ||
483 | } | 483 | } |
484 | 484 | ||
485 | 485 | ||
486 | 486 | ||
487 | //=========================================================================== | 487 | //=========================================================================== |
488 | 488 | ||
489 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) | 489 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) |
490 | : QWidget( parent, name ) | 490 | : QWidget( parent, name ) |
491 | { | 491 | { |
492 | setFixedWidth( AppLnk::smallIconSize()); | 492 | setFixedWidth( AppLnk::smallIconSize()); |
493 | 493 | ||
494 | QImage img = (const char **)snapshot_xpm; | 494 | QImage img = (const char **)snapshot_xpm; |
495 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); | 495 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); |
496 | m_icon.convertFromImage(img); | 496 | m_icon.convertFromImage(img); |