summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 2e7e1a8..139c91b 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -64,257 +64,262 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
64 setOwnerField(); 64 setOwnerField();
65 m_refreshTimer = new QTimer( this ); 65 m_refreshTimer = new QTimer( this );
66 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 66 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
67 m_refreshTimer->start( 15000 ); 67 m_refreshTimer->start( 15000 );
68 m_big_box = 0L; 68 m_big_box = 0L;
69 69
70 70
71 layout = new QVBoxLayout( this ); 71 layout = new QVBoxLayout( this );
72 layout->addWidget( Frame ); 72 layout->addWidget( Frame );
73 layout->addWidget( OwnerField ); 73 layout->addWidget( OwnerField );
74 74
75 m_sv = new QScrollView( this ); 75 m_sv = new QScrollView( this );
76 m_sv->setResizePolicy( QScrollView::AutoOneFit ); 76 m_sv->setResizePolicy( QScrollView::AutoOneFit );
77 m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); 77 m_sv->setHScrollBarMode( QScrollView::AlwaysOff );
78 m_sv->setFrameShape( QFrame::NoFrame ); 78 m_sv->setFrameShape( QFrame::NoFrame );
79 79
80 layout->addWidget( m_sv ); 80 layout->addWidget( m_sv );
81 layout->setStretchFactor( m_sv,4 ); 81 layout->setStretchFactor( m_sv,4 );
82 82
83 qApp->processEvents(); 83 qApp->processEvents();
84 loadPlugins(); 84 loadPlugins();
85 showMaximized(); 85 showMaximized();
86} 86}
87 87
88/** 88/**
89 * Qcop receive method. 89 * Qcop receive method.
90 */ 90 */
91void Today::channelReceived( const QCString &msg, const QByteArray & data ) { 91void Today::channelReceived( const QCString &msg, const QByteArray & data ) {
92 QDataStream stream( data, IO_ReadOnly ); 92 QDataStream stream( data, IO_ReadOnly );
93 if ( msg == "message(QString)" ) { 93 if ( msg == "message(QString)" ) {
94 QString message; 94 QString message;
95 stream >> message; 95 stream >> message;
96 setOwnerField( message ); 96 setOwnerField( message );
97 } 97 }
98} 98}
99 99
100void Today::setRefreshTimer( int interval ) { 100void Today::setRefreshTimer( int interval ) {
101 101
102 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 102 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
103 103
104 // 0 is "never" case 104 // 0 is "never" case
105 if ( !interval == 0 ) { 105 if ( !interval == 0 ) {
106 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 106 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
107 m_refreshTimer->changeInterval( interval ); 107 m_refreshTimer->changeInterval( interval );
108 } 108 }
109} 109}
110 110
111 111
112/** 112/**
113 * Initialises the owner field with the default value, the username 113 * Initialises the owner field with the default value, the username
114 */ 114 */
115void Today::setOwnerField() { 115void Today::setOwnerField() {
116 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); 116 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" );
117 if ( QFile::exists( file ) ) { 117 if ( QFile::exists( file ) ) {
118 Contact cont = Contact::readVCard( file )[0]; 118 Contact cont = Contact::readVCard( file )[0];
119 QString returnString = cont.fullName(); 119 QString returnString = cont.fullName();
120 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); 120 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" );
121 } else { 121 } else {
122 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); 122 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" );
123 } 123 }
124} 124}
125 125
126/** 126/**
127 * Set the owner field with a given QString, for example per qcop. 127 * Set the owner field with a given QString, for example per qcop.
128 */ 128 */
129void Today::setOwnerField( QString &message ) { 129void Today::setOwnerField( QString &message ) {
130 if ( !message.isEmpty() ) { 130 if ( !message.isEmpty() ) {
131 OwnerField->setText( "<b>" + message + "</b>" ); 131 OwnerField->setText( "<b>" + message + "</b>" );
132 } 132 }
133} 133}
134 134
135/** 135/**
136 * Init stuff needed for today. Reads the config file. 136 * Init stuff needed for today. Reads the config file.
137 */ 137 */
138void Today::init() { 138void Today::init() {
139 // read config 139 // read config
140 Config cfg( "today" ); 140 Config cfg( "today" );
141 141
142 cfg.setGroup( "Plugins" ); 142 cfg.setGroup( "Plugins" );
143 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 143 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
144 m_allApplets = cfg.readListEntry( "AllApplets", ',' ); 144 m_allApplets = cfg.readListEntry( "AllApplets", ',' );
145 145
146 cfg.setGroup( "General" ); 146 cfg.setGroup( "General" );
147 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 147 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
148 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); 148 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 );
149 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); 149 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) );
150 150
151 // set the date in top label 151 // set the date in top label
152 QDate date = QDate::currentDate(); 152 QDate date = QDate::currentDate();
153 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); 153 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) );
154 154
155 if ( m_hideBanner ) { 155 if ( m_hideBanner ) {
156 Opiezilla->hide(); 156 Opiezilla->hide();
157 TodayLabel->hide(); 157 TodayLabel->hide();
158 } else { 158 } else {
159 Opiezilla->show(); 159 Opiezilla->show();
160 TodayLabel->show(); 160 TodayLabel->show();
161 } 161 }
162 162
163 if ( m_big_box ) { 163 if ( m_big_box ) {
164 delete m_big_box; 164 delete m_big_box;
165 } 165 }
166 166
167 m_big_box = new QWidget( m_sv->viewport() ); 167 m_big_box = new QWidget( m_sv->viewport() );
168 m_sv->addChild( m_big_box ); 168 m_sv->addChild( m_big_box );
169 m_bblayout = new QVBoxLayout ( m_big_box ); 169 m_bblayout = new QVBoxLayout ( m_big_box );
170} 170}
171 171
172/** 172/**
173 * Load the plugins 173 * Load the plugins
174 */ 174 */
175void Today::loadPlugins() { 175void Today::loadPlugins() {
176 176
177 init(); 177 init();
178 178
179 QValueList<TodayPlugin>::Iterator tit; 179 QValueList<TodayPlugin>::Iterator tit;
180 if ( !pluginList.isEmpty() ) { 180 if ( !pluginList.isEmpty() ) {
181 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { 181 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) {
182 (*tit).guiBox->hide(); 182 (*tit).guiBox->hide();
183 (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); 183 (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) );
184 delete (*tit).guiBox; 184 delete (*tit).guiBox;
185 (*tit).library->unload(); 185 (*tit).library->unload();
186 delete (*tit).library; 186 delete (*tit).library;
187 } 187 }
188 pluginList.clear(); 188 pluginList.clear();
189 } 189 }
190 190
191 QString path = QPEApplication::qpeDir() + "/plugins/today"; 191 QString path = QPEApplication::qpeDir() + "/plugins/today";
192#ifdef Q_OS_MACX
193 qWarning("Searching for Plugins in: %s", path.latin1());
194 QDir dir( path, "lib*.dylib" );
195#else
192 QDir dir( path, "lib*.so" ); 196 QDir dir( path, "lib*.so" );
197#endif
193 198
194 QStringList list = dir.entryList(); 199 QStringList list = dir.entryList();
195 QStringList::Iterator it; 200 QStringList::Iterator it;
196 201
197 // QMap<QString, TodayPlugin> tempList; 202 // QMap<QString, TodayPlugin> tempList;
198 203
199 for ( it = list.begin(); it != list.end(); ++it ) { 204 for ( it = list.begin(); it != list.end(); ++it ) {
200 QInterfacePtr<TodayPluginInterface> iface; 205 QInterfacePtr<TodayPluginInterface> iface;
201 QLibrary *lib = new QLibrary( path + "/" + *it ); 206 QLibrary *lib = new QLibrary( path + "/" + *it );
202 207
203 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); 208 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
204 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 209 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
205 qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); 210 qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() );
206 qDebug( QString(*it) ); 211 qDebug( QString(*it) );
207 212
208 TodayPlugin plugin; 213 TodayPlugin plugin;
209 plugin.library = lib; 214 plugin.library = lib;
210 plugin.iface = iface; 215 plugin.iface = iface;
211 plugin.name = QString(*it); 216 plugin.name = QString(*it);
212 217
213 QString type = (*it).left( (*it).find(".") ); 218 QString type = (*it).left( (*it).find(".") );
214 219
215 QString lang; 220 QString lang;
216 Config config("locale"); 221 Config config("locale");
217 config.setGroup("Language"); 222 config.setGroup("Language");
218 lang = config.readEntry( "Language", "en" ); 223 lang = config.readEntry( "Language", "en" );
219 224
220 qDebug( "Languages: " + lang ); 225 qDebug( "Languages: " + lang );
221 QTranslator * trans = new QTranslator( qApp ); 226 QTranslator * trans = new QTranslator( qApp );
222 QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm"; 227 QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm";
223 if ( trans->load( tfn ) ) { 228 if ( trans->load( tfn ) ) {
224 qApp->installTranslator( trans ); 229 qApp->installTranslator( trans );
225 } else { 230 } else {
226 delete trans; 231 delete trans;
227 } 232 }
228 233
229 234
230 // find out if plugins should be shown 235 // find out if plugins should be shown
231 if ( m_excludeApplets.grep( *it ).isEmpty() ) { 236 if ( m_excludeApplets.grep( *it ).isEmpty() ) {
232 plugin.active = true; 237 plugin.active = true;
233 } else { 238 } else {
234 plugin.active = false; 239 plugin.active = false;
235 } 240 }
236 241
237 plugin.guiPart = plugin.iface->guiPart(); 242 plugin.guiPart = plugin.iface->guiPart();
238 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); 243 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
239 244
240 // package the whole thing into a qwidget so it can be shown and hidden 245 // package the whole thing into a qwidget so it can be shown and hidden
241 plugin.guiBox = new QWidget( m_big_box ); 246 plugin.guiBox = new QWidget( m_big_box );
242 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); 247 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
243 QPixmap plugPix; 248 QPixmap plugPix;
244 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); 249 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
245 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); 250 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
246 plugIcon->setPixmap( plugPix ); 251 plugIcon->setPixmap( plugPix );
247 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); 252 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") );
248 plugIcon->setName( plugin.guiPart->appName() ); 253 plugIcon->setName( plugin.guiPart->appName() );
249 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); 254 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
250 255
251 QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox ); 256 QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox );
252 boxLayout->addWidget( plugIcon, 0, AlignTop ); 257 boxLayout->addWidget( plugIcon, 0, AlignTop );
253 boxLayout->addWidget( plugWidget, 0, AlignTop ); 258 boxLayout->addWidget( plugWidget, 0, AlignTop );
254 boxLayout->setStretchFactor( plugIcon, 1 ); 259 boxLayout->setStretchFactor( plugIcon, 1 );
255 boxLayout->setStretchFactor( plugWidget, 9 ); 260 boxLayout->setStretchFactor( plugWidget, 9 );
256 261
257 // "prebuffer" it in one more list, to get the sorting done 262 // "prebuffer" it in one more list, to get the sorting done
258 tempList.insert( plugin.name, plugin ); 263 tempList.insert( plugin.name, plugin );
259 264
260 // on first start the list is off course empty 265 // on first start the list is off course empty
261 if ( m_allApplets.isEmpty() ) { 266 if ( m_allApplets.isEmpty() ) {
262 pluginList.append( plugin ); 267 pluginList.append( plugin );
263 m_bblayout->addWidget( plugin.guiBox ); 268 m_bblayout->addWidget( plugin.guiBox );
264 } 269 }
265 270
266 // if plugin is not yet in the list, add it to the layout too 271 // if plugin is not yet in the list, add it to the layout too
267 else if ( !m_allApplets.contains( plugin.name ) ) { 272 else if ( !m_allApplets.contains( plugin.name ) ) {
268 pluginList.append( plugin ); 273 pluginList.append( plugin );
269 } 274 }
270 } else { 275 } else {
271 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); 276 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() );
272 delete lib; 277 delete lib;
273 } 278 }
274 279
275 } 280 }
276 281
277 282
278 if ( !m_allApplets.isEmpty() ) { 283 if ( !m_allApplets.isEmpty() ) {
279 TodayPlugin tempPlugin; 284 TodayPlugin tempPlugin;
280 QStringList::Iterator stringit; 285 QStringList::Iterator stringit;
281 286
282 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { 287 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) {
283 tempPlugin = ( tempList.find( *stringit ) ).data(); 288 tempPlugin = ( tempList.find( *stringit ) ).data();
284 if ( !( (tempPlugin.name).isEmpty() ) ) { 289 if ( !( (tempPlugin.name).isEmpty() ) ) {
285 pluginList.append( tempPlugin ); 290 pluginList.append( tempPlugin );
286 m_bblayout->addWidget( tempPlugin.guiBox ); 291 m_bblayout->addWidget( tempPlugin.guiBox );
287 } 292 }
288 } 293 }
289 } 294 }
290 m_bblayout->addStretch( 2 ); 295 m_bblayout->addStretch( 2 );
291 draw(); 296 draw();
292} 297}
293 298
294 299
295 300
296 301
297/** 302/**
298 * Repaint method. Reread all fields. 303 * Repaint method. Reread all fields.
299 */ 304 */
300void Today::draw() { 305void Today::draw() {
301 306
302 if ( pluginList.count() == 0 ) { 307 if ( pluginList.count() == 0 ) {
303 QLabel *noPlugins = new QLabel( this ); 308 QLabel *noPlugins = new QLabel( this );
304 noPlugins->setText( tr( "No plugins found" ) ); 309 noPlugins->setText( tr( "No plugins found" ) );
305 layout->addWidget( noPlugins ); 310 layout->addWidget( noPlugins );
306 return; 311 return;
307 } 312 }
308 313
309 uint count = 0; 314 uint count = 0;
310 TodayPlugin plugin; 315 TodayPlugin plugin;
311 for ( uint i = 0; i < pluginList.count(); i++ ) { 316 for ( uint i = 0; i < pluginList.count(); i++ ) {
312 plugin = pluginList[i]; 317 plugin = pluginList[i];
313 318
314 if ( plugin.active ) { 319 if ( plugin.active ) {
315 // qDebug( plugin.name + " is ACTIVE " ); 320 // qDebug( plugin.name + " is ACTIVE " );
316 plugin.guiBox->show(); 321 plugin.guiBox->show();
317 } else { 322 } else {
318 // qDebug( plugin.name + " is INACTIVE" ); 323 // qDebug( plugin.name + " is INACTIVE" );
319 plugin.guiBox->hide(); 324 plugin.guiBox->hide();
320 } 325 }