-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 | |||
@@ -105,46 +105,47 @@ void Today::setOwnerField( QString &message ) { | |||
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; |
@@ -154,27 +155,29 @@ void Today::loadPlugins() { | |||
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 ); |
@@ -242,25 +245,25 @@ void Today::draw() { | |||
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 | } |
@@ -302,24 +305,29 @@ void Today::refresh() { | |||
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() { |