summaryrefslogtreecommitdiff
authorbipolar <bipolar>2002-03-08 00:11:17 (UTC)
committer bipolar <bipolar>2002-03-08 00:11:17 (UTC)
commit50f8f55346f369787063f42c571d2dc832eb58aa (patch) (unidiff)
tree88a6e75395e9101ae8826d1aeb181dea459fcef5
parent69d2df15c2dbd280f6ed99d5eecf487345f1de08 (diff)
downloadopie-50f8f55346f369787063f42c571d2dc832eb58aa.zip
opie-50f8f55346f369787063f42c571d2dc832eb58aa.tar.gz
opie-50f8f55346f369787063f42c571d2dc832eb58aa.tar.bz2
ljp: added control file and changed default to 1
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/screenshotapplet/opie-screenshotapplet.control9
-rw-r--r--core/applets/screenshotapplet/screenshot.cpp1
2 files changed, 10 insertions, 0 deletions
diff --git a/core/applets/screenshotapplet/opie-screenshotapplet.control b/core/applets/screenshotapplet/opie-screenshotapplet.control
new file mode 100644
index 0000000..4a06a5a
--- a/dev/null
+++ b/core/applets/screenshotapplet/opie-screenshotapplet.control
@@ -0,0 +1,9 @@
1Files: plugins/applets/libscreenshotapplet.so*
2Priority: optional
3Section: opie/system
4Maintainer: L. J. Potter <ljp@llornkcor.com>
5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION.1
7Depends: opie-base ($QPE_VERSION)
8Description: Screenshot Applet
9 A screenshot taskbar applet for the Opie environment
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp
index 20e8554..16d5588 100644
--- a/core/applets/screenshotapplet/screenshot.cpp
+++ b/core/applets/screenshotapplet/screenshot.cpp
@@ -8,190 +8,191 @@
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 <qstring.h> 39#include <qstring.h>
40#include <qfile.h> 40#include <qfile.h>
41#include <qtimer.h> 41#include <qtimer.h>
42 42
43static char * snapshot_xpm[] = { 43static char * snapshot_xpm[] = {
44"16 16 10 1", 44"16 16 10 1",
45" c None", 45" c None",
46". c #000000", 46". c #000000",
47"+ c #00C000", 47"+ c #00C000",
48"@ c #585858", 48"@ c #585858",
49"# c #808080", 49"# c #808080",
50"$ c #00FF00", 50"$ c #00FF00",
51"% c #008000", 51"% c #008000",
52"& c #00FFFF", 52"& c #00FFFF",
53"* c #FF0000", 53"* c #FF0000",
54"= c #FFC0C0", 54"= c #FFC0C0",
55" ", 55" ",
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
73ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) 73ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name )
74 : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) 74 : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
75{ 75{
76 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 76 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
77// qDebug("screenshot control"); 77// qDebug("screenshot control");
78 QVBoxLayout *vbox = new QVBoxLayout( this ); 78 QVBoxLayout *vbox = new QVBoxLayout( this );
79// qDebug("new layout"); 79// qDebug("new layout");
80 delaySpin = new QSpinBox( 0,60,1, this, "Spinner" ); 80 delaySpin = new QSpinBox( 0,60,1, this, "Spinner" );
81// qDebug("new spinbox"); 81// qDebug("new spinbox");
82 delaySpin->setFocusPolicy( QWidget::NoFocus ); 82 delaySpin->setFocusPolicy( QWidget::NoFocus );
83 grabItButton= new QPushButton( this, "GrabButton" ); 83 grabItButton= new QPushButton( this, "GrabButton" );
84// qDebug("new pushbutton"); 84// qDebug("new pushbutton");
85 grabItButton ->setFocusPolicy( QWidget::TabFocus ); 85 grabItButton ->setFocusPolicy( QWidget::TabFocus );
86 grabItButton->setText("Snaphot"); 86 grabItButton->setText("Snaphot");
87 vbox->setMargin( 6 ); 87 vbox->setMargin( 6 );
88 vbox->setSpacing( 3 ); 88 vbox->setSpacing( 3 );
89 vbox->addWidget( delaySpin); 89 vbox->addWidget( delaySpin);
90 vbox->setMargin( 6 ); 90 vbox->setMargin( 6 );
91 vbox->setSpacing( 3 ); 91 vbox->setSpacing( 3 );
92 vbox->addWidget( grabItButton); 92 vbox->addWidget( grabItButton);
93 93
94 setFixedHeight( 100 ); 94 setFixedHeight( 100 );
95 setFixedWidth( sizeHint().width() ); 95 setFixedWidth( sizeHint().width() );
96 setFocusPolicy(QWidget::NoFocus); 96 setFocusPolicy(QWidget::NoFocus);
97 97
98 grabTimer= new QTimer(this,"grab timer"); 98 grabTimer= new QTimer(this,"grab timer");
99// qDebug("newTimer"); 99// qDebug("newTimer");
100 connect( grabTimer, SIGNAL( timeout() ), this, SLOT( grabTimerDone() ) ); 100 connect( grabTimer, SIGNAL( timeout() ), this, SLOT( grabTimerDone() ) );
101 101
102// Config cfg("Snapshot"); 102// Config cfg("Snapshot");
103// cfg.setGroup("General"); 103// cfg.setGroup("General");
104 delaySpin->setValue(1);
104// delaySpin->setValue(cfg.readNumEntry("delay",0)); 105// delaySpin->setValue(cfg.readNumEntry("delay",0));
105 connect( grabItButton, SIGNAL(released()), SLOT(slotGrab()) ); 106 connect( grabItButton, SIGNAL(released()), SLOT(slotGrab()) );
106 107
107} 108}
108 109
109void ScreenshotControl::slotGrab() 110void ScreenshotControl::slotGrab()
110{ 111{
111// qDebug("SlotGrab"); 112// qDebug("SlotGrab");
112 hide(); 113 hide();
113 if ( delaySpin->value() ) { 114 if ( delaySpin->value() ) {
114 grabTimer->start( delaySpin->value() * 1000, true ); 115 grabTimer->start( delaySpin->value() * 1000, true );
115 } else { 116 } else {
116 show(); 117 show();
117 } 118 }
118} 119}
119 120
120 121
121void ScreenshotControl::grabTimerDone() 122void ScreenshotControl::grabTimerDone()
122{ 123{
123 performGrab(); 124 performGrab();
124} 125}
125 126
126void ScreenshotControl::savePixmap() 127void ScreenshotControl::savePixmap()
127{ 128{
128 DocLnk lnk; 129 DocLnk lnk;
129 QString fileName = "sc_"+TimeString::dateString( QDateTime::currentDateTime(),false,true); 130 QString fileName = "sc_"+TimeString::dateString( QDateTime::currentDateTime(),false,true);
130 fileName.replace(QRegExp("'"),""); fileName.replace(QRegExp(" "),"_"); fileName.replace(QRegExp(":"),"."); fileName.replace(QRegExp(","),""); 131 fileName.replace(QRegExp("'"),""); fileName.replace(QRegExp(" "),"_"); fileName.replace(QRegExp(":"),"."); fileName.replace(QRegExp(","),"");
131 132
132 QString dirName = QDir::homeDirPath()+"/Documents/image/png/"; 133 QString dirName = QDir::homeDirPath()+"/Documents/image/png/";
133 if( !QDir( dirName).exists() ) { 134 if( !QDir( dirName).exists() ) {
134 qDebug("making dir "+dirName); 135 qDebug("making dir "+dirName);
135 QString msg = "mkdir -p "+dirName; 136 QString msg = "mkdir -p "+dirName;
136 system(msg.latin1()); 137 system(msg.latin1());
137 } 138 }
138 fileName=dirName+fileName+".png"; 139 fileName=dirName+fileName+".png";
139 lnk.setFile(fileName); //sets File property 140 lnk.setFile(fileName); //sets File property
140 snapshot.save( fileName,"PNG"); 141 snapshot.save( fileName,"PNG");
141 qDebug("saving file "+fileName); 142 qDebug("saving file "+fileName);
142 QFileInfo fi( fileName); 143 QFileInfo fi( fileName);
143 lnk.setName( fi.fileName()); //sets file name 144 lnk.setName( fi.fileName()); //sets file name
144 if(!lnk.writeLink()) 145 if(!lnk.writeLink())
145 qDebug("Writing doclink did not work"); 146 qDebug("Writing doclink did not work");
146 147
147 QPEApplication::beep(); 148 QPEApplication::beep();
148 149
149} 150}
150 151
151void ScreenshotControl::performGrab() 152void ScreenshotControl::performGrab()
152{ 153{
153 qDebug("grabbing screen"); 154 qDebug("grabbing screen");
154 grabTimer->stop(); 155 grabTimer->stop();
155 snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(),0,0,QApplication::desktop()->width(),QApplication::desktop()->height() ); 156 snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(),0,0,QApplication::desktop()->width(),QApplication::desktop()->height() );
156 show(); 157 show();
157 savePixmap(); 158 savePixmap();
158} 159}
159 160
160void ScreenshotControl::setTime(int newTime) 161void ScreenshotControl::setTime(int newTime)
161{ 162{
162 delaySpin->setValue(newTime); 163 delaySpin->setValue(newTime);
163} 164}
164 165
165//=========================================================================== 166//===========================================================================
166 167
167ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) 168ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name )
168 : QWidget( parent, name ) 169 : QWidget( parent, name )
169{ 170{
170// qDebug("beginning applet"); 171// qDebug("beginning applet");
171 setFixedHeight( 18 ); 172 setFixedHeight( 18 );
172 setFixedWidth( 14 ); 173 setFixedWidth( 14 );
173 vc = new ScreenshotControl; 174 vc = new ScreenshotControl;
174// qDebug("new screenshotapplet"); 175// qDebug("new screenshotapplet");
175} 176}
176 177
177ScreenshotApplet::~ScreenshotApplet() 178ScreenshotApplet::~ScreenshotApplet()
178{ 179{
179} 180}
180 181
181void ScreenshotApplet::mousePressEvent( QMouseEvent *) 182void ScreenshotApplet::mousePressEvent( QMouseEvent *)
182{ 183{
183// if(!vc) 184// if(!vc)
184 vc = new ScreenshotControl; 185 vc = new ScreenshotControl;
185 QPoint curPos = mapToGlobal( rect().topLeft() ); 186 QPoint curPos = mapToGlobal( rect().topLeft() );
186 vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 100 ); 187 vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 100 );
187 vc->show(); 188 vc->show();
188 189
189} 190}
190 191
191void ScreenshotApplet::paintEvent( QPaintEvent* ) 192void ScreenshotApplet::paintEvent( QPaintEvent* )
192{ 193{
193 QPainter p(this); 194 QPainter p(this);
194 qDebug("paint pixmap"); 195 qDebug("paint pixmap");
195 p.drawPixmap( 0, 1, ( const char** ) snapshot_xpm ); 196 p.drawPixmap( 0, 1, ( const char** ) snapshot_xpm );
196 197
197} 198}