summaryrefslogtreecommitdiff
path: root/core/pim/today/today.cpp
Unidiff
Diffstat (limited to 'core/pim/today/today.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index f213943..cb18c1c 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -81,197 +81,204 @@ void Today::channelReceived( const QCString &msg, const QByteArray & data ) {
81 stream >> message; 81 stream >> message;
82 setOwnerField( message ); 82 setOwnerField( message );
83 } 83 }
84} 84}
85 85
86void Today::setRefreshTimer( int interval ) { 86void Today::setRefreshTimer( int interval ) {
87 87
88 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 88 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
89 89
90 // 0 is "never" case 90 // 0 is "never" case
91 if ( !interval == 0 ) { 91 if ( !interval == 0 ) {
92 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 92 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
93 m_refreshTimer->changeInterval( interval ); 93 m_refreshTimer->changeInterval( interval );
94 } 94 }
95} 95}
96 96
97 97
98/** 98/**
99 * Initialises the owner field with the default value, the username 99 * Initialises the owner field with the default value, the username
100 */ 100 */
101void Today::setOwnerField() { 101void Today::setOwnerField() {
102 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); 102 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" );
103 if ( QFile::exists( file ) ) { 103 if ( QFile::exists( file ) ) {
104 Contact cont = Contact::readVCard( file )[0]; 104 Contact cont = Contact::readVCard( file )[0];
105 QString returnString = cont.fullName(); 105 QString returnString = cont.fullName();
106 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); 106 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" );
107 } else { 107 } else {
108 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); 108 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" );
109 } 109 }
110} 110}
111 111
112/** 112/**
113 * Set the owner field with a given QString, for example per qcop. 113 * Set the owner field with a given QString, for example per qcop.
114 */ 114 */
115void Today::setOwnerField( QString &message ) { 115void Today::setOwnerField( QString &message ) {
116 if ( !message.isEmpty() ) { 116 if ( !message.isEmpty() ) {
117 OwnerField->setText( "<b>" + message + "</b>" ); 117 OwnerField->setText( "<b>" + message + "</b>" );
118 } 118 }
119} 119}
120 120
121/** 121/**
122 * Init stuff needed for today. Reads the config file. 122 * Init stuff needed for today. Reads the config file.
123 */ 123 */
124void Today::init() { 124void Today::init() {
125 // read config 125 // read config
126 Config cfg( "today" ); 126 Config cfg( "today" );
127 127
128 cfg.setGroup( "Plugins" ); 128 cfg.setGroup( "Plugins" );
129 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 129 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
130 m_allApplets = cfg.readListEntry( "AllApplets", ',' ); 130 m_allApplets = cfg.readListEntry( "AllApplets", ',' );
131 131
132 cfg.setGroup( "General" ); 132 cfg.setGroup( "General" );
133 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 133 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
134 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); 134 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 );
135 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); 135 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) );
136 136
137 // set the date in top label 137 // set the date in top label
138 QDate date = QDate::currentDate(); 138 QDate date = QDate::currentDate();
139 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); 139 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) );
140 140
141 if ( layout ) { 141 if ( layout ) {
142 delete layout; 142 delete layout;
143 } 143 }
144 144
145 if ( m_hideBanner ) { 145 if ( m_hideBanner ) {
146 Opiezilla->hide(); 146 Opiezilla->hide();
147 TodayLabel->hide(); 147 TodayLabel->hide();
148 } else { 148 } else {
149 Opiezilla->show(); 149 Opiezilla->show();
150 TodayLabel->show(); 150 TodayLabel->show();
151 } 151 }
152 152
153 layout = new QVBoxLayout( this ); 153 layout = new QVBoxLayout( this );
154 layout->addWidget( Frame ); 154 layout->addWidget( Frame );
155 layout->addWidget( OwnerField ); 155 layout->addWidget( OwnerField );
156} 156}
157 157
158/** 158/**
159 * Load the plugins 159 * Load the plugins
160 */ 160 */
161void Today::loadPlugins() { 161void Today::loadPlugins() {
162 162
163 init(); 163 init();
164 QValueList<TodayPlugin>::Iterator tit; 164 QValueList<TodayPlugin>::Iterator tit;
165 if ( !pluginList.isEmpty() ) { 165 if ( !pluginList.isEmpty() ) {
166 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { 166 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) {
167 (*tit).guiBox->hide(); 167 (*tit).guiBox->hide();
168 (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); 168 (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) );
169 delete (*tit).guiBox; 169 delete (*tit).guiBox;
170 (*tit).library->unload(); 170 (*tit).library->unload();
171 delete (*tit).library; 171 delete (*tit).library;
172 } 172 }
173 pluginList.clear(); 173 pluginList.clear();
174 } 174 }
175 175
176 QString path = QPEApplication::qpeDir() + "/plugins/today"; 176 QString path = QPEApplication::qpeDir() + "/plugins/today";
177 qWarning("Searching for Plugins in: %s", path.latin1());
178#ifdef Q_OS_MACX
179 QDir dir( path, "lib*.dylib" );
180#else
177 QDir dir( path, "lib*.so" ); 181 QDir dir( path, "lib*.so" );
182#endif
178 183
179 QStringList list = dir.entryList(); 184 QStringList list = dir.entryList();
180 QStringList::Iterator it; 185 QStringList::Iterator it;
181 186
187 qWarning("Found: %d entries !", list.count() );
188
182 QMap<QString, TodayPlugin> tempList; 189 QMap<QString, TodayPlugin> tempList;
183 190
184 for ( it = list.begin(); it != list.end(); ++it ) { 191 for ( it = list.begin(); it != list.end(); ++it ) {
185 QInterfacePtr<TodayPluginInterface> iface; 192 QInterfacePtr<TodayPluginInterface> iface;
186 QLibrary *lib = new QLibrary( path + "/" + *it ); 193 QLibrary *lib = new QLibrary( path + "/" + *it );
187 194
188 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); 195 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
189 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 196 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
190 qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); 197 qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() );
191 qDebug( QString(*it) ); 198 qDebug( QString(*it) );
192 199
193 TodayPlugin plugin; 200 TodayPlugin plugin;
194 plugin.library = lib; 201 plugin.library = lib;
195 plugin.iface = iface; 202 plugin.iface = iface;
196 plugin.name = QString(*it); 203 plugin.name = QString(*it);
197 204
198 QString type = (*it).left( (*it).find(".") ); 205 QString type = (*it).left( (*it).find(".") );
199 206
200 // grr, sharp rom does not know Global::languageList(); 207 // grr, sharp rom does not know Global::languageList();
201 // QStringList langs = Global::languageList(); 208 // QStringList langs = Global::languageList();
202 QString tfn = QPEApplication::qpeDir() + "/i18n/"; 209 QString tfn = QPEApplication::qpeDir() + "/i18n/";
203 QDir langDir = tfn; 210 QDir langDir = tfn;
204 QStringList langs = langDir.entryList("*", QDir::Dirs ); 211 QStringList langs = langDir.entryList("*", QDir::Dirs );
205 212
206 for (QStringList::ConstIterator lit = langs.begin(); lit!=langs.end(); ++lit) { 213 for (QStringList::ConstIterator lit = langs.begin(); lit!=langs.end(); ++lit) {
207 QString lang = *lit; 214 QString lang = *lit;
208 qDebug( "Languages: " + lang ); 215 qDebug( "Languages: " + lang );
209 QTranslator * trans = new QTranslator( qApp ); 216 QTranslator * trans = new QTranslator( qApp );
210 QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm"; 217 QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm";
211 if ( trans->load( tfn ) ) { 218 if ( trans->load( tfn ) ) {
212 qApp->installTranslator( trans ); 219 qApp->installTranslator( trans );
213 } else { 220 } else {
214 delete trans; 221 delete trans;
215 } 222 }
216 } 223 }
217 224
218 // find out if plugins should be shown 225 // find out if plugins should be shown
219 if ( m_excludeApplets.grep( *it ).isEmpty() ) { 226 if ( m_excludeApplets.grep( *it ).isEmpty() ) {
220 plugin.active = true; 227 plugin.active = true;
221 } else { 228 } else {
222 plugin.active = false; 229 plugin.active = false;
223 } 230 }
224 231
225 plugin.guiPart = plugin.iface->guiPart(); 232 plugin.guiPart = plugin.iface->guiPart();
226 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); 233 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
227 234
228 // package the whole thing into a qwidget so it can be shown and hidden 235 // package the whole thing into a qwidget so it can be shown and hidden
229 plugin.guiBox = new QWidget( this ); 236 plugin.guiBox = new QWidget( this );
230 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); 237 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
231 QPixmap plugPix; 238 QPixmap plugPix;
232 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); 239 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
233 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); 240 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
234 plugIcon->setPixmap( plugPix ); 241 plugIcon->setPixmap( plugPix );
235 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); 242 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") );
236 plugIcon->setName( plugin.guiPart->appName() ); 243 plugIcon->setName( plugin.guiPart->appName() );
237 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); 244 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
238 // a scrollview for each plugin 245 // a scrollview for each plugin
239 QScrollView* sv = new QScrollView( plugin.guiBox ); 246 QScrollView* sv = new QScrollView( plugin.guiBox );
240 QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); 247 QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() );
241 // not sure if that is good .-) 248 // not sure if that is good .-)
242 sv->setMinimumHeight( 12 ); 249 sv->setMinimumHeight( 12 );
243 sv->setResizePolicy( QScrollView::AutoOneFit ); 250 sv->setResizePolicy( QScrollView::AutoOneFit );
244 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 251 sv->setHScrollBarMode( QScrollView::AlwaysOff );
245 sv->setFrameShape( QFrame::NoFrame ); 252 sv->setFrameShape( QFrame::NoFrame );
246 sv->addChild( plugWidget ); 253 sv->addChild( plugWidget );
247 // make sure the icon is on the top alligned 254 // make sure the icon is on the top alligned
248 boxLayout->addWidget( plugIcon, 0, AlignTop ); 255 boxLayout->addWidget( plugIcon, 0, AlignTop );
249 boxLayout->addWidget( sv, 0, AlignTop ); 256 boxLayout->addWidget( sv, 0, AlignTop );
250 boxLayout->setStretchFactor( plugIcon, 1 ); 257 boxLayout->setStretchFactor( plugIcon, 1 );
251 boxLayout->setStretchFactor( sv, 9 ); 258 boxLayout->setStretchFactor( sv, 9 );
252 // "prebuffer" it in one more list, to get the sorting done 259 // "prebuffer" it in one more list, to get the sorting done
253 tempList.insert( plugin.name, plugin ); 260 tempList.insert( plugin.name, plugin );
254 261
255 // on first start the list is off course empty 262 // on first start the list is off course empty
256 if ( m_allApplets.isEmpty() ) { 263 if ( m_allApplets.isEmpty() ) {
257 layout->addWidget( plugin.guiBox ); 264 layout->addWidget( plugin.guiBox );
258 pluginList.append( plugin ); 265 pluginList.append( plugin );
259 } 266 }
260 267
261 // if plugin is not yet in the list, add it to the layout too 268 // if plugin is not yet in the list, add it to the layout too
262 else if ( !m_allApplets.contains( plugin.name ) ) { 269 else if ( !m_allApplets.contains( plugin.name ) ) {
263 layout->addWidget( plugin.guiBox ); 270 layout->addWidget( plugin.guiBox );
264 pluginList.append( plugin ); 271 pluginList.append( plugin );
265 } 272 }
266 } else { 273 } else {
267 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); 274 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() );
268 delete lib; 275 delete lib;
269 } 276 }
270 } 277 }
271 278
272 if ( !m_allApplets.isEmpty() ) { 279 if ( !m_allApplets.isEmpty() ) {
273 TodayPlugin tempPlugin; 280 TodayPlugin tempPlugin;
274 QStringList::Iterator stringit; 281 QStringList::Iterator stringit;
275 282
276 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { 283 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) {
277 tempPlugin = ( tempList.find( *stringit ) ).data(); 284 tempPlugin = ( tempList.find( *stringit ) ).data();