summaryrefslogtreecommitdiff
authorzecke <zecke>2004-04-08 00:43:00 (UTC)
committer zecke <zecke>2004-04-08 00:43:00 (UTC)
commit5badc8e0aba089d73fdbfb1b1383b937aa30a301 (patch) (side-by-side diff)
tree07c82bb19e05c608a570f7de286e5c31fb9501c2
parent5afca2540a2d6bf733c89ea97748496a679bc576 (diff)
downloadopie-5badc8e0aba089d73fdbfb1b1383b937aa30a301.zip
opie-5badc8e0aba089d73fdbfb1b1383b937aa30a301.tar.gz
opie-5badc8e0aba089d73fdbfb1b1383b937aa30a301.tar.bz2
Allow to take a ScreenShot, Open it directly with drawpad
Comment it and send via email
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
@@ -1,48 +1,48 @@
/**********************************************************************
** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com
** All rights reserved.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#include "screenshot.h"
#include "inputDialog.h"
/* OPIE */
#include <opie2/odebug.h>
#include <opie2/otaskbarapplet.h>
#include <qpe/qpeapplication.h>
#include <qpe/applnk.h>
-using namespace Opie::Core;
-using namespace Opie::Ui;
+#include <qpe/qcopenvelope_qws.h>
+
/* QT */
#include <qlineedit.h>
#include <qdir.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qpainter.h>
#include <qspinbox.h>
#include <qlayout.h>
#include <qcheckbox.h>
#include <qmessagebox.h>
/* STD */
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
/* XPM */
static char * snapshot_xpm[] = {
"32 32 177 2",
" c None",
". c #042045",
@@ -233,144 +233,162 @@ static char * snapshot_xpm[] = {
"| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ",
"t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ",
"| 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 ",
"| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ",
";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ",
";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ",
";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ",
"t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ",
"| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ",
"; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ",
"9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ",
"9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ",
"; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ",
"; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ",
" ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ",
" # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ",
" + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ",
" < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ",
" $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ",
" ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ",
" | > e L.d L.H.e M.. ; ] ] ",
" > 9 . S.Q.. ; ] ",
" T.; ] "};
+
+using namespace Opie::Core;
+using namespace Opie::Ui;
+
static const char *SCAP_hostname = "www.handhelds.org";
static const int SCAP_port = 80;
ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name )
: QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
{
setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 );
QHBoxLayout *hbox;
hbox = new QHBoxLayout ( vbox );
QLabel *l = new QLabel ( tr( "Delay" ), this );
hbox-> addWidget ( l );
delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" );
delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus );
delaySpin-> setSuffix ( tr( "sec" ));
delaySpin-> setFocusPolicy( QWidget::NoFocus );
delaySpin-> setValue ( 1 );
hbox-> addWidget ( delaySpin );
saveNamedCheck = new QCheckBox ( tr( "Save named" ), this);
saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus );
vbox->addWidget( saveNamedCheck);
vbox-> addSpacing ( 3 );
l = new QLabel ( tr( "Save screenshot as..." ), this );
vbox-> addWidget ( l, AlignCenter );
hbox = new QHBoxLayout ( vbox );
grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" );
grabItButton ->setFocusPolicy( QWidget::TabFocus );
hbox-> addWidget ( grabItButton );
+ QPushButton* drawPadButton = new QPushButton( tr("Opie drawpad"), this, "DrawPadButton" );
+ drawPadButton->setFocusPolicy( QWidget::TabFocus );
+ hbox->addWidget( drawPadButton );
+
scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" );
scapButton ->setFocusPolicy( QWidget::TabFocus );
hbox-> addWidget ( scapButton );
setFixedSize ( sizeHint ( ));
setFocusPolicy ( QWidget::NoFocus );
grabTimer = new QTimer ( this, "grab timer");
connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab()));
connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab()));
connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap()));
+ connect ( drawPadButton, SIGNAL(clicked()), SLOT(slotDrawpad()) );
}
void ScreenshotControl::slotGrab()
{
buttonPushed = 1;
hide();
setFileName = FALSE;
if ( saveNamedCheck->isChecked()) {
setFileName = TRUE;
InputDialog *fileDlg;
fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0);
fileDlg->exec();
fileDlg->raise();
QString fileName, list;
if ( fileDlg->result() == 1 ) {
fileName = fileDlg->LineEdit1->text();
if (fileName.find("/", 0, TRUE) == -1)
FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName;
else
FileNamePath = fileName;
}
delete fileDlg;
}
if ( delaySpin->value() )
grabTimer->start( delaySpin->value() * 1000, true );
else
show();
}
void ScreenshotControl::slotScap()
{
buttonPushed = 2;
hide();
if ( delaySpin->value() )
grabTimer->start( delaySpin->value() * 1000, true );
else
show();
}
+void ScreenshotControl::slotDrawpad()
+{
+ buttonPushed = 3;
+ hide();
+ if ( delaySpin->value() )
+ grabTimer->start( delaySpin->value()*1000, true );
+ else
+ show();
+}
void ScreenshotControl::savePixmap()
{
DocLnk lnk;
QString fileName;
if ( setFileName) {
fileName = FileNamePath;
//not sure why this is needed here, but it forgets fileName
// if this is below the braces
if (fileName.right(3) != "png")
fileName = fileName + ".png";
lnk.setFile(fileName); //sets File property
odebug << "saving file " + fileName << oendl;
snapshot.save( fileName, "PNG");
QFileInfo fi( fileName);
lnk.setName( fi.fileName()); //sets file name
if (!lnk.writeLink())
odebug << "Writing doclink did not work" << oendl;
}
else {
@@ -392,48 +410,53 @@ void ScreenshotControl::savePixmap()
lnk.setFile(fileName); //sets File property
odebug << "saving file " + fileName << oendl;
snapshot.save( fileName, "PNG");
QFileInfo fi( fileName);
lnk.setName( fi.fileName()); //sets file name
if (!lnk.writeLink())
odebug << "Writing doclink did not work" << oendl;
}
QPEApplication::beep();
}
void ScreenshotControl::performGrab()
{
snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() );
if (buttonPushed == 1) {
odebug << "grabbing screen" << oendl;
grabTimer->stop();
show();
qApp->processEvents();
savePixmap();
+ }else if ( buttonPushed == 3 ) {
+ grabTimer->stop();
+ show();
+ QCopEnvelope env("QPE/Application/drawpad", "importPixmap(QPixmap)" );
+ env << snapshot;
} else {
grabTimer->stop();
struct sockaddr_in raddr;
struct hostent *rhost_info;
int sock = -1;
bool ok = false;
QString displayEnv = getenv("QWS_DISPLAY");
odebug << displayEnv << oendl;
if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) {
if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) {
::memset ( &raddr, 0, sizeof (struct sockaddr_in));
::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length );
raddr. sin_family = rhost_info-> h_addrtype;
raddr. sin_port = htons ( SCAP_port );
if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) {
if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) {
QString header;
diff --git a/core/applets/screenshotapplet/screenshot.h b/core/applets/screenshotapplet/screenshot.h
index b753583..e7b6040 100644
--- a/core/applets/screenshotapplet/screenshot.h
+++ b/core/applets/screenshotapplet/screenshot.h
@@ -1,71 +1,72 @@
/**********************************************************************
** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com
** All rights reserved.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
-#ifndef __SCREENSHOT_APPLET_H__
-#define __SCREENSHOT_APPLET_H__
+#ifndef SCREENSHOT_APPLET_H__
+#define SCREENSHOT_APPLET_H__
#include <qwidget.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qguardedptr.h>
#include <qtimer.h>
class QComboBox;
class QCheckBox;
class QSpinBox;
class QPushButton;
//class QImage;
class ScreenshotControl : public QFrame
{
Q_OBJECT
public:
ScreenshotControl( QWidget *parent=0, const char *name=0 );
private:
QPushButton *grabItButton, *scapButton;
QPixmap snapshot;
QTimer* grabTimer;
QCheckBox *saveNamedCheck;
QString FileNamePath;
bool setFileName;
QSpinBox *delaySpin;
int buttonPushed;
private slots:
void slotGrab();
- void slotScap();
+ void slotScap();
+ void slotDrawpad();
void savePixmap();
void performGrab();
};
class ScreenshotApplet : public QWidget {
public:
ScreenshotApplet( QWidget *parent = 0, const char *name=0 );
~ScreenshotApplet();
static int position();
-
+
protected:
void mousePressEvent( QMouseEvent * );
void paintEvent( QPaintEvent* );
-
+
private:
QPixmap m_icon;
};
#endif // __SCREENSHOT_APPLET_H__