author | drw <drw> | 2005-03-08 22:00:32 (UTC) |
---|---|---|
committer | drw <drw> | 2005-03-08 22:00:32 (UTC) |
commit | 9b5178ed0e2dbde4357d3de1906201e5772ee935 (patch) (unidiff) | |
tree | 514613ea41384c5d160b76af7833e0f60dca393a | |
parent | 2b32d3e15f5774ee8f73977d606675e819498614 (diff) | |
download | opie-9b5178ed0e2dbde4357d3de1906201e5772ee935.zip opie-9b5178ed0e2dbde4357d3de1906201e5772ee935.tar.gz opie-9b5178ed0e2dbde4357d3de1906201e5772ee935.tar.bz2 |
Better version of icon
-rw-r--r-- | core/applets/screenshotapplet/opie-screenshotapplet.control | 2 | ||||
-rw-r--r-- | core/applets/screenshotapplet/screenshot.cpp | 225 |
2 files changed, 6 insertions, 221 deletions
diff --git a/core/applets/screenshotapplet/opie-screenshotapplet.control b/core/applets/screenshotapplet/opie-screenshotapplet.control index 5c0b64d..b0b9466 100644 --- a/core/applets/screenshotapplet/opie-screenshotapplet.control +++ b/core/applets/screenshotapplet/opie-screenshotapplet.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-screenshotapplet | 1 | Package: opie-screenshotapplet |
2 | Files: plugins/applets/libscreenshotapplet.so* | 2 | Files: plugins/applets/libscreenshotapplet.so* screenshotapplet/*.png |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applets | 4 | Section: opie/applets |
5 | Maintainer: L. J. Potter <lpotter@trolltech.com> | 5 | Maintainer: L. J. Potter <lpotter@trolltech.com> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Depends: task-opie-minimal | 7 | Depends: task-opie-minimal |
8 | Description: Screenshot Applet | 8 | Description: Screenshot Applet |
9 | A screenshot taskbar applet for the Opie environment | 9 | A screenshot taskbar applet for the Opie environment |
10 | Version: $QPE_VERSION$EXTRAVERSION | 10 | Version: $QPE_VERSION$EXTRAVERSION |
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp index 042f390..1d88aa5 100644 --- a/core/applets/screenshotapplet/screenshot.cpp +++ b/core/applets/screenshotapplet/screenshot.cpp | |||
@@ -1,353 +1,140 @@ | |||
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 | #include <qpe/qcopenvelope_qws.h> | 23 | #include <qpe/qcopenvelope_qws.h> |
24 | #include <qpe/resource.h> | ||
24 | 25 | ||
25 | 26 | ||
26 | /* QT */ | 27 | /* QT */ |
27 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
28 | #include <qdir.h> | 29 | #include <qdir.h> |
29 | #include <qlabel.h> | 30 | #include <qlabel.h> |
30 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
31 | #include <qpainter.h> | 32 | #include <qpainter.h> |
32 | #include <qspinbox.h> | 33 | #include <qspinbox.h> |
33 | #include <qlayout.h> | 34 | #include <qlayout.h> |
34 | #include <qcheckbox.h> | 35 | #include <qcheckbox.h> |
35 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
36 | 37 | ||
37 | /* STD */ | 38 | /* STD */ |
38 | #include <stdlib.h> | 39 | #include <stdlib.h> |
39 | #include <sys/socket.h> | 40 | #include <sys/socket.h> |
40 | #include <netinet/in.h> | 41 | #include <netinet/in.h> |
41 | #include <netdb.h> | 42 | #include <netdb.h> |
42 | #include <unistd.h> | 43 | #include <unistd.h> |
43 | 44 | ||
44 | /* XPM */ | ||
45 | static char * snapshot_xpm[] = { | ||
46 | "32 32 177 2", | ||
47 | " c None", | ||
48 | ". c #042045", | ||
49 | "+ c #0D2B47", | ||
50 | "@ c #0E325E", | ||
51 | "# c #0D2E50", | ||
52 | "$ c #0A1C32", | ||
53 | "% c #0F3A69", | ||
54 | "& c #164680", | ||
55 | "* c #165EAE", | ||
56 | "= c #134D89", | ||
57 | "- c #0A3A6E", | ||
58 | "; c #031024", | ||
59 | "> c #031B36", | ||
60 | ", c #1A5EA3", | ||
61 | "' c #1862B1", | ||
62 | ") c #1866B9", | ||
63 | "! c #0F5AAC", | ||
64 | "~ c #0F56A8", | ||
65 | "{ c #0C4C96", | ||
66 | "] c #030918", | ||
67 | "^ c #060206", | ||
68 | "/ c #20242C", | ||
69 | "( c #3E3B3B", | ||
70 | "_ c #186ABD", | ||
71 | ": c #115EB3", | ||
72 | "< c #082644", | ||
73 | "[ c #222C38", | ||
74 | "} c #5A5859", | ||
75 | "| c #091921", | ||
76 | "1 c #1E7EDE", | ||
77 | "2 c #1A7ADA", | ||
78 | "3 c #1970CD", | ||
79 | "4 c #1758A1", | ||
80 | "5 c #0E529A", | ||
81 | "6 c #094388", | ||
82 | "7 c #22364E", | ||
83 | "8 c #384454", | ||
84 | "9 c #04162C", | ||
85 | "0 c #123451", | ||
86 | "a c #3296B4", | ||
87 | "b c #298AB1", | ||
88 | "c c #2484AC", | ||
89 | "d c #033D86", | ||
90 | "e c #033677", | ||
91 | "f c #072C58", | ||
92 | "g c #525862", | ||
93 | "h c #5E5E5E", | ||
94 | "i c #23492A", | ||
95 | "j c #4FBD3F", | ||
96 | "k c #50B24C", | ||
97 | "l c #51C72E", | ||
98 | "m c #42C64A", | ||
99 | "n c #2686CA", | ||
100 | "o c #0B52A4", | ||
101 | "p c #054A9A", | ||
102 | "q c #053B7C", | ||
103 | "r c #2B2325", | ||
104 | "s c #6E7070", | ||
105 | "t c #0D240E", | ||
106 | "u c #1E423E", | ||
107 | "v c #468ABE", | ||
108 | "w c #6A8AC2", | ||
109 | "x c #7EAA8E", | ||
110 | "y c #84BE4E", | ||
111 | "z c #65C639", | ||
112 | "A c #064EA0", | ||
113 | "B c #0A4DA0", | ||
114 | "C c #4E5242", | ||
115 | "D c #62362E", | ||
116 | "E c #721A1A", | ||
117 | "F c #6E0A0A", | ||
118 | "G c #3E0E0E", | ||
119 | "H c #6AB85E", | ||
120 | "I c #7E8ECA", | ||
121 | "J c #929CD4", | ||
122 | "K c #9EAECA", | ||
123 | "L c #9EBEAE", | ||
124 | "M c #8EC26A", | ||
125 | "N c #32A276", | ||
126 | "O c #20518C", | ||
127 | "P c #46566E", | ||
128 | "Q c #614A51", | ||
129 | "R c #AE2A26", | ||
130 | "S c #C41C1A", | ||
131 | "T c #CE0A0A", | ||
132 | "U c #A60606", | ||
133 | "V c #921616", | ||
134 | "W c #863735", | ||
135 | "X c #866A66", | ||
136 | "Y c #9E9EA2", | ||
137 | "Z c #1E5212", | ||
138 | "` c #7EC652", | ||
139 | " . c #B2B2F2", | ||
140 | ".. c #CACAF6", | ||
141 | "+. c #AECEC6", | ||
142 | "@. c #92CE72", | ||
143 | "#. c #42AA86", | ||
144 | "$. c #365E96", | ||
145 | "%. c #B82420", | ||
146 | "&. c #E20E0E", | ||
147 | "*. c #EF0E0B", | ||
148 | "=. c #566A86", | ||
149 | "-. c #92929A", | ||
150 | ";. c #16260E", | ||
151 | ">. c #2E571A", | ||
152 | ",. c #7ED64E", | ||
153 | "'. c #9ECEB2", | ||
154 | "). c #C6D5EF", | ||
155 | "!. c #E2E0FE", | ||
156 | "~. c #A2DE8A", | ||
157 | "{. c #4AAA5B", | ||
158 | "]. c #2A6AB2", | ||
159 | "^. c #9A7A6E", | ||
160 | "/. c #D25A52", | ||
161 | "(. c #F62626", | ||
162 | "_. c #FA0206", | ||
163 | ":. c #DE1E16", | ||
164 | "<. c #B63A26", | ||
165 | "[. c #865A2E", | ||
166 | "}. c #26568E", | ||
167 | "|. c #435F7D", | ||
168 | "1. c #7AE246", | ||
169 | "2. c #96EA6E", | ||
170 | "3. c #BEEAAE", | ||
171 | "4. c #D0EADC", | ||
172 | "5. c #B6CEFE", | ||
173 | "6. c #9ADE8A", | ||
174 | "7. c #2A609A", | ||
175 | "8. c #7E623E", | ||
176 | "9. c #CA7A72", | ||
177 | "0. c #F26E6E", | ||
178 | "a. c #FE5252", | ||
179 | "b. c #FA3638", | ||
180 | "c. c #DA2E28", | ||
181 | "d. c #9E3E3A", | ||
182 | "e. c #3E7656", | ||
183 | "f. c #76CB3A", | ||
184 | "g. c #90DE44", | ||
185 | "h. c #A2EE6A", | ||
186 | "i. c #9EEA9A", | ||
187 | "j. c #92BEDE", | ||
188 | "k. c #7ADA7E", | ||
189 | "l. c #5ECE52", | ||
190 | "m. c #6A5E52", | ||
191 | "n. c #A83238", | ||
192 | "o. c #FA5656", | ||
193 | "p. c #F29A92", | ||
194 | "q. c #D29E92", | ||
195 | "r. c #8A7A62", | ||
196 | "s. c #05336B", | ||
197 | "t. c #59C631", | ||
198 | "u. c #8AD23A", | ||
199 | "v. c #66E242", | ||
200 | "w. c #1D6FC1", | ||
201 | "x. c #E61212", | ||
202 | "y. c #CA261E", | ||
203 | "z. c #5A763E", | ||
204 | "A. c #1E6E9A", | ||
205 | "B. c #023272", | ||
206 | "C. c #329696", | ||
207 | "D. c #2074B6", | ||
208 | "E. c #3E4E76", | ||
209 | "F. c #5A525E", | ||
210 | "G. c #425868", | ||
211 | "H. c #04448E", | ||
212 | "I. c #28828A", | ||
213 | "J. c #2D8593", | ||
214 | "K. c #12427A", | ||
215 | "L. c #054696", | ||
216 | "M. c #042B5E", | ||
217 | "N. c #134F95", | ||
218 | "O. c #1E6ABB", | ||
219 | "P. c #1A5E96", | ||
220 | "Q. c #022E67", | ||
221 | "R. c #0C3E7C", | ||
222 | "S. c #023E8A", | ||
223 | "T. c #021A3E", | ||
224 | " ", | ||
225 | " ", | ||
226 | " ", | ||
227 | " . + @ # + ", | ||
228 | " $ # % & * * = - # $ ", | ||
229 | "; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", | ||
230 | "; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", | ||
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 } ", | ||
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 ", | ||
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 =.-. ", | ||
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 # ", | ||
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.> ", | ||
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.> ", | ||
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 ", | ||
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.> ", | ||
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. ", | ||
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 ", | ||
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 ; ] ", | ||
253 | " | > e L.d L.H.e M.. ; ] ] ", | ||
254 | " > 9 . S.Q.. ; ] ", | ||
255 | " T.; ] "}; | ||
256 | |||
257 | |||
258 | using namespace Opie::Core; | 45 | using namespace Opie::Core; |
259 | using namespace Opie::Ui; | 46 | using namespace Opie::Ui; |
260 | 47 | ||
261 | static const char *SCAP_hostname = "www.handhelds.org"; | 48 | static const char *SCAP_hostname = "www.handhelds.org"; |
262 | static const int SCAP_port = 80; | 49 | static const int SCAP_port = 80; |
263 | 50 | ||
264 | 51 | ||
265 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) | 52 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) |
266 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 53 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
267 | { | 54 | { |
268 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 55 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
269 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); | 56 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); |
270 | QHBoxLayout *hbox; | 57 | QHBoxLayout *hbox; |
271 | 58 | ||
272 | hbox = new QHBoxLayout ( vbox ); | 59 | hbox = new QHBoxLayout ( vbox ); |
273 | 60 | ||
274 | QLabel *l = new QLabel ( tr( "Delay" ), this ); | 61 | QLabel *l = new QLabel ( tr( "Delay" ), this ); |
275 | hbox-> addWidget ( l ); | 62 | hbox-> addWidget ( l ); |
276 | 63 | ||
277 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); | 64 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); |
278 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 65 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
279 | delaySpin-> setSuffix ( tr( "sec" )); | 66 | delaySpin-> setSuffix ( tr( "sec" )); |
280 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); | 67 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); |
281 | delaySpin-> setValue ( 1 ); | 68 | delaySpin-> setValue ( 1 ); |
282 | hbox-> addWidget ( delaySpin ); | 69 | hbox-> addWidget ( delaySpin ); |
283 | 70 | ||
284 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); | 71 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); |
285 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); | 72 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); |
286 | vbox->addWidget( saveNamedCheck); | 73 | vbox->addWidget( saveNamedCheck); |
287 | 74 | ||
288 | vbox-> addSpacing ( 3 ); | 75 | vbox-> addSpacing ( 3 ); |
289 | 76 | ||
290 | l = new QLabel ( tr( "Save screenshot as..." ), this ); | 77 | l = new QLabel ( tr( "Save screenshot as..." ), this ); |
291 | vbox-> addWidget ( l, AlignCenter ); | 78 | vbox-> addWidget ( l, AlignCenter ); |
292 | 79 | ||
293 | hbox = new QHBoxLayout ( vbox ); | 80 | hbox = new QHBoxLayout ( vbox ); |
294 | 81 | ||
295 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); | 82 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); |
296 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); | 83 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); |
297 | hbox-> addWidget ( grabItButton ); | 84 | hbox-> addWidget ( grabItButton ); |
298 | 85 | ||
299 | QPushButton* drawPadButton = new QPushButton( tr("Opie drawpad"), this, "DrawPadButton" ); | 86 | QPushButton* drawPadButton = new QPushButton( tr("Opie drawpad"), this, "DrawPadButton" ); |
300 | drawPadButton->setFocusPolicy( QWidget::TabFocus ); | 87 | drawPadButton->setFocusPolicy( QWidget::TabFocus ); |
301 | hbox->addWidget( drawPadButton ); | 88 | hbox->addWidget( drawPadButton ); |
302 | 89 | ||
303 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); | 90 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); |
304 | scapButton ->setFocusPolicy( QWidget::TabFocus ); | 91 | scapButton ->setFocusPolicy( QWidget::TabFocus ); |
305 | hbox-> addWidget ( scapButton ); | 92 | hbox-> addWidget ( scapButton ); |
306 | 93 | ||
307 | setFixedSize ( sizeHint ( )); | 94 | setFixedSize ( sizeHint ( )); |
308 | setFocusPolicy ( QWidget::NoFocus ); | 95 | setFocusPolicy ( QWidget::NoFocus ); |
309 | 96 | ||
310 | 97 | ||
311 | grabTimer = new QTimer ( this, "grab timer"); | 98 | grabTimer = new QTimer ( this, "grab timer"); |
312 | 99 | ||
313 | connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab())); | 100 | connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab())); |
314 | connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab())); | 101 | connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab())); |
315 | connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap())); | 102 | connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap())); |
316 | connect ( drawPadButton, SIGNAL(clicked()), SLOT(slotDrawpad()) ); | 103 | connect ( drawPadButton, SIGNAL(clicked()), SLOT(slotDrawpad()) ); |
317 | } | 104 | } |
318 | 105 | ||
319 | void ScreenshotControl::slotGrab() | 106 | void ScreenshotControl::slotGrab() |
320 | { | 107 | { |
321 | buttonPushed = 1; | 108 | buttonPushed = 1; |
322 | hide(); | 109 | hide(); |
323 | 110 | ||
324 | setFileName = FALSE; | 111 | setFileName = FALSE; |
325 | if ( saveNamedCheck->isChecked()) { | 112 | if ( saveNamedCheck->isChecked()) { |
326 | setFileName = TRUE; | 113 | setFileName = TRUE; |
327 | InputDialog *fileDlg; | 114 | InputDialog *fileDlg; |
328 | 115 | ||
329 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); | 116 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); |
330 | fileDlg->exec(); | 117 | fileDlg->exec(); |
331 | fileDlg->raise(); | 118 | fileDlg->raise(); |
332 | QString fileName, list; | 119 | QString fileName, list; |
333 | if ( fileDlg->result() == 1 ) { | 120 | if ( fileDlg->result() == 1 ) { |
334 | fileName = fileDlg->LineEdit1->text(); | 121 | fileName = fileDlg->LineEdit1->text(); |
335 | 122 | ||
336 | if (fileName.find("/", 0, TRUE) == -1) | 123 | if (fileName.find("/", 0, TRUE) == -1) |
337 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; | 124 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; |
338 | else | 125 | else |
339 | FileNamePath = fileName; | 126 | FileNamePath = fileName; |
340 | 127 | ||
341 | } | 128 | } |
342 | delete fileDlg; | 129 | delete fileDlg; |
343 | } | 130 | } |
344 | 131 | ||
345 | if ( delaySpin->value() ) | 132 | if ( delaySpin->value() ) |
346 | grabTimer->start( delaySpin->value() * 1000, true ); | 133 | grabTimer->start( delaySpin->value() * 1000, true ); |
347 | else | 134 | else |
348 | show(); | 135 | show(); |
349 | } | 136 | } |
350 | 137 | ||
351 | void ScreenshotControl::slotScap() | 138 | void ScreenshotControl::slotScap() |
352 | { | 139 | { |
353 | buttonPushed = 2; | 140 | buttonPushed = 2; |
@@ -422,146 +209,144 @@ void ScreenshotControl::savePixmap() | |||
422 | } | 209 | } |
423 | 210 | ||
424 | void ScreenshotControl::performGrab() | 211 | void ScreenshotControl::performGrab() |
425 | { | 212 | { |
426 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); | 213 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); |
427 | 214 | ||
428 | if (buttonPushed == 1) { | 215 | if (buttonPushed == 1) { |
429 | odebug << "grabbing screen" << oendl; | 216 | odebug << "grabbing screen" << oendl; |
430 | grabTimer->stop(); | 217 | grabTimer->stop(); |
431 | show(); | 218 | show(); |
432 | qApp->processEvents(); | 219 | qApp->processEvents(); |
433 | savePixmap(); | 220 | savePixmap(); |
434 | }else if ( buttonPushed == 3 ) { | 221 | }else if ( buttonPushed == 3 ) { |
435 | grabTimer->stop(); | 222 | grabTimer->stop(); |
436 | show(); | 223 | show(); |
437 | QCopEnvelope env("QPE/Application/drawpad", "importPixmap(QPixmap)" ); | 224 | QCopEnvelope env("QPE/Application/drawpad", "importPixmap(QPixmap)" ); |
438 | env << snapshot; | 225 | env << snapshot; |
439 | } else { | 226 | } else { |
440 | grabTimer->stop(); | 227 | grabTimer->stop(); |
441 | 228 | ||
442 | struct sockaddr_in raddr; | 229 | struct sockaddr_in raddr; |
443 | struct hostent *rhost_info; | 230 | struct hostent *rhost_info; |
444 | int sock = -1; | 231 | int sock = -1; |
445 | bool ok = false; | 232 | bool ok = false; |
446 | 233 | ||
447 | QString displayEnv = getenv("QWS_DISPLAY"); | 234 | QString displayEnv = getenv("QWS_DISPLAY"); |
448 | odebug << displayEnv << oendl; | 235 | odebug << displayEnv << oendl; |
449 | 236 | ||
450 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { | 237 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { |
451 | 238 | ||
452 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { | 239 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { |
453 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); | 240 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); |
454 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); | 241 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); |
455 | raddr. sin_family = rhost_info-> h_addrtype; | 242 | raddr. sin_family = rhost_info-> h_addrtype; |
456 | raddr. sin_port = htons ( SCAP_port ); | 243 | raddr. sin_port = htons ( SCAP_port ); |
457 | 244 | ||
458 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { | 245 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { |
459 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { | 246 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { |
460 | 247 | ||
461 | QString header; | 248 | QString header; |
462 | 249 | ||
463 | QPixmap pix; | 250 | QPixmap pix; |
464 | 251 | ||
465 | QString SCAP_model=""; | 252 | QString SCAP_model=""; |
466 | #warning FIXME: model string should be filled with actual device model | 253 | #warning FIXME: model string should be filled with actual device model |
467 | if( snapshot.width() > 320) | 254 | if( snapshot.width() > 320) |
468 | SCAP_model ="Corgi"; | 255 | SCAP_model ="Corgi"; |
469 | 256 | ||
470 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! | 257 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! |
471 | pix = snapshot.xForm(QWMatrix().rotate(90)); | 258 | pix = snapshot.xForm(QWMatrix().rotate(90)); |
472 | } else | 259 | } else |
473 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); | 260 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); |
474 | 261 | ||
475 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it | 262 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it |
476 | 263 | ||
477 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user | 264 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user |
478 | "Content-length: %3\n" // 3: content length | 265 | "Content-length: %3\n" // 3: content length |
479 | "Content-Type: image/png\n" | 266 | "Content-Type: image/png\n" |
480 | "Host: %4\n" // 4: scap host | 267 | "Host: %4\n" // 4: scap host |
481 | "\n"; | 268 | "\n"; |
482 | 269 | ||
483 | 270 | ||
484 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); | 271 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); |
485 | odebug << header << oendl; | 272 | odebug << header << oendl; |
486 | 273 | ||
487 | if ( !pix.isNull() ) { | 274 | if ( !pix.isNull() ) { |
488 | const char *ascii = header.latin1( ); | 275 | const char *ascii = header.latin1( ); |
489 | uint ascii_len = ::strlen( ascii ); | 276 | uint ascii_len = ::strlen( ascii ); |
490 | ::write ( sock, ascii, ascii_len ); | 277 | ::write ( sock, ascii, ascii_len ); |
491 | ::write ( sock, img.bits(), img.numBytes() ); | 278 | ::write ( sock, img.bits(), img.numBytes() ); |
492 | 279 | ||
493 | ok = true; | 280 | ok = true; |
494 | } | 281 | } |
495 | } | 282 | } |
496 | ::close ( sock ); | 283 | ::close ( sock ); |
497 | } | 284 | } |
498 | } | 285 | } |
499 | if ( ok ) { | 286 | if ( ok ) { |
500 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); | 287 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); |
501 | } else { | 288 | } else { |
502 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); | 289 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); |
503 | } | 290 | } |
504 | } else { | 291 | } else { |
505 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); | 292 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); |
506 | } | 293 | } |
507 | } | 294 | } |
508 | 295 | ||
509 | } | 296 | } |
510 | 297 | ||
511 | 298 | ||
512 | 299 | ||
513 | //=========================================================================== | 300 | //=========================================================================== |
514 | 301 | ||
515 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) | 302 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) |
516 | : QWidget( parent, name ) | 303 | : QWidget( parent, name ) |
517 | { | 304 | { |
518 | setFixedWidth( AppLnk::smallIconSize()); | 305 | setFixedHeight( AppLnk::smallIconSize() ); |
519 | 306 | setFixedWidth( AppLnk::smallIconSize() ); | |
520 | QImage img = (const char **)snapshot_xpm; | 307 | m_icon.convertFromImage( Resource::loadImage( "screenshotapplet/screenshot" ).smoothScale( height(), width() ) ); |
521 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); | ||
522 | m_icon.convertFromImage(img); | ||
523 | } | 308 | } |
524 | 309 | ||
525 | ScreenshotApplet::~ScreenshotApplet() | 310 | ScreenshotApplet::~ScreenshotApplet() |
526 | { | 311 | { |
527 | } | 312 | } |
528 | 313 | ||
529 | int ScreenshotApplet::position() | 314 | int ScreenshotApplet::position() |
530 | { | 315 | { |
531 | return 6; | 316 | return 6; |
532 | } | 317 | } |
533 | 318 | ||
534 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) | 319 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) |
535 | { | 320 | { |
536 | ScreenshotControl *sc = new ScreenshotControl ( ); | 321 | ScreenshotControl *sc = new ScreenshotControl ( ); |
537 | QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); | 322 | QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); |
538 | 323 | ||
539 | // windowPosX is the windows position centered above the applets icon. | 324 | // windowPosX is the windows position centered above the applets icon. |
540 | // If the icon is near the edge of the screen, the window would leave the visible area | 325 | // If the icon is near the edge of the screen, the window would leave the visible area |
541 | // so we check the position against the screen width and correct the difference if needed | 326 | // so we check the position against the screen width and correct the difference if needed |
542 | 327 | ||
543 | int screenWidth = qApp->desktop()->width(); | 328 | int screenWidth = qApp->desktop()->width(); |
544 | int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; | 329 | int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; |
545 | int ZwindowPosX, XwindowPosX; | 330 | int ZwindowPosX, XwindowPosX; |
546 | 331 | ||
547 | // the window would be placed beyond the screen wich doesn't look tooo good | 332 | // the window would be placed beyond the screen wich doesn't look tooo good |
548 | if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { | 333 | if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { |
549 | XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; | 334 | XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; |
550 | ZwindowPosX = windowPosX - XwindowPosX - 1; | 335 | ZwindowPosX = windowPosX - XwindowPosX - 1; |
551 | } else { | 336 | } else { |
552 | ZwindowPosX = windowPosX; | 337 | ZwindowPosX = windowPosX; |
553 | } | 338 | } |
554 | 339 | ||
555 | sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); | 340 | sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); |
556 | sc-> show ( ); | 341 | sc-> show ( ); |
557 | } | 342 | } |
558 | 343 | ||
559 | void ScreenshotApplet::paintEvent( QPaintEvent* ) | 344 | void ScreenshotApplet::paintEvent( QPaintEvent* ) |
560 | { | 345 | { |
561 | QPainter p ( this ); | 346 | QPainter p ( this ); |
562 | p.drawPixmap( 0,0, m_icon ); | 347 | p.drawPixmap( 0, 2, m_icon ); |
563 | } | 348 | } |
564 | 349 | ||
565 | 350 | ||
566 | EXPORT_OPIE_APPLET_v1( ScreenshotApplet ) | 351 | EXPORT_OPIE_APPLET_v1( ScreenshotApplet ) |
567 | 352 | ||