-rw-r--r-- | core/pim/today/today.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 35758d5..34ec3cb 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -93,100 +93,103 @@ void Today::setOwnerField() { | |||
93 | OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); | 93 | OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Set the owner field with a given QString, for example per qcop. | 98 | * Set the owner field with a given QString, for example per qcop. |
99 | */ | 99 | */ |
100 | void Today::setOwnerField( QString &message ) { | 100 | void Today::setOwnerField( QString &message ) { |
101 | if ( !message.isEmpty() ) { | 101 | if ( !message.isEmpty() ) { |
102 | OwnerField->setText( "<b>" + message + "</b>" ); | 102 | OwnerField->setText( "<b>" + message + "</b>" ); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | /** | 107 | /** |
108 | * Init stuff needed for today. Reads the config file. | 108 | * Init stuff needed for today. Reads the config file. |
109 | */ | 109 | */ |
110 | void Today::init() { | 110 | void Today::init() { |
111 | // read config | 111 | // read config |
112 | Config cfg( "today" ); | 112 | Config cfg( "today" ); |
113 | cfg.setGroup( "Plugins" ); | 113 | cfg.setGroup( "Plugins" ); |
114 | 114 | ||
115 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | 115 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
116 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); | 116 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); |
117 | cfg.setGroup( "General" ); | ||
118 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | ||
117 | } | 119 | } |
118 | 120 | ||
119 | 121 | ||
120 | /** | 122 | /** |
121 | * Load the plugins | 123 | * Load the plugins |
122 | */ | 124 | */ |
123 | void Today::loadPlugins() { | 125 | void Today::loadPlugins() { |
124 | 126 | ||
125 | QValueList<TodayPlugin>::Iterator tit; | 127 | QValueList<TodayPlugin>::Iterator tit; |
126 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { | 128 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { |
127 | (*tit).library->unload(); | 129 | (*tit).library->unload(); |
128 | delete (*tit).library; | 130 | delete (*tit).library; |
129 | } | 131 | } |
130 | pluginList.clear(); | 132 | pluginList.clear(); |
131 | 133 | ||
132 | QString path = QPEApplication::qpeDir() + "/plugins/today"; | 134 | QString path = QPEApplication::qpeDir() + "/plugins/today"; |
133 | QDir dir( path, "lib*.so" ); | 135 | QDir dir( path, "lib*.so" ); |
134 | 136 | ||
135 | QStringList list = dir.entryList(); | 137 | QStringList list = dir.entryList(); |
136 | QStringList::Iterator it; | 138 | QStringList::Iterator it; |
137 | 139 | ||
138 | |||
139 | QMap<QString, TodayPlugin> tempList; | 140 | QMap<QString, TodayPlugin> tempList; |
140 | 141 | ||
141 | for ( it = list.begin(); it != list.end(); ++it ) { | 142 | for ( it = list.begin(); it != list.end(); ++it ) { |
142 | TodayPluginInterface *iface = 0; | 143 | TodayPluginInterface *iface = 0; |
143 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 144 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
144 | 145 | ||
145 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); | 146 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); |
146 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | 147 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { |
147 | qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); | 148 | qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); |
148 | qDebug( QString(*it) ); | 149 | qDebug( QString(*it) ); |
149 | TodayPlugin plugin; | 150 | TodayPlugin plugin; |
150 | plugin.library = lib; | 151 | plugin.library = lib; |
151 | plugin.iface = iface; | 152 | plugin.iface = iface; |
152 | plugin.name = QString(*it); | 153 | plugin.name = QString(*it); |
153 | 154 | ||
154 | // find out if plugins should be shown | 155 | // find out if plugins should be shown |
155 | if ( m_excludeApplets.grep( *it ).isEmpty() ) { | 156 | if ( m_excludeApplets.grep( *it ).isEmpty() ) { |
156 | plugin.active = true; | 157 | plugin.active = true; |
157 | } else { | 158 | } else { |
158 | plugin.active = false; | 159 | plugin.active = false; |
159 | } | 160 | } |
160 | plugin.guiPart = plugin.iface->guiPart(); | 161 | plugin.guiPart = plugin.iface->guiPart(); |
161 | 162 | ||
162 | // package the whole thing into a qwidget so it can be shown and hidden | 163 | // package the whole thing into a qwidget so it can be shown and hidden |
163 | plugin.guiBox = new QWidget( this ); | 164 | plugin.guiBox = new QWidget( this ); |
164 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); | 165 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); |
165 | QPixmap plugPix; | 166 | QPixmap plugPix; |
166 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( 18, 18 ), 0 ); | 167 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); |
167 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); | 168 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); |
168 | plugIcon->setPixmap( plugPix ); | 169 | plugIcon->setPixmap( plugPix ); |
170 | plugIcon->setName( plugin.guiPart->appName() ); | ||
171 | connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); | ||
169 | // a scrollview for each plugin | 172 | // a scrollview for each plugin |
170 | QScrollView* sv = new QScrollView( plugin.guiBox ); | 173 | QScrollView* sv = new QScrollView( plugin.guiBox ); |
171 | QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); | 174 | QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); |
172 | // not sure if that is good .-) | 175 | // not sure if that is good .-) |
173 | sv->setMinimumHeight( 10 ); | 176 | sv->setMinimumHeight( 10 ); |
174 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 177 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
175 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 178 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
176 | sv->setFrameShape( QFrame::NoFrame ); | 179 | sv->setFrameShape( QFrame::NoFrame ); |
177 | sv->addChild( plugWidget ); | 180 | sv->addChild( plugWidget ); |
178 | // make sure the icon is on the top alligned | 181 | // make sure the icon is on the top alligned |
179 | boxLayout->addWidget( plugIcon, 0, AlignTop ); | 182 | boxLayout->addWidget( plugIcon, 0, AlignTop ); |
180 | boxLayout->addWidget( sv, 0, AlignTop ); | 183 | boxLayout->addWidget( sv, 0, AlignTop ); |
181 | boxLayout->setStretchFactor( plugIcon, 1 ); | 184 | boxLayout->setStretchFactor( plugIcon, 1 ); |
182 | boxLayout->setStretchFactor( sv, 9 ); | 185 | boxLayout->setStretchFactor( sv, 9 ); |
183 | // "prebuffer" it in one more list, to get the sorting done | 186 | // "prebuffer" it in one more list, to get the sorting done |
184 | tempList.insert( plugin.name, plugin ); | 187 | tempList.insert( plugin.name, plugin ); |
185 | 188 | ||
186 | // on first start the list is off course empty | 189 | // on first start the list is off course empty |
187 | if ( m_allApplets.isEmpty() ) { | 190 | if ( m_allApplets.isEmpty() ) { |
188 | layout->addWidget( plugin.guiBox ); | 191 | layout->addWidget( plugin.guiBox ); |
189 | pluginList.append( plugin ); | 192 | pluginList.append( plugin ); |
190 | } | 193 | } |
191 | } else { | 194 | } else { |
192 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); | 195 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); |
@@ -230,49 +233,49 @@ void Today::draw() { | |||
230 | plugin.guiBox->show(); | 233 | plugin.guiBox->show(); |
231 | } else { | 234 | } else { |
232 | // qDebug( plugin.name + " is INACTIVE" ); | 235 | // qDebug( plugin.name + " is INACTIVE" ); |
233 | plugin.guiBox->hide(); | 236 | plugin.guiBox->hide(); |
234 | } | 237 | } |
235 | count++; | 238 | count++; |
236 | } | 239 | } |
237 | 240 | ||
238 | if ( count == 0 ) { | 241 | if ( count == 0 ) { |
239 | QLabel *noPluginsActive = new QLabel( this ); | 242 | QLabel *noPluginsActive = new QLabel( this ); |
240 | noPluginsActive->setText( tr( "No plugins activated" ) ); | 243 | noPluginsActive->setText( tr( "No plugins activated" ) ); |
241 | layout->addWidget( noPluginsActive ); | 244 | layout->addWidget( noPluginsActive ); |
242 | } | 245 | } |
243 | layout->addStretch(0); | 246 | layout->addStretch(0); |
244 | } | 247 | } |
245 | 248 | ||
246 | 249 | ||
247 | /** | 250 | /** |
248 | * The method for the configuration dialog. | 251 | * The method for the configuration dialog. |
249 | */ | 252 | */ |
250 | void Today::startConfig() { | 253 | void Today::startConfig() { |
251 | 254 | ||
252 | TodayConfig conf( this, "dialog", true ); | 255 | TodayConfig conf( this, "dialog", true ); |
253 | 256 | ||
254 | TodayPlugin plugin; | 257 | TodayPlugin plugin; |
255 | QList<TodayConfigWidget> configWidgetList; | 258 | QList<TodayConfigWidget> configWidgetList; |
256 | 259 | ||
257 | for ( int i = pluginList.count() - 1 ; i >= 0; i-- ) { | 260 | for ( int i = pluginList.count() - 1 ; i >= 0; i-- ) { |
258 | plugin = pluginList[i]; | 261 | plugin = pluginList[i]; |
259 | 262 | ||
260 | // load the config widgets in the tabs | 263 | // load the config widgets in the tabs |
261 | if ( plugin.guiPart->configWidget( this ) != 0l ) { | 264 | if ( plugin.guiPart->configWidget( this ) != 0l ) { |
262 | TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); | 265 | TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); |
263 | configWidgetList.append( widget ); | 266 | configWidgetList.append( widget ); |
264 | conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig() | 267 | conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig() |
265 | , plugin.guiPart->appName() ); | 268 | , plugin.guiPart->appName() ); |
266 | } | 269 | } |
267 | // set the order/activate tab | 270 | // set the order/activate tab |
268 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), | 271 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), |
269 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); | 272 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); |
270 | } | 273 | } |
271 | 274 | ||
272 | if ( conf.exec() == QDialog::Accepted ) { | 275 | if ( conf.exec() == QDialog::Accepted ) { |
273 | conf.writeConfig(); | 276 | conf.writeConfig(); |
274 | TodayConfigWidget *confWidget; | 277 | TodayConfigWidget *confWidget; |
275 | for ( confWidget = configWidgetList.first(); confWidget != 0; | 278 | for ( confWidget = configWidgetList.first(); confWidget != 0; |
276 | confWidget = configWidgetList.next() ) { | 279 | confWidget = configWidgetList.next() ) { |
277 | confWidget->writeConfig(); | 280 | confWidget->writeConfig(); |
278 | } | 281 | } |
@@ -290,38 +293,43 @@ void Today::refresh() { | |||
290 | 293 | ||
291 | // set the date in top label | 294 | // set the date in top label |
292 | QDate date = QDate::currentDate(); | 295 | QDate date = QDate::currentDate(); |
293 | QString time = ( tr( date.toString() ) ); | 296 | QString time = ( tr( date.toString() ) ); |
294 | 297 | ||
295 | DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); | 298 | DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); |
296 | 299 | ||
297 | if ( layout ) { | 300 | if ( layout ) { |
298 | delete layout; | 301 | delete layout; |
299 | } | 302 | } |
300 | layout = new QVBoxLayout( this ); | 303 | layout = new QVBoxLayout( this ); |
301 | layout->addWidget( Frame ); | 304 | layout->addWidget( Frame ); |
302 | layout->addWidget( OwnerField ); | 305 | layout->addWidget( OwnerField ); |
303 | 306 | ||
304 | loadPlugins(); | 307 | loadPlugins(); |
305 | draw(); | 308 | draw(); |
306 | } | 309 | } |
307 | 310 | ||
308 | void Today::startAddressbook() { | 311 | void Today::startAddressbook() { |
309 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 312 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
310 | e << QString( "addressbook" ); | 313 | e << QString( "addressbook" ); |
311 | } | 314 | } |
312 | 315 | ||
313 | 316 | ||
317 | void Today::startApplication() { | ||
318 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | ||
319 | e << QString( sender()->name() ); | ||
320 | } | ||
321 | |||
314 | /** | 322 | /** |
315 | * launch addressbook (personal card) | 323 | * launch addressbook (personal card) |
316 | */ | 324 | */ |
317 | void Today::editCard() { | 325 | void Today::editCard() { |
318 | startAddressbook(); | 326 | startAddressbook(); |
319 | while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) { | 327 | while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) { |
320 | qApp->processEvents(); | 328 | qApp->processEvents(); |
321 | } | 329 | } |
322 | QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" ); | 330 | QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" ); |
323 | } | 331 | } |
324 | 332 | ||
325 | Today::~Today() { | 333 | Today::~Today() { |
326 | } | 334 | } |
327 | 335 | ||