summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index d78b5b5..066a5a8 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -69,250 +69,249 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
69 init(); 69 init();
70 loadPlugins(); 70 loadPlugins();
71 draw(); 71 draw();
72 showMaximized(); 72 showMaximized();
73} 73}
74 74
75/** 75/**
76 * Qcop receive method. 76 * Qcop receive method.
77 */ 77 */
78void Today::channelReceived( const QCString &msg, const QByteArray & data ) { 78void Today::channelReceived( const QCString &msg, const QByteArray & data ) {
79 QDataStream stream( data, IO_ReadOnly ); 79 QDataStream stream( data, IO_ReadOnly );
80 if ( msg == "message(QString)" ) { 80 if ( msg == "message(QString)" ) {
81 QString message; 81 QString message;
82 stream >> message; 82 stream >> message;
83 setOwnerField( message ); 83 setOwnerField( message );
84 } 84 }
85} 85}
86 86
87/** 87/**
88 * Initialises the owner field with the default value, the username 88 * Initialises the owner field with the default value, the username
89 */ 89 */
90void Today::setOwnerField() { 90void Today::setOwnerField() {
91 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); 91 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" );
92 if ( QFile::exists( file ) ) { 92 if ( QFile::exists( file ) ) {
93 Contact cont = Contact::readVCard( file )[0]; 93 Contact cont = Contact::readVCard( file )[0];
94 QString returnString = cont.fullName(); 94 QString returnString = cont.fullName();
95 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); 95 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" );
96 } else { 96 } else {
97 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); 97 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" );
98 } 98 }
99} 99}
100 100
101/** 101/**
102 * Set the owner field with a given QString, for example per qcop. 102 * Set the owner field with a given QString, for example per qcop.
103 */ 103 */
104void Today::setOwnerField( QString &message ) { 104void Today::setOwnerField( QString &message ) {
105 if ( !message.isEmpty() ) { 105 if ( !message.isEmpty() ) {
106 OwnerField->setText( "<b>" + message + "</b>" ); 106 OwnerField->setText( "<b>" + message + "</b>" );
107 } 107 }
108} 108}
109 109
110 110
111/** 111/**
112 * Init stuff needed for today. Reads the config file. 112 * Init stuff needed for today. Reads the config file.
113 */ 113 */
114void Today::init() { 114void Today::init() {
115 115
116 QDate date = QDate::currentDate(); 116 QDate date = QDate::currentDate();
117 QString time = ( tr( date.toString() ) ); 117 QString time = ( tr( date.toString() ) );
118 118
119 DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); 119 DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) );
120 120
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 */
132void Today::loadPlugins() { 132void 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 */
201void Today::draw() { 201void 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 ); 217 // QHBoxLayout* plugLayout = new QHBoxLayout( this );
218 plugin.guiBox->show(); 218 plugin.guiBox->show();
219 } else { 219 } else {
220 // plugin.guiWidget->hide(); 220 // plugin.guiWidget->hide();
221 qDebug( plugin.name + " is INACTIVE" ); 221 qDebug( plugin.name + " is INACTIVE" );
222 plugin.guiBox->hide(); 222 plugin.guiBox->hide();
223 } 223 }
224 count++; 224 count++;
225 } 225 }
226 226
227 if ( count == 0 ) { 227 if ( count == 0 ) {
228 QLabel *noPluginsActive = new QLabel( this ); 228 QLabel *noPluginsActive = new QLabel( this );
229 noPluginsActive->setText( tr( "No plugins activated" ) ); 229 noPluginsActive->setText( tr( "No plugins activated" ) );
230 layout->addWidget( noPluginsActive ); 230 layout->addWidget( noPluginsActive );
231 } 231 }
232 232
233 layout->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 233 layout->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
234} 234}
235 235
236 236
237/** 237/**
238 * The method for the configuration dialog. 238 * The method for the configuration dialog.
239 */ 239 */
240void Today::startConfig() { 240void Today::startConfig() {
241 241
242 TodayConfig conf( this, "dialog", true ); 242 TodayConfig conf( this, "dialog", true );
243 243
244 TodayPlugin plugin; 244 TodayPlugin plugin;
245 245
246 QList<ConfigWidget> configWidgetList; 246 QList<ConfigWidget> configWidgetList;
247 for ( uint i = 0; i < pluginList.count(); i++ ) { 247 for ( uint i = 0; i < pluginList.count(); i++ ) {
248 plugin = pluginList[i]; 248 plugin = pluginList[i];
249 249
250 // load the config widgets in the tabs 250 // load the config widgets in the tabs
251 if ( plugin.guiPart->configWidget( this ) != 0l ) { 251 if ( plugin.guiPart->configWidget( this ) != 0l ) {
252 ConfigWidget* widget = plugin.guiPart->configWidget( this ); 252 ConfigWidget* widget = plugin.guiPart->configWidget( this );
253 configWidgetList.append( widget ); 253 configWidgetList.append( widget );
254 conf.TabWidget3->insertTab( widget, plugin.guiPart->appName() ); 254 conf.TabWidget3->insertTab( widget, plugin.guiPart->appName() );
255 } 255 }
256 // set the order/activate tab 256 // set the order/activate tab
257 conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), 257 conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(),
258 Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); 258 Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) );
259 } 259 }
260 260
261 conf.exec();
262 if ( conf.exec() == QDialog::Accepted ) { 261 if ( conf.exec() == QDialog::Accepted ) {
263 conf.writeConfig(); 262 conf.writeConfig();
264 ConfigWidget *confWidget; 263 ConfigWidget *confWidget;
265 for ( confWidget = configWidgetList.first(); confWidget != 0; 264 for ( confWidget = configWidgetList.first(); confWidget != 0;
266 confWidget = configWidgetList.next() ) { 265 confWidget = configWidgetList.next() ) {
267 confWidget->writeConfig(); 266 confWidget->writeConfig();
268 } 267 }
269 init();
270 268
269 init();
271 270
272 TodayPlugin plugin; 271 TodayPlugin plugin;
273 for ( uint i = 0; i < pluginList.count(); i++ ) { 272 for ( uint i = 0; i < pluginList.count(); i++ ) {
274 plugin = pluginList[i]; 273 plugin = pluginList[i];
275 274
276 if ( m_excludeApplets.grep( plugin.name ).isEmpty() ) { 275 if ( m_excludeApplets.grep( plugin.name ).isEmpty() ) {
277 qDebug("CONFIG" + plugin.name + "ACTIVE"); 276 qDebug("CONFIG " + plugin.name + " ACTIVE");
278 plugin.active = true; 277 plugin.active = true;
279 } else { 278 } else {
280 qDebug("CONFIG" + plugin.name + "INACTIVE"); 279 qDebug("CONFIG " + plugin.name + " INACTIVE");
281 280
282 plugin.active = false; 281 plugin.active = false;
283 } 282 }
284 } 283 }
285 284
286 draw(); 285 draw();
287 } 286 }
288} 287}
289 288
290 289
291void Today::startAddressbook() { 290void Today::startAddressbook() {
292 QCopEnvelope e( "QPE/System", "execute(QString)" ); 291 QCopEnvelope e( "QPE/System", "execute(QString)" );
293 e << QString( "addressbook" ); 292 e << QString( "addressbook" );
294} 293}
295 294
296 295
297/** 296/**
298 * launch addressbook (personal card) 297 * launch addressbook (personal card)
299 */ 298 */
300void Today::editCard() { 299void Today::editCard() {
301 startAddressbook(); 300 startAddressbook();
302 while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) { 301 while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) {
303 qApp->processEvents(); 302 qApp->processEvents();
304 } 303 }
305 QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" ); 304 QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" );
306} 305}
307 306
308/* 307/*
309 * launches an App 308 * launches an App
310 */ 309 */
311void Today::launchApp( QString appName ) { 310void Today::launchApp( QString appName ) {
312 QCopEnvelope e( "QPE/System", "execute(QString)" ); 311 QCopEnvelope e( "QPE/System", "execute(QString)" );
313 e << QString( appName ); 312 e << QString( appName );
314} 313}
315 314
316Today::~Today() { 315Today::~Today() {
317} 316}
318 317