summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp5
-rw-r--r--core/pim/today/todayconfig.cpp8
-rw-r--r--core/pim/today/todayconfig.h3
3 files changed, 8 insertions, 8 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index d8b427d..901a61a 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -1,325 +1,326 @@
1/* 1/*
2 * today.cpp 2 * today.cpp
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17 17
18#include "today.h" 18#include "today.h"
19#include "configwidget.h" 19#include "configwidget.h"
20 20
21#include <qpe/config.h> 21#include <qpe/config.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/global.h> 24#include <qpe/global.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/contact.h> 26#include <qpe/contact.h>
27 27
28#include <qdir.h> 28#include <qdir.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qpixmap.h> 33#include <qpixmap.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qhbox.h> 35#include <qhbox.h>
36#include <qtabwidget.h> 36#include <opie/otabwidget.h>
37#include <qdialog.h> 37#include <qdialog.h>
38 38
39 39
40struct TodayPlugin { 40struct TodayPlugin {
41 QLibrary *library; 41 QLibrary *library;
42 TodayPluginInterface *iface; 42 TodayPluginInterface *iface;
43 TodayPluginObject *guiPart; 43 TodayPluginObject *guiPart;
44 QWidget *guiBox; 44 QWidget *guiBox;
45 QString name; 45 QString name;
46 bool active; 46 bool active;
47 int pos; 47 int pos;
48}; 48};
49 49
50static QValueList<TodayPlugin> pluginList; 50static QValueList<TodayPlugin> pluginList;
51 51
52Today::Today( QWidget* parent, const char* name, WFlags fl ) 52Today::Today( QWidget* parent, const char* name, WFlags fl )
53 : TodayBase( parent, name, fl ) { 53 : TodayBase( parent, name, fl ) {
54 54
55 QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); 55 QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) );
56 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); 56 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) );
57 57
58#if defined(Q_WS_QWS) 58#if defined(Q_WS_QWS)
59#if !defined(QT_NO_COP) 59#if !defined(QT_NO_COP)
60 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); 60 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this );
61 connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), 61 connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
62 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); 62 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
63#endif 63#endif
64#endif 64#endif
65 65
66 setOwnerField(); 66 setOwnerField();
67 refresh(); 67 refresh();
68 showMaximized(); 68 showMaximized();
69} 69}
70 70
71/** 71/**
72 * Qcop receive method. 72 * Qcop receive method.
73 */ 73 */
74void Today::channelReceived( const QCString &msg, const QByteArray & data ) { 74void Today::channelReceived( const QCString &msg, const QByteArray & data ) {
75 QDataStream stream( data, IO_ReadOnly ); 75 QDataStream stream( data, IO_ReadOnly );
76 if ( msg == "message(QString)" ) { 76 if ( msg == "message(QString)" ) {
77 QString message; 77 QString message;
78 stream >> message; 78 stream >> message;
79 setOwnerField( message ); 79 setOwnerField( message );
80 } 80 }
81} 81}
82 82
83/** 83/**
84 * Initialises the owner field with the default value, the username 84 * Initialises the owner field with the default value, the username
85 */ 85 */
86void Today::setOwnerField() { 86void Today::setOwnerField() {
87 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); 87 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" );
88 if ( QFile::exists( file ) ) { 88 if ( QFile::exists( file ) ) {
89 Contact cont = Contact::readVCard( file )[0]; 89 Contact cont = Contact::readVCard( file )[0];
90 QString returnString = cont.fullName(); 90 QString returnString = cont.fullName();
91 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); 91 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" );
92 } else { 92 } else {
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 */
100void Today::setOwnerField( QString &message ) { 100void 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 */
110void Today::init() { 110void 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} 117}
118 118
119 119
120/** 120/**
121 * Load the plugins 121 * Load the plugins
122 */ 122 */
123void Today::loadPlugins() { 123void Today::loadPlugins() {
124 124
125 QValueList<TodayPlugin>::Iterator tit; 125 QValueList<TodayPlugin>::Iterator tit;
126 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { 126 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) {
127 (*tit).library->unload(); 127 (*tit).library->unload();
128 delete (*tit).library; 128 delete (*tit).library;
129 } 129 }
130 pluginList.clear(); 130 pluginList.clear();
131 131
132 QString path = QPEApplication::qpeDir() + "/plugins/today"; 132 QString path = QPEApplication::qpeDir() + "/plugins/today";
133 QDir dir( path, "lib*.so" ); 133 QDir dir( path, "lib*.so" );
134 134
135 QStringList list = dir.entryList(); 135 QStringList list = dir.entryList();
136 QStringList::Iterator it; 136 QStringList::Iterator it;
137 137
138 138
139 QMap<QString, TodayPlugin> tempList; 139 QMap<QString, TodayPlugin> tempList;
140 140
141 for ( it = list.begin(); it != list.end(); ++it ) { 141 for ( it = list.begin(); it != list.end(); ++it ) {
142 TodayPluginInterface *iface = 0; 142 TodayPluginInterface *iface = 0;
143 QLibrary *lib = new QLibrary( path + "/" + *it ); 143 QLibrary *lib = new QLibrary( path + "/" + *it );
144 144
145 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); 145 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
146 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 146 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
147 qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); 147 qDebug( "loading: %s", QString( path + "/" + *it ).latin1() );
148 qDebug( QString(*it) ); 148 qDebug( QString(*it) );
149 TodayPlugin plugin; 149 TodayPlugin plugin;
150 plugin.library = lib; 150 plugin.library = lib;
151 plugin.iface = iface; 151 plugin.iface = iface;
152 plugin.name = QString(*it); 152 plugin.name = QString(*it);
153 153
154 // find out if plugins should be shown 154 // find out if plugins should be shown
155 if ( m_excludeApplets.grep( *it ).isEmpty() ) { 155 if ( m_excludeApplets.grep( *it ).isEmpty() ) {
156 plugin.active = true; 156 plugin.active = true;
157 } else { 157 } else {
158 plugin.active = false; 158 plugin.active = false;
159 } 159 }
160 plugin.guiPart = plugin.iface->guiPart(); 160 plugin.guiPart = plugin.iface->guiPart();
161 161
162 // package the whole thing into a qwidget so it can be shown and hidden 162 // package the whole thing into a qwidget so it can be shown and hidden
163 plugin.guiBox = new QWidget( this ); 163 plugin.guiBox = new QWidget( this );
164 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); 164 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
165 QPixmap plugPix; 165 QPixmap plugPix;
166 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( 18, 18 ), 0 ); 166 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( 18, 18 ), 0 );
167 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); 167 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
168 plugIcon->setPixmap( plugPix ); 168 plugIcon->setPixmap( plugPix );
169 // a scrollview for each plugin 169 // a scrollview for each plugin
170 QScrollView* sv = new QScrollView( plugin.guiBox ); 170 QScrollView* sv = new QScrollView( plugin.guiBox );
171 QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); 171 QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() );
172 sv->setMinimumHeight( plugin.guiPart->minHeight() ); 172 sv->setMinimumHeight( plugin.guiPart->minHeight() );
173 sv->setResizePolicy( QScrollView::AutoOneFit ); 173 sv->setResizePolicy( QScrollView::AutoOneFit );
174 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 174 sv->setHScrollBarMode( QScrollView::AlwaysOff );
175 sv->setFrameShape( QFrame::NoFrame ); 175 sv->setFrameShape( QFrame::NoFrame );
176 sv->addChild( plugWidget ); 176 sv->addChild( plugWidget );
177 // make sure the icon is on the top alligned 177 // make sure the icon is on the top alligned
178 boxLayout->addWidget( plugIcon, 0, AlignTop ); 178 boxLayout->addWidget( plugIcon, 0, AlignTop );
179 boxLayout->addWidget( sv, 0, AlignTop ); 179 boxLayout->addWidget( sv, 0, AlignTop );
180 boxLayout->setStretchFactor( plugIcon, 1 ); 180 boxLayout->setStretchFactor( plugIcon, 1 );
181 boxLayout->setStretchFactor( sv, 9 ); 181 boxLayout->setStretchFactor( sv, 9 );
182 // "prebuffer" it in one more list, to get the sorting done 182 // "prebuffer" it in one more list, to get the sorting done
183 tempList.insert( plugin.name, plugin ); 183 tempList.insert( plugin.name, plugin );
184 184
185 // on first start the list is off course empty 185 // on first start the list is off course empty
186 if ( m_allApplets.isEmpty() ) { 186 if ( m_allApplets.isEmpty() ) {
187 layout->addWidget( plugin.guiBox ); 187 layout->addWidget( plugin.guiBox );
188 pluginList.append( plugin ); 188 pluginList.append( plugin );
189 } 189 }
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 if ( !m_allApplets.isEmpty() ) { 196 if ( !m_allApplets.isEmpty() ) {
197 TodayPlugin tempPlugin; 197 TodayPlugin tempPlugin;
198 QStringList::Iterator stringit; 198 QStringList::Iterator stringit;
199 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { 199 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) {
200 tempPlugin = ( tempList.find( *stringit ) ).data(); 200 tempPlugin = ( tempList.find( *stringit ) ).data();
201 if ( !( (tempPlugin.name).isEmpty() ) ) { 201 if ( !( (tempPlugin.name).isEmpty() ) ) {
202 layout->addWidget( tempPlugin.guiBox ); 202 layout->addWidget( tempPlugin.guiBox );
203 pluginList.append( tempPlugin ); 203 pluginList.append( tempPlugin );
204 } 204 }
205 } 205 }
206 } 206 }
207} 207}
208 208
209 209
210/** 210/**
211 * Repaint method. Reread all fields. 211 * Repaint method. Reread all fields.
212 */ 212 */
213void Today::draw() { 213void Today::draw() {
214 214
215 if ( pluginList.count() == 0 ) { 215 if ( pluginList.count() == 0 ) {
216 QLabel *noPlugins = new QLabel( this ); 216 QLabel *noPlugins = new QLabel( this );
217 noPlugins->setText( tr( "No plugins found" ) ); 217 noPlugins->setText( tr( "No plugins found" ) );
218 layout->addWidget( noPlugins ); 218 layout->addWidget( noPlugins );
219 return; 219 return;
220 } 220 }
221 221
222 uint count = 0; 222 uint count = 0;
223 TodayPlugin plugin; 223 TodayPlugin plugin;
224 for ( uint i = 0; i < pluginList.count(); i++ ) { 224 for ( uint i = 0; i < pluginList.count(); i++ ) {
225 plugin = pluginList[i]; 225 plugin = pluginList[i];
226 226
227 if ( plugin.active ) { 227 if ( plugin.active ) {
228 qDebug( plugin.name + " is ACTIVE " ); 228 qDebug( plugin.name + " is ACTIVE " );
229 plugin.guiBox->show(); 229 plugin.guiBox->show();
230 } else { 230 } else {
231 qDebug( plugin.name + " is INACTIVE" ); 231 qDebug( plugin.name + " is INACTIVE" );
232 plugin.guiBox->hide(); 232 plugin.guiBox->hide();
233 } 233 }
234 count++; 234 count++;
235 } 235 }
236 236
237 if ( count == 0 ) { 237 if ( count == 0 ) {
238 QLabel *noPluginsActive = new QLabel( this ); 238 QLabel *noPluginsActive = new QLabel( this );
239 noPluginsActive->setText( tr( "No plugins activated" ) ); 239 noPluginsActive->setText( tr( "No plugins activated" ) );
240 layout->addWidget( noPluginsActive ); 240 layout->addWidget( noPluginsActive );
241 } 241 }
242 layout->addStretch(0); 242 layout->addStretch(0);
243} 243}
244 244
245 245
246/** 246/**
247 * The method for the configuration dialog. 247 * The method for the configuration dialog.
248 */ 248 */
249void Today::startConfig() { 249void Today::startConfig() {
250 250
251 TodayConfig conf( this, "dialog", true ); 251 TodayConfig conf( this, "dialog", true );
252 252
253 TodayPlugin plugin; 253 TodayPlugin plugin;
254 QList<ConfigWidget> configWidgetList; 254 QList<ConfigWidget> configWidgetList;
255 255
256 for ( int i = pluginList.count() - 1 ; i >= 0; i-- ) { 256 for ( int i = pluginList.count() - 1 ; i >= 0; i-- ) {
257 plugin = pluginList[i]; 257 plugin = pluginList[i];
258 258
259 // load the config widgets in the tabs 259 // load the config widgets in the tabs
260 if ( plugin.guiPart->configWidget( this ) != 0l ) { 260 if ( plugin.guiPart->configWidget( this ) != 0l ) {
261 ConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); 261 ConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 );
262 configWidgetList.append( widget ); 262 configWidgetList.append( widget );
263 conf.TabWidget3->insertTab( widget, plugin.guiPart->appName() ); 263 conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig()
264 , plugin.guiPart->appName() );
264 } 265 }
265 // set the order/activate tab 266 // set the order/activate tab
266 conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), 267 conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(),
267 Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); 268 Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) );
268 } 269 }
269 270
270 if ( conf.exec() == QDialog::Accepted ) { 271 if ( conf.exec() == QDialog::Accepted ) {
271 conf.writeConfig(); 272 conf.writeConfig();
272 ConfigWidget *confWidget; 273 ConfigWidget *confWidget;
273 for ( confWidget = configWidgetList.first(); confWidget != 0; 274 for ( confWidget = configWidgetList.first(); confWidget != 0;
274 confWidget = configWidgetList.next() ) { 275 confWidget = configWidgetList.next() ) {
275 confWidget->writeConfig(); 276 confWidget->writeConfig();
276 } 277 }
277 refresh(); 278 refresh();
278 } 279 }
279} 280}
280 281
281 282
282/** 283/**
283 * Refresh for the view. Reload all applets 284 * Refresh for the view. Reload all applets
284 * 285 *
285 */ 286 */
286void Today::refresh() { 287void Today::refresh() {
287 init(); 288 init();
288 289
289 // set the date in top label 290 // set the date in top label
290 QDate date = QDate::currentDate(); 291 QDate date = QDate::currentDate();
291 QString time = ( tr( date.toString() ) ); 292 QString time = ( tr( date.toString() ) );
292 293
293 DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); 294 DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) );
294 295
295 if ( layout ) { 296 if ( layout ) {
296 delete layout; 297 delete layout;
297 } 298 }
298 layout = new QVBoxLayout( this ); 299 layout = new QVBoxLayout( this );
299 layout->addWidget( Frame ); 300 layout->addWidget( Frame );
300 layout->addWidget( OwnerField ); 301 layout->addWidget( OwnerField );
301 302
302 loadPlugins(); 303 loadPlugins();
303 draw(); 304 draw();
304} 305}
305 306
306void Today::startAddressbook() { 307void Today::startAddressbook() {
307 QCopEnvelope e( "QPE/System", "execute(QString)" ); 308 QCopEnvelope e( "QPE/System", "execute(QString)" );
308 e << QString( "addressbook" ); 309 e << QString( "addressbook" );
309} 310}
310 311
311 312
312/** 313/**
313 * launch addressbook (personal card) 314 * launch addressbook (personal card)
314 */ 315 */
315void Today::editCard() { 316void Today::editCard() {
316 startAddressbook(); 317 startAddressbook();
317 while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) { 318 while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) {
318 qApp->processEvents(); 319 qApp->processEvents();
319 } 320 }
320 QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" ); 321 QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" );
321} 322}
322 323
323Today::~Today() { 324Today::~Today() {
324} 325}
325 326
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp
index 532d126..04f595b 100644
--- a/core/pim/today/todayconfig.cpp
+++ b/core/pim/today/todayconfig.cpp
@@ -1,220 +1,218 @@
1/* 1/*
2 * todayconfig.cpp 2 * todayconfig.cpp
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#include "todayconfig.h" 17#include "todayconfig.h"
18 18
19#include <qpe/config.h> 19#include <qpe/config.h>
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/qcopenvelope_qws.h> 21#include <qpe/qcopenvelope_qws.h>
22 22
23#include <qcheckbox.h> 23#include <qcheckbox.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qspinbox.h> 25#include <qspinbox.h>
26#include <qtabwidget.h> 26#include <qtabwidget.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qheader.h> 28#include <qheader.h>
29#include <qhbox.h> 29#include <qhbox.h>
30#include <qvbox.h> 30#include <qvbox.h>
31#include <qtoolbutton.h> 31#include <qtoolbutton.h>
32 32
33class ToolButton : public QToolButton { 33class ToolButton : public QToolButton {
34 34
35public: 35public:
36 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 36 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
37 : QToolButton( parent, name ) { 37 : QToolButton( parent, name ) {
38 setPixmap( Resource::loadPixmap( icon ) ); 38 setPixmap( Resource::loadPixmap( icon ) );
39 setAutoRaise( TRUE ); 39 setAutoRaise( TRUE );
40 setFocusPolicy( QWidget::NoFocus ); 40 setFocusPolicy( QWidget::NoFocus );
41 setToggleButton( t ); 41 setToggleButton( t );
42 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 42 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
43 } 43 }
44}; 44};
45 45
46 46
47/** 47/**
48 * The class has currently quite some duplicate code. 48 * The class has currently quite some duplicate code.
49 * By that way it would be real easy to have it as seperate app in settings tab 49 * By that way it would be real easy to have it as seperate app in settings tab
50 * 50 *
51 */ 51 */
52TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal, WFlags fl ) 52TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal, WFlags fl )
53 : QDialog( parent, name, modal, fl ) { 53 : QDialog( parent, name, modal, fl ) {
54 54
55 setCaption( tr( "Today config" ) ); 55 setCaption( tr( "Today config" ) );
56 56
57 QVBoxLayout *layout = new QVBoxLayout( this ); 57 QVBoxLayout *layout = new QVBoxLayout( this );
58 TabWidget3 = new QTabWidget( this, "TabWidget3" ); 58 TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom );
59 TabWidget3->setAutoMask( FALSE );
60 TabWidget3->setTabShape( QTabWidget::Rounded );
61 layout->addWidget( TabWidget3 ); 59 layout->addWidget( TabWidget3 );
62 60
63 tab_2 = new QWidget( TabWidget3, "tab_2" ); 61 tab_2 = new QWidget( TabWidget3, "tab_2" );
64 QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); 62 QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 );
65 QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); 63 QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 );
66 tab2Layout->addWidget( l ); 64 tab2Layout->addWidget( l );
67 QHBox *hbox1 = new QHBox( tab_2 ); 65 QHBox *hbox1 = new QHBox( tab_2 );
68 m_appletListView = new QListView( hbox1 ); 66 m_appletListView = new QListView( hbox1 );
69 m_appletListView->addColumn( "PluginList" ); 67 m_appletListView->addColumn( "PluginList" );
70 m_appletListView->header()->hide(); 68 m_appletListView->header()->hide();
71 m_appletListView->setSorting( -1 ); 69 m_appletListView->setSorting( -1 );
72 QVBox *vbox1 = new QVBox( hbox1 ); 70 QVBox *vbox1 = new QVBox( hbox1 );
73 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", this , SLOT( moveSelectedUp() ) ); 71 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", this , SLOT( moveSelectedUp() ) );
74 new ToolButton( vbox1, tr( "Move Down" ),"opieplayer/down", this , SLOT( moveSelectedDown() ) ); 72 new ToolButton( vbox1, tr( "Move Down" ),"opieplayer/down", this , SLOT( moveSelectedDown() ) );
75 tab2Layout->addWidget( hbox1 ); 73 tab2Layout->addWidget( hbox1 );
76 TabWidget3->insertTab( tab_2, tr( "active/order" ) ); 74 TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) );
77 75
78 tab_3 = new QWidget( TabWidget3, "tab_3" ); 76 tab_3 = new QWidget( TabWidget3, "tab_3" );
79 QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); 77 QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 );
80 tab3Layout->setMargin( 20 ); 78 tab3Layout->setMargin( 20 );
81 QHBox *hbox_auto = new QHBox( tab_3 ); 79 QHBox *hbox_auto = new QHBox( tab_3 );
82 TextLabel2 = new QLabel( hbox_auto, "AutoStart" ); 80 TextLabel2 = new QLabel( hbox_auto, "AutoStart" );
83 TextLabel2->setText( tr( "autostart on \nresume?\n (Opie only)" ) ); 81 TextLabel2->setText( tr( "autostart on \nresume?\n (Opie only)" ) );
84 CheckBoxAuto = new QCheckBox( hbox_auto, "CheckBoxAuto" ); 82 CheckBoxAuto = new QCheckBox( hbox_auto, "CheckBoxAuto" );
85 QHBox *hbox_inactive = new QHBox( tab_3 ); 83 QHBox *hbox_inactive = new QHBox( tab_3 );
86 TimeLabel = new QLabel( hbox_inactive , "TimeLabel" ); 84 TimeLabel = new QLabel( hbox_inactive , "TimeLabel" );
87 TimeLabel->setText( tr( "minutes inactive" ) ); 85 TimeLabel->setText( tr( "minutes inactive" ) );
88 SpinBoxTime = new QSpinBox( hbox_inactive, "TimeSpinner" ); 86 SpinBoxTime = new QSpinBox( hbox_inactive, "TimeSpinner" );
89 tab3Layout->addWidget( hbox_auto ); 87 tab3Layout->addWidget( hbox_auto );
90 tab3Layout->addWidget( hbox_inactive ); 88 tab3Layout->addWidget( hbox_inactive );
91 TabWidget3->insertTab( tab_3, tr( "Misc" ) ); 89 TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) );
92 90
93 m_applets_changed = false; 91 m_applets_changed = false;
94 92
95 connect ( m_appletListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( appletChanged ( ) ) ); 93 connect ( m_appletListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( appletChanged ( ) ) );
96 94
97 readConfig(); 95 readConfig();
98 showMaximized(); 96 showMaximized();
99} 97}
100 98
101 99
102/** 100/**
103 * Autostart, uses the new (opie only) autostart method in the launcher code. 101 * Autostart, uses the new (opie only) autostart method in the launcher code.
104 * If registered against that today ist started on each resume. 102 * If registered against that today ist started on each resume.
105 */ 103 */
106void TodayConfig::setAutoStart() { 104void TodayConfig::setAutoStart() {
107 Config cfg( "today" ); 105 Config cfg( "today" );
108 cfg.setGroup( "Autostart" ); 106 cfg.setGroup( "Autostart" );
109 int autostart = cfg.readNumEntry( "autostart", 1 ); 107 int autostart = cfg.readNumEntry( "autostart", 1 );
110 if ( autostart ) { 108 if ( autostart ) {
111 QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); 109 QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" );
112 e << QString( "add" ); 110 e << QString( "add" );
113 e << QString( "today" ); 111 e << QString( "today" );
114 e << m_autoStartTimer; 112 e << m_autoStartTimer;
115 } else { 113 } else {
116 QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); 114 QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" );
117 e << QString( "remove" ); 115 e << QString( "remove" );
118 e << QString( "today" ); 116 e << QString( "today" );
119 } 117 }
120} 118}
121 119
122/** 120/**
123 * Read the config part 121 * Read the config part
124 */ 122 */
125void TodayConfig::readConfig() { 123void TodayConfig::readConfig() {
126 Config cfg( "today" ); 124 Config cfg( "today" );
127 cfg.setGroup( "Autostart" ); 125 cfg.setGroup( "Autostart" );
128 m_autoStart = cfg.readNumEntry( "autostart", 1 ); 126 m_autoStart = cfg.readNumEntry( "autostart", 1 );
129 CheckBoxAuto->setChecked( m_autoStart ); 127 CheckBoxAuto->setChecked( m_autoStart );
130 m_autoStartTimer = cfg.readEntry( "autostartdelay", "0" ); 128 m_autoStartTimer = cfg.readEntry( "autostartdelay", "0" );
131 SpinBoxTime->setValue( m_autoStartTimer.toInt() ); 129 SpinBoxTime->setValue( m_autoStartTimer.toInt() );
132 130
133 cfg.setGroup( "Plugins" ); 131 cfg.setGroup( "Plugins" );
134 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 132 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
135} 133}
136 134
137/** 135/**
138 * Write the config part 136 * Write the config part
139 */ 137 */
140void TodayConfig::writeConfig() { 138void TodayConfig::writeConfig() {
141 Config cfg( "today" ); 139 Config cfg( "today" );
142 cfg.setGroup( "Plugins" ); 140 cfg.setGroup( "Plugins" );
143 if ( m_applets_changed ) { 141 if ( m_applets_changed ) {
144 QStringList exclude; 142 QStringList exclude;
145 QStringList include; 143 QStringList include;
146 QStringList all_applets; 144 QStringList all_applets;
147 145
148 QListViewItemIterator list_it( m_appletListView ); 146 QListViewItemIterator list_it( m_appletListView );
149 147
150 // this makes sure the names get saved in the order selected 148 // this makes sure the names get saved in the order selected
151 for ( ; list_it.current(); ++list_it ) { 149 for ( ; list_it.current(); ++list_it ) {
152 QMap <QString, QCheckListItem *>::Iterator it; 150 QMap <QString, QCheckListItem *>::Iterator it;
153 for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { 151 for ( it = m_applets.begin(); it != m_applets. end (); ++it ) {
154 if ( list_it.current() == (*it) && !(*it)-> isOn () ) { 152 if ( list_it.current() == (*it) && !(*it)-> isOn () ) {
155 exclude << it.key(); 153 exclude << it.key();
156 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ 154 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){
157 include << it.key(); 155 include << it.key();
158 } 156 }
159 if ( list_it.current() == (*it) ) { 157 if ( list_it.current() == (*it) ) {
160 all_applets << it.key(); 158 all_applets << it.key();
161 } 159 }
162 } 160 }
163 } 161 }
164 cfg.writeEntry( "ExcludeApplets", exclude, ',' ); 162 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
165 cfg.writeEntry( "IncludeApplets", include, ',' ); 163 cfg.writeEntry( "IncludeApplets", include, ',' );
166 cfg.writeEntry( "AllApplets", all_applets, ',' ); 164 cfg.writeEntry( "AllApplets", all_applets, ',' );
167 } 165 }
168 166
169 cfg.setGroup( "Autostart" ); 167 cfg.setGroup( "Autostart" );
170 m_autoStart = CheckBoxAuto->isChecked(); 168 m_autoStart = CheckBoxAuto->isChecked();
171 cfg.writeEntry( "autostart", m_autoStart ); 169 cfg.writeEntry( "autostart", m_autoStart );
172 m_autoStartTimer = SpinBoxTime->value(); 170 m_autoStartTimer = SpinBoxTime->value();
173 cfg.readEntry( "autostartdelay", m_autoStartTimer ); 171 cfg.readEntry( "autostartdelay", m_autoStartTimer );
174} 172}
175 173
176 174
177void TodayConfig::moveSelectedUp() { 175void TodayConfig::moveSelectedUp() {
178 QListViewItem *item = m_appletListView->selectedItem(); 176 QListViewItem *item = m_appletListView->selectedItem();
179 if ( item && item->itemAbove() ) { 177 if ( item && item->itemAbove() ) {
180 item->itemAbove()->moveItem( item ); 178 item->itemAbove()->moveItem( item );
181 } 179 }
182} 180}
183 181
184 182
185void TodayConfig::moveSelectedDown() { 183void TodayConfig::moveSelectedDown() {
186 QListViewItem *item = m_appletListView->selectedItem(); 184 QListViewItem *item = m_appletListView->selectedItem();
187 if ( item && item->itemBelow() ) { 185 if ( item && item->itemBelow() ) {
188 item->moveItem( item->itemBelow() ); 186 item->moveItem( item->itemBelow() );
189 } 187 }
190} 188}
191 189
192 190
193/** 191/**
194 * Set up the 192 * Set up the
195 */ 193 */
196void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { 194void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) {
197 195
198 QCheckListItem *item; 196 QCheckListItem *item;
199 item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox ); 197 item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox );
200 198
201 if ( !icon.isNull() ) { 199 if ( !icon.isNull() ) {
202 item->setPixmap( 0, icon ); 200 item->setPixmap( 0, icon );
203 } 201 }
204 202
205 if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) { 203 if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) {
206 item->setOn( TRUE ); 204 item->setOn( TRUE );
207 } 205 }
208 206
209 m_applets[libName] = item; 207 m_applets[libName] = item;
210} 208}
211 209
212 210
213void TodayConfig::appletChanged() { 211void TodayConfig::appletChanged() {
214 m_applets_changed = true; 212 m_applets_changed = true;
215} 213}
216 214
217 215
218TodayConfig::~TodayConfig() { 216TodayConfig::~TodayConfig() {
219} 217}
220 218
diff --git a/core/pim/today/todayconfig.h b/core/pim/today/todayconfig.h
index d5bdb4b..49cd10f 100644
--- a/core/pim/today/todayconfig.h
+++ b/core/pim/today/todayconfig.h
@@ -1,69 +1,70 @@
1/* 1/*
2 * todayconfig.h 2 * todayconfig.h
3 * 3 *
4 * copyright : (c) 2002 by Maximilian Reiß 4 * copyright : (c) 2002 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#ifndef TODAYCONFIG_H 17#ifndef TODAYCONFIG_H
18#define TODAYCONFIG_H 18#define TODAYCONFIG_H
19 19
20#include <qvariant.h> 20#include <qvariant.h>
21#include <qdialog.h> 21#include <qdialog.h>
22#include <qlistview.h> 22#include <qlistview.h>
23#include <opie/otabwidget.h>
23 24
24class QCheckBox; 25class QCheckBox;
25class QLabel; 26class QLabel;
26class QSpinBox; 27class QSpinBox;
27class QTabWidget; 28class QTabWidget;
28 29
29class TodayConfig : public QDialog { 30class TodayConfig : public QDialog {
30 31
31 Q_OBJECT 32 Q_OBJECT
32 33
33public: 34public:
34 TodayConfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 35 TodayConfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
35 ~TodayConfig(); 36 ~TodayConfig();
36 37
37 QTabWidget* TabWidget3; 38 OTabWidget* TabWidget3;
38 39
39 void writeConfig(); 40 void writeConfig();
40 void pluginManagement( QString libName, QString name, QPixmap icon ); 41 void pluginManagement( QString libName, QString name, QPixmap icon );
41 42
42protected slots: 43protected slots:
43 void appletChanged(); 44 void appletChanged();
44 void moveSelectedUp(); 45 void moveSelectedUp();
45 void moveSelectedDown(); 46 void moveSelectedDown();
46 47
47private: 48private:
48 void setAutoStart(); 49 void setAutoStart();
49 void readConfig(); 50 void readConfig();
50 51
51 QListView* m_appletListView; 52 QListView* m_appletListView;
52 QMap<QString,QCheckListItem*> m_applets; 53 QMap<QString,QCheckListItem*> m_applets;
53 54
54 int m_autoStart; 55 int m_autoStart;
55 QString m_autoStartTimer; 56 QString m_autoStartTimer;
56 QStringList m_excludeApplets; 57 QStringList m_excludeApplets;
57 bool m_applets_changed; 58 bool m_applets_changed;
58 59
59 QLabel* TextLabel2; 60 QLabel* TextLabel2;
60 QCheckBox* CheckBoxAuto; 61 QCheckBox* CheckBoxAuto;
61 QWidget* tab_2; 62 QWidget* tab_2;
62 QWidget* tab_3; 63 QWidget* tab_3;
63 QLabel* TextLabel1; 64 QLabel* TextLabel1;
64 QSpinBox* SpinBox7; 65 QSpinBox* SpinBox7;
65 QLabel* TimeLabel; 66 QLabel* TimeLabel;
66 QSpinBox* SpinBoxTime; 67 QSpinBox* SpinBoxTime;
67}; 68};
68 69
69#endif 70#endif