-rw-r--r-- | core/applets/clockapplet/clock.cpp | 12 | ||||
-rw-r--r-- | core/applets/clockapplet/clock.h | 1 | ||||
-rw-r--r-- | core/applets/clockapplet/clockapplet.pro | 4 | ||||
-rw-r--r-- | core/applets/clockapplet/clockappletimpl.cpp | 67 | ||||
-rw-r--r-- | core/applets/clockapplet/clockappletimpl.h | 45 |
5 files changed, 15 insertions, 114 deletions
diff --git a/core/applets/clockapplet/clock.cpp b/core/applets/clockapplet/clock.cpp index aadd9b6..9fead03 100644 --- a/core/applets/clockapplet/clock.cpp +++ b/core/applets/clockapplet/clock.cpp | |||
@@ -1,109 +1,121 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
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 "clock.h" | 21 | #include "clock.h" |
22 | 22 | ||
23 | #include <opie2/otaskbarapplet.h> | ||
23 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
26 | 27 | ||
27 | LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) | 28 | LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) |
28 | { | 29 | { |
29 | // If you want a sunken border around the clock do this: | 30 | // If you want a sunken border around the clock do this: |
30 | // setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 31 | // setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
31 | //setFont( QFont( "Helvetica", , QFont::Normal ) ); | 32 | //setFont( QFont( "Helvetica", , QFont::Normal ) ); |
32 | connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime( ) ) ); | 33 | connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime( ) ) ); |
33 | connect( qApp, SIGNAL( clockChanged( bool ) ), | 34 | connect( qApp, SIGNAL( clockChanged( bool ) ), |
34 | this, SLOT( slotClockChanged( bool ) ) ); | 35 | this, SLOT( slotClockChanged( bool ) ) ); |
35 | readConfig(); | 36 | readConfig(); |
36 | timerId = 0; | 37 | timerId = 0; |
37 | timerEvent( 0 ); | 38 | timerEvent( 0 ); |
38 | show(); | 39 | show(); |
39 | } | 40 | } |
40 | 41 | ||
42 | int LauncherClock::position() | ||
43 | { | ||
44 | return 10; | ||
45 | } | ||
46 | |||
41 | void LauncherClock::readConfig() { | 47 | void LauncherClock::readConfig() { |
42 | Config config( "qpe" ); | 48 | Config config( "qpe" ); |
43 | config.setGroup( "Time" ); | 49 | config.setGroup( "Time" ); |
44 | ampmFormat = config.readBoolEntry( "AMPM", TRUE ); | 50 | ampmFormat = config.readBoolEntry( "AMPM", TRUE ); |
45 | config.setGroup( "Date" ); | 51 | config.setGroup( "Date" ); |
46 | format = config.readNumEntry("ClockApplet",0); | 52 | format = config.readNumEntry("ClockApplet",0); |
47 | } | 53 | } |
48 | 54 | ||
49 | void LauncherClock::mouseReleaseEvent( QMouseEvent * ) | 55 | void LauncherClock::mouseReleaseEvent( QMouseEvent * ) |
50 | { | 56 | { |
51 | QCString setTimeApp; | 57 | QCString setTimeApp; |
52 | setTimeApp="systemtime"; | 58 | setTimeApp="systemtime"; |
53 | QCopEnvelope e("QPE/Application/"+setTimeApp, "raise()"); | 59 | QCopEnvelope e("QPE/Application/"+setTimeApp, "raise()"); |
54 | } | 60 | } |
55 | 61 | ||
56 | 62 | ||
57 | void LauncherClock::timerEvent( QTimerEvent *e ) | 63 | void LauncherClock::timerEvent( QTimerEvent *e ) |
58 | { | 64 | { |
59 | if ( !e || e->timerId() == timerId ) { | 65 | if ( !e || e->timerId() == timerId ) { |
60 | killTimer( timerId ); | 66 | killTimer( timerId ); |
61 | changeTime(); | 67 | changeTime(); |
62 | QTime t = QTime::currentTime(); | 68 | QTime t = QTime::currentTime(); |
63 | int ms = (60 - t.second())*1000 - t.msec(); | 69 | int ms = (60 - t.second())*1000 - t.msec(); |
64 | timerId = startTimer( ms ); | 70 | timerId = startTimer( ms ); |
65 | } else { | 71 | } else { |
66 | QLabel::timerEvent( e ); | 72 | QLabel::timerEvent( e ); |
67 | } | 73 | } |
68 | } | 74 | } |
69 | 75 | ||
70 | void LauncherClock::updateTime( void ) | 76 | void LauncherClock::updateTime( void ) |
71 | { | 77 | { |
72 | changeTime(); | 78 | changeTime(); |
73 | } | 79 | } |
74 | 80 | ||
75 | void LauncherClock::changeTime( void ) | 81 | void LauncherClock::changeTime( void ) |
76 | { | 82 | { |
77 | QTime tm = QDateTime::currentDateTime().time(); | 83 | QTime tm = QDateTime::currentDateTime().time(); |
78 | QString s; | 84 | QString s; |
79 | if( ampmFormat ) { | 85 | if( ampmFormat ) { |
80 | int hour = tm.hour(); | 86 | int hour = tm.hour(); |
81 | if (hour == 0) | 87 | if (hour == 0) |
82 | hour = 12; | 88 | hour = 12; |
83 | if (hour > 12) | 89 | if (hour > 12) |
84 | hour -= 12; | 90 | hour -= 12; |
85 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 91 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
86 | (tm.hour() >= 12) ? "PM" : "AM" ); | 92 | (tm.hour() >= 12) ? "PM" : "AM" ); |
87 | } else | 93 | } else |
88 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 94 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
89 | 95 | ||
90 | if (format==1) { | 96 | if (format==1) { |
91 | QDate dm = QDate::currentDate(); | 97 | QDate dm = QDate::currentDate(); |
92 | QString d; | 98 | QString d; |
93 | d.sprintf("%d/%d ", dm.day(), dm.month()); | 99 | d.sprintf("%d/%d ", dm.day(), dm.month()); |
94 | setText( d+s ); | 100 | setText( d+s ); |
95 | } else if (format==2) { | 101 | } else if (format==2) { |
96 | QDate dm = QDate::currentDate(); | 102 | QDate dm = QDate::currentDate(); |
97 | QString d; | 103 | QString d; |
98 | d.sprintf("%d/%d ", dm.month(), dm.day()); | 104 | d.sprintf("%d/%d ", dm.month(), dm.day()); |
99 | setText( d+s ); | 105 | setText( d+s ); |
100 | } else { | 106 | } else { |
101 | setText( s ); | 107 | setText( s ); |
102 | } | 108 | } |
103 | } | 109 | } |
104 | 110 | ||
105 | void LauncherClock::slotClockChanged( bool pm ) | 111 | void LauncherClock::slotClockChanged( bool pm ) |
106 | { | 112 | { |
107 | readConfig(); | 113 | readConfig(); |
108 | updateTime(); | 114 | updateTime(); |
109 | } | 115 | } |
116 | |||
117 | Q_EXPORT_INTERFACE() | ||
118 | { | ||
119 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<LauncherClock> ); | ||
120 | } | ||
121 | |||
diff --git a/core/applets/clockapplet/clock.h b/core/applets/clockapplet/clock.h index caa0c5f..996fb56 100644 --- a/core/applets/clockapplet/clock.h +++ b/core/applets/clockapplet/clock.h | |||
@@ -1,48 +1,49 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
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 | #ifndef __LAUNCHER_CLOCK_H__ | 20 | #ifndef __LAUNCHER_CLOCK_H__ |
21 | #define __LAUNCHER_CLOCK_H__ | 21 | #define __LAUNCHER_CLOCK_H__ |
22 | 22 | ||
23 | 23 | ||
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | 26 | ||
27 | class LauncherClock : public QLabel | 27 | class LauncherClock : public QLabel |
28 | { | 28 | { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | LauncherClock( QWidget *parent ); | 31 | LauncherClock( QWidget *parent ); |
32 | static int position(); | ||
32 | 33 | ||
33 | protected slots: | 34 | protected slots: |
34 | void updateTime( void ); | 35 | void updateTime( void ); |
35 | void slotClockChanged( bool pm ); | 36 | void slotClockChanged( bool pm ); |
36 | 37 | ||
37 | protected: | 38 | protected: |
38 | void mouseReleaseEvent( QMouseEvent * ); | 39 | void mouseReleaseEvent( QMouseEvent * ); |
39 | void timerEvent( QTimerEvent * ); | 40 | void timerEvent( QTimerEvent * ); |
40 | void changeTime( void ); | 41 | void changeTime( void ); |
41 | void readConfig(); | 42 | void readConfig(); |
42 | bool ampmFormat; | 43 | bool ampmFormat; |
43 | int timerId; | 44 | int timerId; |
44 | int format; | 45 | int format; |
45 | }; | 46 | }; |
46 | 47 | ||
47 | 48 | ||
48 | #endif // __LAUNCHER_CLOCK_H__ | 49 | #endif // __LAUNCHER_CLOCK_H__ |
diff --git a/core/applets/clockapplet/clockapplet.pro b/core/applets/clockapplet/clockapplet.pro index 057e332..8ce3f6f 100644 --- a/core/applets/clockapplet/clockapplet.pro +++ b/core/applets/clockapplet/clockapplet.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= clock.h clockappletimpl.h | 3 | HEADERS = clock.h |
4 | SOURCES= clock.cpp clockappletimpl.cpp | 4 | SOURCES = clock.cpp |
5 | TARGET = clockapplet | 5 | TARGET = clockapplet |
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/clockapplet/clockappletimpl.cpp b/core/applets/clockapplet/clockappletimpl.cpp deleted file mode 100644 index 7481f19..0000000 --- a/core/applets/clockapplet/clockappletimpl.cpp +++ b/dev/null | |||
@@ -1,67 +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 "clock.h" | ||
21 | #include "clockappletimpl.h" | ||
22 | |||
23 | |||
24 | ClockAppletImpl::ClockAppletImpl() | ||
25 | : clock(0) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | ClockAppletImpl::~ClockAppletImpl() | ||
30 | { | ||
31 | delete clock; | ||
32 | } | ||
33 | |||
34 | QWidget *ClockAppletImpl::applet( QWidget *parent ) | ||
35 | { | ||
36 | if ( !clock ) | ||
37 | clock = new LauncherClock( parent ); | ||
38 | return clock; | ||
39 | } | ||
40 | |||
41 | int ClockAppletImpl::position() const | ||
42 | { | ||
43 | return 10; | ||
44 | } | ||
45 | |||
46 | #ifndef QT_NO_COMPONENT | ||
47 | QRESULT ClockAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | ||
48 | { | ||
49 | *iface = 0; | ||
50 | if ( uuid == IID_QUnknown ) | ||
51 | *iface = this; | ||
52 | else if ( uuid == IID_TaskbarApplet ) | ||
53 | *iface = this; | ||
54 | else | ||
55 | return QS_FALSE; | ||
56 | |||
57 | if ( *iface ) | ||
58 | (*iface)->addRef(); | ||
59 | return QS_OK; | ||
60 | } | ||
61 | |||
62 | Q_EXPORT_INTERFACE() | ||
63 | { | ||
64 | Q_CREATE_INSTANCE( ClockAppletImpl ) | ||
65 | } | ||
66 | #endif | ||
67 | |||
diff --git a/core/applets/clockapplet/clockappletimpl.h b/core/applets/clockapplet/clockappletimpl.h deleted file mode 100644 index 1f9c8f0..0000000 --- a/core/applets/clockapplet/clockappletimpl.h +++ b/dev/null | |||
@@ -1,45 +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 CLOCKAPPLETIMPL_H | ||
21 | #define CLOCKAPPLETIMPL_H | ||
22 | |||
23 | #include <qpe/taskbarappletinterface.h> | ||
24 | |||
25 | class LauncherClock; | ||
26 | |||
27 | class ClockAppletImpl : public TaskbarAppletInterface | ||
28 | { | ||
29 | public: | ||
30 | ClockAppletImpl(); | ||
31 | virtual ~ClockAppletImpl(); | ||
32 | |||
33 | #ifndef QT_NO_COMPONENT | ||
34 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
35 | Q_REFCOUNT | ||
36 | #endif | ||
37 | |||
38 | virtual QWidget *applet( QWidget *parent ); | ||
39 | virtual int position() const; | ||
40 | |||
41 | private: | ||
42 | LauncherClock *clock; | ||
43 | }; | ||
44 | |||
45 | #endif | ||