summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/screenshotapplet/screenshot.cpp2
-rw-r--r--core/applets/screenshotapplet/screenshotapplet.pro13
2 files changed, 13 insertions, 2 deletions
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp
index d95396b..8a2a956 100644
--- a/core/applets/screenshotapplet/screenshot.cpp
+++ b/core/applets/screenshotapplet/screenshot.cpp
@@ -1,199 +1,199 @@
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 <qapplication.h> 16#include <qapplication.h>
17#include <stdlib.h> 17#include <stdlib.h>
18 18
19 19
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22#include <qpe/timestring.h> 22#include <qpe/timestring.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27 27
28#include <qdir.h> 28#include <qdir.h>
29#include <qfileinfo.h> 29#include <qfileinfo.h>
30#include <qpoint.h> 30#include <qpoint.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qpainter.h> 32#include <qpainter.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qspinbox.h> 34#include <qspinbox.h>
35#include <qslider.h> 35#include <qslider.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qframe.h> 37#include <qframe.h>
38#include <qpixmap.h> 38#include <qpixmap.h>
39#include <qregexp.h> 39#include <qregexp.h>
40#include <qstring.h> 40#include <qstring.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qtimer.h> 42#include <qtimer.h>
43 43
44static char * snapshot_xpm[] = { 44static char * snapshot_xpm[] = {
45"16 16 10 1", 45"16 16 10 1",
46" c None", 46" c None",
47". c #000000", 47". c #000000",
48"+ c #00C000", 48"+ c #00C000",
49"@ c #585858", 49"@ c #585858",
50"# c #808080", 50"# c #808080",
51"$ c #00FF00", 51"$ c #00FF00",
52"% c #008000", 52"% c #008000",
53"& c #00FFFF", 53"& c #00FFFF",
54"* c #FF0000", 54"* c #FF0000",
55"= c #FFC0C0", 55"= c #FFC0C0",
56" ", 56" ",
57" ... ", 57" ... ",
58" ..+++..@#. ", 58" ..+++..@#. ",
59" .$++++++.#. ", 59" .$++++++.#. ",
60" .%$$++++++. ", 60" .%$$++++++. ",
61" .&%%$$++@***. ", 61" .&%%$$++@***. ",
62" .$&$++$=**@+. ", 62" .$&$++$=**@+. ",
63" .+$$+++@*$%%. ", 63" .+$$+++@*$%%. ",
64" .+++++%+++%%. ", 64" .+++++%+++%%. ",
65" .%%++++..+%%. ", 65" .%%++++..+%%. ",
66" ..%%+++++%%. ", 66" ..%%+++++%%. ",
67" ..%%+++%%. ", 67" ..%%+++%%. ",
68" ..%%+%%. ", 68" ..%%+%%. ",
69" ..%%.. ", 69" ..%%.. ",
70" .. ", 70" .. ",
71" "}; 71" "};
72 72
73 73
74ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) 74ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name )
75 : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) 75 : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
76{ 76{
77 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 77 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
78// qDebug("screenshot control"); 78// qDebug("screenshot control");
79 QVBoxLayout *vbox = new QVBoxLayout( this ); 79 QVBoxLayout *vbox = new QVBoxLayout( this );
80// qDebug("new layout"); 80// qDebug("new layout");
81 delaySpin = new QSpinBox( 0,60,1, this, "Spinner" ); 81 delaySpin = new QSpinBox( 0,60,1, this, "Spinner" );
82// qDebug("new spinbox"); 82// qDebug("new spinbox");
83 delaySpin->setFocusPolicy( QWidget::NoFocus ); 83 delaySpin->setFocusPolicy( QWidget::NoFocus );
84 grabItButton= new QPushButton( this, "GrabButton" ); 84 grabItButton= new QPushButton( this, "GrabButton" );
85// qDebug("new pushbutton"); 85// qDebug("new pushbutton");
86 grabItButton ->setFocusPolicy( QWidget::TabFocus ); 86 grabItButton ->setFocusPolicy( QWidget::TabFocus );
87 grabItButton->setText("Snapshot"); 87 grabItButton->setText(tr("Snapshot"));
88 vbox->setMargin( 6 ); 88 vbox->setMargin( 6 );
89 vbox->setSpacing( 3 ); 89 vbox->setSpacing( 3 );
90 vbox->addWidget( delaySpin); 90 vbox->addWidget( delaySpin);
91 vbox->setMargin( 6 ); 91 vbox->setMargin( 6 );
92 vbox->setSpacing( 3 ); 92 vbox->setSpacing( 3 );
93 vbox->addWidget( grabItButton); 93 vbox->addWidget( grabItButton);
94 94
95 setFixedHeight( 100 ); 95 setFixedHeight( 100 );
96 setFixedWidth( sizeHint().width() ); 96 setFixedWidth( sizeHint().width() );
97 setFocusPolicy(QWidget::NoFocus); 97 setFocusPolicy(QWidget::NoFocus);
98 98
99 grabTimer= new QTimer(this,"grab timer"); 99 grabTimer= new QTimer(this,"grab timer");
100// qDebug("newTimer"); 100// qDebug("newTimer");
101 connect( grabTimer, SIGNAL( timeout() ), this, SLOT( grabTimerDone() ) ); 101 connect( grabTimer, SIGNAL( timeout() ), this, SLOT( grabTimerDone() ) );
102 102
103// Config cfg("Snapshot"); 103// Config cfg("Snapshot");
104// cfg.setGroup("General"); 104// cfg.setGroup("General");
105 delaySpin->setValue(1); 105 delaySpin->setValue(1);
106// delaySpin->setValue(cfg.readNumEntry("delay",0)); 106// delaySpin->setValue(cfg.readNumEntry("delay",0));
107 connect( grabItButton, SIGNAL(released()), SLOT(slotGrab()) ); 107 connect( grabItButton, SIGNAL(released()), SLOT(slotGrab()) );
108 108
109} 109}
110 110
111void ScreenshotControl::slotGrab() 111void ScreenshotControl::slotGrab()
112{ 112{
113// qDebug("SlotGrab"); 113// qDebug("SlotGrab");
114 hide(); 114 hide();
115 if ( delaySpin->value() ) { 115 if ( delaySpin->value() ) {
116 grabTimer->start( delaySpin->value() * 1000, true ); 116 grabTimer->start( delaySpin->value() * 1000, true );
117 } else { 117 } else {
118 show(); 118 show();
119 } 119 }
120} 120}
121 121
122 122
123void ScreenshotControl::grabTimerDone() 123void ScreenshotControl::grabTimerDone()
124{ 124{
125 performGrab(); 125 performGrab();
126} 126}
127 127
128void ScreenshotControl::savePixmap() 128void ScreenshotControl::savePixmap()
129{ 129{
130 DocLnk lnk; 130 DocLnk lnk;
131 QString fileName = "sc_"+TimeString::dateString( QDateTime::currentDateTime(),false,true); 131 QString fileName = "sc_"+TimeString::dateString( QDateTime::currentDateTime(),false,true);
132 fileName.replace(QRegExp("'"),""); fileName.replace(QRegExp(" "),"_"); fileName.replace(QRegExp(":"),"."); fileName.replace(QRegExp(","),""); 132 fileName.replace(QRegExp("'"),""); fileName.replace(QRegExp(" "),"_"); fileName.replace(QRegExp(":"),"."); fileName.replace(QRegExp(","),"");
133 133
134 QString dirName = QDir::homeDirPath()+"/Documents/image/png/"; 134 QString dirName = QDir::homeDirPath()+"/Documents/image/png/";
135 if( !QDir( dirName).exists() ) { 135 if( !QDir( dirName).exists() ) {
136 qDebug("making dir "+dirName); 136 qDebug("making dir "+dirName);
137 QString msg = "mkdir -p "+dirName; 137 QString msg = "mkdir -p "+dirName;
138 system(msg.latin1()); 138 system(msg.latin1());
139 } 139 }
140 fileName=dirName+fileName+".png"; 140 fileName=dirName+fileName+".png";
141 lnk.setFile(fileName); //sets File property 141 lnk.setFile(fileName); //sets File property
142 snapshot.save( fileName,"PNG"); 142 snapshot.save( fileName,"PNG");
143 qDebug("saving file "+fileName); 143 qDebug("saving file "+fileName);
144 QFileInfo fi( fileName); 144 QFileInfo fi( fileName);
145 lnk.setName( fi.fileName()); //sets file name 145 lnk.setName( fi.fileName()); //sets file name
146 if(!lnk.writeLink()) 146 if(!lnk.writeLink())
147 qDebug("Writing doclink did not work"); 147 qDebug("Writing doclink did not work");
148 148
149 QPEApplication::beep(); 149 QPEApplication::beep();
150 150
151} 151}
152 152
153void ScreenshotControl::performGrab() 153void ScreenshotControl::performGrab()
154{ 154{
155 qDebug("grabbing screen"); 155 qDebug("grabbing screen");
156 grabTimer->stop(); 156 grabTimer->stop();
157 snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(),0,0,QApplication::desktop()->width(),QApplication::desktop()->height() ); 157 snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(),0,0,QApplication::desktop()->width(),QApplication::desktop()->height() );
158 show(); 158 show();
159 savePixmap(); 159 savePixmap();
160} 160}
161 161
162void ScreenshotControl::setTime(int newTime) 162void ScreenshotControl::setTime(int newTime)
163{ 163{
164 delaySpin->setValue(newTime); 164 delaySpin->setValue(newTime);
165} 165}
166 166
167//=========================================================================== 167//===========================================================================
168 168
169ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) 169ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name )
170 : QWidget( parent, name ) 170 : QWidget( parent, name )
171{ 171{
172// qDebug("beginning applet"); 172// qDebug("beginning applet");
173 setFixedHeight( 18 ); 173 setFixedHeight( 18 );
174 setFixedWidth( 14 ); 174 setFixedWidth( 14 );
175 vc = new ScreenshotControl; 175 vc = new ScreenshotControl;
176// qDebug("new screenshotapplet"); 176// qDebug("new screenshotapplet");
177} 177}
178 178
179ScreenshotApplet::~ScreenshotApplet() 179ScreenshotApplet::~ScreenshotApplet()
180{ 180{
181} 181}
182 182
183void ScreenshotApplet::mousePressEvent( QMouseEvent *) 183void ScreenshotApplet::mousePressEvent( QMouseEvent *)
184{ 184{
185// if(!vc) 185// if(!vc)
186 vc = new ScreenshotControl; 186 vc = new ScreenshotControl;
187 QPoint curPos = mapToGlobal( rect().topLeft() ); 187 QPoint curPos = mapToGlobal( rect().topLeft() );
188 vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 100 ); 188 vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 100 );
189 vc->show(); 189 vc->show();
190 190
191} 191}
192 192
193void ScreenshotApplet::paintEvent( QPaintEvent* ) 193void ScreenshotApplet::paintEvent( QPaintEvent* )
194{ 194{
195 QPainter p(this); 195 QPainter p(this);
196 qDebug("paint pixmap"); 196 qDebug("paint pixmap");
197 p.drawPixmap( 0, 1, ( const char** ) snapshot_xpm ); 197 p.drawPixmap( 0, 1, ( const char** ) snapshot_xpm );
198 198
199} 199}
diff --git a/core/applets/screenshotapplet/screenshotapplet.pro b/core/applets/screenshotapplet/screenshotapplet.pro
index e38074d..e3c5440 100644
--- a/core/applets/screenshotapplet/screenshotapplet.pro
+++ b/core/applets/screenshotapplet/screenshotapplet.pro
@@ -1,16 +1,27 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3HEADERS = screenshot.h screenshotappletimpl.h 3HEADERS = screenshot.h screenshotappletimpl.h
4SOURCES = screenshot.cpp screenshotappletimpl.cpp 4SOURCES = screenshot.cpp screenshotappletimpl.cpp
5TARGET = screenshotapplet 5TARGET = screenshotapplet
6DESTDIR = ../../plugins/applets 6DESTDIR = ../../plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += ../$(OPIEDIR)/include 8DEPENDPATH += ../$(OPIEDIR)/include
9LIBS += -lqpe 9LIBS += -lqpe
10VERSION = 1.0.0 10VERSION = 1.0.0
11MOC_DIR=opieobj 11MOC_DIR=opieobj
12OBJECTS_DIR=opieobj 12OBJECTS_DIR=opieobj
13 13
14TRANSLATIONS = ../../i18n/pt_BR/libscreenshotapplet.ts 14TRANSLATIONS = ../../i18n/pt_BR/libscreenshotapplet.ts
15TRANSLATIONS += ../../i18n/es/libscreenshotapplet.ts
16TRANSLATIONS += ../../i18n/pt/libscreenshotapplet.ts 15TRANSLATIONS += ../../i18n/pt/libscreenshotapplet.ts
16TRANSLATIONS += ../../i18n/de/libscreenshotapplet.ts
17TRANSLATIONS += ../../i18n/en/libscreenshotapplet.ts
18TRANSLATIONS += ../../i18n/es/libscreenshotapplet.ts
19TRANSLATIONS += ../../i18n/fr/libscreenshotapplet.ts
20TRANSLATIONS += ../../i18n/hu/libscreenshotapplet.ts
21TRANSLATIONS += ../../i18n/ja/libscreenshotapplet.ts
22TRANSLATIONS += ../../i18n/ko/libscreenshotapplet.ts
23TRANSLATIONS += ../../i18n/no/libscreenshotapplet.ts
24TRANSLATIONS += ../../i18n/pl/libscreenshotapplet.ts
25TRANSLATIONS += ../../i18n/sl/libscreenshotapplet.ts
26TRANSLATIONS += ../../i18n/zh_CN/libscreenshotapplet.ts
27TRANSLATIONS += ../../i18n/zh_TW/libscreenshotapplet.ts