summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-02-09 02:08:42 (UTC)
committer llornkcor <llornkcor>2002-02-09 02:08:42 (UTC)
commiteca8d68c7cbc82b11879f03e0b6b4a5894cbe435 (patch) (side-by-side diff)
tree6d6634ecf2d70e15d82b2474fa2e4f4eec51c555 /core
parentcde778848f13e384e55e66117754578d12a5b1e2 (diff)
downloadopie-eca8d68c7cbc82b11879f03e0b6b4a5894cbe435.zip
opie-eca8d68c7cbc82b11879f03e0b6b4a5894cbe435.tar.gz
opie-eca8d68c7cbc82b11879f03e0b6b4a5894cbe435.tar.bz2
added screenshotapplet
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/screenshotapplet/screenshot.cpp189
-rw-r--r--core/applets/screenshotapplet/screenshot.h76
-rw-r--r--core/applets/screenshotapplet/screenshotapplet.pro13
-rw-r--r--core/applets/screenshotapplet/screenshotappletimpl.cpp64
-rw-r--r--core/applets/screenshotapplet/screenshotappletimpl.h44
5 files changed, 386 insertions, 0 deletions
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp
new file mode 100644
index 0000000..d70b57c
--- a/dev/null
+++ b/core/applets/screenshotapplet/screenshot.cpp
@@ -0,0 +1,189 @@
+/**********************************************************************
+** 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 <qapplication.h>
+
+#include <qpe/resource.h>
+#include <qpe/qpeapplication.h>
+#include <qpe/timestring.h>
+#include <qpe/resource.h>
+#include <qpe/config.h>
+#include <qpe/applnk.h>
+#include <qpe/config.h>
+
+
+#include <qfileinfo.h>
+#include <qpoint.h>
+#include <qpushbutton.h>
+#include <qpainter.h>
+#include <qcombobox.h>
+#include <qspinbox.h>
+#include <qslider.h>
+#include <qlayout.h>
+#include <qframe.h>
+#include <qpixmap.h>
+#include <qstring.h>
+#include <qfile.h>
+#include <qtimer.h>
+
+static char * snapshot_xpm[] = {
+"16 16 10 1",
+" c None",
+". c #000000",
+"+ c #00C000",
+"@ c #585858",
+"# c #808080",
+"$ c #00FF00",
+"% c #008000",
+"& c #00FFFF",
+"* c #FF0000",
+"= c #FFC0C0",
+" ",
+" ... ",
+" ..+++..@#. ",
+" .$++++++.#. ",
+" .%$$++++++. ",
+" .&%%$$++@***. ",
+" .$&$++$=**@+. ",
+" .+$$+++@*$%%. ",
+" .+++++%+++%%. ",
+" .%%++++..+%%. ",
+" ..%%+++++%%. ",
+" ..%%+++%%. ",
+" ..%%+%%. ",
+" ..%%.. ",
+" .. ",
+" "};
+
+
+ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name )
+ : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
+{
+ setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
+// qDebug("screenshot control");
+ QVBoxLayout *vbox = new QVBoxLayout( this );
+// qDebug("new layout");
+ delaySpin = new QSpinBox( 0,60,1, this, "Spinner" );
+// qDebug("new spinbox");
+ delaySpin->setFocusPolicy( QWidget::NoFocus );
+ grabItButton= new QPushButton( this, "GrabButton" );
+// qDebug("new pushbutton");
+ grabItButton ->setFocusPolicy( QWidget::TabFocus );
+ grabItButton->setText("Snaphot");
+ vbox->setMargin( 6 );
+ vbox->setSpacing( 3 );
+ vbox->addWidget( delaySpin);
+ vbox->setMargin( 6 );
+ vbox->setSpacing( 3 );
+ vbox->addWidget( grabItButton);
+
+ setFixedHeight( 100 );
+ setFixedWidth( sizeHint().width() );
+ setFocusPolicy(QWidget::NoFocus);
+
+ grabTimer= new QTimer(this,"grab timer");
+// qDebug("newTimer");
+ connect( grabTimer, SIGNAL( timeout() ), this, SLOT( grabTimerDone() ) );
+
+// Config cfg("Snapshot");
+// cfg.setGroup("General");
+// delaySpin->setValue(cfg.readNumEntry("delay",0));
+ connect( grabItButton, SIGNAL(released()), SLOT(slotGrab()) );
+
+}
+
+void ScreenshotControl::slotGrab()
+{
+// qDebug("SlotGrab");
+ hide();
+ if ( delaySpin->value() ) {
+ grabTimer->start( delaySpin->value() * 1000, true );
+ } else {
+ show();
+ }
+}
+
+
+void ScreenshotControl::grabTimerDone()
+{
+ performGrab();
+}
+
+void ScreenshotControl::savePixmap()
+{
+ DocLnk lnk;
+ QString fileName = "sc_"+TimeString::dateString( QDateTime::currentDateTime(),false,true);
+ fileName.replace(QRegExp("'"),""); fileName.replace(QRegExp(" "),"_"); fileName.replace(QRegExp(":"),"."); fileName.replace(QRegExp(","),"");
+
+ fileName="/home/root/Documents/image/png/"+fileName+".png";
+ lnk.setFile(fileName); //sets File property
+ snapshot.save( fileName,"PNG");
+ qDebug("saving file "+fileName);
+ QFileInfo fi( fileName);
+ lnk.setName( fi.fileName()); //sets file name
+ if(!lnk.writeLink())
+ qDebug("Writing doclink did not work");
+
+ QPEApplication::beep();
+
+}
+
+void ScreenshotControl::performGrab()
+{
+ qDebug("grabbing screen");
+ grabTimer->stop();
+ snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(),0,0,QApplication::desktop()->width(),QApplication::desktop()->height() );
+ show();
+ savePixmap();
+}
+
+void ScreenshotControl::setTime(int newTime)
+{
+ delaySpin->setValue(newTime);
+}
+
+//===========================================================================
+
+ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name )
+ : QWidget( parent, name )
+{
+// qDebug("beginning applet");
+ setFixedHeight( 18 );
+ setFixedWidth( 14 );
+ vc = new ScreenshotControl;
+// qDebug("new screenshotapplet");
+}
+
+ScreenshotApplet::~ScreenshotApplet()
+{
+}
+
+void ScreenshotApplet::mousePressEvent( QMouseEvent *)
+{
+// if(!vc)
+ vc = new ScreenshotControl;
+ QPoint curPos = mapToGlobal( rect().topLeft() );
+ vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 100 );
+ vc->show();
+
+}
+
+void ScreenshotApplet::paintEvent( QPaintEvent* )
+{
+ QPainter p(this);
+ qDebug("paint pixmap");
+ p.drawPixmap( 0, 1, ( const char** ) snapshot_xpm );
+
+}
diff --git a/core/applets/screenshotapplet/screenshot.h b/core/applets/screenshotapplet/screenshot.h
new file mode 100644
index 0000000..82800b9
--- a/dev/null
+++ b/core/applets/screenshotapplet/screenshot.h
@@ -0,0 +1,76 @@
+/**********************************************************************
+** 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__
+
+
+
+#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 );
+ void performGrab();
+
+public:
+ QPushButton *grabItButton;
+ QPixmap snapshot;
+ QTimer* grabTimer;
+ void slotSave();
+ void slotCopy();
+ void setTime(int newTime);
+
+ QSpinBox *delaySpin;
+private:
+private slots:
+ void slotGrab();
+ void savePixmap();
+ void grabTimerDone();
+};
+
+class ScreenshotApplet : public QWidget
+{
+ Q_OBJECT
+public:
+ ScreenshotApplet( QWidget *parent = 0, const char *name=0 );
+ ~ScreenshotApplet();
+ ScreenshotControl *vc;
+public slots:
+private:
+ void mousePressEvent( QMouseEvent * );
+ void paintEvent( QPaintEvent* );
+
+private:
+ QPixmap snapshotPixmap;
+private slots:
+
+
+};
+
+
+#endif // __SCREENSHOT_APPLET_H__
+
diff --git a/core/applets/screenshotapplet/screenshotapplet.pro b/core/applets/screenshotapplet/screenshotapplet.pro
new file mode 100644
index 0000000..095cce2
--- a/dev/null
+++ b/core/applets/screenshotapplet/screenshotapplet.pro
@@ -0,0 +1,13 @@
+TEMPLATE = lib
+CONFIG += qt warn_on release
+HEADERS = screenshot.h screenshotappletimpl.h
+SOURCES = screenshot.cpp screenshotappletimpl.cpp
+TARGET = screenshotapplet
+DESTDIR = ../../plugins/applets
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += ../$(OPIEDIR)/include
+LIBS += -lqpe
+VERSION = 1.0.0
+MOC_DIR=opieobj
+OBJECTS_DIR=opieobj
+
diff --git a/core/applets/screenshotapplet/screenshotappletimpl.cpp b/core/applets/screenshotapplet/screenshotappletimpl.cpp
new file mode 100644
index 0000000..f1a9827
--- a/dev/null
+++ b/core/applets/screenshotapplet/screenshotappletimpl.cpp
@@ -0,0 +1,64 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** 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.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+#include "screenshot.h"
+#include "screenshotappletimpl.h"
+
+
+ScreenshotAppletImpl::ScreenshotAppletImpl()
+ : volume(0), ref(0)
+{
+}
+
+ScreenshotAppletImpl::~ScreenshotAppletImpl()
+{
+ delete volume;
+}
+
+QWidget *ScreenshotAppletImpl::applet( QWidget *parent )
+{
+ if ( !volume )
+ volume = new ScreenshotApplet( parent );
+ return volume;
+}
+
+int ScreenshotAppletImpl::position() const
+{
+ return 6;
+}
+
+QRESULT ScreenshotAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = this;
+ else if ( uuid == IID_TaskbarApplet )
+ *iface = this;
+
+ if ( *iface )
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( ScreenshotAppletImpl )
+}
+
+
diff --git a/core/applets/screenshotapplet/screenshotappletimpl.h b/core/applets/screenshotapplet/screenshotappletimpl.h
new file mode 100644
index 0000000..deca7a9
--- a/dev/null
+++ b/core/applets/screenshotapplet/screenshotappletimpl.h
@@ -0,0 +1,44 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** 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.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+#ifndef SCREENSHOTAPPLETIMPL_H
+#define SCREENSHOTAPPLETIMPL_H
+
+#include <qpe/taskbarappletinterface.h>
+
+class ScreenshotApplet;
+
+class ScreenshotAppletImpl : public TaskbarAppletInterface
+{
+public:
+ ScreenshotAppletImpl();
+ virtual ~ScreenshotAppletImpl();
+
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT
+
+ virtual QWidget *applet( QWidget *parent );
+ virtual int position() const;
+
+private:
+ ScreenshotApplet *volume;
+ ulong ref;
+};
+
+#endif