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/clipboardapplet | |
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/clipboardapplet') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/applets/clipboardapplet/clipboard.cpp | 11 | ||||
-rw-r--r-- | core/applets/clipboardapplet/clipboard.h | 1 | ||||
-rw-r--r-- | core/applets/clipboardapplet/clipboardapplet.pro | 4 | ||||
-rw-r--r-- | core/applets/clipboardapplet/clipboardappletimpl.cpp | 66 | ||||
-rw-r--r-- | core/applets/clipboardapplet/clipboardappletimpl.h | 43 |
5 files changed, 14 insertions, 111 deletions
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp index bb0db9b..34d151e 100644 --- a/core/applets/clipboardapplet/clipboard.cpp +++ b/core/applets/clipboardapplet/clipboard.cpp | |||
@@ -11,24 +11,25 @@ | |||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "clipboard.h" | 21 | #include "clipboard.h" |
22 | 22 | ||
23 | #include <opie2/otaskbarapplet.h> | ||
23 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
24 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
25 | 26 | ||
26 | #include <qpainter.h> | 27 | #include <qpainter.h> |
27 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
28 | #include <qwindowsystem_qws.h> | 29 | #include <qwindowsystem_qws.h> |
29 | #include <qapplication.h> | 30 | #include <qapplication.h> |
30 | #include <qclipboard.h> | 31 | #include <qclipboard.h> |
31 | #include <qtimer.h> | 32 | #include <qtimer.h> |
32 | 33 | ||
33 | //=========================================================================== | 34 | //=========================================================================== |
34 | 35 | ||
@@ -51,24 +52,29 @@ ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( | |||
51 | 52 | ||
52 | m_menu = 0; | 53 | m_menu = 0; |
53 | m_dirty = true; | 54 | m_dirty = true; |
54 | m_lasttext = QString::null; | 55 | m_lasttext = QString::null; |
55 | 56 | ||
56 | m_timer-> start ( 0, true ); | 57 | m_timer-> start ( 0, true ); |
57 | } | 58 | } |
58 | 59 | ||
59 | ClipboardApplet::~ClipboardApplet ( ) | 60 | ClipboardApplet::~ClipboardApplet ( ) |
60 | { | 61 | { |
61 | } | 62 | } |
62 | 63 | ||
64 | int ClipboardApplet::position() | ||
65 | { | ||
66 | return 6; | ||
67 | } | ||
68 | |||
63 | void ClipboardApplet::shutdown ( ) | 69 | void ClipboardApplet::shutdown ( ) |
64 | { | 70 | { |
65 | // the timer has to be stopped, or Qt/E will hang on quit() | 71 | // the timer has to be stopped, or Qt/E will hang on quit() |
66 | // see launcher/desktop.cpp | 72 | // see launcher/desktop.cpp |
67 | 73 | ||
68 | m_timer-> stop ( ); | 74 | m_timer-> stop ( ); |
69 | } | 75 | } |
70 | 76 | ||
71 | void ClipboardApplet::mousePressEvent ( QMouseEvent *) | 77 | void ClipboardApplet::mousePressEvent ( QMouseEvent *) |
72 | { | 78 | { |
73 | if ( m_dirty ) { | 79 | if ( m_dirty ) { |
74 | delete m_menu; | 80 | delete m_menu; |
@@ -167,12 +173,17 @@ void ClipboardApplet::newData ( ) | |||
167 | m_history. append ( txt ); | 173 | m_history. append ( txt ); |
168 | 174 | ||
169 | if ( m_history. count ( ) > 5 ) | 175 | if ( m_history. count ( ) > 5 ) |
170 | m_history. remove ( m_history. begin ( )); | 176 | m_history. remove ( m_history. begin ( )); |
171 | 177 | ||
172 | m_dirty = true; | 178 | m_dirty = true; |
173 | } | 179 | } |
174 | 180 | ||
175 | m_timer-> start ( 1500, true ); | 181 | m_timer-> start ( 1500, true ); |
176 | 182 | ||
177 | excllock = false; | 183 | excllock = false; |
178 | } | 184 | } |
185 | |||
186 | Q_EXPORT_INTERFACE() | ||
187 | { | ||
188 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<ClipboardApplet> ); | ||
189 | } | ||
diff --git a/core/applets/clipboardapplet/clipboard.h b/core/applets/clipboardapplet/clipboard.h index ec87d39..bbda0ff 100644 --- a/core/applets/clipboardapplet/clipboard.h +++ b/core/applets/clipboardapplet/clipboard.h | |||
@@ -23,24 +23,25 @@ | |||
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
25 | #include <qstringlist.h> | 25 | #include <qstringlist.h> |
26 | 26 | ||
27 | class QTimer; | 27 | class QTimer; |
28 | 28 | ||
29 | class ClipboardApplet : public QWidget | 29 | class ClipboardApplet : public QWidget |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | public: |
33 | ClipboardApplet ( QWidget *parent = 0, const char *name=0 ); | 33 | ClipboardApplet ( QWidget *parent = 0, const char *name=0 ); |
34 | ~ClipboardApplet ( ); | 34 | ~ClipboardApplet ( ); |
35 | static int position(); | ||
35 | 36 | ||
36 | protected: | 37 | protected: |
37 | void mousePressEvent ( QMouseEvent *); | 38 | void mousePressEvent ( QMouseEvent *); |
38 | void paintEvent ( QPaintEvent* ); | 39 | void paintEvent ( QPaintEvent* ); |
39 | 40 | ||
40 | private slots: | 41 | private slots: |
41 | void action ( int ); | 42 | void action ( int ); |
42 | void newData ( ); | 43 | void newData ( ); |
43 | void shutdown ( ); | 44 | void shutdown ( ); |
44 | 45 | ||
45 | private: | 46 | private: |
46 | QPopupMenu * m_menu; | 47 | QPopupMenu * m_menu; |
diff --git a/core/applets/clipboardapplet/clipboardapplet.pro b/core/applets/clipboardapplet/clipboardapplet.pro index f6842a2..74cf48c 100644 --- a/core/applets/clipboardapplet/clipboardapplet.pro +++ b/core/applets/clipboardapplet/clipboardapplet.pro | |||
@@ -1,13 +1,13 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt plugin warn_on release | 2 | CONFIG += qt plugin warn_on release |
3 | HEADERS= clipboard.h clipboardappletimpl.h | 3 | HEADERS = clipboard.h |
4 | SOURCES= clipboard.cpp clipboardappletimpl.cpp | 4 | SOURCES = clipboard.cpp |
5 | TARGET = clipboardapplet | 5 | TARGET = clipboardapplet |
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 | 11 | ||
12 | include ( $(OPIEDIR)/include.pro ) | 12 | include ( $(OPIEDIR)/include.pro ) |
13 | target.path = $$prefix/plugins/applets | 13 | target.path = $$prefix/plugins/applets |
diff --git a/core/applets/clipboardapplet/clipboardappletimpl.cpp b/core/applets/clipboardapplet/clipboardappletimpl.cpp deleted file mode 100644 index f454529..0000000 --- a/core/applets/clipboardapplet/clipboardappletimpl.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 "clipboard.h" | ||
21 | #include "clipboardappletimpl.h" | ||
22 | |||
23 | |||
24 | ClipboardAppletImpl::ClipboardAppletImpl() | ||
25 | : clipboard(0) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | ClipboardAppletImpl::~ClipboardAppletImpl() | ||
30 | { | ||
31 | delete clipboard; | ||
32 | } | ||
33 | |||
34 | QWidget *ClipboardAppletImpl::applet( QWidget *parent ) | ||
35 | { | ||
36 | if ( !clipboard ) | ||
37 | clipboard = new ClipboardApplet( parent ); | ||
38 | return clipboard; | ||
39 | } | ||
40 | |||
41 | int ClipboardAppletImpl::position() const | ||
42 | { | ||
43 | return 6; | ||
44 | } | ||
45 | |||
46 | QRESULT ClipboardAppletImpl::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( ClipboardAppletImpl ) | ||
64 | } | ||
65 | |||
66 | |||
diff --git a/core/applets/clipboardapplet/clipboardappletimpl.h b/core/applets/clipboardapplet/clipboardappletimpl.h deleted file mode 100644 index 497360c..0000000 --- a/core/applets/clipboardapplet/clipboardappletimpl.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 CLIPBOARDAPPLETIMPL_H | ||
21 | #define CLIPBOARDAPPLETIMPL_H | ||
22 | |||
23 | #include <qpe/taskbarappletinterface.h> | ||
24 | |||
25 | class ClipboardApplet; | ||
26 | |||
27 | class ClipboardAppletImpl : public TaskbarAppletInterface | ||
28 | { | ||
29 | public: | ||
30 | ClipboardAppletImpl(); | ||
31 | virtual ~ClipboardAppletImpl(); | ||
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 | ClipboardApplet *clipboard; | ||
41 | }; | ||
42 | |||
43 | #endif | ||