summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/screenshotapplet/screenshot.cpp27
-rw-r--r--core/applets/screenshotapplet/screenshot.h11
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
@@ -11,26 +11,26 @@
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>
23using namespace Opie::Core; 23#include <qpe/qcopenvelope_qws.h>
24using 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
@@ -245,24 +245,28 @@ static char * snapshot_xpm[] = {
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
258using namespace Opie::Core;
259using namespace Opie::Ui;
260
257static const char *SCAP_hostname = "www.handhelds.org"; 261static const char *SCAP_hostname = "www.handhelds.org";
258static const int SCAP_port = 80; 262static const int SCAP_port = 80;
259 263
260 264
261ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) 265ScreenshotControl::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 );
@@ -283,37 +287,42 @@ ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name )
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
310void ScreenshotControl::slotGrab() 319void 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
@@ -341,24 +350,33 @@ void ScreenshotControl::slotGrab()
341 350
342void ScreenshotControl::slotScap() 351void 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
362void 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
354void ScreenshotControl::savePixmap() 372void 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")
@@ -404,24 +422,29 @@ void ScreenshotControl::savePixmap()
404} 422}
405 423
406void ScreenshotControl::performGrab() 424void 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())) {
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
@@ -3,26 +3,26 @@
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
26class QComboBox; 26class QComboBox;
27class QCheckBox; 27class QCheckBox;
28class QSpinBox; 28class QSpinBox;
@@ -38,34 +38,35 @@ public:
38private: 38private:
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
48private slots: 48private 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
55class ScreenshotApplet : public QWidget { 56class ScreenshotApplet : public QWidget {
56public: 57public:
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
61protected: 62protected:
62 void mousePressEvent( QMouseEvent * ); 63 void mousePressEvent( QMouseEvent * );
63 void paintEvent( QPaintEvent* ); 64 void paintEvent( QPaintEvent* );
64 65
65private: 66private:
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