summaryrefslogtreecommitdiff
authordrw <drw>2005-04-29 00:41:53 (UTC)
committer drw <drw>2005-04-29 00:41:53 (UTC)
commit7e13110d8d0c7cf0d7566484aae9a0664340a69e (patch) (unidiff)
treed042f58fc9352eac332d73886633c70fc7b06510
parentcaedcea372fd99c7fae116ac3d0d1625f88bf138 (diff)
downloadopie-7e13110d8d0c7cf0d7566484aae9a0664340a69e.zip
opie-7e13110d8d0c7cf0d7566484aae9a0664340a69e.tar.gz
opie-7e13110d8d0c7cf0d7566484aae9a0664340a69e.tar.bz2
Resource -> OResource, simplified saving of image using name and used the correct MIME types for save dialog
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/screenshotapplet/inputDialog.cpp65
-rw-r--r--core/applets/screenshotapplet/inputDialog.h30
-rw-r--r--core/applets/screenshotapplet/opie-screenshotapplet.control2
-rw-r--r--core/applets/screenshotapplet/screenshot.cpp27
-rw-r--r--core/applets/screenshotapplet/screenshotapplet.pro6
5 files changed, 13 insertions, 117 deletions
diff --git a/core/applets/screenshotapplet/inputDialog.cpp b/core/applets/screenshotapplet/inputDialog.cpp
deleted file mode 100644
index ce03ec0..0000000
--- a/core/applets/screenshotapplet/inputDialog.cpp
+++ b/dev/null
@@ -1,65 +0,0 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'inputDialog.ui'
3**
4** Created: Sat Mar 2 07:55:03 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "inputDialog.h"
10
11#include <qpe/resource.h>
12
13#include <opie2/ofiledialog.h>
14
15#include <qlineedit.h>
16#include <qpushbutton.h>
17
18using namespace Opie::Ui;
19InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
20 : QDialog( parent, name, modal, fl )
21{
22 if ( !name )
23 setName( "InputDialog" );
24 resize( 234, 115);
25 setMaximumSize( QSize( 240, 40));
26 setCaption( tr(name ) );
27
28 QPushButton *browserButton;
29 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
30 browserButton->setGeometry( QRect( 205, 10, 22, 22));
31 connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
32 LineEdit1 = new QLineEdit( this, "LineEdit1" );
33 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
34}
35
36/*
37 * Destroys the object and frees any allocated resources
38 */
39InputDialog::~InputDialog()
40{
41 inputText= LineEdit1->text();
42
43}
44
45void InputDialog::browse() {
46
47 MimeTypes types;
48 QStringList audio, video, all;
49 audio << "audio/*";
50 audio << "playlist/plain";
51 audio << "audio/x-mpegurl";
52
53 video << "video/*";
54 video << "playlist/plain";
55
56 all += audio;
57 all += video;
58 types.insert("All Media Files", all );
59 types.insert("Audio", audio );
60 types.insert("Video", video );
61
62 QString str = Opie::Ui::OFileDialog::getOpenFileName( 1,"/","", types, 0 );
63 LineEdit1->setText(str);
64}
65
diff --git a/core/applets/screenshotapplet/inputDialog.h b/core/applets/screenshotapplet/inputDialog.h
deleted file mode 100644
index 3e3e36f..0000000
--- a/core/applets/screenshotapplet/inputDialog.h
+++ b/dev/null
@@ -1,30 +0,0 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'inputDialog.ui'
3**
4** Created: Sat Mar 2 07:54:46 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef INPUTDIALOG_H
10#define INPUTDIALOG_H
11
12#include <qvariant.h>
13#include <qdialog.h>
14
15class QLineEdit;
16
17class InputDialog : public QDialog
18{
19 Q_OBJECT
20
21public:
22 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
23 ~InputDialog();
24 QString inputText;
25 QLineEdit* LineEdit1;
26protected slots:
27 void browse();
28};
29
30#endif // INPUTDIALOG_H
diff --git a/core/applets/screenshotapplet/opie-screenshotapplet.control b/core/applets/screenshotapplet/opie-screenshotapplet.control
index b0b9466..c08953b 100644
--- a/core/applets/screenshotapplet/opie-screenshotapplet.control
+++ b/core/applets/screenshotapplet/opie-screenshotapplet.control
@@ -1,10 +1,10 @@
1Package: opie-screenshotapplet 1Package: opie-screenshotapplet
2Files: plugins/applets/libscreenshotapplet.so* screenshotapplet/*.png 2Files: plugins/applets/libscreenshotapplet.so* screenshotapplet/*.png
3Priority: optional 3Priority: optional
4Section: opie/applets 4Section: opie/applets
5Maintainer: L. J. Potter <lpotter@trolltech.com> 5Maintainer: L. J. Potter <lpotter@trolltech.com>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal, libopiecore2, libopieui2
8Description: Screenshot Applet 8Description: Screenshot Applet
9 A screenshot taskbar applet for the Opie environment 9 A screenshot taskbar applet for the Opie environment
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp
index 1d88aa5..4ea81c8 100644
--- a/core/applets/screenshotapplet/screenshot.cpp
+++ b/core/applets/screenshotapplet/screenshot.cpp
@@ -1,57 +1,57 @@
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 "inputDialog.h"
17 16
18/* OPIE */ 17/* OPIE */
19#include <opie2/odebug.h> 18#include <opie2/odebug.h>
19#include <opie2/ofiledialog.h>
20#include <opie2/oresource.h>
20#include <opie2/otaskbarapplet.h> 21#include <opie2/otaskbarapplet.h>
22
21#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
22#include <qpe/applnk.h> 24#include <qpe/applnk.h>
23#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
24#include <qpe/resource.h>
25
26 26
27/* QT */ 27/* QT */
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qpainter.h> 32#include <qpainter.h>
33#include <qspinbox.h> 33#include <qspinbox.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qcheckbox.h> 35#include <qcheckbox.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37 37
38/* STD */ 38/* STD */
39#include <stdlib.h> 39#include <stdlib.h>
40#include <sys/socket.h> 40#include <sys/socket.h>
41#include <netinet/in.h> 41#include <netinet/in.h>
42#include <netdb.h> 42#include <netdb.h>
43#include <unistd.h> 43#include <unistd.h>
44 44
45using namespace Opie::Core; 45using namespace Opie::Core;
46using namespace Opie::Ui; 46using namespace Opie::Ui;
47 47
48static const char *SCAP_hostname = "www.handhelds.org"; 48static const char *SCAP_hostname = "www.handhelds.org";
49static const int SCAP_port = 80; 49static const int SCAP_port = 80;
50 50
51 51
52ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) 52ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name )
53 : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) 53 : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
54{ 54{
55 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 55 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
56 QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); 56 QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 );
57 QHBoxLayout *hbox; 57 QHBoxLayout *hbox;
@@ -82,80 +82,71 @@ ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name )
82 grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); 82 grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" );
83 grabItButton ->setFocusPolicy( QWidget::TabFocus ); 83 grabItButton ->setFocusPolicy( QWidget::TabFocus );
84 hbox-> addWidget ( grabItButton ); 84 hbox-> addWidget ( grabItButton );
85 85
86 QPushButton* drawPadButton = new QPushButton( tr("Opie drawpad"), this, "DrawPadButton" ); 86 QPushButton* drawPadButton = new QPushButton( tr("Opie drawpad"), this, "DrawPadButton" );
87 drawPadButton->setFocusPolicy( QWidget::TabFocus ); 87 drawPadButton->setFocusPolicy( QWidget::TabFocus );
88 hbox->addWidget( drawPadButton ); 88 hbox->addWidget( drawPadButton );
89 89
90 scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); 90 scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" );
91 scapButton ->setFocusPolicy( QWidget::TabFocus ); 91 scapButton ->setFocusPolicy( QWidget::TabFocus );
92 hbox-> addWidget ( scapButton ); 92 hbox-> addWidget ( scapButton );
93 93
94 setFixedSize ( sizeHint ( )); 94 setFixedSize ( sizeHint ( ));
95 setFocusPolicy ( QWidget::NoFocus ); 95 setFocusPolicy ( QWidget::NoFocus );
96 96
97 97
98 grabTimer = new QTimer ( this, "grab timer"); 98 grabTimer = new QTimer ( this, "grab timer");
99 99
100 connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab())); 100 connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab()));
101 connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab())); 101 connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab()));
102 connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap())); 102 connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap()));
103 connect ( drawPadButton, SIGNAL(clicked()), SLOT(slotDrawpad()) ); 103 connect ( drawPadButton, SIGNAL(clicked()), SLOT(slotDrawpad()) );
104} 104}
105 105
106void ScreenshotControl::slotGrab() 106void ScreenshotControl::slotGrab()
107{ 107{
108 buttonPushed = 1; 108 buttonPushed = 1;
109 hide(); 109 hide();
110 110
111 setFileName = FALSE; 111 setFileName = FALSE;
112 if ( saveNamedCheck->isChecked()) { 112 if ( saveNamedCheck->isChecked()) {
113 setFileName = TRUE; 113 setFileName = TRUE;
114 InputDialog *fileDlg;
115 114
116 fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); 115 MimeTypes types;
117 fileDlg->exec(); 116 QStringList list;
118 fileDlg->raise(); 117 list << "image/*";
119 QString fileName, list; 118 types. insert ( "Images", list );
120 if ( fileDlg->result() == 1 ) {
121 fileName = fileDlg->LineEdit1->text();
122 119
123 if (fileName.find("/", 0, TRUE) == -1) 120 FileNamePath = Opie::Ui::OFileDialog::getSaveFileName( 1,"/","", types, 0 );
124 FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName;
125 else
126 FileNamePath = fileName;
127
128 }
129 delete fileDlg;
130 } 121 }
131 122
132 if ( delaySpin->value() ) 123 if ( delaySpin->value() )
133 grabTimer->start( delaySpin->value() * 1000, true ); 124 grabTimer->start( delaySpin->value() * 1000, true );
134 else 125 else
135 show(); 126 show();
136} 127}
137 128
138void ScreenshotControl::slotScap() 129void ScreenshotControl::slotScap()
139{ 130{
140 buttonPushed = 2; 131 buttonPushed = 2;
141 hide(); 132 hide();
142 133
143 if ( delaySpin->value() ) 134 if ( delaySpin->value() )
144 grabTimer->start( delaySpin->value() * 1000, true ); 135 grabTimer->start( delaySpin->value() * 1000, true );
145 else 136 else
146 show(); 137 show();
147} 138}
148 139
149void ScreenshotControl::slotDrawpad() 140void ScreenshotControl::slotDrawpad()
150{ 141{
151 buttonPushed = 3; 142 buttonPushed = 3;
152 hide(); 143 hide();
153 if ( delaySpin->value() ) 144 if ( delaySpin->value() )
154 grabTimer->start( delaySpin->value()*1000, true ); 145 grabTimer->start( delaySpin->value()*1000, true );
155 else 146 else
156 show(); 147 show();
157} 148}
158 149
159void ScreenshotControl::savePixmap() 150void ScreenshotControl::savePixmap()
160{ 151{
161 DocLnk lnk; 152 DocLnk lnk;
@@ -275,65 +266,65 @@ void ScreenshotControl::performGrab()
275 const char *ascii = header.latin1( ); 266 const char *ascii = header.latin1( );
276 uint ascii_len = ::strlen( ascii ); 267 uint ascii_len = ::strlen( ascii );
277 ::write ( sock, ascii, ascii_len ); 268 ::write ( sock, ascii, ascii_len );
278 ::write ( sock, img.bits(), img.numBytes() ); 269 ::write ( sock, img.bits(), img.numBytes() );
279 270
280 ok = true; 271 ok = true;
281 } 272 }
282 } 273 }
283 ::close ( sock ); 274 ::close ( sock );
284 } 275 }
285 } 276 }
286 if ( ok ) { 277 if ( ok ) {
287 QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); 278 QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname ));
288 } else { 279 } else {
289 QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); 280 QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname ));
290 } 281 }
291 } else { 282 } else {
292 QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); 283 QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable."));
293 } 284 }
294 } 285 }
295 286
296} 287}
297 288
298 289
299 290
300//=========================================================================== 291//===========================================================================
301 292
302ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) 293ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name )
303 : QWidget( parent, name ) 294 : QWidget( parent, name )
304{ 295{
305 setFixedHeight( AppLnk::smallIconSize() ); 296 setFixedHeight( AppLnk::smallIconSize() );
306 setFixedWidth( AppLnk::smallIconSize() ); 297 setFixedWidth( AppLnk::smallIconSize() );
307 m_icon.convertFromImage( Resource::loadImage( "screenshotapplet/screenshot" ).smoothScale( height(), width() ) ); 298 m_icon = Opie::Core::OResource::loadPixmap( "screenshotapplet/screenshot", Opie::Core::OResource::SmallIcon );
308} 299}
309 300
310ScreenshotApplet::~ScreenshotApplet() 301ScreenshotApplet::~ScreenshotApplet()
311{ 302{
312} 303}
313 304
314int ScreenshotApplet::position() 305int ScreenshotApplet::position()
315{ 306{
316 return 6; 307 return 6;
317} 308}
318 309
319void ScreenshotApplet::mousePressEvent( QMouseEvent *) 310void ScreenshotApplet::mousePressEvent( QMouseEvent *)
320{ 311{
321 ScreenshotControl *sc = new ScreenshotControl ( ); 312 ScreenshotControl *sc = new ScreenshotControl ( );
322 QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); 313 QPoint curPos = mapToGlobal ( QPoint ( 0, 0 ));
323 314
324 // windowPosX is the windows position centered above the applets icon. 315 // windowPosX is the windows position centered above the applets icon.
325 // If the icon is near the edge of the screen, the window would leave the visible area 316 // If the icon is near the edge of the screen, the window would leave the visible area
326 // so we check the position against the screen width and correct the difference if needed 317 // so we check the position against the screen width and correct the difference if needed
327 318
328 int screenWidth = qApp->desktop()->width(); 319 int screenWidth = qApp->desktop()->width();
329 int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; 320 int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ;
330 int ZwindowPosX, XwindowPosX; 321 int ZwindowPosX, XwindowPosX;
331 322
332 // the window would be placed beyond the screen wich doesn't look tooo good 323 // the window would be placed beyond the screen wich doesn't look tooo good
333 if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { 324 if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) {
334 XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; 325 XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth;
335 ZwindowPosX = windowPosX - XwindowPosX - 1; 326 ZwindowPosX = windowPosX - XwindowPosX - 1;
336 } else { 327 } else {
337 ZwindowPosX = windowPosX; 328 ZwindowPosX = windowPosX;
338 } 329 }
339 330
diff --git a/core/applets/screenshotapplet/screenshotapplet.pro b/core/applets/screenshotapplet/screenshotapplet.pro
index fe8299e..1e4d6a4 100644
--- a/core/applets/screenshotapplet/screenshotapplet.pro
+++ b/core/applets/screenshotapplet/screenshotapplet.pro
@@ -1,13 +1,13 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt plugin warn_on 2CONFIG += qt plugin warn_on
3HEADERS = screenshot.h inputDialog.h 3HEADERS = screenshot.h
4SOURCES = screenshot.cpp inputDialog.cpp 4SOURCES = screenshot.cpp
5TARGET = screenshotapplet 5TARGET = screenshotapplet
6DESTDIR = $(OPIEDIR)/plugins/applets 6DESTDIR = $(OPIEDIR)/plugins/applets
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += 8DEPENDPATH +=
9LIBS += -lqpe 9LIBS += -lqpe -lopiecore2 -lopieui2
10VERSION = 1.0.0 10VERSION = 1.0.0
11 11
12include( $(OPIEDIR)/include.pro ) 12include( $(OPIEDIR)/include.pro )
13target.path = $$prefix/plugins/applets 13target.path = $$prefix/plugins/applets