author | harlekin <harlekin> | 2004-06-03 20:36:44 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-06-03 20:36:44 (UTC) |
commit | 52f849d3031f9d2fad2272ad069e7a1456c0ee54 (patch) (unidiff) | |
tree | 7d03d229363b81c40d180ee99d168e99c4f6c06e | |
parent | 74109985fd9ebdffd6cf0416207a69b17b563fd6 (diff) | |
download | opie-52f849d3031f9d2fad2272ad069e7a1456c0ee54.zip opie-52f849d3031f9d2fad2272ad069e7a1456c0ee54.tar.gz opie-52f849d3031f9d2fad2272ad069e7a1456c0ee54.tar.bz2 |
updated today to use the new opluginloader, migration not finished yet but mostly working
-rw-r--r-- | core/pim/today/today.cpp | 372 | ||||
-rw-r--r-- | core/pim/today/today.h | 27 | ||||
-rw-r--r-- | core/pim/today/todayconfig.cpp | 137 | ||||
-rw-r--r-- | core/pim/today/todayconfig.h | 18 |
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 | |||
@@ -5,111 +5,112 @@ | |||
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 | #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> |
26 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/contact.h> | 26 | #include <qpe/contact.h> |
28 | 27 | ||
29 | #include <qdir.h> | 28 | #include <qdir.h> |
30 | #include <qtimer.h> | 29 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
32 | 31 | ||
33 | using namespace Opie::Ui; | 32 | using namespace Opie::Ui; |
33 | using Opie::Core::OPluginItem; | ||
34 | using Opie::Core::OPluginLoader; | ||
35 | using Opie::Core::OPluginManager; | ||
36 | using Opie::Core::OConfig; | ||
37 | |||
38 | |||
34 | struct TodayPlugin { | 39 | struct TodayPlugin { |
35 | TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} | 40 | TodayPlugin() : 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 | ||
46 | static QValueList<TodayPlugin> pluginList; | 49 | static QMap<QString, TodayPlugin> pluginList; |
47 | |||
48 | static QMap<QString, TodayPlugin> tempList; | ||
49 | 50 | ||
50 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 51 | Today::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 ); |
73 | layout->addWidget( OwnerField ); | 71 | layout->addWidget( OwnerField ); |
74 | 72 | ||
75 | m_sv = new QScrollView( this ); | 73 | m_sv = new QScrollView( this ); |
76 | m_sv->setResizePolicy( QScrollView::AutoOneFit ); | 74 | m_sv->setResizePolicy( QScrollView::AutoOneFit ); |
77 | m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 75 | m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
78 | m_sv->setFrameShape( QFrame::NoFrame ); | 76 | m_sv->setFrameShape( QFrame::NoFrame ); |
79 | 77 | ||
80 | layout->addWidget( m_sv ); | 78 | layout->addWidget( m_sv ); |
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 | } |
87 | 89 | ||
88 | /** | 90 | /** |
89 | * Qcop receive method. | 91 | * Qcop receive method. |
90 | */ | 92 | */ |
91 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { | 93 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { |
92 | QDataStream stream( data, IO_ReadOnly ); | 94 | QDataStream stream( data, IO_ReadOnly ); |
93 | if ( msg == "message(QString)" ) { | 95 | if ( msg == "message(QString)" ) { |
94 | QString message; | 96 | QString message; |
95 | stream >> message; | 97 | stream >> message; |
96 | setOwnerField( message ); | 98 | setOwnerField( message ); |
97 | } | 99 | } |
98 | } | 100 | } |
99 | 101 | ||
100 | void Today::setRefreshTimer( int interval ) { | 102 | 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 ) { |
106 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 107 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
107 | m_refreshTimer->changeInterval( interval ); | 108 | m_refreshTimer->changeInterval( interval ); |
108 | } | 109 | } |
109 | } | 110 | } |
110 | 111 | ||
111 | 112 | ||
112 | /** | 113 | /** |
113 | * Initialises the owner field with the default value, the username | 114 | * Initialises the owner field with the default value, the username |
114 | */ | 115 | */ |
115 | void Today::setOwnerField() { | 116 | void Today::setOwnerField() { |
@@ -123,34 +124,34 @@ void Today::setOwnerField() { | |||
123 | } | 124 | } |
124 | } | 125 | } |
125 | 126 | ||
126 | /** | 127 | /** |
127 | * Set the owner field with a given QString, for example per qcop. | 128 | * Set the owner field with a given QString, for example per qcop. |
128 | */ | 129 | */ |
129 | void Today::setOwnerField( QString &message ) { | 130 | void Today::setOwnerField( QString &message ) { |
130 | if ( !message.isEmpty() ) { | 131 | if ( !message.isEmpty() ) { |
131 | OwnerField->setText( "<b>" + message + "</b>" ); | 132 | OwnerField->setText( "<b>" + message + "</b>" ); |
132 | } | 133 | } |
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. |
137 | */ | 139 | */ |
138 | void Today::init() { | 140 | void 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" ); |
147 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 148 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
148 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); | 149 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); |
149 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); | 150 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); |
150 | 151 | ||
151 | // set the date in top label | 152 | // set the date in top label |
152 | QDate date = QDate::currentDate(); | 153 | QDate date = QDate::currentDate(); |
153 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); | 154 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); |
154 | 155 | ||
155 | if ( m_hideBanner ) { | 156 | if ( m_hideBanner ) { |
156 | Opiezilla->hide(); | 157 | Opiezilla->hide(); |
@@ -160,319 +161,194 @@ void Today::init() { | |||
160 | TodayLabel->show(); | 161 | TodayLabel->show(); |
161 | } | 162 | } |
162 | 163 | ||
163 | if ( m_big_box ) { | 164 | if ( m_big_box ) { |
164 | delete m_big_box; | 165 | delete m_big_box; |
165 | } | 166 | } |
166 | 167 | ||
167 | m_big_box = new QWidget( m_sv->viewport() ); | 168 | m_big_box = new QWidget( m_sv->viewport() ); |
168 | m_sv->addChild( m_big_box ); | 169 | m_sv->addChild( m_big_box ); |
169 | m_bblayout = new QVBoxLayout ( m_big_box ); | 170 | m_bblayout = new QVBoxLayout ( m_big_box ); |
170 | } | 171 | } |
171 | 172 | ||
173 | |||
172 | /** | 174 | /** |
173 | * Load the plugins | 175 | * Load the plugins |
174 | */ | 176 | */ |
175 | void Today::loadPlugins() { | 177 | void 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 | */ | ||
305 | void 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 | ||
337 | 223 | ||
338 | /** | 224 | /** |
339 | * The method for the configuration dialog. | 225 | * The method for the configuration dialog. |
340 | */ | 226 | */ |
341 | void Today::startConfig() { | 227 | void Today::startConfig() { |
342 | 228 | ||
343 | // disconnect timer to prevent problems while being on config dialog | 229 | // disconnect timer to prevent problems while being on config dialog |
344 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 230 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
345 | m_refreshTimer->stop( ); | 231 | m_refreshTimer->stop( ); |
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() ) ); |
383 | } | 243 | } |
384 | } | 244 | } |
385 | 245 | ||
386 | 246 | ||
387 | 247 | void Today::initialize() { | |
388 | void 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" ); |
413 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 254 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
414 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); | 255 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); |
415 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); | 256 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); |
416 | 257 | ||
417 | // set the date in top label | 258 | // set the date in top label |
418 | QDate date = QDate::currentDate(); | 259 | QDate date = QDate::currentDate(); |
419 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); | 260 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); |
420 | 261 | ||
421 | if ( m_hideBanner ) { | 262 | if ( m_hideBanner ) { |
422 | Opiezilla->hide(); | 263 | Opiezilla->hide(); |
423 | TodayLabel->hide(); | 264 | TodayLabel->hide(); |
424 | } else { | 265 | } else { |
425 | Opiezilla->show(); | 266 | Opiezilla->show(); |
426 | TodayLabel->show(); | 267 | TodayLabel->show(); |
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 | ||
444 | /** | 311 | /** |
445 | * Refresh for the view. Reload all applets | 312 | * Refresh for the view. Reload all applets |
446 | * | 313 | * |
447 | */ | 314 | */ |
448 | void Today::refresh() { | 315 | void 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 | ||
458 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) ); | 325 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) ); |
459 | 326 | ||
460 | updateGeometry(); | 327 | updateGeometry(); |
461 | repaint(); | 328 | repaint(); |
462 | } | 329 | } |
463 | 330 | ||
331 | |||
464 | void Today::startApplication() { | 332 | void Today::startApplication() { |
465 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 333 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
466 | e << QString( sender()->name() ); | 334 | e << QString( sender()->name() ); |
467 | } | 335 | } |
468 | 336 | ||
337 | |||
469 | /** | 338 | /** |
470 | * launch addressbook (personal card) | 339 | * launch addressbook (personal card) |
471 | */ | 340 | */ |
472 | void Today::editCard() { | 341 | void Today::editCard() { |
473 | QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); | 342 | QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); |
474 | } | 343 | } |
475 | 344 | ||
345 | |||
476 | Today::~Today() { | 346 | Today::~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 | |||
@@ -13,70 +13,79 @@ | |||
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | #ifndef TODAY_H | 16 | #ifndef TODAY_H |
17 | #define TODAY_H | 17 | #define TODAY_H |
18 | 18 | ||
19 | 19 | ||
20 | #include "todayconfig.h" | 20 | #include "todayconfig.h" |
21 | #include "todaybase.h" | 21 | #include "todaybase.h" |
22 | 22 | ||
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> |
27 | 28 | ||
28 | #include <qscrollview.h> | 29 | #include <qscrollview.h> |
29 | #include <qvbox.h> | 30 | #include <qvbox.h> |
30 | 31 | ||
31 | 32 | ||
32 | class QVBoxLayout; | 33 | class QVBoxLayout; |
33 | 34 | ||
35 | namespace Opie { | ||
36 | namespace Core { | ||
37 | class OPluginManager; | ||
38 | class OPluginLoader; | ||
39 | } | ||
40 | } | ||
41 | |||
34 | class Today : public TodayBase { | 42 | class Today : public TodayBase { |
35 | 43 | ||
36 | Q_OBJECT | 44 | Q_OBJECT |
37 | 45 | ||
38 | public: | 46 | public: |
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 | ||
43 | private slots: | 53 | private slots: |
44 | void startConfig(); | 54 | void startConfig(); |
45 | void startApplication(); | 55 | void startApplication(); |
46 | void editCard(); | 56 | void editCard(); |
47 | void refresh(); | 57 | void refresh(); |
48 | 58 | ||
49 | private: | 59 | private: |
50 | void init(); | 60 | void init(); |
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 ); |
58 | 66 | ||
59 | private slots: | 67 | private 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: | 71 | private: |
63 | TodayConfig *conf; | 72 | TodayConfig *conf; |
64 | QStringList m_excludeApplets; | 73 | QStringList m_excludeApplets; |
65 | QStringList m_allApplets; | 74 | QStringList m_allApplets; |
66 | 75 | ||
67 | QScrollView *m_sv; | 76 | QScrollView *m_sv; |
68 | QWidget* m_big_box; | 77 | QWidget* m_big_box; |
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; |
74 | 84 | ||
75 | bool m_refreshTimerEnabled; | 85 | bool m_refreshTimerEnabled; |
76 | int m_newStart; | 86 | int m_newStart; |
77 | int m_iconSize; | 87 | int m_iconSize; |
78 | int m_maxCharClip; | 88 | int m_maxCharClip; |
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 | |||
@@ -7,225 +7,244 @@ | |||
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 "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> |
22 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
23 | 26 | ||
24 | #include <qcheckbox.h> | 27 | #include <qcheckbox.h> |
25 | #include <qlabel.h> | 28 | #include <qlabel.h> |
26 | #include <qspinbox.h> | 29 | #include <qspinbox.h> |
27 | #include <qlayout.h> | 30 | #include <qlayout.h> |
28 | #include <qheader.h> | 31 | #include <qheader.h> |
29 | #include <qvbox.h> | 32 | #include <qvbox.h> |
30 | #include <qtoolbutton.h> | 33 | #include <qtoolbutton.h> |
31 | #include <qwhatsthis.h> | 34 | #include <qwhatsthis.h> |
32 | 35 | ||
33 | using namespace Opie::Ui; | 36 | using namespace Opie::Ui; |
37 | using Opie::Core::OConfig; | ||
38 | using Opie::Core::OPluginManager; | ||
39 | using Opie::Core::OPluginLoader; | ||
40 | using Opie::Core::OPluginItem; | ||
41 | |||
34 | class ToolButton : public QToolButton { | 42 | class ToolButton : public QToolButton { |
35 | 43 | ||
36 | public: | 44 | public: |
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 ); |
41 | setFocusPolicy( QWidget::NoFocus ); | 49 | setFocusPolicy( QWidget::NoFocus ); |
42 | setToggleButton( t ); | 50 | setToggleButton( t ); |
43 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 51 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
44 | } | 52 | } |
45 | }; | 53 | }; |
46 | 54 | ||
47 | 55 | ||
48 | /** | 56 | /** |
49 | * The class has currently quite some duplicate code. | 57 | * The class has currently quite some duplicate code. |
50 | * By that way it would be real easy to have it as seperate app in settings tab | 58 | * By that way it would be real easy to have it as seperate app in settings tab |
51 | * | 59 | * |
52 | */ | 60 | */ |
53 | TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) | 61 | TodayConfig::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" ) ); |
57 | 65 | ||
58 | QVBoxLayout *layout = new QVBoxLayout( this ); | 66 | QVBoxLayout *layout = new QVBoxLayout( this ); |
59 | TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 67 | TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
60 | layout->addWidget( TabWidget3 ); | 68 | layout->addWidget( TabWidget3 ); |
61 | 69 | ||
62 | tab_2 = new QWidget( TabWidget3, "tab_2" ); | 70 | tab_2 = new QWidget( TabWidget3, "tab_2" ); |
63 | QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); | 71 | QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); |
64 | QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); | 72 | QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); |
65 | tab2Layout->addWidget( l ); | 73 | tab2Layout->addWidget( l ); |
66 | QHBox *hbox1 = new QHBox( tab_2 ); | 74 | QHBox *hbox1 = new QHBox( tab_2 ); |
67 | m_appletListView = new QListView( hbox1 ); | 75 | m_appletListView = new QListView( hbox1 ); |
68 | m_appletListView->addColumn( "PluginList" ); | 76 | m_appletListView->addColumn( "PluginList" ); |
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() ) ); |
74 | new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); | 83 | new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); |
75 | tab2Layout->addWidget( hbox1 ); | 84 | tab2Layout->addWidget( hbox1 ); |
76 | TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) ); | 85 | TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) ); |
77 | 86 | ||
78 | // Misc tab | 87 | // Misc tab |
79 | tab_3 = new QWidget( TabWidget3, "tab_3" ); | 88 | tab_3 = new QWidget( TabWidget3, "tab_3" ); |
80 | QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); | 89 | QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); |
81 | 90 | ||
82 | m_guiMisc = new TodayConfigMiscBase( tab_3 ); | 91 | m_guiMisc = new TodayConfigMiscBase( tab_3 ); |
83 | 92 | ||
84 | tab3Layout->addWidget( m_guiMisc ); | 93 | tab3Layout->addWidget( m_guiMisc ); |
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 ); |
93 | } | 100 | } |
94 | 101 | ||
95 | 102 | ||
103 | void 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. |
98 | * If registered against that today ist started on each resume. | 133 | * If registered against that today ist started on each resume. |
99 | */ | 134 | */ |
100 | void TodayConfig::setAutoStart() { | 135 | void 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 ) { |
104 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); | 139 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); |
105 | e << QString( "add" ); | 140 | e << QString( "add" ); |
106 | e << QString( "today" ); | 141 | e << QString( "today" ); |
107 | e << QString( "%1" ).arg( m_autoStartTimer ); | 142 | e << QString( "%1" ).arg( m_autoStartTimer ); |
108 | } else { | 143 | } else { |
109 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); | 144 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); |
110 | e << QString( "remove" ); | 145 | e << QString( "remove" ); |
111 | e << QString( "today" ); | 146 | e << QString( "today" ); |
112 | } | 147 | } |
113 | } | 148 | } |
114 | 149 | ||
115 | /** | 150 | /** |
116 | * Read the config part | 151 | * Read the config part |
117 | */ | 152 | */ |
118 | void TodayConfig::readConfig() { | 153 | void 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 ); |
122 | m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); | 157 | m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); |
123 | m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 ); | 158 | m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 ); |
124 | m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer ); | 159 | m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer ); |
125 | 160 | ||
126 | cfg.setGroup( "General" ); | 161 | cfg.setGroup( "General" ); |
127 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 162 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
128 | m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); | 163 | m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); |
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 | ||
137 | /** | 168 | /** |
138 | * Write the config part | 169 | * Write the config part |
139 | */ | 170 | */ |
140 | void TodayConfig::writeConfig() { | 171 | void 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 ); |
174 | m_iconSize = m_guiMisc->SpinBoxIconSize->value(); | 196 | m_iconSize = m_guiMisc->SpinBoxIconSize->value(); |
175 | 197 | ||
176 | cfg.setGroup( "General" ); | 198 | cfg.setGroup( "General" ); |
177 | cfg.writeEntry( "IconSize", m_iconSize ); | 199 | cfg.writeEntry( "IconSize", m_iconSize ); |
178 | cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() ); | 200 | cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() ); |
179 | cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 ); | 201 | cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 ); |
180 | 202 | ||
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 | ||
185 | 215 | ||
186 | void TodayConfig::moveSelectedUp() { | 216 | void TodayConfig::moveSelectedUp() { |
187 | QListViewItem *item = m_appletListView->selectedItem(); | 217 | QListViewItem *item = m_appletListView->selectedItem(); |
188 | if ( item && item->itemAbove() ) { | 218 | if ( item && item->itemAbove() ) { |
189 | item->itemAbove()->moveItem( item ); | 219 | item->itemAbove()->moveItem( item ); |
190 | } | 220 | } |
191 | } | 221 | } |
192 | 222 | ||
193 | 223 | ||
194 | void TodayConfig::moveSelectedDown() { | 224 | void TodayConfig::moveSelectedDown() { |
195 | QListViewItem *item = m_appletListView->selectedItem(); | 225 | QListViewItem *item = m_appletListView->selectedItem(); |
196 | if ( item && item->itemBelow() ) { | 226 | if ( item && item->itemBelow() ) { |
197 | item->moveItem( item->itemBelow() ); | 227 | item->moveItem( item->itemBelow() ); |
198 | } | 228 | } |
199 | } | 229 | } |
200 | 230 | ||
201 | 231 | ||
202 | /** | 232 | /** |
203 | * Set up the icons in the order/active tab | 233 | * Set up the icons in the order/active tab |
204 | */ | 234 | */ |
205 | void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { | 235 | void 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 ); | |
224 | void TodayConfig::appletChanged() { | 243 | } |
225 | m_applets_changed = true; | 244 | item->setOn( plugItem.isEnabled() ); |
245 | previousItem = item; | ||
226 | } | 246 | } |
227 | 247 | ||
228 | 248 | ||
229 | TodayConfig::~TodayConfig() { | ||
230 | } | ||
231 | 249 | ||
250 | TodayConfig::~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 | |||
@@ -11,63 +11,77 @@ | |||
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 | #ifndef TODAYCONFIG_H | 17 | #ifndef TODAYCONFIG_H |
18 | #define TODAYCONFIG_H | 18 | #define TODAYCONFIG_H |
19 | 19 | ||
20 | #include "todayconfigmiscbase.h" | 20 | #include "todayconfigmiscbase.h" |
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> |
25 | #include <qdialog.h> | 26 | #include <qdialog.h> |
26 | #include <qlistview.h> | 27 | #include <qlistview.h> |
27 | 28 | ||
28 | class QCheckBox; | 29 | class QCheckBox; |
29 | class QLabel; | 30 | class QLabel; |
30 | class QSpinBox; | 31 | class QSpinBox; |
31 | class QTabWidget; | 32 | class QTabWidget; |
32 | 33 | ||
34 | namespace Opie { | ||
35 | namespace Core { | ||
36 | class OPluginManager; | ||
37 | class OPluginLoader; | ||
38 | class OPluginItem; | ||
39 | } | ||
40 | } | ||
41 | |||
33 | class TodayConfig : public QDialog { | 42 | class TodayConfig : public QDialog { |
34 | 43 | ||
35 | Q_OBJECT | 44 | Q_OBJECT |
36 | 45 | ||
37 | public: | 46 | public: |
38 | TodayConfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE ); | 47 | TodayConfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE ); |
39 | ~TodayConfig(); | 48 | ~TodayConfig(); |
40 | 49 | ||
41 | Opie::Ui::OTabWidget* TabWidget3; | 50 | Opie::Ui::OTabWidget* TabWidget3; |
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 | ||
47 | protected slots: | 56 | protected slots: |
48 | void appletChanged(); | ||
49 | void moveSelectedUp(); | 57 | void moveSelectedUp(); |
50 | void moveSelectedDown(); | 58 | void moveSelectedDown(); |
51 | 59 | ||
52 | private: | 60 | 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; |
57 | QMap<QString,QCheckListItem*> m_applets; | 66 | QMap<QString,QCheckListItem*> m_applets; |
58 | 67 | ||
59 | int m_autoStart; | 68 | int m_autoStart; |
60 | int m_autoStartTimer; | 69 | int m_autoStartTimer; |
61 | int m_iconSize; | 70 | int m_iconSize; |
62 | QStringList m_excludeApplets; | 71 | QStringList m_excludeApplets; |
63 | bool m_applets_changed; | 72 | bool m_applets_changed; |
64 | 73 | ||
65 | QWidget* tab_2; | 74 | QWidget* tab_2; |
66 | QWidget* tab_3; | 75 | QWidget* tab_3; |
67 | QLabel* TextLabel1, *TextLabel4; | 76 | QLabel* TextLabel1, *TextLabel4; |
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 | }; |
72 | 86 | ||
73 | #endif | 87 | #endif |