author | mickeyl <mickeyl> | 2004-03-01 19:19:37 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-03-01 19:19:37 (UTC) |
commit | ddc3d749af5f7afebf69488b79641771fe246b5b (patch) (unidiff) | |
tree | 8ea8614906c568e4677493ef09040724d60dd2d4 /core/applets/screenshotapplet | |
parent | fb0981f47e529f9d1dd77fa005ffa3c3ecedff67 (diff) | |
download | opie-ddc3d749af5f7afebf69488b79641771fe246b5b.zip opie-ddc3d749af5f7afebf69488b79641771fe246b5b.tar.gz opie-ddc3d749af5f7afebf69488b79641771fe246b5b.tar.bz2 |
remove duplicated boiler plate code in favour of the OTaskbarApplet template
Diffstat (limited to 'core/applets/screenshotapplet') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/applets/screenshotapplet/screenshot.cpp | 25 | ||||
-rw-r--r-- | core/applets/screenshotapplet/screenshot.h | 1 | ||||
-rw-r--r-- | core/applets/screenshotapplet/screenshotapplet.pro | 6 | ||||
-rw-r--r-- | core/applets/screenshotapplet/screenshotappletimpl.cpp | 66 | ||||
-rw-r--r-- | core/applets/screenshotapplet/screenshotappletimpl.h | 43 |
5 files changed, 22 insertions, 119 deletions
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp index 56a031c..5d6bce4 100644 --- a/core/applets/screenshotapplet/screenshot.cpp +++ b/core/applets/screenshotapplet/screenshot.cpp | |||
@@ -1,60 +1,63 @@ | |||
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" | 16 | #include "inputDialog.h" |
17 | 17 | ||
18 | #include <stdlib.h> | 18 | /* OPIE */ |
19 | #include <sys/socket.h> | 19 | #include <opie2/otaskbarapplet.h> |
20 | #include <netinet/in.h> | ||
21 | #include <netdb.h> | ||
22 | #include <unistd.h> | ||
23 | |||
24 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/applnk.h> | 21 | #include <qpe/applnk.h> |
26 | 22 | ||
23 | /* QT */ | ||
27 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
28 | #include <qdir.h> | 25 | #include <qdir.h> |
29 | #include <qlabel.h> | 26 | #include <qlabel.h> |
30 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
31 | #include <qpainter.h> | 28 | #include <qpainter.h> |
32 | #include <qspinbox.h> | 29 | #include <qspinbox.h> |
33 | #include <qlayout.h> | 30 | #include <qlayout.h> |
34 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
35 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
36 | 33 | ||
34 | /* STD */ | ||
35 | #include <stdlib.h> | ||
36 | #include <sys/socket.h> | ||
37 | #include <netinet/in.h> | ||
38 | #include <netdb.h> | ||
39 | #include <unistd.h> | ||
37 | 40 | ||
38 | /* XPM */ | 41 | /* XPM */ |
39 | static char * snapshot_xpm[] = { | 42 | static char * snapshot_xpm[] = { |
40 | "32 32 177 2", | 43 | "32 32 177 2", |
41 | " c None", | 44 | " c None", |
42 | ". c #042045", | 45 | ". c #042045", |
43 | "+ c #0D2B47", | 46 | "+ c #0D2B47", |
44 | "@ c #0E325E", | 47 | "@ c #0E325E", |
45 | "# c #0D2E50", | 48 | "# c #0D2E50", |
46 | "$ c #0A1C32", | 49 | "$ c #0A1C32", |
47 | "% c #0F3A69", | 50 | "% c #0F3A69", |
48 | "& c #164680", | 51 | "& c #164680", |
49 | "* c #165EAE", | 52 | "* c #165EAE", |
50 | "= c #134D89", | 53 | "= c #134D89", |
51 | "- c #0A3A6E", | 54 | "- c #0A3A6E", |
52 | "; c #031024", | 55 | "; c #031024", |
53 | "> c #031B36", | 56 | "> c #031B36", |
54 | ", c #1A5EA3", | 57 | ", c #1A5EA3", |
55 | "' c #1862B1", | 58 | "' c #1862B1", |
56 | ") c #1866B9", | 59 | ") c #1866B9", |
57 | "! c #0F5AAC", | 60 | "! c #0F5AAC", |
58 | "~ c #0F56A8", | 61 | "~ c #0F56A8", |
59 | "{ c #0C4C96", | 62 | "{ c #0C4C96", |
60 | "] c #030918", | 63 | "] c #030918", |
@@ -476,55 +479,65 @@ void ScreenshotControl::performGrab() | |||
476 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); | 479 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); |
477 | } | 480 | } |
478 | } | 481 | } |
479 | 482 | ||
480 | } | 483 | } |
481 | 484 | ||
482 | 485 | ||
483 | 486 | ||
484 | //=========================================================================== | 487 | //=========================================================================== |
485 | 488 | ||
486 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) | 489 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) |
487 | : QWidget( parent, name ) | 490 | : QWidget( parent, name ) |
488 | { | 491 | { |
489 | setFixedWidth( AppLnk::smallIconSize()); | 492 | setFixedWidth( AppLnk::smallIconSize()); |
490 | 493 | ||
491 | QImage img = (const char **)snapshot_xpm; | 494 | QImage img = (const char **)snapshot_xpm; |
492 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); | 495 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); |
493 | m_icon.convertFromImage(img); | 496 | m_icon.convertFromImage(img); |
494 | } | 497 | } |
495 | 498 | ||
496 | ScreenshotApplet::~ScreenshotApplet() | 499 | ScreenshotApplet::~ScreenshotApplet() |
497 | { | 500 | { |
498 | } | 501 | } |
499 | 502 | ||
503 | int ScreenshotApplet::position() | ||
504 | { | ||
505 | return 6; | ||
506 | } | ||
507 | |||
500 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) | 508 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) |
501 | { | 509 | { |
502 | ScreenshotControl *sc = new ScreenshotControl ( ); | 510 | ScreenshotControl *sc = new ScreenshotControl ( ); |
503 | QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); | 511 | QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); |
504 | 512 | ||
505 | // windowPosX is the windows position centered above the applets icon. | 513 | // windowPosX is the windows position centered above the applets icon. |
506 | // If the icon is near the edge of the screen, the window would leave the visible area | 514 | // If the icon is near the edge of the screen, the window would leave the visible area |
507 | // so we check the position against the screen width and correct the difference if needed | 515 | // so we check the position against the screen width and correct the difference if needed |
508 | 516 | ||
509 | int screenWidth = qApp->desktop()->width(); | 517 | int screenWidth = qApp->desktop()->width(); |
510 | int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; | 518 | int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; |
511 | int ZwindowPosX, XwindowPosX; | 519 | int ZwindowPosX, XwindowPosX; |
512 | 520 | ||
513 | // the window would be placed beyond the screen wich doesn't look tooo good | 521 | // the window would be placed beyond the screen wich doesn't look tooo good |
514 | if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { | 522 | if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { |
515 | XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; | 523 | XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; |
516 | ZwindowPosX = windowPosX - XwindowPosX - 1; | 524 | ZwindowPosX = windowPosX - XwindowPosX - 1; |
517 | } else { | 525 | } else { |
518 | ZwindowPosX = windowPosX; | 526 | ZwindowPosX = windowPosX; |
519 | } | 527 | } |
520 | 528 | ||
521 | sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); | 529 | sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); |
522 | sc-> show ( ); | 530 | sc-> show ( ); |
523 | } | 531 | } |
524 | 532 | ||
525 | void ScreenshotApplet::paintEvent( QPaintEvent* ) | 533 | void ScreenshotApplet::paintEvent( QPaintEvent* ) |
526 | { | 534 | { |
527 | QPainter p ( this ); | 535 | QPainter p ( this ); |
528 | p.drawPixmap( 0,0, m_icon ); | 536 | p.drawPixmap( 0,0, m_icon ); |
529 | } | 537 | } |
530 | 538 | ||
539 | Q_EXPORT_INTERFACE() | ||
540 | { | ||
541 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<ScreenshotApplet> ); | ||
542 | } | ||
543 | |||
diff --git a/core/applets/screenshotapplet/screenshot.h b/core/applets/screenshotapplet/screenshot.h index 74cc5e6..b753583 100644 --- a/core/applets/screenshotapplet/screenshot.h +++ b/core/applets/screenshotapplet/screenshot.h | |||
@@ -35,36 +35,37 @@ class ScreenshotControl : public QFrame | |||
35 | public: | 35 | public: |
36 | ScreenshotControl( QWidget *parent=0, const char *name=0 ); | 36 | ScreenshotControl( QWidget *parent=0, const char *name=0 ); |
37 | 37 | ||
38 | private: | 38 | private: |
39 | QPushButton *grabItButton, *scapButton; | 39 | QPushButton *grabItButton, *scapButton; |
40 | QPixmap snapshot; | 40 | QPixmap snapshot; |
41 | QTimer* grabTimer; | 41 | QTimer* grabTimer; |
42 | QCheckBox *saveNamedCheck; | 42 | QCheckBox *saveNamedCheck; |
43 | QString FileNamePath; | 43 | QString FileNamePath; |
44 | bool setFileName; | 44 | bool setFileName; |
45 | QSpinBox *delaySpin; | 45 | QSpinBox *delaySpin; |
46 | int buttonPushed; | 46 | int buttonPushed; |
47 | 47 | ||
48 | private slots: | 48 | private slots: |
49 | void slotGrab(); | 49 | void slotGrab(); |
50 | void slotScap(); | 50 | void slotScap(); |
51 | void savePixmap(); | 51 | void savePixmap(); |
52 | void performGrab(); | 52 | void performGrab(); |
53 | }; | 53 | }; |
54 | 54 | ||
55 | class ScreenshotApplet : public QWidget { | 55 | class ScreenshotApplet : public QWidget { |
56 | public: | 56 | public: |
57 | ScreenshotApplet( QWidget *parent = 0, const char *name=0 ); | 57 | ScreenshotApplet( QWidget *parent = 0, const char *name=0 ); |
58 | ~ScreenshotApplet(); | 58 | ~ScreenshotApplet(); |
59 | static int position(); | ||
59 | 60 | ||
60 | protected: | 61 | protected: |
61 | void mousePressEvent( QMouseEvent * ); | 62 | void mousePressEvent( QMouseEvent * ); |
62 | void paintEvent( QPaintEvent* ); | 63 | void paintEvent( QPaintEvent* ); |
63 | 64 | ||
64 | private: | 65 | private: |
65 | QPixmap m_icon; | 66 | QPixmap m_icon; |
66 | }; | 67 | }; |
67 | 68 | ||
68 | 69 | ||
69 | #endif // __SCREENSHOT_APPLET_H__ | 70 | #endif // __SCREENSHOT_APPLET_H__ |
70 | 71 | ||
diff --git a/core/applets/screenshotapplet/screenshotapplet.pro b/core/applets/screenshotapplet/screenshotapplet.pro index 45a5759..c7fcc3e 100644 --- a/core/applets/screenshotapplet/screenshotapplet.pro +++ b/core/applets/screenshotapplet/screenshotapplet.pro | |||
@@ -1,15 +1,13 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt plugin warn_on release | 2 | CONFIG += qt plugin warn_on release |
3 | HEADERS = screenshot.h inputDialog.h screenshotappletimpl.h | 3 | HEADERS = screenshot.h inputDialog.h |
4 | SOURCES = screenshot.cpp inputDialog.cpp screenshotappletimpl.cpp | 4 | SOURCES = screenshot.cpp inputDialog.cpp |
5 | TARGET = screenshotapplet | 5 | TARGET = screenshotapplet |
6 | DESTDIR = $(OPIEDIR)/plugins/applets | 6 | DESTDIR = $(OPIEDIR)/plugins/applets |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += ../$(OPIEDIR)/include | 8 | DEPENDPATH += ../$(OPIEDIR)/include |
9 | LIBS += -lqpe | 9 | LIBS += -lqpe |
10 | VERSION = 1.0.0 | 10 | VERSION = 1.0.0 |
11 | MOC_DIR=opieobj | ||
12 | OBJECTS_DIR=opieobj | ||
13 | 11 | ||
14 | include ( $(OPIEDIR)/include.pro ) | 12 | include ( $(OPIEDIR)/include.pro ) |
15 | target.path = $$prefix/plugins/applets | 13 | target.path = $$prefix/plugins/applets |
diff --git a/core/applets/screenshotapplet/screenshotappletimpl.cpp b/core/applets/screenshotapplet/screenshotappletimpl.cpp deleted file mode 100644 index e99ecb0..0000000 --- a/core/applets/screenshotapplet/screenshotappletimpl.cpp +++ b/dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #include "screenshot.h" | ||
21 | #include "screenshotappletimpl.h" | ||
22 | |||
23 | |||
24 | ScreenshotAppletImpl::ScreenshotAppletImpl() | ||
25 | : screenshot(0) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | ScreenshotAppletImpl::~ScreenshotAppletImpl() | ||
30 | { | ||
31 | delete screenshot; | ||
32 | } | ||
33 | |||
34 | QWidget *ScreenshotAppletImpl::applet( QWidget *parent ) | ||
35 | { | ||
36 | if ( !screenshot ) | ||
37 | screenshot = new ScreenshotApplet( parent ); | ||
38 | return screenshot; | ||
39 | } | ||
40 | |||
41 | int ScreenshotAppletImpl::position() const | ||
42 | { | ||
43 | return 6; | ||
44 | } | ||
45 | |||
46 | QRESULT ScreenshotAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | ||
47 | { | ||
48 | *iface = 0; | ||
49 | if ( uuid == IID_QUnknown ) | ||
50 | *iface = this; | ||
51 | else if ( uuid == IID_TaskbarApplet ) | ||
52 | *iface = this; | ||
53 | else | ||
54 | return QS_FALSE; | ||
55 | |||
56 | if ( *iface ) | ||
57 | (*iface)->addRef(); | ||
58 | return QS_OK; | ||
59 | } | ||
60 | |||
61 | Q_EXPORT_INTERFACE() | ||
62 | { | ||
63 | Q_CREATE_INSTANCE( ScreenshotAppletImpl ) | ||
64 | } | ||
65 | |||
66 | |||
diff --git a/core/applets/screenshotapplet/screenshotappletimpl.h b/core/applets/screenshotapplet/screenshotappletimpl.h deleted file mode 100644 index 988a34c..0000000 --- a/core/applets/screenshotapplet/screenshotappletimpl.h +++ b/dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef SCREENSHOTAPPLETIMPL_H | ||
21 | #define SCREENSHOTAPPLETIMPL_H | ||
22 | |||
23 | #include <qpe/taskbarappletinterface.h> | ||
24 | |||
25 | class ScreenshotApplet; | ||
26 | |||
27 | class ScreenshotAppletImpl : public TaskbarAppletInterface | ||
28 | { | ||
29 | public: | ||
30 | ScreenshotAppletImpl(); | ||
31 | virtual ~ScreenshotAppletImpl(); | ||
32 | |||
33 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
34 | Q_REFCOUNT | ||
35 | |||
36 | virtual QWidget *applet( QWidget *parent ); | ||
37 | virtual int position() const; | ||
38 | |||
39 | private: | ||
40 | ScreenshotApplet *screenshot; | ||
41 | }; | ||
42 | |||
43 | #endif | ||