author | zecke <zecke> | 2004-09-12 20:31:20 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-12 20:31:20 (UTC) |
commit | b52e2e46ec535a5307276b8fdf1e578aa5d29283 (patch) (unidiff) | |
tree | f30d0fd2faaf89c2bc982e3f8a645645bf74edd8 | |
parent | 90aaa298cc69522e88e1f81ade7d5259131b1544 (diff) | |
download | opie-b52e2e46ec535a5307276b8fdf1e578aa5d29283.zip opie-b52e2e46ec535a5307276b8fdf1e578aa5d29283.tar.gz opie-b52e2e46ec535a5307276b8fdf1e578aa5d29283.tar.bz2 |
-Only create configWidgets once per config dialog, properly delete them
-Delete the Widgets before we remove the plugin from our address space
some random clean ups
-rw-r--r-- | core/pim/today/today.cpp | 38 | ||||
-rw-r--r-- | core/pim/today/today.h | 1 | ||||
-rw-r--r-- | core/pim/today/todayconfig.cpp | 32 | ||||
-rw-r--r-- | core/pim/today/todayconfig.h | 4 |
4 files changed, 43 insertions, 32 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index a8c8651..be7cbce 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -1,354 +1,364 @@ | |||
1 | /* | 1 | /* |
2 | * today.cpp | 2 | * today.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002,2003,2004 by Maximilian Reiß | 4 | * copyright : (c) 2002,2003,2004 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 "today.h" | 17 | #include "today.h" |
18 | 18 | ||
19 | #include <opie2/odebug.h> | 19 | #include <opie2/odebug.h> |
20 | #include <opie2/opluginloader.h> | 20 | #include <opie2/opluginloader.h> |
21 | #include <opie2/oconfig.h> | 21 | #include <opie2/oconfig.h> |
22 | 22 | ||
23 | #include <qpe/qcopenvelope_qws.h> | 23 | #include <qpe/qcopenvelope_qws.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.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 <qtimer.h> | 29 | #include <qtimer.h> |
30 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
31 | #include <qmessagebox.h> | ||
31 | 32 | ||
32 | using namespace Opie::Ui; | 33 | using namespace Opie::Ui; |
33 | using Opie::Core::OPluginItem; | 34 | using Opie::Core::OPluginItem; |
34 | using Opie::Core::OPluginLoader; | 35 | using Opie::Core::OPluginLoader; |
35 | using Opie::Core::OPluginManager; | 36 | using Opie::Core::OPluginManager; |
36 | using Opie::Core::OConfig; | 37 | using Opie::Core::OConfig; |
37 | 38 | ||
38 | 39 | ||
39 | struct TodayPlugin { | 40 | struct TodayPlugin { |
40 | TodayPlugin() : iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} | 41 | TodayPlugin() : iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} |
41 | QInterfacePtr<TodayPluginInterface> iface; | 42 | QInterfacePtr<TodayPluginInterface> iface; |
42 | TodayPluginObject *guiPart; | 43 | TodayPluginObject *guiPart; |
43 | OPluginItem oplugin; | 44 | OPluginItem oplugin; |
44 | QWidget *guiBox; | 45 | QWidget *guiBox; |
45 | QString name; | 46 | QString name; |
46 | bool excludeRefresh; | 47 | bool excludeRefresh; |
47 | }; | 48 | }; |
48 | 49 | ||
49 | static QMap<QString, TodayPlugin> pluginList; | 50 | static QMap<QString, TodayPlugin> pluginList; |
50 | 51 | ||
51 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 52 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
52 | : TodayBase( parent, name, fl ) { | 53 | : TodayBase( parent, name, fl ) { |
53 | 54 | ||
54 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); | 55 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); |
55 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); | 56 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); |
56 | 57 | ||
57 | #if defined(Q_WS_QWS) | 58 | #if !defined(QT_NO_COP) |
58 | #if !defined(QT_NO_COP) | ||
59 | 59 | ||
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 | ||
65 | 64 | ||
66 | setOwnerField(); | 65 | setOwnerField(); |
67 | m_big_box = 0L; | 66 | m_big_box = 0L; |
68 | 67 | ||
69 | layout = new QVBoxLayout( this ); | 68 | layout = new QVBoxLayout( this ); |
70 | layout->addWidget( Frame ); | 69 | layout->addWidget( Frame ); |
71 | layout->addWidget( OwnerField ); | 70 | layout->addWidget( OwnerField ); |
72 | 71 | ||
73 | m_sv = new QScrollView( this ); | 72 | m_sv = new QScrollView( this ); |
74 | m_sv->setResizePolicy( QScrollView::AutoOneFit ); | 73 | m_sv->setResizePolicy( QScrollView::AutoOneFit ); |
75 | m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 74 | m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
76 | m_sv->setFrameShape( QFrame::NoFrame ); | 75 | m_sv->setFrameShape( QFrame::NoFrame ); |
77 | 76 | ||
78 | layout->addWidget( m_sv ); | 77 | layout->addWidget( m_sv ); |
79 | layout->setStretchFactor( m_sv,4 ); | 78 | layout->setStretchFactor( m_sv,4 ); |
80 | 79 | ||
81 | m_refreshTimer = new QTimer( this ); | 80 | m_refreshTimer = new QTimer( this ); |
82 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 81 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
83 | 82 | ||
84 | init(); | 83 | init(); |
85 | loadPlugins(); | 84 | loadPlugins(); |
86 | initialize(); | 85 | initialize(); |
87 | QPEApplication::showWidget( this ); | ||
88 | } | 86 | } |
89 | 87 | ||
90 | /** | 88 | /** |
91 | * Qcop receive method. | 89 | * Qcop receive method. |
92 | */ | 90 | */ |
93 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { | 91 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { |
94 | QDataStream stream( data, IO_ReadOnly ); | 92 | QDataStream stream( data, IO_ReadOnly ); |
95 | if ( msg == "message(QString)" ) { | 93 | if ( msg == "message(QString)" ) { |
96 | QString message; | 94 | QString message; |
97 | stream >> message; | 95 | stream >> message; |
98 | setOwnerField( message ); | 96 | setOwnerField( message ); |
99 | } | 97 | } |
100 | } | 98 | } |
101 | 99 | ||
102 | void Today::setRefreshTimer( int interval ) { | 100 | void Today::setRefreshTimer( int interval ) { |
103 | 101 | ||
104 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 102 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
105 | // 0 is "never" case | 103 | // 0 is "never" case |
106 | if ( !interval == 0 ) { | 104 | if ( !interval == 0 ) { |
107 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 105 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
108 | m_refreshTimer->changeInterval( interval ); | 106 | m_refreshTimer->changeInterval( interval ); |
109 | } | 107 | } |
110 | } | 108 | } |
111 | 109 | ||
112 | 110 | ||
113 | /** | 111 | /** |
114 | * Initialises the owner field with the default value, the username | 112 | * Initialises the owner field with the default value, the username |
115 | */ | 113 | */ |
116 | void Today::setOwnerField() { | 114 | void Today::setOwnerField() { |
117 | QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); | 115 | QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); |
118 | if ( QFile::exists( file ) ) { | 116 | if ( QFile::exists( file ) ) { |
119 | Contact cont = Contact::readVCard( file )[0]; | 117 | Contact cont = Contact::readVCard( file )[0]; |
120 | QString returnString = cont.fullName(); | 118 | QString returnString = cont.fullName(); |
121 | OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); | 119 | OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); |
122 | } else { | 120 | } else { |
123 | OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); | 121 | OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); |
124 | } | 122 | } |
125 | } | 123 | } |
126 | 124 | ||
127 | /** | 125 | /** |
128 | * Set the owner field with a given QString, for example per qcop. | 126 | * Set the owner field with a given QString, for example per qcop. |
129 | */ | 127 | */ |
130 | void Today::setOwnerField( QString &message ) { | 128 | void Today::setOwnerField( QString &message ) { |
131 | if ( !message.isEmpty() ) { | 129 | if ( !message.isEmpty() ) { |
132 | OwnerField->setText( "<b>" + message + "</b>" ); | 130 | OwnerField->setText( "<b>" + message + "</b>" ); |
133 | } | 131 | } |
134 | } | 132 | } |
135 | 133 | ||
136 | 134 | ||
137 | /** | 135 | /** |
138 | * Init stuff needed for today. Reads the config file. | 136 | * Init stuff needed for today. Reads the config file. |
139 | */ | 137 | */ |
140 | void Today::init() { | 138 | void Today::init() { |
141 | // read config | 139 | // read config |
142 | OConfig cfg( "today" ); | 140 | OConfig cfg( "today" ); |
143 | cfg.setGroup( "Plugins" ); | 141 | cfg.setGroup( "Plugins" ); |
144 | // m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | 142 | // m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
145 | // m_allApplets = cfg.readListEntry( "AllApplets", ',' ); | 143 | // m_allApplets = cfg.readListEntry( "AllApplets", ',' ); |
146 | 144 | ||
147 | cfg.setGroup( "General" ); | 145 | cfg.setGroup( "General" ); |
148 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 146 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
149 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); | 147 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); |
150 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); | 148 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); |
151 | 149 | ||
152 | // set the date in top label | 150 | // set the date in top label |
153 | QDate date = QDate::currentDate(); | 151 | QDate date = QDate::currentDate(); |
154 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); | 152 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); |
155 | 153 | ||
156 | if ( m_hideBanner ) { | 154 | if ( m_hideBanner ) { |
157 | Opiezilla->hide(); | 155 | Opiezilla->hide(); |
158 | TodayLabel->hide(); | 156 | TodayLabel->hide(); |
159 | } else { | 157 | } else { |
160 | Opiezilla->show(); | 158 | Opiezilla->show(); |
161 | TodayLabel->show(); | 159 | TodayLabel->show(); |
162 | } | 160 | } |
163 | 161 | ||
164 | if ( m_big_box ) { | 162 | if ( m_big_box ) { |
165 | delete m_big_box; | 163 | delete m_big_box; |
166 | } | 164 | } |
167 | 165 | ||
168 | m_big_box = new QWidget( m_sv->viewport() ); | 166 | m_big_box = new QWidget( m_sv->viewport() ); |
169 | m_sv->addChild( m_big_box ); | 167 | m_sv->addChild( m_big_box ); |
170 | m_bblayout = new QVBoxLayout ( m_big_box ); | 168 | m_bblayout = new QVBoxLayout ( m_big_box ); |
171 | } | 169 | } |
172 | 170 | ||
173 | 171 | ||
174 | /** | 172 | /** |
175 | * Load the plugins | 173 | * Load the plugins |
176 | */ | 174 | */ |
177 | void Today::loadPlugins() { | 175 | void Today::loadPlugins() { |
178 | 176 | ||
179 | m_pluginLoader = new OPluginLoader( "today", true ); | 177 | m_pluginLoader = new OPluginLoader( "today", true ); |
180 | m_pluginLoader->setAutoDelete( true ); | 178 | m_pluginLoader->setAutoDelete( true ); |
181 | 179 | ||
182 | OPluginItem::List lst = m_pluginLoader->allAvailable( true ); | ||
183 | |||
184 | m_manager = new OPluginManager( m_pluginLoader ); | 180 | m_manager = new OPluginManager( m_pluginLoader ); |
185 | m_manager->load(); | 181 | m_manager->load(); |
186 | 182 | ||
183 | /* | ||
184 | * check if loading of Plugins crashed | ||
185 | */ | ||
186 | if( m_pluginLoader->isInSafeMode() ) { | ||
187 | QMessageBox::information(this, tr("Today Error"), | ||
188 | tr("<qt>The plugin '%1' caused Today to crash." | ||
189 | " It could be that the plugin is not properly" | ||
190 | " installed.<br>Today tries to continue loading" | ||
191 | " plugins.</qt>") | ||
192 | .arg( m_manager->crashedPlugin().name())); | ||
193 | } | ||
194 | |||
195 | OPluginItem::List lst = m_pluginLoader->filtered( true ); | ||
196 | |||
197 | |||
187 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 198 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
188 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); | 199 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); |
189 | 200 | ||
190 | TodayPlugin plugin; | 201 | TodayPlugin plugin; |
191 | plugin.iface = iface; | 202 | plugin.iface = iface; |
192 | plugin.name = (*it).name(); | 203 | plugin.name = (*it).name(); |
193 | plugin.oplugin = (*it); | 204 | plugin.oplugin = (*it); |
194 | 205 | ||
195 | plugin.guiPart = plugin.iface->guiPart(); | 206 | plugin.guiPart = plugin.iface->guiPart(); |
196 | plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); | 207 | plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); |
197 | 208 | ||
198 | // package the whole thing into a qwidget so it can be shown and hidden | 209 | // package the whole thing into a qwidget so it can be shown and hidden |
199 | plugin.guiBox = new QWidget( m_big_box ); | 210 | plugin.guiBox = new QWidget( m_big_box ); |
200 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); | 211 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); |
201 | QPixmap plugPix; | 212 | QPixmap plugPix; |
202 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); | 213 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); |
203 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); | 214 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); |
204 | plugIcon->setPixmap( plugPix ); | 215 | plugIcon->setPixmap( plugPix ); |
205 | QWhatsThis::add | 216 | QWhatsThis::add |
206 | ( plugIcon, tr("Click here to launch the associated app") ); | 217 | ( plugIcon, tr("Click here to launch the associated app") ); |
207 | plugIcon->setName( plugin.guiPart->appName() ); | 218 | plugIcon->setName( plugin.guiPart->appName() ); |
208 | connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); | 219 | connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); |
209 | 220 | ||
210 | QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox ); | 221 | QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox ); |
211 | boxLayout->addWidget( plugIcon, 0, AlignTop ); | 222 | boxLayout->addWidget( plugIcon, 0, AlignTop ); |
212 | boxLayout->addWidget( plugWidget, 0, AlignTop ); | 223 | boxLayout->addWidget( plugWidget, 0, AlignTop ); |
213 | boxLayout->setStretchFactor( plugIcon, 1 ); | 224 | boxLayout->setStretchFactor( plugIcon, 1 ); |
214 | boxLayout->setStretchFactor( plugWidget, 9 ); | 225 | boxLayout->setStretchFactor( plugWidget, 9 ); |
215 | 226 | ||
216 | pluginList.insert( plugin.name, plugin ); | 227 | pluginList.insert( plugin.name, plugin ); |
217 | m_bblayout->addWidget(plugin.guiBox); | 228 | m_bblayout->addWidget(plugin.guiBox); |
218 | } | 229 | } |
219 | 230 | ||
220 | m_bblayout->addStretch( 1 ); | 231 | m_bblayout->addStretch( 1 ); |
221 | } | 232 | } |
222 | 233 | ||
223 | 234 | ||
224 | /** | 235 | /** |
225 | * The method for the configuration dialog. | 236 | * The method for the configuration dialog. |
226 | */ | 237 | */ |
227 | void Today::startConfig() { | 238 | void Today::startConfig() { |
228 | 239 | ||
229 | // disconnect timer to prevent problems while being on config dialog | 240 | // disconnect timer to prevent problems while being on config dialog |
230 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 241 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
231 | m_refreshTimer->stop( ); | 242 | m_refreshTimer->stop( ); |
232 | 243 | ||
233 | TodayConfig conf( this, "dialog", true ); | 244 | TodayConfig conf( this, "dialog", true ); |
234 | conf.setUpPlugins( m_manager, m_pluginLoader ); | 245 | conf.setUpPlugins( m_manager, m_pluginLoader ); |
235 | 246 | ||
236 | if ( conf.exec() == QDialog::Accepted ) { | 247 | if ( QPEApplication::execDialog(&conf) == QDialog::Accepted ) { |
237 | conf.writeConfig(); | 248 | conf.writeConfig(); |
238 | initialize(); | 249 | initialize(); |
239 | } else { | 250 | } else { |
240 | // since reinitialize is not called in that case , reconnect the signal | 251 | // since reinitialize is not called in that case , reconnect the signal |
241 | m_refreshTimer->start( 15000 ); // get the config value in here later | 252 | m_refreshTimer->start( 15000 ); // get the config value in here later |
242 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 253 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
243 | } | 254 | } |
244 | } | 255 | } |
245 | 256 | ||
246 | 257 | ||
247 | void Today::initialize() { | 258 | void Today::initialize() { |
248 | 259 | ||
249 | Config cfg( "today" ); | 260 | Config cfg( "today" ); |
250 | cfg.setGroup( "Plugins" ); | 261 | cfg.setGroup( "Plugins" ); |
251 | 262 | ||
252 | 263 | ||
253 | cfg.setGroup( "General" ); | 264 | cfg.setGroup( "General" ); |
254 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 265 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
255 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); | 266 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); |
256 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); | 267 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); |
257 | 268 | ||
258 | // set the date in top label | 269 | // set the date in top label |
259 | QDate date = QDate::currentDate(); | 270 | QDate date = QDate::currentDate(); |
260 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); | 271 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); |
261 | 272 | ||
262 | if ( m_hideBanner ) { | 273 | if ( m_hideBanner ) { |
263 | Opiezilla->hide(); | 274 | Opiezilla->hide(); |
264 | TodayLabel->hide(); | 275 | TodayLabel->hide(); |
265 | } else { | 276 | } else { |
266 | Opiezilla->show(); | 277 | Opiezilla->show(); |
267 | TodayLabel->show(); | 278 | TodayLabel->show(); |
268 | } | 279 | } |
269 | 280 | ||
270 | if ( m_bblayout ) { | 281 | if ( m_bblayout ) { |
271 | delete m_bblayout; | 282 | delete m_bblayout; |
272 | } | 283 | } |
273 | m_bblayout = new QVBoxLayout ( m_big_box ); | 284 | m_bblayout = new QVBoxLayout ( m_big_box ); |
274 | 285 | ||
275 | if ( pluginList.count() == 0 ) { | 286 | if ( pluginList.count() == 0 ) { |
276 | QLabel *noPlugins = new QLabel( this ); | 287 | QLabel *noPlugins = new QLabel( this ); |
277 | noPlugins->setText( tr( "No plugins found" ) ); | 288 | noPlugins->setText( tr( "No plugins found" ) ); |
278 | layout->addWidget( noPlugins ); | 289 | layout->addWidget( noPlugins ); |
279 | } else { | 290 | } else { |
280 | 291 | ||
281 | uint count = 0; | 292 | uint count = 0; |
282 | TodayPlugin tempPlugin; | 293 | TodayPlugin tempPlugin; |
283 | OPluginItem::List lst = m_pluginLoader->allAvailable( true ); | 294 | OPluginItem::List lst = m_pluginLoader->allAvailable( true ); |
284 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 295 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
285 | 296 | ||
286 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); | 297 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); |
287 | 298 | ||
288 | tempPlugin = ( pluginList.find( (*it).name() ).data() ); | 299 | tempPlugin = ( pluginList.find( (*it).name() ).data() ); |
289 | if ( !( (tempPlugin.name).isEmpty() ) ) { | 300 | if ( !( (tempPlugin.name).isEmpty() ) ) { |
290 | if ( (*it).isEnabled() ) { | 301 | if ( (*it).isEnabled() ) { |
291 | iface->guiPart()->reinitialize(); | 302 | iface->guiPart()->reinitialize(); |
292 | odebug << "reinit" << oendl; | 303 | odebug << "reinit" << oendl; |
293 | tempPlugin.guiBox->show(); | 304 | tempPlugin.guiBox->show(); |
294 | m_bblayout->addWidget(tempPlugin.guiBox); | 305 | m_bblayout->addWidget(tempPlugin.guiBox); |
295 | count++; | 306 | count++; |
296 | } else { | 307 | } else { |
297 | tempPlugin.guiBox->hide(); | 308 | tempPlugin.guiBox->hide(); |
298 | } | 309 | } |
299 | } | 310 | } |
300 | } | 311 | } |
301 | if ( count == 0 ) { | 312 | if ( count == 0 ) { |
302 | QLabel *noPluginsActive = new QLabel( this ); | 313 | QLabel *noPluginsActive = new QLabel( this ); |
303 | noPluginsActive->setText( tr( "No plugins activated" ) ); | 314 | noPluginsActive->setText( tr( "No plugins activated" ) ); |
304 | layout->addWidget( noPluginsActive ); | 315 | layout->addWidget( noPluginsActive ); |
305 | } | 316 | } |
306 | } | 317 | } |
307 | m_bblayout->addStretch( 1 ); | 318 | m_bblayout->addStretch( 1 ); |
308 | repaint(); | 319 | repaint(); |
309 | } | 320 | } |
310 | 321 | ||
311 | /** | 322 | /** |
312 | * Refresh for the view. Reload all applets | 323 | * Refresh for the view. Reload all applets |
313 | * | 324 | * |
314 | */ | 325 | */ |
315 | void Today::refresh() { | 326 | void Today::refresh() { |
316 | 327 | ||
317 | OPluginItem::List lst = m_pluginLoader->filtered( true ); | 328 | OPluginItem::List lst = m_pluginLoader->filtered( true ); |
318 | 329 | ||
319 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 330 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
320 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); | 331 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); |
321 | iface->guiPart()->refresh(); | 332 | iface->guiPart()->refresh(); |
322 | odebug << "refresh" << oendl; | 333 | odebug << "refresh" << oendl; |
323 | } | 334 | } |
324 | 335 | ||
325 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) ); | 336 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) ); |
326 | 337 | ||
327 | updateGeometry(); | 338 | updateGeometry(); |
328 | repaint(); | 339 | repaint(); |
329 | } | 340 | } |
330 | 341 | ||
331 | 342 | ||
332 | void Today::startApplication() { | 343 | void Today::startApplication() { |
333 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 344 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
334 | e << QString( sender()->name() ); | 345 | e << QString( sender()->name() ); |
335 | } | 346 | } |
336 | 347 | ||
337 | 348 | ||
338 | /** | 349 | /** |
339 | * launch addressbook (personal card) | 350 | * launch addressbook (personal card) |
340 | */ | 351 | */ |
341 | void Today::editCard() { | 352 | void Today::editCard() { |
342 | QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); | 353 | QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); |
343 | } | 354 | } |
344 | 355 | ||
345 | 356 | ||
346 | Today::~Today() { | 357 | Today::~Today() { |
347 | if (m_pluginLoader) { | 358 | for(QMap<QString, TodayPlugin>::Iterator it = pluginList.begin(); it != pluginList.end(); ++it ) |
348 | delete m_pluginLoader; | 359 | delete it.data().guiBox; |
349 | } | 360 | |
350 | if (m_manager) { | 361 | delete m_pluginLoader; |
351 | delete m_manager; | 362 | delete m_manager; |
352 | } | ||
353 | } | 363 | } |
354 | 364 | ||
diff --git a/core/pim/today/today.h b/core/pim/today/today.h index c947ae1..dfc819d 100644 --- a/core/pim/today/today.h +++ b/core/pim/today/today.h | |||
@@ -1,91 +1,90 @@ | |||
1 | /* | 1 | /* |
2 | * today.h | 2 | * today.h |
3 | * | 3 | * |
4 | * copyright : (c) 2002,2003,2004 by Maximilian Reiß | 4 | * copyright : (c) 2002,2003,2004 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 | #ifndef TODAY_H | 16 | #ifndef TODAY_H |
17 | #define TODAY_H | 17 | #define TODAY_H |
18 | 18 | ||
19 | 19 | ||
20 | #include "todayconfig.h" | 20 | #include "todayconfig.h" |
21 | #include "todaybase.h" | 21 | #include "todaybase.h" |
22 | 22 | ||
23 | #include <opie2/todayplugininterface.h> | 23 | #include <opie2/todayplugininterface.h> |
24 | #include <opie2/oclickablelabel.h> | 24 | #include <opie2/oclickablelabel.h> |
25 | #include <opie2/opluginloader.h> | 25 | #include <opie2/opluginloader.h> |
26 | 26 | ||
27 | #include <qpe/qlibrary.h> | 27 | #include <qpe/qlibrary.h> |
28 | 28 | ||
29 | #include <qscrollview.h> | 29 | #include <qscrollview.h> |
30 | #include <qvbox.h> | 30 | #include <qvbox.h> |
31 | 31 | ||
32 | 32 | ||
33 | class QVBoxLayout; | 33 | class QVBoxLayout; |
34 | 34 | ||
35 | namespace Opie { | 35 | namespace Opie { |
36 | namespace Core { | 36 | namespace Core { |
37 | class OPluginManager; | 37 | class OPluginManager; |
38 | class OPluginLoader; | 38 | class OPluginLoader; |
39 | } | 39 | } |
40 | } | 40 | } |
41 | 41 | ||
42 | class Today : public TodayBase { | 42 | class Today : public TodayBase { |
43 | |||
44 | Q_OBJECT | 43 | Q_OBJECT |
45 | 44 | ||
46 | public: | 45 | public: |
47 | Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 46 | Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
48 | ~Today(); | 47 | ~Today(); |
49 | static QString appName() { | 48 | static QString appName() { |
50 | return QString::fromLatin1("today"); | 49 | return QString::fromLatin1("today"); |
51 | } | 50 | } |
52 | 51 | ||
53 | private slots: | 52 | private slots: |
54 | void startConfig(); | 53 | void startConfig(); |
55 | void startApplication(); | 54 | void startApplication(); |
56 | void editCard(); | 55 | void editCard(); |
57 | void refresh(); | 56 | void refresh(); |
58 | 57 | ||
59 | private: | 58 | private: |
60 | void init(); | 59 | void init(); |
61 | void setOwnerField(); | 60 | void setOwnerField(); |
62 | void setOwnerField(QString &string); | 61 | void setOwnerField(QString &string); |
63 | void initialize(); | 62 | void initialize(); |
64 | 63 | ||
65 | void setRefreshTimer( int ); | 64 | void setRefreshTimer( int ); |
66 | 65 | ||
67 | private slots: | 66 | private slots: |
68 | void channelReceived(const QCString &msg, const QByteArray & data); | 67 | void channelReceived(const QCString &msg, const QByteArray & data); |
69 | void loadPlugins(); | 68 | void loadPlugins(); |
70 | 69 | ||
71 | private: | 70 | private: |
72 | TodayConfig *conf; | 71 | TodayConfig *conf; |
73 | QStringList m_excludeApplets; | 72 | QStringList m_excludeApplets; |
74 | QStringList m_allApplets; | 73 | QStringList m_allApplets; |
75 | 74 | ||
76 | QScrollView *m_sv; | 75 | QScrollView *m_sv; |
77 | QWidget* m_big_box; | 76 | QWidget* m_big_box; |
78 | QVBoxLayout *m_bblayout; | 77 | QVBoxLayout *m_bblayout; |
79 | 78 | ||
80 | Opie::Core::OPluginLoader *m_pluginLoader; | 79 | Opie::Core::OPluginLoader *m_pluginLoader; |
81 | Opie::Core::OPluginManager *m_manager; | 80 | Opie::Core::OPluginManager *m_manager; |
82 | 81 | ||
83 | QTimer *m_refreshTimer; | 82 | QTimer *m_refreshTimer; |
84 | 83 | ||
85 | bool m_refreshTimerEnabled; | 84 | bool m_refreshTimerEnabled; |
86 | int m_newStart; | 85 | int m_newStart; |
87 | int m_iconSize; | 86 | int m_iconSize; |
88 | int m_maxCharClip; | 87 | int m_maxCharClip; |
89 | int m_hideBanner; | 88 | int m_hideBanner; |
90 | }; | 89 | }; |
91 | #endif | 90 | #endif |
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index c9823d4..dacce8b 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp | |||
@@ -1,250 +1,250 @@ | |||
1 | /* | 1 | /* |
2 | * todayconfig.cpp | 2 | * todayconfig.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002, 2003, 2004 by Maximilian Reiß | 4 | * copyright : (c) 2002, 2003, 2004 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 <opie2/oconfig.h> | 19 | #include <opie2/oconfig.h> |
20 | #include <opie2/opluginloader.h> | 20 | #include <opie2/opluginloader.h> |
21 | #include <opie2/todayplugininterface.h> | 21 | #include <opie2/todayplugininterface.h> |
22 | 22 | ||
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | 26 | ||
27 | #include <qcheckbox.h> | 27 | #include <qcheckbox.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qspinbox.h> | 29 | #include <qspinbox.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qheader.h> | 31 | #include <qheader.h> |
32 | #include <qvbox.h> | 32 | #include <qvbox.h> |
33 | #include <qtoolbutton.h> | 33 | #include <qtoolbutton.h> |
34 | #include <qwhatsthis.h> | 34 | #include <qwhatsthis.h> |
35 | 35 | ||
36 | using namespace Opie::Ui; | 36 | using namespace Opie::Ui; |
37 | using Opie::Core::OConfig; | 37 | using Opie::Core::OConfig; |
38 | using Opie::Core::OPluginManager; | 38 | using Opie::Core::OPluginManager; |
39 | using Opie::Core::OPluginLoader; | 39 | using Opie::Core::OPluginLoader; |
40 | using Opie::Core::OPluginItem; | 40 | using Opie::Core::OPluginItem; |
41 | 41 | ||
42 | class ToolButton : public QToolButton { | 42 | class ToolButton : public QToolButton { |
43 | 43 | ||
44 | public: | 44 | public: |
45 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 45 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
46 | : QToolButton( parent, name ) { | 46 | : QToolButton( parent, name ) { |
47 | setPixmap( Resource::loadPixmap( icon ) ); | 47 | setPixmap( Resource::loadPixmap( icon ) ); |
48 | setAutoRaise( TRUE ); | 48 | setAutoRaise( TRUE ); |
49 | setFocusPolicy( QWidget::NoFocus ); | 49 | setFocusPolicy( QWidget::NoFocus ); |
50 | setToggleButton( t ); | 50 | setToggleButton( t ); |
51 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 51 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
52 | } | 52 | } |
53 | }; | 53 | }; |
54 | 54 | ||
55 | 55 | ||
56 | /** | 56 | /** |
57 | * The class has currently quite some duplicate code. | 57 | * The class has currently quite some duplicate code. |
58 | * By that way it would be real easy to have it as seperate app in settings tab | 58 | * By that way it would be real easy to have it as seperate app in settings tab |
59 | * | 59 | * |
60 | */ | 60 | */ |
61 | TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) | 61 | TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) |
62 | : QDialog( parent, name, modal, WStyle_ContextHelp ) { | 62 | : QDialog( parent, name, modal, WStyle_ContextHelp ) { |
63 | 63 | ||
64 | setCaption( tr( "Today Config" ) ); | 64 | setCaption( tr( "Today Config" ) ); |
65 | 65 | ||
66 | QVBoxLayout *layout = new QVBoxLayout( this ); | 66 | QVBoxLayout *layout = new QVBoxLayout( this ); |
67 | TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 67 | TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
68 | layout->addWidget( TabWidget3 ); | 68 | layout->addWidget( TabWidget3 ); |
69 | 69 | ||
70 | tab_2 = new QWidget( TabWidget3, "tab_2" ); | 70 | tab_2 = new QWidget( TabWidget3, "tab_2" ); |
71 | QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); | 71 | QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); |
72 | QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); | 72 | QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); |
73 | tab2Layout->addWidget( l ); | 73 | tab2Layout->addWidget( l ); |
74 | QHBox *hbox1 = new QHBox( tab_2 ); | 74 | QHBox *hbox1 = new QHBox( tab_2 ); |
75 | m_appletListView = new QListView( hbox1 ); | 75 | m_appletListView = new QListView( hbox1 ); |
76 | m_appletListView->addColumn( "PluginList" ); | 76 | m_appletListView->addColumn( "PluginList" ); |
77 | m_appletListView->header()->hide(); | 77 | m_appletListView->header()->hide(); |
78 | m_appletListView->setSorting( -1 ); | 78 | m_appletListView->setSorting( -1 ); |
79 | QWhatsThis::add | 79 | QWhatsThis::add |
80 | ( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); | 80 | ( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); |
81 | QVBox *vbox1 = new QVBox( hbox1 ); | 81 | QVBox *vbox1 = new QVBox( hbox1 ); |
82 | new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); | 82 | new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); |
83 | new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); | 83 | new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); |
84 | tab2Layout->addWidget( hbox1 ); | 84 | tab2Layout->addWidget( hbox1 ); |
85 | TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) ); | 85 | TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) ); |
86 | 86 | ||
87 | // Misc tab | 87 | // Misc tab |
88 | tab_3 = new QWidget( TabWidget3, "tab_3" ); | 88 | tab_3 = new QWidget( TabWidget3, "tab_3" ); |
89 | QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); | 89 | QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); |
90 | 90 | ||
91 | m_guiMisc = new TodayConfigMiscBase( tab_3 ); | 91 | m_guiMisc = new TodayConfigMiscBase( tab_3 ); |
92 | 92 | ||
93 | tab3Layout->addWidget( m_guiMisc ); | 93 | tab3Layout->addWidget( m_guiMisc ); |
94 | TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) ); | 94 | TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) ); |
95 | 95 | ||
96 | connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) ); | 96 | connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) ); |
97 | previousItem = 0l; | 97 | previousItem = 0l; |
98 | readConfig(); | 98 | readConfig(); |
99 | QPEApplication::showDialog( this ); | ||
100 | } | 99 | } |
101 | 100 | ||
102 | 101 | ||
103 | void TodayConfig::setUpPlugins( OPluginManager * plugManager, OPluginLoader *plugLoader ) { | 102 | void TodayConfig::setUpPlugins( OPluginManager * plugManager, OPluginLoader *plugLoader ) { |
104 | 103 | m_configMap.clear(); | |
105 | 104 | ||
106 | m_pluginManager = plugManager; | 105 | m_pluginManager = plugManager; |
107 | m_pluginLoader = plugLoader; | 106 | m_pluginLoader = plugLoader; |
108 | 107 | ||
109 | OPluginItem::List inLst = m_pluginLoader->allAvailable( true ); | 108 | OPluginItem::List inLst = m_pluginLoader->allAvailable( true ); |
110 | 109 | ||
111 | OPluginItem::List lst; | 110 | OPluginItem::List lst; |
112 | for ( OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { | 111 | for ( OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { |
113 | lst.prepend((*it)); | 112 | lst.prepend((*it)); |
114 | 113 | ||
115 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); | 114 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); |
115 | TodayConfigWidget *widget = iface->guiPart()->configWidget( TabWidget3 ); | ||
116 | 116 | ||
117 | if ( iface->guiPart()->configWidget(this) != 0l ) { | 117 | if (!widget ) |
118 | TodayConfigWidget* widget = iface->guiPart()->configWidget( TabWidget3 ); | 118 | continue; |
119 | TabWidget3->addTab( widget, iface->guiPart()->pixmapNameConfig() | 119 | |
120 | , iface->guiPart()->appName() ); | 120 | m_configMap.insert( iface, widget ); |
121 | } | 121 | TabWidget3->addTab( widget, iface->guiPart()->pixmapNameConfig() |
122 | , iface->guiPart()->appName() ); | ||
122 | } | 123 | } |
123 | 124 | ||
124 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 125 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) |
125 | pluginManagement( (*it) ); | 126 | pluginManagement( (*it) ); |
126 | } | 127 | |
127 | 128 | ||
128 | TabWidget3->setCurrentTab( tab_2 ); | 129 | TabWidget3->setCurrentTab( tab_2 ); |
129 | } | 130 | } |
130 | 131 | ||
131 | /** | 132 | /** |
132 | * Autostart, uses the new (opie only) autostart method in the launcher code. | 133 | * Autostart, uses the new (opie only) autostart method in the launcher code. |
133 | * If registered against that today ist started on each resume. | 134 | * If registered against that today ist started on each resume. |
134 | */ | 135 | */ |
135 | void TodayConfig::setAutoStart() { | 136 | void TodayConfig::setAutoStart() { |
136 | OConfig cfg( "today" ); | 137 | OConfig cfg( "today" ); |
137 | cfg.setGroup( "Autostart" ); | 138 | cfg.setGroup( "Autostart" ); |
138 | if ( m_autoStart ) { | 139 | if ( m_autoStart ) { |
139 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); | 140 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); |
140 | e << QString( "add" ); | 141 | e << QString( "add" ); |
141 | e << QString( "today" ); | 142 | e << QString( "today" ); |
142 | e << QString( "%1" ).arg( m_autoStartTimer ); | 143 | e << QString( "%1" ).arg( m_autoStartTimer ); |
143 | } else { | 144 | } else { |
144 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); | 145 | QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); |
145 | e << QString( "remove" ); | 146 | e << QString( "remove" ); |
146 | e << QString( "today" ); | 147 | e << QString( "today" ); |
147 | } | 148 | } |
148 | } | 149 | } |
149 | 150 | ||
150 | /** | 151 | /** |
151 | * Read the config part | 152 | * Read the config part |
152 | */ | 153 | */ |
153 | void TodayConfig::readConfig() { | 154 | void TodayConfig::readConfig() { |
154 | OConfig cfg( "today" ); | 155 | OConfig cfg( "today" ); |
155 | cfg.setGroup( "Autostart" ); | 156 | cfg.setGroup( "Autostart" ); |
156 | m_autoStart = cfg.readNumEntry( "autostart", 1 ); | 157 | m_autoStart = cfg.readNumEntry( "autostart", 1 ); |
157 | m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); | 158 | m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); |
158 | m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 ); | 159 | m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 ); |
159 | m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer ); | 160 | m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer ); |
160 | 161 | ||
161 | cfg.setGroup( "General" ); | 162 | cfg.setGroup( "General" ); |
162 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 163 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
163 | m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); | 164 | m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); |
164 | m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 ); | 165 | m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 ); |
165 | m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); | 166 | m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); |
166 | } | 167 | } |
167 | 168 | ||
168 | /** | 169 | /** |
169 | * Write the config part | 170 | * Write the config part |
170 | */ | 171 | */ |
171 | void TodayConfig::writeConfig() { | 172 | void TodayConfig::writeConfig() { |
172 | OConfig cfg( "today" ); | 173 | OConfig cfg( "today" ); |
173 | 174 | ||
174 | int position = m_appletListView->childCount(); | 175 | int position = m_appletListView->childCount(); |
175 | 176 | ||
176 | QListViewItemIterator list_it( m_appletListView ); | 177 | QListViewItemIterator list_it( m_appletListView ); |
177 | // | 178 | OPluginItem::List lst = m_pluginLoader->allAvailable( true ); |
179 | |||
178 | // this makes sure the names get saved in the order selected | 180 | // this makes sure the names get saved in the order selected |
179 | for ( ; list_it.current(); ++list_it ) { | 181 | for ( ; list_it.current(); ++list_it ) { |
180 | OPluginItem::List lst = m_pluginLoader->allAvailable( true ); | ||
181 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 182 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
182 | if ( QString::compare( (*it).name() , list_it.current()->text(0) ) == 0 ) { | 183 | if ( QString::compare( (*it).name() , list_it.current()->text(0) ) == 0 ) { |
183 | (*it).setPosition(position--); | 184 | (*it).setPosition(position--); |
184 | m_pluginManager->setEnabled( (*it),((QCheckListItem*)list_it.current())->isOn() ); | 185 | m_pluginManager->setEnabled( (*it),((QCheckListItem*)list_it.current())->isOn() ); |
185 | } | 186 | } |
186 | } | 187 | } |
187 | } | 188 | } |
188 | 189 | ||
189 | m_pluginManager->save(); | 190 | m_pluginManager->save(); |
190 | 191 | ||
191 | cfg.setGroup( "Autostart" ); | 192 | cfg.setGroup( "Autostart" ); |
192 | m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); | 193 | m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); |
193 | cfg.writeEntry( "autostart", m_autoStart ); | 194 | cfg.writeEntry( "autostart", m_autoStart ); |
194 | m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); | 195 | m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); |
195 | cfg.writeEntry( "autostartdelay", m_autoStartTimer ); | 196 | cfg.writeEntry( "autostartdelay", m_autoStartTimer ); |
196 | m_iconSize = m_guiMisc->SpinBoxIconSize->value(); | 197 | m_iconSize = m_guiMisc->SpinBoxIconSize->value(); |
197 | 198 | ||
198 | cfg.setGroup( "General" ); | 199 | cfg.setGroup( "General" ); |
199 | cfg.writeEntry( "IconSize", m_iconSize ); | 200 | cfg.writeEntry( "IconSize", m_iconSize ); |
200 | cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() ); | 201 | cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() ); |
201 | cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 ); | 202 | cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 ); |
202 | 203 | ||
203 | // set autostart settings | 204 | // set autostart settings |
204 | setAutoStart(); | 205 | setAutoStart(); |
205 | 206 | ||
206 | OPluginItem::List lst = m_pluginManager->managedPlugins(); | 207 | OPluginItem::List managedLst = m_pluginManager->managedPlugins(); |
207 | for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 208 | for ( OPluginItem::List::Iterator it = managedLst.begin(); it != managedLst.end(); ++it ) { |
208 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); | 209 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface ); |
209 | if ( iface->guiPart()->configWidget(this) != 0l ) { | 210 | if ( m_configMap.contains( iface ) ) |
210 | iface->guiPart()->configWidget(this)->writeConfig(); | 211 | m_configMap[iface]->writeConfig(); |
211 | } | ||
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | void TodayConfig::moveSelectedUp() { | 216 | void TodayConfig::moveSelectedUp() { |
217 | QListViewItem *item = m_appletListView->selectedItem(); | 217 | QListViewItem *item = m_appletListView->selectedItem(); |
218 | if ( item && item->itemAbove() ) { | 218 | if ( item && item->itemAbove() ) { |
219 | item->itemAbove()->moveItem( item ); | 219 | item->itemAbove()->moveItem( item ); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | 223 | ||
224 | void TodayConfig::moveSelectedDown() { | 224 | void TodayConfig::moveSelectedDown() { |
225 | QListViewItem *item = m_appletListView->selectedItem(); | 225 | QListViewItem *item = m_appletListView->selectedItem(); |
226 | if ( item && item->itemBelow() ) { | 226 | if ( item && item->itemBelow() ) { |
227 | item->moveItem( item->itemBelow() ); | 227 | item->moveItem( item->itemBelow() ); |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | /** | 232 | /** |
233 | * Set up the icons in the order/active tab | 233 | * Set up the icons in the order/active tab |
234 | */ | 234 | */ |
235 | void TodayConfig::pluginManagement( OPluginItem plugItem ) { | 235 | void TodayConfig::pluginManagement( OPluginItem plugItem ) { |
236 | 236 | ||
237 | QCheckListItem *item = new QCheckListItem( m_appletListView, plugItem.name(), QCheckListItem::CheckBox ); | 237 | QCheckListItem *item = new QCheckListItem( m_appletListView, plugItem.name(), QCheckListItem::CheckBox ); |
238 | 238 | ||
239 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( plugItem, IID_TodayPluginInterface ); | 239 | TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( plugItem, IID_TodayPluginInterface ); |
240 | QPixmap icon = Resource::loadPixmap( iface->guiPart()->pixmapNameWidget() ); | 240 | QPixmap icon = Resource::loadPixmap( iface->guiPart()->pixmapNameWidget() ); |
241 | if ( !icon.isNull() ) { | 241 | if ( !icon.isNull() ) { |
242 | item->setPixmap( 0, icon ); | 242 | item->setPixmap( 0, icon ); |
243 | } | 243 | } |
244 | item->setOn( plugItem.isEnabled() ); | 244 | item->setOn( plugItem.isEnabled() ); |
245 | previousItem = item; | 245 | previousItem = item; |
246 | } | 246 | } |
247 | 247 | ||
248 | 248 | ||
249 | 249 | ||
250 | TodayConfig::~TodayConfig() {} | 250 | TodayConfig::~TodayConfig() {} |
diff --git a/core/pim/today/todayconfig.h b/core/pim/today/todayconfig.h index ab79f31..81120d3 100644 --- a/core/pim/today/todayconfig.h +++ b/core/pim/today/todayconfig.h | |||
@@ -1,87 +1,89 @@ | |||
1 | /* | 1 | /* |
2 | * todayconfig.h | 2 | * todayconfig.h |
3 | * | 3 | * |
4 | * copyright : (c) 2002,2003, 2004 by Maximilian Reiß | 4 | * copyright : (c) 2002,2003, 2004 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 "todayconfigmiscbase.h" | 20 | #include "todayconfigmiscbase.h" |
21 | 21 | ||
22 | #include <opie2/otabwidget.h> | 22 | #include <opie2/otabwidget.h> |
23 | #include <opie2/opluginloader.h> | 23 | #include <opie2/opluginloader.h> |
24 | 24 | ||
25 | #include <qvariant.h> | 25 | #include <qvariant.h> |
26 | #include <qdialog.h> | 26 | #include <qdialog.h> |
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | 28 | ||
29 | class QCheckBox; | 29 | class QCheckBox; |
30 | class QLabel; | 30 | class QLabel; |
31 | class QSpinBox; | 31 | class QSpinBox; |
32 | class QTabWidget; | 32 | class QTabWidget; |
33 | class TodayConfigWidget; | ||
34 | class TodayPluginInterface; | ||
33 | 35 | ||
34 | namespace Opie { | 36 | namespace Opie { |
35 | namespace Core { | 37 | namespace Core { |
36 | class OPluginManager; | 38 | class OPluginManager; |
37 | class OPluginLoader; | 39 | class OPluginLoader; |
38 | class OPluginItem; | 40 | class OPluginItem; |
39 | } | 41 | } |
40 | } | 42 | } |
41 | 43 | ||
42 | class TodayConfig : public QDialog { | 44 | class TodayConfig : public QDialog { |
43 | |||
44 | Q_OBJECT | 45 | Q_OBJECT |
45 | 46 | ||
46 | public: | 47 | public: |
47 | TodayConfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE ); | 48 | TodayConfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE ); |
48 | ~TodayConfig(); | 49 | ~TodayConfig(); |
49 | 50 | ||
50 | Opie::Ui::OTabWidget* TabWidget3; | 51 | Opie::Ui::OTabWidget* TabWidget3; |
51 | 52 | ||
52 | void writeConfig(); | 53 | void writeConfig(); |
53 | 54 | ||
54 | void setUpPlugins( Opie::Core::OPluginManager * plugManager, Opie::Core::OPluginLoader * plugLoader ); | 55 | void setUpPlugins( Opie::Core::OPluginManager * plugManager, Opie::Core::OPluginLoader * plugLoader ); |
55 | 56 | ||
56 | protected slots: | 57 | protected slots: |
57 | void moveSelectedUp(); | 58 | void moveSelectedUp(); |
58 | void moveSelectedDown(); | 59 | void moveSelectedDown(); |
59 | 60 | ||
60 | private: | 61 | private: |
61 | void setAutoStart(); | 62 | void setAutoStart(); |
62 | void readConfig(); | 63 | void readConfig(); |
63 | void pluginManagement( Opie::Core::OPluginItem plugItem); | 64 | void pluginManagement( Opie::Core::OPluginItem plugItem); |
64 | 65 | ||
65 | QListView* m_appletListView; | 66 | QListView* m_appletListView; |
66 | QMap<QString,QCheckListItem*> m_applets; | 67 | QMap<QString,QCheckListItem*> m_applets; |
68 | QMap<TodayPluginInterface*,TodayConfigWidget*> m_configMap; | ||
67 | 69 | ||
68 | int m_autoStart; | 70 | int m_autoStart; |
69 | int m_autoStartTimer; | 71 | int m_autoStartTimer; |
70 | int m_iconSize; | 72 | int m_iconSize; |
71 | QStringList m_excludeApplets; | 73 | QStringList m_excludeApplets; |
72 | bool m_applets_changed; | 74 | bool m_applets_changed; |
73 | 75 | ||
74 | QWidget* tab_2; | 76 | QWidget* tab_2; |
75 | QWidget* tab_3; | 77 | QWidget* tab_3; |
76 | QLabel* TextLabel1, *TextLabel4; | 78 | QLabel* TextLabel1, *TextLabel4; |
77 | QSpinBox* SpinBox7; | 79 | QSpinBox* SpinBox7; |
78 | 80 | ||
79 | Opie::Core::OPluginManager *m_pluginManager; | 81 | Opie::Core::OPluginManager *m_pluginManager; |
80 | Opie::Core::OPluginLoader *m_pluginLoader; | 82 | Opie::Core::OPluginLoader *m_pluginLoader; |
81 | 83 | ||
82 | QCheckListItem *previousItem; | 84 | QCheckListItem *previousItem; |
83 | 85 | ||
84 | TodayConfigMiscBase *m_guiMisc; | 86 | TodayConfigMiscBase *m_guiMisc; |
85 | }; | 87 | }; |
86 | 88 | ||
87 | #endif | 89 | #endif |