author | zecke <zecke> | 2004-05-06 21:14:26 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-05-06 21:14:26 (UTC) |
commit | a6f2e9cf92a4f7dc91696394e1fe41d7c7bb372f (patch) (unidiff) | |
tree | 092e72540b7f595e02bb9d6bde3f372a37db80c8 | |
parent | 49588c7322679fe3dadf7aaad058d7df76e0d8d3 (diff) | |
download | opie-a6f2e9cf92a4f7dc91696394e1fe41d7c7bb372f.zip opie-a6f2e9cf92a4f7dc91696394e1fe41d7c7bb372f.tar.gz opie-a6f2e9cf92a4f7dc91696394e1fe41d7c7bb372f.tar.bz2 |
Obey styleguide and show popups as in Qtopia
-rw-r--r-- | core/applets/clockapplet/clock.cpp | 46 | ||||
-rw-r--r-- | core/applets/clockapplet/clock.h | 2 |
2 files changed, 42 insertions, 6 deletions
diff --git a/core/applets/clockapplet/clock.cpp b/core/applets/clockapplet/clock.cpp index 7d396e7..d7d326d 100644 --- a/core/applets/clockapplet/clock.cpp +++ b/core/applets/clockapplet/clock.cpp | |||
@@ -1,8 +1,9 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002 Trolltech AS. All rights reserved. | ||
3 | ** | 4 | ** |
4 | ** This file is part of Qtopia Environment. | 5 | ** This file is part of Qtopia Environment. |
5 | ** | 6 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 7 | ** 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 | ** 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 | ** Foundation and appearing in the file LICENSE.GPL included in the |
@@ -14,21 +15,27 @@ | |||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 16 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 18 | ** not clear to you. |
18 | ** | 19 | ** |
19 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | // merged in the StyleFix. Applets should raise Popup! | ||
22 | // by zecke@handhelds.org 6th of may 2004 | ||
20 | 23 | ||
21 | #include "clock.h" | 24 | #include "clock.h" |
22 | 25 | ||
23 | /* OPIE */ | 26 | /* OPIE */ |
24 | #include <opie2/odebug.h> | 27 | #include <opie2/odebug.h> |
25 | #include <opie2/otaskbarapplet.h> | 28 | #include <opie2/otaskbarapplet.h> |
29 | |||
26 | #include <qpe/qpeapplication.h> | 30 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
28 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <qpe/resource.h> | ||
34 | |||
35 | #include <qpopupmenu.h> | ||
29 | 36 | ||
30 | using namespace Opie::Core; | 37 | using namespace Opie::Core; |
31 | using namespace Opie::Ui; | 38 | using namespace Opie::Ui; |
32 | 39 | ||
33 | LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) | 40 | LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) |
34 | { | 41 | { |
@@ -54,17 +61,46 @@ void LauncherClock::readConfig() { | |||
54 | config.setGroup( "Time" ); | 61 | config.setGroup( "Time" ); |
55 | ampmFormat = config.readBoolEntry( "AMPM", TRUE ); | 62 | ampmFormat = config.readBoolEntry( "AMPM", TRUE ); |
56 | config.setGroup( "Date" ); | 63 | config.setGroup( "Date" ); |
57 | format = config.readNumEntry("ClockApplet",0); | 64 | format = config.readNumEntry("ClockApplet",0); |
58 | } | 65 | } |
59 | 66 | ||
60 | void LauncherClock::mouseReleaseEvent( QMouseEvent * ) | 67 | void LauncherClock::mousePressEvent( QMouseEvent * ) |
61 | { | 68 | { |
62 | QCString setTimeApp; | 69 | QPopupMenu *menu = new QPopupMenu(this); |
63 | setTimeApp="systemtime"; | 70 | menu->insertItem(tr("Set time..."), 0); |
64 | QCopEnvelope e("QPE/Application/"+setTimeApp, "raise()"); | 71 | menu->insertSeparator(); |
72 | menu->insertItem(tr("Clock.."), 1); | ||
73 | |||
74 | |||
75 | Config config( "Clock" ); | ||
76 | config.setGroup( "Daily Alarm" ); | ||
77 | bool alarmOn = config.readBoolEntry("Enabled", FALSE); | ||
78 | menu->insertItem(Resource::loadIconSet(alarmOn?"clockapplet/smallalarm":"clockapplet/smallalarm_off" ), | ||
79 | tr("Alarm..."), 2); | ||
80 | |||
81 | |||
82 | /* FIXME use OTaskBarApplet ### */ | ||
83 | QPoint curPos = mapToGlobal( QPoint(0,0) ); | ||
84 | QSize sh = menu->sizeHint(); | ||
85 | switch (menu->exec( curPos-QPoint((sh.width()-width())/2,sh.height()) )) { | ||
86 | case 0: | ||
87 | Global::execute( "systemtime" ); | ||
88 | break; | ||
89 | case 1: { | ||
90 | QCopEnvelope e("QPE/Application/clock", "showClock()" ); | ||
91 | } | ||
92 | break; | ||
93 | case 2: { | ||
94 | QCopEnvelope e("QPE/Application/clock", "editDailyAlarm()" ); | ||
95 | } | ||
96 | break; | ||
97 | default: | ||
98 | break; | ||
99 | } | ||
100 | delete menu; | ||
65 | } | 101 | } |
66 | 102 | ||
67 | 103 | ||
68 | void LauncherClock::timerEvent( QTimerEvent *e ) | 104 | void LauncherClock::timerEvent( QTimerEvent *e ) |
69 | { | 105 | { |
70 | if ( !e || e->timerId() == timerId ) { | 106 | if ( !e || e->timerId() == timerId ) { |
@@ -110,13 +146,13 @@ void LauncherClock::changeTime( void ) | |||
110 | setText( d+s ); | 146 | setText( d+s ); |
111 | } else { | 147 | } else { |
112 | setText( s ); | 148 | setText( s ); |
113 | } | 149 | } |
114 | } | 150 | } |
115 | 151 | ||
116 | void LauncherClock::slotClockChanged( bool pm ) | 152 | void LauncherClock::slotClockChanged( bool ) |
117 | { | 153 | { |
118 | readConfig(); | 154 | readConfig(); |
119 | updateTime(); | 155 | updateTime(); |
120 | } | 156 | } |
121 | 157 | ||
122 | 158 | ||
diff --git a/core/applets/clockapplet/clock.h b/core/applets/clockapplet/clock.h index 996fb56..43639bb 100644 --- a/core/applets/clockapplet/clock.h +++ b/core/applets/clockapplet/clock.h | |||
@@ -33,13 +33,13 @@ public: | |||
33 | 33 | ||
34 | protected slots: | 34 | protected slots: |
35 | void updateTime( void ); | 35 | void updateTime( void ); |
36 | void slotClockChanged( bool pm ); | 36 | void slotClockChanged( bool pm ); |
37 | 37 | ||
38 | protected: | 38 | protected: |
39 | void mouseReleaseEvent( QMouseEvent * ); | 39 | void mousePressEvent( QMouseEvent * ); |
40 | void timerEvent( QTimerEvent * ); | 40 | void timerEvent( QTimerEvent * ); |
41 | void changeTime( void ); | 41 | void changeTime( void ); |
42 | void readConfig(); | 42 | void readConfig(); |
43 | bool ampmFormat; | 43 | bool ampmFormat; |
44 | int timerId; | 44 | int timerId; |
45 | int format; | 45 | int format; |