-rw-r--r-- | core/pim/today/today.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 066a5a8..2095174 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -121,197 +121,197 @@ void Today::init() { | |||
121 | // read config | 121 | // read config |
122 | Config cfg( "today" ); | 122 | Config cfg( "today" ); |
123 | 123 | ||
124 | cfg.setGroup( "Applets" ); | 124 | cfg.setGroup( "Applets" ); |
125 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | 125 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | /** | 129 | /** |
130 | * Load the plugins | 130 | * Load the plugins |
131 | */ | 131 | */ |
132 | void Today::loadPlugins() { | 132 | void Today::loadPlugins() { |
133 | 133 | ||
134 | QValueList<TodayPlugin>::Iterator tit; | 134 | QValueList<TodayPlugin>::Iterator tit; |
135 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { | 135 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { |
136 | (*tit).library->unload(); | 136 | (*tit).library->unload(); |
137 | delete (*tit).library; | 137 | delete (*tit).library; |
138 | } | 138 | } |
139 | pluginList.clear(); | 139 | pluginList.clear(); |
140 | 140 | ||
141 | QString path = QPEApplication::qpeDir() + "/plugins/today"; | 141 | QString path = QPEApplication::qpeDir() + "/plugins/today"; |
142 | QDir dir( path, "lib*.so" ); | 142 | QDir dir( path, "lib*.so" ); |
143 | 143 | ||
144 | QStringList list = dir.entryList(); | 144 | QStringList list = dir.entryList(); |
145 | QStringList::Iterator it; | 145 | QStringList::Iterator it; |
146 | 146 | ||
147 | uint count = 0; | 147 | uint count = 0; |
148 | for ( it = list.begin(); it != list.end(); ++it ) { | 148 | for ( it = list.begin(); it != list.end(); ++it ) { |
149 | TodayPluginInterface *iface = 0; | 149 | TodayPluginInterface *iface = 0; |
150 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 150 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
151 | 151 | ||
152 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); | 152 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); |
153 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | 153 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { |
154 | qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); | 154 | qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); |
155 | qDebug( QString(*it) ); | 155 | qDebug( QString(*it) ); |
156 | TodayPlugin plugin; | 156 | TodayPlugin plugin; |
157 | plugin.library = lib; | 157 | plugin.library = lib; |
158 | plugin.iface = iface; | 158 | plugin.iface = iface; |
159 | plugin.name = QString(*it); | 159 | plugin.name = QString(*it); |
160 | 160 | ||
161 | if ( m_excludeApplets.grep( *it ).isEmpty() ) { | 161 | if ( m_excludeApplets.grep( *it ).isEmpty() ) { |
162 | plugin.active = true; | 162 | plugin.active = true; |
163 | } else { | 163 | } else { |
164 | plugin.active = false; | 164 | plugin.active = false; |
165 | } | 165 | } |
166 | plugin.guiPart = plugin.iface->guiPart(); | 166 | plugin.guiPart = plugin.iface->guiPart(); |
167 | 167 | ||
168 | plugin.guiBox = new QHBox( this ); | 168 | plugin.guiBox = new QHBox( this ); |
169 | QPixmap plugPix; | 169 | QPixmap plugPix; |
170 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( 18, 18 ), 0 ); | 170 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( 18, 18 ), 0 ); |
171 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); | 171 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); |
172 | plugIcon->setPixmap( plugPix ); | 172 | plugIcon->setPixmap( plugPix ); |
173 | QScrollView* sv = new QScrollView( plugin.guiBox ); | 173 | QScrollView* sv = new QScrollView( plugin.guiBox ); |
174 | QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); | 174 | QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); |
175 | sv->setMinimumHeight( plugin.guiPart->minHeight() ); | 175 | sv->setMinimumHeight( plugin.guiPart->minHeight() ); |
176 | //sv->setMaximumHeight( plugin.guiPart->maxHeight() ); | 176 | //sv->setMaximumHeight( plugin.guiPart->maxHeight() ); |
177 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 177 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
178 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 178 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
179 | sv->setFrameShape( QFrame::NoFrame ); | 179 | sv->setFrameShape( QFrame::NoFrame ); |
180 | sv->addChild( plugWidget ); | 180 | sv->addChild( plugWidget ); |
181 | 181 | ||
182 | //plugin.guiBox->addWidget( plugIcon, 0, AlignTop ); | 182 | //plugin.guiBox->addWidget( plugIcon, 0, AlignTop ); |
183 | //plugin.guiBox->addWidget( sv, 0, AlignTop ); | 183 | //plugin.guiBox->addWidget( sv, 0, AlignTop ); |
184 | plugin.guiBox->setStretchFactor( plugIcon, 1 ); | 184 | plugin.guiBox->setStretchFactor( plugIcon, 1 ); |
185 | plugin.guiBox->setStretchFactor( sv, 9 ); | 185 | plugin.guiBox->setStretchFactor( sv, 9 ); |
186 | layout->addWidget( plugin.guiBox ); | 186 | layout->addWidget( plugin.guiBox ); |
187 | 187 | ||
188 | pluginList.append( plugin ); | 188 | pluginList.append( plugin ); |
189 | count++; | 189 | count++; |
190 | } else { | 190 | } else { |
191 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); | 191 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); |
192 | delete lib; | 192 | delete lib; |
193 | } | 193 | } |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | /** | 198 | /** |
199 | * Repaint method. Reread all fields. | 199 | * Repaint method. Reread all fields. |
200 | */ | 200 | */ |
201 | void Today::draw() { | 201 | void Today::draw() { |
202 | 202 | ||
203 | if ( pluginList.count() == 0 ) { | 203 | if ( pluginList.count() == 0 ) { |
204 | QLabel *noPlugins = new QLabel( this ); | 204 | QLabel *noPlugins = new QLabel( this ); |
205 | noPlugins->setText( tr( "No plugins found" ) ); | 205 | noPlugins->setText( tr( "No plugins found" ) ); |
206 | layout->addWidget( noPlugins ); | 206 | layout->addWidget( noPlugins ); |
207 | return; | 207 | return; |
208 | } | 208 | } |
209 | 209 | ||
210 | uint count = 0; | 210 | uint count = 0; |
211 | TodayPlugin plugin; | 211 | TodayPlugin plugin; |
212 | for ( uint i = 0; i < pluginList.count(); i++ ) { | 212 | for ( uint i = 0; i < pluginList.count(); i++ ) { |
213 | plugin = pluginList[i]; | 213 | plugin = pluginList[i]; |
214 | 214 | ||
215 | if ( plugin.active ) { | 215 | if ( plugin.active ) { |
216 | qDebug( plugin.name + " is ACTIVE " ); | 216 | qDebug( plugin.name + " is ACTIVE " ); |
217 | // QHBoxLayout* plugLayout = new QHBoxLayout( this ); | ||
218 | plugin.guiBox->show(); | 217 | plugin.guiBox->show(); |
219 | } else { | 218 | } else { |
220 | // plugin.guiWidget->hide(); | ||
221 | qDebug( plugin.name + " is INACTIVE" ); | 219 | qDebug( plugin.name + " is INACTIVE" ); |
222 | plugin.guiBox->hide(); | 220 | plugin.guiBox->hide(); |
223 | } | 221 | } |
224 | count++; | 222 | count++; |
225 | } | 223 | } |
226 | 224 | ||
227 | if ( count == 0 ) { | 225 | if ( count == 0 ) { |
228 | QLabel *noPluginsActive = new QLabel( this ); | 226 | QLabel *noPluginsActive = new QLabel( this ); |
229 | noPluginsActive->setText( tr( "No plugins activated" ) ); | 227 | noPluginsActive->setText( tr( "No plugins activated" ) ); |
230 | layout->addWidget( noPluginsActive ); | 228 | layout->addWidget( noPluginsActive ); |
231 | } | 229 | } |
232 | 230 | ||
233 | layout->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 231 | layout->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
234 | } | 232 | } |
235 | 233 | ||
236 | 234 | ||
237 | /** | 235 | /** |
238 | * The method for the configuration dialog. | 236 | * The method for the configuration dialog. |
239 | */ | 237 | */ |
240 | void Today::startConfig() { | 238 | void Today::startConfig() { |
241 | 239 | ||
242 | TodayConfig conf( this, "dialog", true ); | 240 | TodayConfig conf( this, "dialog", true ); |
243 | 241 | ||
244 | TodayPlugin plugin; | 242 | TodayPlugin plugin; |
245 | 243 | ||
246 | QList<ConfigWidget> configWidgetList; | 244 | QList<ConfigWidget> configWidgetList; |
247 | for ( uint i = 0; i < pluginList.count(); i++ ) { | 245 | for ( uint i = 0; i < pluginList.count(); i++ ) { |
248 | plugin = pluginList[i]; | 246 | plugin = pluginList[i]; |
249 | 247 | ||
250 | // load the config widgets in the tabs | 248 | // load the config widgets in the tabs |
251 | if ( plugin.guiPart->configWidget( this ) != 0l ) { | 249 | if ( plugin.guiPart->configWidget( this ) != 0l ) { |
252 | ConfigWidget* widget = plugin.guiPart->configWidget( this ); | 250 | ConfigWidget* widget = plugin.guiPart->configWidget( this ); |
253 | configWidgetList.append( widget ); | 251 | configWidgetList.append( widget ); |
254 | conf.TabWidget3->insertTab( widget, plugin.guiPart->appName() ); | 252 | conf.TabWidget3->insertTab( widget, plugin.guiPart->appName() ); |
255 | } | 253 | } |
256 | // set the order/activate tab | 254 | // set the order/activate tab |
257 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), | 255 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), |
258 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); | 256 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); |
259 | } | 257 | } |
260 | 258 | ||
261 | if ( conf.exec() == QDialog::Accepted ) { | 259 | if ( conf.exec() == QDialog::Accepted ) { |
262 | conf.writeConfig(); | 260 | conf.writeConfig(); |
263 | ConfigWidget *confWidget; | 261 | ConfigWidget *confWidget; |
264 | for ( confWidget = configWidgetList.first(); confWidget != 0; | 262 | for ( confWidget = configWidgetList.first(); confWidget != 0; |
265 | confWidget = configWidgetList.next() ) { | 263 | confWidget = configWidgetList.next() ) { |
266 | confWidget->writeConfig(); | 264 | confWidget->writeConfig(); |
267 | } | 265 | } |
268 | 266 | ||
269 | init(); | 267 | init(); |
270 | 268 | ||
271 | TodayPlugin plugin; | 269 | TodayPlugin plugin; |
270 | QValueList<TodayPlugin> plugList; | ||
272 | for ( uint i = 0; i < pluginList.count(); i++ ) { | 271 | for ( uint i = 0; i < pluginList.count(); i++ ) { |
273 | plugin = pluginList[i]; | 272 | plugin = pluginList[i]; |
274 | 273 | ||
275 | if ( m_excludeApplets.grep( plugin.name ).isEmpty() ) { | 274 | if ( m_excludeApplets.grep( plugin.name ).isEmpty() ) { |
276 | qDebug("CONFIG " + plugin.name + " ACTIVE"); | 275 | qDebug("CONFIG " + plugin.name + " ACTIVE"); |
277 | plugin.active = true; | 276 | plugin.active = true; |
278 | } else { | 277 | } else { |
279 | qDebug("CONFIG " + plugin.name + " INACTIVE"); | 278 | qDebug("CONFIG " + plugin.name + " INACTIVE"); |
280 | |||
281 | plugin.active = false; | 279 | plugin.active = false; |
282 | } | 280 | } |
281 | plugList.append( plugin ); | ||
283 | } | 282 | } |
283 | pluginList = plugList; | ||
284 | 284 | ||
285 | draw(); | 285 | draw(); |
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | void Today::startAddressbook() { | 290 | void Today::startAddressbook() { |
291 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 291 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
292 | e << QString( "addressbook" ); | 292 | e << QString( "addressbook" ); |
293 | } | 293 | } |
294 | 294 | ||
295 | 295 | ||
296 | /** | 296 | /** |
297 | * launch addressbook (personal card) | 297 | * launch addressbook (personal card) |
298 | */ | 298 | */ |
299 | void Today::editCard() { | 299 | void Today::editCard() { |
300 | startAddressbook(); | 300 | startAddressbook(); |
301 | while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) { | 301 | while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) { |
302 | qApp->processEvents(); | 302 | qApp->processEvents(); |
303 | } | 303 | } |
304 | QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" ); | 304 | QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" ); |
305 | } | 305 | } |
306 | 306 | ||
307 | /* | 307 | /* |
308 | * launches an App | 308 | * launches an App |
309 | */ | 309 | */ |
310 | void Today::launchApp( QString appName ) { | 310 | void Today::launchApp( QString appName ) { |
311 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 311 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
312 | e << QString( appName ); | 312 | e << QString( appName ); |
313 | } | 313 | } |
314 | 314 | ||
315 | Today::~Today() { | 315 | Today::~Today() { |
316 | } | 316 | } |
317 | 317 | ||