summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-02-12 11:40:53 (UTC)
committer harlekin <harlekin>2003-02-12 11:40:53 (UTC)
commitd5ca5bf9f6fc8d47c2786af80342b13036f14d36 (patch) (unidiff)
tree83b131e59306b2a387f893bc13491fbae6357702
parentd9f46624eff7817ea46a4cb2f9bd4e908308df45 (diff)
downloadopie-d5ca5bf9f6fc8d47c2786af80342b13036f14d36.zip
opie-d5ca5bf9f6fc8d47c2786af80342b13036f14d36.tar.gz
opie-d5ca5bf9f6fc8d47c2786af80342b13036f14d36.tar.bz2
now plugins should be translatable too
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/plugins/datebook/datebookevent.cpp4
-rw-r--r--core/pim/today/today.cpp25
2 files changed, 24 insertions, 5 deletions
diff --git a/core/pim/today/plugins/datebook/datebookevent.cpp b/core/pim/today/plugins/datebook/datebookevent.cpp
index 48f204e..3c1e97a 100644
--- a/core/pim/today/plugins/datebook/datebookevent.cpp
+++ b/core/pim/today/plugins/datebook/datebookevent.cpp
@@ -1,138 +1,138 @@
1/* 1/*
2 * datebookevent.cpp 2 * datebookevent.cpp
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#include "datebookevent.h" 17#include "datebookevent.h"
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include <qpe/timestring.h> 19#include <qpe/timestring.h>
20#include <qpe/qcopenvelope_qws.h> 20#include <qpe/qcopenvelope_qws.h>
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22 22
23#include <opie/odevice.h> 23#include <opie/odevice.h>
24 24
25using namespace Opie; 25using namespace Opie;
26 26
27DateBookEvent::DateBookEvent(const EffectiveEvent &ev, 27DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
28 QWidget* parent, 28 QWidget* parent,
29 bool show_location, 29 bool show_location,
30 bool show_notes, 30 bool show_notes,
31 int maxCharClip, 31 int maxCharClip,
32 const char* name, 32 const char* name,
33 WFlags fl) : 33 WFlags fl) :
34 OClickableLabel(parent,name,fl), event(ev) { 34 OClickableLabel(parent,name,fl), event(ev) {
35 35
36 // setAlignment( AlignTop ); 36 // setAlignment( AlignTop );
37 37
38 QString msg; 38 QString msg;
39 39
40 Config config( "qpe" ); 40 Config config( "qpe" );
41 config.setGroup( "Time" ); 41 config.setGroup( "Time" );
42 // if 24 h format 42 // if 24 h format
43 ampm = config.readBoolEntry( "AMPM", TRUE ); 43 ampm = config.readBoolEntry( "AMPM", TRUE );
44 44
45 msg += "<B>" + (ev).description() + "</B>"; 45 msg += "<B>" + (ev).description() + "</B>";
46 if ( (ev).event().hasAlarm() ) { 46 if ( (ev).event().hasAlarm() ) {
47 msg += " <b>[with alarm]</b>"; 47 msg += " <b>" + tr("[with alarm]") +"</b>";
48 } 48 }
49 49
50 // include location or not 50 // include location or not
51 if ( show_location ) { 51 if ( show_location ) {
52 msg += "<BR><i>" + (ev).location() + "</i>"; 52 msg += "<BR><i>" + (ev).location() + "</i>";
53 } 53 }
54 54
55 if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" ) 55 if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" )
56 && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) { 56 && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) {
57 msg += "<br>All day"; 57 msg += "<br>All day";
58 } else { 58 } else {
59 // start time of event 59 // start time of event
60 QDate tempDate = (ev).event().start().date(); 60 QDate tempDate = (ev).event().start().date();
61 msg += "<br>" 61 msg += "<br>"
62 + ampmTime( QTime( (ev).event().start().time() ) ) 62 + ampmTime( QTime( (ev).event().start().time() ) )
63 // end time of event 63 // end time of event
64 + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) ) 64 + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) )
65 + differDate( tempDate ); 65 + differDate( tempDate );
66 } 66 }
67 67
68 // include possible note or not 68 // include possible note or not
69 if ( show_notes ) { 69 if ( show_notes ) {
70 msg += "<br> <i>note</i>:" +( (ev).notes() ).mid( 0, maxCharClip ); 70 msg += "<br> <i>" + tr("note") + "</i>:" +( (ev).notes() ).mid( 0, maxCharClip );
71 } 71 }
72 setText( msg ); 72 setText( msg );
73 connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) ); 73 connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) );
74} 74}
75 75
76DateBookEvent::~DateBookEvent() { 76DateBookEvent::~DateBookEvent() {
77} 77}
78 78
79/** 79/**
80 * AM/PM timestring conversion. 80 * AM/PM timestring conversion.
81 * @param tm the timestring 81 * @param tm the timestring
82 * @return formatted to am/pm is system is set to it 82 * @return formatted to am/pm is system is set to it
83 */ 83 */
84QString DateBookEvent::ampmTime( QTime tm ) { 84QString DateBookEvent::ampmTime( QTime tm ) {
85 QString s; 85 QString s;
86 if( ampm ) { 86 if( ampm ) {
87 int hour = tm.hour(); 87 int hour = tm.hour();
88 if ( hour == 0 ) { 88 if ( hour == 0 ) {
89 hour = 12; 89 hour = 12;
90 } 90 }
91 if ( hour > 12 ) { 91 if ( hour > 12 ) {
92 hour -= 12; 92 hour -= 12;
93 } 93 }
94 s.sprintf( "%2d:%02d %s", hour, tm.minute(), 94 s.sprintf( "%2d:%02d %s", hour, tm.minute(),
95 (tm.hour() >= 12) ? "PM" : "AM" ); 95 (tm.hour() >= 12) ? "PM" : "AM" );
96 return s; 96 return s;
97 } else { 97 } else {
98 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); 98 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
99 return s; 99 return s;
100 } 100 }
101} 101}
102 102
103QString DateBookEvent::differDate( QDate date ) { 103QString DateBookEvent::differDate( QDate date ) {
104 QDate currentDate = QDate::currentDate(); 104 QDate currentDate = QDate::currentDate();
105 QString returnText = "<font color = #407DD9><b> "; 105 QString returnText = "<font color = #407DD9><b> ";
106 int differDate = currentDate.daysTo( date ); 106 int differDate = currentDate.daysTo( date );
107 if ( currentDate.dayOfWeek() == date.dayOfWeek() ) { 107 if ( currentDate.dayOfWeek() == date.dayOfWeek() ) {
108 returnText += "" ; 108 returnText += "" ;
109 // not working right for recurring events 109 // not working right for recurring events
110 //} else if ( differDate == 1 ) { 110 //} else if ( differDate == 1 ) {
111 //returnText += tr( "tomorrow" ); 111 //returnText += tr( "tomorrow" );
112 } else { 112 } else {
113 //returnText += tr( "in %1 days" ).arg( differDate ); 113 //returnText += tr( "in %1 days" ).arg( differDate );
114 returnText += " [ " + date.dayName( date.dayOfWeek() ) + " ] "; 114 returnText += " [ " + date.dayName( date.dayOfWeek() ) + " ] ";
115 } 115 }
116 returnText += "</b></font>"; 116 returnText += "</b></font>";
117 return returnText; 117 return returnText;
118} 118}
119 119
120 120
121/** 121/**
122 * starts the edit dialog as known from datebook 122 * starts the edit dialog as known from datebook
123 */ 123 */
124void DateBookEvent::editEventSlot( const Event &e ) { 124void DateBookEvent::editEventSlot( const Event &e ) {
125 125
126 if ( ODevice::inst()->system() == System_Zaurus ) { 126 if ( ODevice::inst()->system() == System_Zaurus ) {
127 QCopEnvelope env( "QPE/Application/datebook", "raise()" ); 127 QCopEnvelope env( "QPE/Application/datebook", "raise()" );
128 } else { 128 } else {
129 QCopEnvelope env( "QPE/Datebook", "editEvent(int)" ); 129 QCopEnvelope env( "QPE/Datebook", "editEvent(int)" );
130 env << e.uid(); 130 env << e.uid();
131 } 131 }
132} 132}
133 133
134 134
135void DateBookEvent::editMe() { 135void DateBookEvent::editMe() {
136 emit editEvent( event.event() ); 136 emit editEvent( event.event() );
137} 137}
138 138
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 2f6907d..2497ee1 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -1,373 +1,392 @@
1/* 1/*
2 * today.cpp 2 * today.cpp
3 * 3 *
4 * copyright : (c) 2002,2003 by Maximilian Reiß 4 * copyright : (c) 2002,2003 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17 17
18
19#define QTOPIA_INTERNAL_LANGLIST
20
18#include "today.h" 21#include "today.h"
19#include <opie/todayconfigwidget.h> 22#include <opie/todayconfigwidget.h>
20 23
21#include <qpe/config.h> 24#include <qpe/config.h>
22#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
23#include <qpe/resource.h> 26#include <qpe/resource.h>
24#include <qpe/global.h> 27#include <qpe/global.h>
25#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
26#include <qpe/contact.h> 29#include <qpe/contact.h>
27 30
28#include <qdir.h> 31#include <qdir.h>
29#include <qfile.h> 32#include <qfile.h>
30#include <qpushbutton.h> 33#include <qpushbutton.h>
31#include <qlabel.h> 34#include <qlabel.h>
32#include <qtimer.h> 35#include <qtimer.h>
33#include <qpixmap.h> 36#include <qpixmap.h>
34#include <qlayout.h> 37#include <qlayout.h>
35#include <qhbox.h> 38#include <qhbox.h>
36#include <opie/otabwidget.h> 39#include <opie/otabwidget.h>
37#include <qdialog.h> 40#include <qdialog.h>
38#include <qwhatsthis.h> 41#include <qwhatsthis.h>
39 42#include <qtranslator.h>
40 43
41struct TodayPlugin { 44struct TodayPlugin {
42 TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} 45 TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {}
43 QLibrary *library; 46 QLibrary *library;
44 QInterfacePtr<TodayPluginInterface> iface; 47 QInterfacePtr<TodayPluginInterface> iface;
45 TodayPluginObject *guiPart; 48 TodayPluginObject *guiPart;
46 QWidget *guiBox; 49 QWidget *guiBox;
47 QString name; 50 QString name;
48 bool active; 51 bool active;
49 bool excludeRefresh; 52 bool excludeRefresh;
50 int pos; 53 int pos;
51}; 54};
52 55
53static QValueList<TodayPlugin> pluginList; 56static QValueList<TodayPlugin> pluginList;
54 57
55Today::Today( QWidget* parent, const char* name, WFlags fl ) 58Today::Today( QWidget* parent, const char* name, WFlags fl )
56 : TodayBase( parent, name, fl ) { 59 : TodayBase( parent, name, fl ) {
57 60
58 QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); 61 QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) );
59 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); 62 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) );
60 63
61#if defined(Q_WS_QWS) 64#if defined(Q_WS_QWS)
62#if !defined(QT_NO_COP) 65#if !defined(QT_NO_COP)
63 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); 66 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this );
64 connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), 67 connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
65 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); 68 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
66#endif 69#endif
67#endif 70#endif
68 71
69 setOwnerField(); 72 setOwnerField();
70 m_refreshTimer = new QTimer( this ); 73 m_refreshTimer = new QTimer( this );
71 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 74 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
72 m_refreshTimer->start( 15000 ); 75 m_refreshTimer->start( 15000 );
73 //init(); 76 //init();
74 loadPlugins(); 77 loadPlugins();
75 showMaximized(); 78 showMaximized();
76} 79}
77 80
78/** 81/**
79 * Qcop receive method. 82 * Qcop receive method.
80 */ 83 */
81void Today::channelReceived( const QCString &msg, const QByteArray & data ) { 84void Today::channelReceived( const QCString &msg, const QByteArray & data ) {
82 QDataStream stream( data, IO_ReadOnly ); 85 QDataStream stream( data, IO_ReadOnly );
83 if ( msg == "message(QString)" ) { 86 if ( msg == "message(QString)" ) {
84 QString message; 87 QString message;
85 stream >> message; 88 stream >> message;
86 setOwnerField( message ); 89 setOwnerField( message );
87 } 90 }
88} 91}
89 92
90void Today::setRefreshTimer( int interval ) { 93void Today::setRefreshTimer( int interval ) {
91 94
92 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 95 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
93 96
94 // 0 is "never" case 97 // 0 is "never" case
95 if ( !interval == 0 ) { 98 if ( !interval == 0 ) {
96 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 99 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
97 m_refreshTimer->changeInterval( interval ); 100 m_refreshTimer->changeInterval( interval );
98 } 101 }
99} 102}
100 103
101 104
102/** 105/**
103 * Initialises the owner field with the default value, the username 106 * Initialises the owner field with the default value, the username
104 */ 107 */
105void Today::setOwnerField() { 108void Today::setOwnerField() {
106 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); 109 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" );
107 if ( QFile::exists( file ) ) { 110 if ( QFile::exists( file ) ) {
108 Contact cont = Contact::readVCard( file )[0]; 111 Contact cont = Contact::readVCard( file )[0];
109 QString returnString = cont.fullName(); 112 QString returnString = cont.fullName();
110 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); 113 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" );
111 } else { 114 } else {
112 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); 115 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" );
113 } 116 }
114} 117}
115 118
116/** 119/**
117 * Set the owner field with a given QString, for example per qcop. 120 * Set the owner field with a given QString, for example per qcop.
118 */ 121 */
119void Today::setOwnerField( QString &message ) { 122void Today::setOwnerField( QString &message ) {
120 if ( !message.isEmpty() ) { 123 if ( !message.isEmpty() ) {
121 OwnerField->setText( "<b>" + message + "</b>" ); 124 OwnerField->setText( "<b>" + message + "</b>" );
122 } 125 }
123} 126}
124 127
125/** 128/**
126 * Init stuff needed for today. Reads the config file. 129 * Init stuff needed for today. Reads the config file.
127 */ 130 */
128void Today::init() { 131void Today::init() {
129 // read config 132 // read config
130 Config cfg( "today" ); 133 Config cfg( "today" );
131 134
132 cfg.setGroup( "Plugins" ); 135 cfg.setGroup( "Plugins" );
133 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 136 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
134 m_allApplets = cfg.readListEntry( "AllApplets", ',' ); 137 m_allApplets = cfg.readListEntry( "AllApplets", ',' );
135 138
136 cfg.setGroup( "General" ); 139 cfg.setGroup( "General" );
137 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 140 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
138 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); 141 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) );
139 142
140 // set the date in top label 143 // set the date in top label
141 QDate date = QDate::currentDate(); 144 QDate date = QDate::currentDate();
142 QString time = ( tr( date.toString() ) ); 145 QString time = ( tr( date.toString() ) );
143 DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); 146 DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) );
144 147
145 if ( layout ) { 148 if ( layout ) {
146 delete layout; 149 delete layout;
147 } 150 }
148 layout = new QVBoxLayout( this ); 151 layout = new QVBoxLayout( this );
149 layout->addWidget( Frame ); 152 layout->addWidget( Frame );
150 layout->addWidget( OwnerField ); 153 layout->addWidget( OwnerField );
151} 154}
152 155
153/** 156/**
154 * Load the plugins 157 * Load the plugins
155 */ 158 */
156void Today::loadPlugins() { 159void Today::loadPlugins() {
157 160
158 init(); 161 init();
159 QValueList<TodayPlugin>::Iterator tit; 162 QValueList<TodayPlugin>::Iterator tit;
160 if ( !pluginList.isEmpty() ) { 163 if ( !pluginList.isEmpty() ) {
161 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { 164 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) {
162 (*tit).guiBox->hide(); 165 (*tit).guiBox->hide();
163 (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); 166 (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) );
164 (*tit).library->unload();
165 delete (*tit).guiBox; 167 delete (*tit).guiBox;
168 (*tit).library->unload();
166 delete (*tit).library; 169 delete (*tit).library;
167 } 170 }
168 pluginList.clear(); 171 pluginList.clear();
169 } 172 }
170 173
171 QString path = QPEApplication::qpeDir() + "/plugins/today"; 174 QString path = QPEApplication::qpeDir() + "/plugins/today";
172 QDir dir( path, "lib*.so" ); 175 QDir dir( path, "lib*.so" );
173 176
174 QStringList list = dir.entryList(); 177 QStringList list = dir.entryList();
175 QStringList::Iterator it; 178 QStringList::Iterator it;
176 179
177 QMap<QString, TodayPlugin> tempList; 180 QMap<QString, TodayPlugin> tempList;
178 181
179 for ( it = list.begin(); it != list.end(); ++it ) { 182 for ( it = list.begin(); it != list.end(); ++it ) {
180 QInterfacePtr<TodayPluginInterface> iface; 183 QInterfacePtr<TodayPluginInterface> iface;
181 QLibrary *lib = new QLibrary( path + "/" + *it ); 184 QLibrary *lib = new QLibrary( path + "/" + *it );
182 185
183 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); 186 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
184 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 187 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
185 qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); 188 qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() );
186 qDebug( QString(*it) ); 189 qDebug( QString(*it) );
187 190
188 TodayPlugin plugin; 191 TodayPlugin plugin;
189 plugin.library = lib; 192 plugin.library = lib;
190 plugin.iface = iface; 193 plugin.iface = iface;
191 plugin.name = QString(*it); 194 plugin.name = QString(*it);
192 195
196 QString type = (*it).left( (*it).find(".") );
197 QStringList langs = Global::languageList();
198 for (QStringList::ConstIterator lit = langs.begin(); lit!=langs.end(); ++lit) {
199 QString lang = *lit;
200 qDebug( "Languages: " + lang );
201 QTranslator * trans = new QTranslator( qApp );
202 QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm";
203 if ( trans->load( tfn ) ) {
204 qApp->installTranslator( trans );
205 } else {
206 delete trans;
207 }
208 }
209
193 // find out if plugins should be shown 210 // find out if plugins should be shown
194 if ( m_excludeApplets.grep( *it ).isEmpty() ) { 211 if ( m_excludeApplets.grep( *it ).isEmpty() ) {
195 plugin.active = true; 212 plugin.active = true;
196 } else { 213 } else {
197 plugin.active = false; 214 plugin.active = false;
198 } 215 }
199 216
200 plugin.guiPart = plugin.iface->guiPart(); 217 plugin.guiPart = plugin.iface->guiPart();
201 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); 218 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
202 219
203 // package the whole thing into a qwidget so it can be shown and hidden 220 // package the whole thing into a qwidget so it can be shown and hidden
204 plugin.guiBox = new QWidget( this ); 221 plugin.guiBox = new QWidget( this );
205 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); 222 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
206 QPixmap plugPix; 223 QPixmap plugPix;
207 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); 224 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
208 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); 225 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
209 plugIcon->setPixmap( plugPix ); 226 plugIcon->setPixmap( plugPix );
210 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); 227 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") );
211 plugIcon->setName( plugin.guiPart->appName() ); 228 plugIcon->setName( plugin.guiPart->appName() );
212 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); 229 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
213 // a scrollview for each plugin 230 // a scrollview for each plugin
214 QScrollView* sv = new QScrollView( plugin.guiBox ); 231 QScrollView* sv = new QScrollView( plugin.guiBox );
215 QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); 232 QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() );
216 // not sure if that is good .-) 233 // not sure if that is good .-)
217 sv->setMinimumHeight( 12 ); 234 sv->setMinimumHeight( 12 );
218 sv->setResizePolicy( QScrollView::AutoOneFit ); 235 sv->setResizePolicy( QScrollView::AutoOneFit );
219 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 236 sv->setHScrollBarMode( QScrollView::AlwaysOff );
220 sv->setFrameShape( QFrame::NoFrame ); 237 sv->setFrameShape( QFrame::NoFrame );
221 sv->addChild( plugWidget ); 238 sv->addChild( plugWidget );
222 // make sure the icon is on the top alligned 239 // make sure the icon is on the top alligned
223 boxLayout->addWidget( plugIcon, 0, AlignTop ); 240 boxLayout->addWidget( plugIcon, 0, AlignTop );
224 boxLayout->addWidget( sv, 0, AlignTop ); 241 boxLayout->addWidget( sv, 0, AlignTop );
225 boxLayout->setStretchFactor( plugIcon, 1 ); 242 boxLayout->setStretchFactor( plugIcon, 1 );
226 boxLayout->setStretchFactor( sv, 9 ); 243 boxLayout->setStretchFactor( sv, 9 );
227 // "prebuffer" it in one more list, to get the sorting done 244 // "prebuffer" it in one more list, to get the sorting done
228 tempList.insert( plugin.name, plugin ); 245 tempList.insert( plugin.name, plugin );
229 246
230 // on first start the list is off course empty 247 // on first start the list is off course empty
231 if ( m_allApplets.isEmpty() ) { 248 if ( m_allApplets.isEmpty() ) {
232 layout->addWidget( plugin.guiBox ); 249 layout->addWidget( plugin.guiBox );
233 pluginList.append( plugin ); 250 pluginList.append( plugin );
234 } 251 }
235 252
236 // if plugin is not yet in the list, add it to the layout too 253 // if plugin is not yet in the list, add it to the layout too
237 else if ( !m_allApplets.contains( plugin.name ) ) { 254 else if ( !m_allApplets.contains( plugin.name ) ) {
238 layout->addWidget( plugin.guiBox ); 255 layout->addWidget( plugin.guiBox );
239 pluginList.append( plugin ); 256 pluginList.append( plugin );
240 } 257 }
241 } else { 258 } else {
242 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); 259 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() );
243 delete lib; 260 delete lib;
244 } 261 }
245 } 262 }
246 263
247 if ( !m_allApplets.isEmpty() ) { 264 if ( !m_allApplets.isEmpty() ) {
248 TodayPlugin tempPlugin; 265 TodayPlugin tempPlugin;
249 QStringList::Iterator stringit; 266 QStringList::Iterator stringit;
250 267
251 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { 268 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) {
252 tempPlugin = ( tempList.find( *stringit ) ).data(); 269 tempPlugin = ( tempList.find( *stringit ) ).data();
253 if ( !( (tempPlugin.name).isEmpty() ) ) { 270 if ( !( (tempPlugin.name).isEmpty() ) ) {
254 layout->addWidget( tempPlugin.guiBox ); 271 layout->addWidget( tempPlugin.guiBox );
255 pluginList.append( tempPlugin ); 272 pluginList.append( tempPlugin );
256 } 273 }
257 } 274 }
258 } 275 }
259 draw(); 276 draw();
260} 277}
261 278
262 279
263/** 280/**
264 * Repaint method. Reread all fields. 281 * Repaint method. Reread all fields.
265 */ 282 */
266void Today::draw() { 283void Today::draw() {
267 284
268 if ( pluginList.count() == 0 ) { 285 if ( pluginList.count() == 0 ) {
269 QLabel *noPlugins = new QLabel( this ); 286 QLabel *noPlugins = new QLabel( this );
270 noPlugins->setText( tr( "No plugins found" ) ); 287 noPlugins->setText( tr( "No plugins found" ) );
271 layout->addWidget( noPlugins ); 288 layout->addWidget( noPlugins );
272 return; 289 return;
273 } 290 }
274 291
275 uint count = 0; 292 uint count = 0;
276 TodayPlugin plugin; 293 TodayPlugin plugin;
277 for ( uint i = 0; i < pluginList.count(); i++ ) { 294 for ( uint i = 0; i < pluginList.count(); i++ ) {
278 plugin = pluginList[i]; 295 plugin = pluginList[i];
279 296
280 if ( plugin.active ) { 297 if ( plugin.active ) {
281 // qDebug( plugin.name + " is ACTIVE " ); 298 // qDebug( plugin.name + " is ACTIVE " );
282 plugin.guiBox->show(); 299 plugin.guiBox->show();
283 } else { 300 } else {
284 // qDebug( plugin.name + " is INACTIVE" ); 301 // qDebug( plugin.name + " is INACTIVE" );
285 plugin.guiBox->hide(); 302 plugin.guiBox->hide();
286 } 303 }
287 count++; 304 count++;
288 } 305 }
289 306
290 if ( count == 0 ) { 307 if ( count == 0 ) {
291 QLabel *noPluginsActive = new QLabel( this ); 308 QLabel *noPluginsActive = new QLabel( this );
292 noPluginsActive->setText( tr( "No plugins activated" ) ); 309 noPluginsActive->setText( tr( "No plugins activated" ) );
293 layout->addWidget( noPluginsActive ); 310 layout->addWidget( noPluginsActive );
294 } 311 }
295 layout->addStretch(0); 312 layout->addStretch(0);
296} 313}
297 314
298 315
299/** 316/**
300 * The method for the configuration dialog. 317 * The method for the configuration dialog.
301 */ 318 */
302void Today::startConfig() { 319void Today::startConfig() {
303 320
304 // disconnect timer to prevent problems while being on config dialog 321 // disconnect timer to prevent problems while being on config dialog
305 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 322 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
323 m_refreshTimer->stop( );
306 324
307 TodayConfig conf( this, "dialog", true ); 325 TodayConfig conf( this, "dialog", true );
308 326
309 TodayPlugin plugin; 327 TodayPlugin plugin;
310 QList<TodayConfigWidget> configWidgetList; 328 QList<TodayConfigWidget> configWidgetList;
311 329
312 for ( int i = pluginList.count() - 1 ; i >= 0; i-- ) { 330 for ( int i = pluginList.count() - 1 ; i >= 0; i-- ) {
313 plugin = pluginList[i]; 331 plugin = pluginList[i];
314 332
315 // load the config widgets in the tabs 333 // load the config widgets in the tabs
316 if ( plugin.guiPart->configWidget( this ) != 0l ) { 334 if ( plugin.guiPart->configWidget( this ) != 0l ) {
317 TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); 335 TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 );
318 configWidgetList.append( widget ); 336 configWidgetList.append( widget );
319 conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig() 337 conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig()
320 , plugin.guiPart->appName() ); 338 , plugin.guiPart->appName() );
321 } 339 }
322 // set the order/activate tab 340 // set the order/activate tab
323 conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), 341 conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(),
324 Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); 342 Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) );
325 } 343 }
326 344
327 if ( conf.exec() == QDialog::Accepted ) { 345 if ( conf.exec() == QDialog::Accepted ) {
328 conf.writeConfig(); 346 conf.writeConfig();
329 TodayConfigWidget *confWidget; 347 TodayConfigWidget *confWidget;
330 for ( confWidget = configWidgetList.first(); confWidget != 0; 348 for ( confWidget = configWidgetList.first(); confWidget != 0;
331 confWidget = configWidgetList.next() ) { 349 confWidget = configWidgetList.next() ) {
332 confWidget->writeConfig(); 350 confWidget->writeConfig();
333 } 351 }
334 loadPlugins(); 352 loadPlugins();
335 } else { 353 } else {
336 // since refresh is not called in that case , reconnect the signal 354 // since refresh is not called in that case , reconnect the signal
337 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 355 m_refreshTimer->start( 15000 ); // get the config value in here later
356 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
338 } 357 }
339} 358}
340 359
341 360
342/** 361/**
343 * Refresh for the view. Reload all applets 362 * Refresh for the view. Reload all applets
344 * 363 *
345 */ 364 */
346void Today::refresh() { 365void Today::refresh() {
347 366
348 init(); 367 init();
349 368
350 QValueList<TodayPlugin>::Iterator it; 369 QValueList<TodayPlugin>::Iterator it;
351 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { 370 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
352 if ( !(*it).excludeRefresh ) { 371 if ( !(*it).excludeRefresh ) {
353 (*it).guiPart->refresh(); 372 (*it).guiPart->refresh();
354 qDebug( "refresh" ); 373 qDebug( "refresh" );
355 } 374 }
356 } 375 }
357} 376}
358 377
359void Today::startApplication() { 378void Today::startApplication() {
360 QCopEnvelope e( "QPE/System", "execute(QString)" ); 379 QCopEnvelope e( "QPE/System", "execute(QString)" );
361 e << QString( sender()->name() ); 380 e << QString( sender()->name() );
362} 381}
363 382
364/** 383/**
365 * launch addressbook (personal card) 384 * launch addressbook (personal card)
366 */ 385 */
367void Today::editCard() { 386void Today::editCard() {
368 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); 387 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" );
369} 388}
370 389
371Today::~Today() { 390Today::~Today() {
372} 391}
373 392