summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp372
-rw-r--r--core/pim/today/today.h27
-rw-r--r--core/pim/today/todayconfig.cpp137
-rw-r--r--core/pim/today/todayconfig.h18
4 files changed, 236 insertions, 318 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 0a6269e..a8c8651 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -15,11 +15,10 @@
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#define QTOPIA_INTERNAL_LANGLIST
18
19#include "today.h" 17#include "today.h"
20 18
21#include <opie2/odebug.h> 19#include <opie2/odebug.h>
20#include <opie2/opluginloader.h>
21#include <opie2/oconfig.h>
22 22
23#include <qpe/config.h>
24#include <qpe/qcopenvelope_qws.h> 23#include <qpe/qcopenvelope_qws.h>
25#include <qpe/resource.h> 24#include <qpe/resource.h>
@@ -32,41 +31,40 @@
32 31
33using namespace Opie::Ui; 32using namespace Opie::Ui;
33using Opie::Core::OPluginItem;
34using Opie::Core::OPluginLoader;
35using Opie::Core::OPluginManager;
36using Opie::Core::OConfig;
37
38
34struct TodayPlugin { 39struct TodayPlugin {
35 TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} 40TodayPlugin() : iface( 0 ), guiPart( 0 ), guiBox( 0 ) {}
36 QLibrary *library;
37 QInterfacePtr<TodayPluginInterface> iface; 41 QInterfacePtr<TodayPluginInterface> iface;
38 TodayPluginObject *guiPart; 42 TodayPluginObject *guiPart;
43 OPluginItem oplugin;
39 QWidget *guiBox; 44 QWidget *guiBox;
40 QString name; 45 QString name;
41 bool active;
42 bool excludeRefresh; 46 bool excludeRefresh;
43 int pos;
44}; 47};
45 48
46static QValueList<TodayPlugin> pluginList; 49static QMap<QString, TodayPlugin> pluginList;
47
48static QMap<QString, TodayPlugin> tempList;
49 50
50Today::Today( QWidget* parent, const char* name, WFlags fl ) 51Today::Today( QWidget* parent, const char* name, WFlags fl )
51 : TodayBase( parent, name, fl ) { 52: TodayBase( parent, name, fl ) {
52 53
53 QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); 54 QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) );
54 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); 55 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) );
55 56
56#if defined(Q_WS_QWS) 57 #if defined(Q_WS_QWS)
57#if !defined(QT_NO_COP) 58 #if !defined(QT_NO_COP)
59
58 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); 60 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this );
59 connect ( todayChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 61 connect ( todayChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
60 this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); 62 this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) );
61#endif 63 #endif
62#endif 64 #endif
63 65
64 setOwnerField(); 66 setOwnerField();
65 m_refreshTimer = new QTimer( this );
66 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
67 m_refreshTimer->start( 15000 );
68 m_big_box = 0L; 67 m_big_box = 0L;
69 68
70
71 layout = new QVBoxLayout( this ); 69 layout = new QVBoxLayout( this );
72 layout->addWidget( Frame ); 70 layout->addWidget( Frame );
@@ -81,6 +79,10 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
81 layout->setStretchFactor( m_sv,4 ); 79 layout->setStretchFactor( m_sv,4 );
82 80
83 qApp->processEvents(); 81 m_refreshTimer = new QTimer( this );
82 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
83
84 init();
84 loadPlugins(); 85 loadPlugins();
86 initialize();
85 QPEApplication::showWidget( this ); 87 QPEApplication::showWidget( this );
86} 88}
@@ -101,5 +103,4 @@ void Today::setRefreshTimer( int interval ) {
101 103
102 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 104 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
103
104 // 0 is "never" case 105 // 0 is "never" case
105 if ( !interval == 0 ) { 106 if ( !interval == 0 ) {
@@ -133,4 +134,5 @@ void Today::setOwnerField( QString &message ) {
133} 134}
134 135
136
135/** 137/**
136 * Init stuff needed for today. Reads the config file. 138 * Init stuff needed for today. Reads the config file.
@@ -138,9 +140,8 @@ void Today::setOwnerField( QString &message ) {
138void Today::init() { 140void Today::init() {
139 // read config 141 // read config
140 Config cfg( "today" ); 142 OConfig cfg( "today" );
141
142 cfg.setGroup( "Plugins" ); 143 cfg.setGroup( "Plugins" );
143 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 144 // m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
144 m_allApplets = cfg.readListEntry( "AllApplets", ',' ); 145 // m_allApplets = cfg.readListEntry( "AllApplets", ',' );
145 146
146 cfg.setGroup( "General" ); 147 cfg.setGroup( "General" );
@@ -170,4 +171,5 @@ void Today::init() {
170} 171}
171 172
173
172/** 174/**
173 * Load the plugins 175 * Load the plugins
@@ -175,162 +177,46 @@ void Today::init() {
175void Today::loadPlugins() { 177void Today::loadPlugins() {
176 178
177 init(); 179 m_pluginLoader = new OPluginLoader( "today", true );
178 180 m_pluginLoader->setAutoDelete( true );
179 QValueList<TodayPlugin>::Iterator tit; 181
180 if ( !pluginList.isEmpty() ) { 182 OPluginItem::List lst = m_pluginLoader->allAvailable( true );
181 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { 183
182 (*tit).guiBox->hide(); 184 m_manager = new OPluginManager( m_pluginLoader );
183 (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); 185 m_manager->load();
184 delete (*tit).guiBox; 186
185 (*tit).library->unload(); 187 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
186 delete (*tit).library; 188 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
187 } 189
188 pluginList.clear(); 190 TodayPlugin plugin;
191 plugin.iface = iface;
192 plugin.name = (*it).name();
193 plugin.oplugin = (*it);
194
195 plugin.guiPart = plugin.iface->guiPart();
196 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
197
198 // package the whole thing into a qwidget so it can be shown and hidden
199 plugin.guiBox = new QWidget( m_big_box );
200 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
201 QPixmap plugPix;
202 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
203 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
204 plugIcon->setPixmap( plugPix );
205 QWhatsThis::add
206 ( plugIcon, tr("Click here to launch the associated app") );
207 plugIcon->setName( plugin.guiPart->appName() );
208 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
209
210 QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox );
211 boxLayout->addWidget( plugIcon, 0, AlignTop );
212 boxLayout->addWidget( plugWidget, 0, AlignTop );
213 boxLayout->setStretchFactor( plugIcon, 1 );
214 boxLayout->setStretchFactor( plugWidget, 9 );
215
216 pluginList.insert( plugin.name, plugin );
217 m_bblayout->addWidget(plugin.guiBox);
189 } 218 }
190 219
191 QString path = QPEApplication::qpeDir() + "/plugins/today"; 220 m_bblayout->addStretch( 1 );
192#ifdef Q_OS_MACX
193 owarn << "Searching for Plugins in: " << path << oendl;
194 QDir dir( path, "lib*.dylib" );
195#else
196 QDir dir( path, "lib*.so" );
197#endif
198
199 QStringList list = dir.entryList();
200 QStringList::Iterator it;
201
202 // QMap<QString, TodayPlugin> tempList;
203
204 for ( it = list.begin(); it != list.end(); ++it ) {
205 QInterfacePtr<TodayPluginInterface> iface;
206 QLibrary *lib = new QLibrary( path + "/" + *it );
207
208 odebug << "querying: " << path + "/" + *it << oendl;
209 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
210 odebug << "accepted: " << path + "/" + *it << oendl;
211 odebug << *it << oendl;
212
213 TodayPlugin plugin;
214 plugin.library = lib;
215 plugin.iface = iface;
216 plugin.name = QString(*it);
217
218 QString type = (*it).left( (*it).find(".") );
219
220 QString lang;
221 Config config("locale");
222 config.setGroup("Language");
223 lang = config.readEntry( "Language", "en" );
224
225 odebug << "Languages: " << lang << oendl;
226 QTranslator * trans = new QTranslator( qApp );
227 QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm";
228 if ( trans->load( tfn ) ) {
229 qApp->installTranslator( trans );
230 } else {
231 delete trans;
232 }
233
234
235 // find out if plugins should be shown
236 if ( m_excludeApplets.grep( *it ).isEmpty() ) {
237 plugin.active = true;
238 } else {
239 plugin.active = false;
240 }
241
242 plugin.guiPart = plugin.iface->guiPart();
243 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
244
245 // package the whole thing into a qwidget so it can be shown and hidden
246 plugin.guiBox = new QWidget( m_big_box );
247 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
248 QPixmap plugPix;
249 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
250 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
251 plugIcon->setPixmap( plugPix );
252 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") );
253 plugIcon->setName( plugin.guiPart->appName() );
254 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
255
256 QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox );
257 boxLayout->addWidget( plugIcon, 0, AlignTop );
258 boxLayout->addWidget( plugWidget, 0, AlignTop );
259 boxLayout->setStretchFactor( plugIcon, 1 );
260 boxLayout->setStretchFactor( plugWidget, 9 );
261
262 // "prebuffer" it in one more list, to get the sorting done
263 tempList.insert( plugin.name, plugin );
264
265 // on first start the list is off course empty
266 if ( m_allApplets.isEmpty() ) {
267 pluginList.append( plugin );
268 m_bblayout->addWidget( plugin.guiBox );
269 }
270
271 // if plugin is not yet in the list, add it to the layout too
272 else if ( !m_allApplets.contains( plugin.name ) ) {
273 pluginList.append( plugin );
274 }
275 } else {
276 odebug << "could not recognize " << path + "/" + *it << oendl;
277 delete lib;
278 }
279
280 }
281
282
283 if ( !m_allApplets.isEmpty() ) {
284 TodayPlugin tempPlugin;
285 QStringList::Iterator stringit;
286
287 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) {
288 tempPlugin = ( tempList.find( *stringit ) ).data();
289 if ( !( (tempPlugin.name).isEmpty() ) ) {
290 pluginList.append( tempPlugin );
291 m_bblayout->addWidget( tempPlugin.guiBox );
292 }
293 }
294 }
295 m_bblayout->addStretch( 2 );
296 draw();
297}
298
299
300
301
302/**
303 * Repaint method. Reread all fields.
304 */
305void Today::draw() {
306
307 if ( pluginList.count() == 0 ) {
308 QLabel *noPlugins = new QLabel( this );
309 noPlugins->setText( tr( "No plugins found" ) );
310 layout->addWidget( noPlugins );
311 return;
312 }
313
314 uint count = 0;
315 TodayPlugin plugin;
316 for ( uint i = 0; i < pluginList.count(); i++ ) {
317 plugin = pluginList[i];
318
319 if ( plugin.active ) {
320 //odebug << plugin.name << " is ACTIVE " << oendl;
321 plugin.guiBox->show();
322 } else {
323 //odebug << plugin.name << " is INACTIVE " << oendl;
324 plugin.guiBox->hide();
325 }
326 count++;
327 }
328
329 if ( count == 0 ) {
330 QLabel *noPluginsActive = new QLabel( this );
331 noPluginsActive->setText( tr( "No plugins activated" ) );
332 layout->addWidget( noPluginsActive );
333 }
334 repaint();
335} 221}
336 222
@@ -346,37 +232,11 @@ void Today::startConfig() {
346 232
347 TodayConfig conf( this, "dialog", true ); 233 TodayConfig conf( this, "dialog", true );
348 234 conf.setUpPlugins( m_manager, m_pluginLoader );
349 TodayPlugin plugin;
350 QList<TodayConfigWidget> configWidgetList;
351
352 for ( int i = pluginList.count() - 1; i >= 0; i-- ) {
353 plugin = pluginList[i];
354
355 // load the config widgets in the tabs
356 if ( plugin.guiPart->configWidget( this ) != 0l ) {
357 TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 );
358 configWidgetList.append( widget );
359 conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig()
360 , plugin.guiPart->appName() );
361 }
362 // set the order/activate tab
363 conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(),
364 Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) );
365 }
366 235
367 if ( conf.exec() == QDialog::Accepted ) { 236 if ( conf.exec() == QDialog::Accepted ) {
368 conf.writeConfig(); 237 conf.writeConfig();
369 TodayConfigWidget *confWidget; 238 initialize();
370 for ( confWidget = configWidgetList.first(); confWidget != 0;
371 confWidget = configWidgetList.next() ) {
372 confWidget->writeConfig();
373 }
374
375 // make the plugins to reinitialize ( reread its configs )
376 reinitialize();
377 draw();
378
379 } else { 239 } else {
380 // since refresh is not called in that case , reconnect the signal 240 // since reinitialize is not called in that case , reconnect the signal
381 m_refreshTimer->start( 15000 ); // get the config value in here later 241 m_refreshTimer->start( 15000 ); // get the config value in here later
382 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 242 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
@@ -385,28 +245,9 @@ void Today::startConfig() {
385 245
386 246
387 247void Today::initialize() {
388void Today::reinitialize() {
389 248
390 Config cfg( "today" ); 249 Config cfg( "today" );
391 cfg.setGroup( "Plugins" ); 250 cfg.setGroup( "Plugins" );
392 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
393 m_allApplets = cfg.readListEntry( "AllApplets", ',' );
394
395 /* reinitialize all plugins */
396 QValueList<TodayPlugin>::Iterator it;
397 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
398 if ( !(*it).excludeRefresh ) {
399 (*it).guiPart->reinitialize();
400 odebug << "reinit" << oendl;
401 }
402 251
403 /* check if plugins is still to be shown */
404 if ( m_excludeApplets.grep( (*it).name ).isEmpty() ) {
405 (*it).active = true;
406 } else {
407 (*it).active = false;
408 }
409
410 }
411 252
412 cfg.setGroup( "General" ); 253 cfg.setGroup( "General" );
@@ -427,17 +268,43 @@ void Today::reinitialize() {
427 } 268 }
428 269
429 delete m_bblayout; 270 if ( m_bblayout ) {
430 m_bblayout = new QVBoxLayout( m_big_box ); 271 delete m_bblayout;
431 TodayPlugin tempPlugin; 272 }
432 QStringList::Iterator stringit; 273 m_bblayout = new QVBoxLayout ( m_big_box );
274
275 if ( pluginList.count() == 0 ) {
276 QLabel *noPlugins = new QLabel( this );
277 noPlugins->setText( tr( "No plugins found" ) );
278 layout->addWidget( noPlugins );
279 } else {
280
281 uint count = 0;
282 TodayPlugin tempPlugin;
283 OPluginItem::List lst = m_pluginLoader->allAvailable( true );
284 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
433 285
434 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { 286 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
435 tempPlugin = ( tempList.find( *stringit ) ).data(); 287
436 if ( !( (tempPlugin.name).isEmpty() ) ) { 288 tempPlugin = ( pluginList.find( (*it).name() ).data() );
437 m_bblayout->addWidget( tempPlugin.guiBox ); 289 if ( !( (tempPlugin.name).isEmpty() ) ) {
290 if ( (*it).isEnabled() ) {
291 iface->guiPart()->reinitialize();
292 odebug << "reinit" << oendl;
293 tempPlugin.guiBox->show();
294 m_bblayout->addWidget(tempPlugin.guiBox);
295 count++;
296 } else {
297 tempPlugin.guiBox->hide();
298 }
299 }
300 }
301 if ( count == 0 ) {
302 QLabel *noPluginsActive = new QLabel( this );
303 noPluginsActive->setText( tr( "No plugins activated" ) );
304 layout->addWidget( noPluginsActive );
438 } 305 }
439 } 306 }
440 m_bblayout->addStretch( 2 ); 307 m_bblayout->addStretch( 1 );
441 308 repaint();
442} 309}
443 310
@@ -448,10 +315,10 @@ void Today::reinitialize() {
448void Today::refresh() { 315void Today::refresh() {
449 316
450 QValueList<TodayPlugin>::Iterator it; 317 OPluginItem::List lst = m_pluginLoader->filtered( true );
451 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { 318
452 if ( !(*it).excludeRefresh ) { 319 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
453 (*it).guiPart->refresh(); 320 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
454 odebug << "refresh" << oendl; 321 iface->guiPart()->refresh();
455 } 322 odebug << "refresh" << oendl;
456 } 323 }
457 324
@@ -462,4 +329,5 @@ void Today::refresh() {
462} 329}
463 330
331
464void Today::startApplication() { 332void Today::startApplication() {
465 QCopEnvelope e( "QPE/System", "execute(QString)" ); 333 QCopEnvelope e( "QPE/System", "execute(QString)" );
@@ -467,12 +335,20 @@ void Today::startApplication() {
467} 335}
468 336
337
469/** 338/**
470 * launch addressbook (personal card) 339* launch addressbook (personal card)
471 */ 340*/
472void Today::editCard() { 341void Today::editCard() {
473 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); 342 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" );
474} 343}
475 344
345
476Today::~Today() { 346Today::~Today() {
347 if (m_pluginLoader) {
348 delete m_pluginLoader;
349 }
350 if (m_manager) {
351 delete m_manager;
352 }
477} 353}
478 354
diff --git a/core/pim/today/today.h b/core/pim/today/today.h
index 89170e1..c947ae1 100644
--- a/core/pim/today/today.h
+++ b/core/pim/today/today.h
@@ -23,4 +23,5 @@
23#include <opie2/todayplugininterface.h> 23#include <opie2/todayplugininterface.h>
24#include <opie2/oclickablelabel.h> 24#include <opie2/oclickablelabel.h>
25#include <opie2/opluginloader.h>
25 26
26#include <qpe/qlibrary.h> 27#include <qpe/qlibrary.h>
@@ -29,15 +30,24 @@
29#include <qvbox.h> 30#include <qvbox.h>
30 31
31 32
32class QVBoxLayout; 33class QVBoxLayout;
33 34
35namespace Opie {
36 namespace Core {
37 class OPluginManager;
38 class OPluginLoader;
39 }
40}
41
34class Today : public TodayBase { 42class Today : public TodayBase {
35 43
36 Q_OBJECT 44 Q_OBJECT
37 45
38 public: 46public:
39 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 47 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
40 ~Today(); 48 ~Today();
41 static QString appName() { return QString::fromLatin1("today"); } 49 static QString appName() {
50 return QString::fromLatin1("today");
51 }
42 52
43private slots: 53private slots:
@@ -51,7 +61,5 @@ private:
51 void setOwnerField(); 61 void setOwnerField();
52 void setOwnerField(QString &string); 62 void setOwnerField(QString &string);
53 void loadPlugins(); 63 void initialize();
54 void draw();
55 void reinitialize();
56 64
57 void setRefreshTimer( int ); 65 void setRefreshTimer( int );
@@ -59,6 +67,7 @@ private:
59private slots: 67private slots:
60 void channelReceived(const QCString &msg, const QByteArray & data); 68 void channelReceived(const QCString &msg, const QByteArray & data);
69 void loadPlugins();
61 70
62 private: 71private:
63 TodayConfig *conf; 72 TodayConfig *conf;
64 QStringList m_excludeApplets; 73 QStringList m_excludeApplets;
@@ -69,5 +78,6 @@ private slots:
69 QVBoxLayout *m_bblayout; 78 QVBoxLayout *m_bblayout;
70 79
71 80 Opie::Core::OPluginLoader *m_pluginLoader;
81 Opie::Core::OPluginManager *m_manager;
72 82
73 QTimer *m_refreshTimer; 83 QTimer *m_refreshTimer;
@@ -79,4 +89,3 @@ private slots:
79 int m_hideBanner; 89 int m_hideBanner;
80}; 90};
81
82#endif 91#endif
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp
index 4f0877c..c9823d4 100644
--- a/core/pim/today/todayconfig.cpp
+++ b/core/pim/today/todayconfig.cpp
@@ -17,5 +17,8 @@
17#include "todayconfig.h" 17#include "todayconfig.h"
18 18
19#include <qpe/config.h> 19#include <opie2/oconfig.h>
20#include <opie2/opluginloader.h>
21#include <opie2/todayplugininterface.h>
22
20#include <qpe/resource.h> 23#include <qpe/resource.h>
21#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
@@ -32,9 +35,14 @@
32 35
33using namespace Opie::Ui; 36using namespace Opie::Ui;
37using Opie::Core::OConfig;
38using Opie::Core::OPluginManager;
39using Opie::Core::OPluginLoader;
40using Opie::Core::OPluginItem;
41
34class ToolButton : public QToolButton { 42class ToolButton : public QToolButton {
35 43
36public: 44public:
37 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 45 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
38 : QToolButton( parent, name ) { 46: QToolButton( parent, name ) {
39 setPixmap( Resource::loadPixmap( icon ) ); 47 setPixmap( Resource::loadPixmap( icon ) );
40 setAutoRaise( TRUE ); 48 setAutoRaise( TRUE );
@@ -52,5 +60,5 @@ public:
52 */ 60 */
53TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) 61TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
54 : QDialog( parent, name, modal, WStyle_ContextHelp ) { 62: QDialog( parent, name, modal, WStyle_ContextHelp ) {
55 63
56 setCaption( tr( "Today Config" ) ); 64 setCaption( tr( "Today Config" ) );
@@ -69,5 +77,6 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
69 m_appletListView->header()->hide(); 77 m_appletListView->header()->hide();
70 m_appletListView->setSorting( -1 ); 78 m_appletListView->setSorting( -1 );
71 QWhatsThis::add( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); 79 QWhatsThis::add
80 ( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) );
72 QVBox *vbox1 = new QVBox( hbox1 ); 81 QVBox *vbox1 = new QVBox( hbox1 );
73 new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); 82 new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) );
@@ -85,8 +94,6 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
85 TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) ); 94 TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) );
86 95
87 m_applets_changed = false;
88
89 connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) ); 96 connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) );
90 97 previousItem = 0l;
91 readConfig(); 98 readConfig();
92 QPEApplication::showDialog( this ); 99 QPEApplication::showDialog( this );
@@ -94,4 +101,32 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
94 101
95 102
103void TodayConfig::setUpPlugins( OPluginManager * plugManager, OPluginLoader *plugLoader ) {
104
105
106 m_pluginManager = plugManager;
107 m_pluginLoader = plugLoader;
108
109 OPluginItem::List inLst = m_pluginLoader->allAvailable( true );
110
111 OPluginItem::List lst;
112 for ( OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) {
113 lst.prepend((*it));
114
115 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
116
117 if ( iface->guiPart()->configWidget(this) != 0l ) {
118 TodayConfigWidget* widget = iface->guiPart()->configWidget( TabWidget3 );
119 TabWidget3->addTab( widget, iface->guiPart()->pixmapNameConfig()
120 , iface->guiPart()->appName() );
121 }
122 }
123
124 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
125 pluginManagement( (*it) );
126 }
127
128 TabWidget3->setCurrentTab( tab_2 );
129}
130
96/** 131/**
97 * Autostart, uses the new (opie only) autostart method in the launcher code. 132 * Autostart, uses the new (opie only) autostart method in the launcher code.
@@ -99,5 +134,5 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
99 */ 134 */
100void TodayConfig::setAutoStart() { 135void TodayConfig::setAutoStart() {
101 Config cfg( "today" ); 136 OConfig cfg( "today" );
102 cfg.setGroup( "Autostart" ); 137 cfg.setGroup( "Autostart" );
103 if ( m_autoStart ) { 138 if ( m_autoStart ) {
@@ -117,5 +152,5 @@ void TodayConfig::setAutoStart() {
117 */ 152 */
118void TodayConfig::readConfig() { 153void TodayConfig::readConfig() {
119 Config cfg( "today" ); 154 OConfig cfg( "today" );
120 cfg.setGroup( "Autostart" ); 155 cfg.setGroup( "Autostart" );
121 m_autoStart = cfg.readNumEntry( "autostart", 1 ); 156 m_autoStart = cfg.readNumEntry( "autostart", 1 );
@@ -129,8 +164,4 @@ void TodayConfig::readConfig() {
129 m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 ); 164 m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 );
130 m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); 165 m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) );
131
132
133 cfg.setGroup( "Plugins" );
134 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
135} 166}
136 167
@@ -139,35 +170,26 @@ void TodayConfig::readConfig() {
139 */ 170 */
140void TodayConfig::writeConfig() { 171void TodayConfig::writeConfig() {
141 Config cfg( "today" ); 172 OConfig cfg( "today" );
142 cfg.setGroup( "Plugins" ); 173
143 if ( m_applets_changed ) { 174 int position = m_appletListView->childCount();
144 QStringList exclude; 175
145 QStringList include; 176 QListViewItemIterator list_it( m_appletListView );
146 QStringList all_applets; 177 //
147 178 // this makes sure the names get saved in the order selected
148 QListViewItemIterator list_it( m_appletListView ); 179 for ( ; list_it.current(); ++list_it ) {
149 180 OPluginItem::List lst = m_pluginLoader->allAvailable( true );
150 // this makes sure the names get saved in the order selected 181 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
151 for ( ; list_it.current(); ++list_it ) { 182 if ( QString::compare( (*it).name() , list_it.current()->text(0) ) == 0 ) {
152 QMap <QString, QCheckListItem *>::Iterator it; 183 (*it).setPosition(position--);
153 for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { 184 m_pluginManager->setEnabled( (*it),((QCheckListItem*)list_it.current())->isOn() );
154 if ( list_it.current() == (*it) && !(*it)-> isOn () ) {
155 exclude << it.key();
156 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){
157 include << it.key();
158 }
159 if ( list_it.current() == (*it) ) {
160 all_applets << it.key();
161 }
162 } 185 }
163 } 186 }
164 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
165 cfg.writeEntry( "IncludeApplets", include, ',' );
166 cfg.writeEntry( "AllApplets", all_applets, ',' );
167 } 187 }
168 188
189 m_pluginManager->save();
190
169 cfg.setGroup( "Autostart" ); 191 cfg.setGroup( "Autostart" );
170 m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); 192 m_autoStart = m_guiMisc->CheckBoxAuto->isChecked();
171 cfg.writeEntry( "autostart", m_autoStart ); 193 cfg.writeEntry( "autostart", m_autoStart );
172 m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); 194 m_autoStartTimer = m_guiMisc->SpinBoxTime->value();
173 cfg.writeEntry( "autostartdelay", m_autoStartTimer ); 195 cfg.writeEntry( "autostartdelay", m_autoStartTimer );
@@ -181,4 +203,12 @@ void TodayConfig::writeConfig() {
181 // set autostart settings 203 // set autostart settings
182 setAutoStart(); 204 setAutoStart();
205
206 OPluginItem::List lst = m_pluginManager->managedPlugins();
207 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
208 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
209 if ( iface->guiPart()->configWidget(this) != 0l ) {
210 iface->guiPart()->configWidget(this)->writeConfig();
211 }
212 }
183} 213}
184 214
@@ -203,29 +233,18 @@ void TodayConfig::moveSelectedDown() {
203 * Set up the icons in the order/active tab 233 * Set up the icons in the order/active tab
204 */ 234 */
205void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { 235void TodayConfig::pluginManagement( OPluginItem plugItem ) {
206
207 QCheckListItem *item;
208 item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox );
209 236
210 if ( !icon.isNull() ) { 237 QCheckListItem *item = new QCheckListItem( m_appletListView, plugItem.name(), QCheckListItem::CheckBox );
211 item->setPixmap( 0, icon );
212 }
213
214 if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) {
215 item->setOn( TRUE );
216 }
217
218 m_applets[libName] = item;
219 238
220 // kind of hack to get the first tab as default. 239 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( plugItem, IID_TodayPluginInterface );
221 TabWidget3->setCurrentTab( tab_2 ); 240 QPixmap icon = Resource::loadPixmap( iface->guiPart()->pixmapNameWidget() );
222} 241 if ( !icon.isNull() ) {
223 242 item->setPixmap( 0, icon );
224void TodayConfig::appletChanged() { 243 }
225 m_applets_changed = true; 244 item->setOn( plugItem.isEnabled() );
245 previousItem = item;
226} 246}
227 247
228 248
229TodayConfig::~TodayConfig() {
230}
231 249
250TodayConfig::~TodayConfig() {}
diff --git a/core/pim/today/todayconfig.h b/core/pim/today/todayconfig.h
index 2b6c507..ab79f31 100644
--- a/core/pim/today/todayconfig.h
+++ b/core/pim/today/todayconfig.h
@@ -21,4 +21,5 @@
21 21
22#include <opie2/otabwidget.h> 22#include <opie2/otabwidget.h>
23#include <opie2/opluginloader.h>
23 24
24#include <qvariant.h> 25#include <qvariant.h>
@@ -31,4 +32,12 @@ class QSpinBox;
31class QTabWidget; 32class QTabWidget;
32 33
34namespace Opie {
35 namespace Core {
36 class OPluginManager;
37 class OPluginLoader;
38 class OPluginItem;
39 }
40}
41
33class TodayConfig : public QDialog { 42class TodayConfig : public QDialog {
34 43
@@ -42,9 +51,8 @@ public:
42 51
43 void writeConfig(); 52 void writeConfig();
44 void pluginManagement( QString libName, QString name, QPixmap icon );
45 53
54 void setUpPlugins( Opie::Core::OPluginManager * plugManager, Opie::Core::OPluginLoader * plugLoader );
46 55
47protected slots: 56protected slots:
48 void appletChanged();
49 void moveSelectedUp(); 57 void moveSelectedUp();
50 void moveSelectedDown(); 58 void moveSelectedDown();
@@ -53,4 +61,5 @@ private:
53 void setAutoStart(); 61 void setAutoStart();
54 void readConfig(); 62 void readConfig();
63 void pluginManagement( Opie::Core::OPluginItem plugItem);
55 64
56 QListView* m_appletListView; 65 QListView* m_appletListView;
@@ -68,4 +77,9 @@ private:
68 QSpinBox* SpinBox7; 77 QSpinBox* SpinBox7;
69 78
79 Opie::Core::OPluginManager *m_pluginManager;
80 Opie::Core::OPluginLoader *m_pluginLoader;
81
82 QCheckListItem *previousItem;
83
70 TodayConfigMiscBase *m_guiMisc; 84 TodayConfigMiscBase *m_guiMisc;
71}; 85};