author | alwin <alwin> | 2004-11-09 20:19:53 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-11-09 20:19:53 (UTC) |
commit | c7b97ac140de31282dba2463a00f434c7a5bba69 (patch) (unidiff) | |
tree | 3be0a497f30d2265359e99dbc0951ab0b594e865 | |
parent | 439b89dbda8afb2deeb0461dcd249a3e80131825 (diff) | |
download | opie-c7b97ac140de31282dba2463a00f434c7a5bba69.zip opie-c7b97ac140de31282dba2463a00f434c7a5bba69.tar.gz opie-c7b97ac140de31282dba2463a00f434c7a5bba69.tar.bz2 |
- removed code which let qpe crash when generating image icons
- when edit properties of an document item it will reread the table of categories
-rw-r--r-- | core/launcher/launcher.cpp | 18 | ||||
-rw-r--r-- | core/launcher/launcherview.cpp | 127 | ||||
-rw-r--r-- | core/launcher/launcherview.h | 1 |
3 files changed, 70 insertions, 76 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 010a2e9..5ec1cf8 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -104,678 +104,680 @@ LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : | |||
104 | createDocLoadingWidget(); | 104 | createDocLoadingWidget(); |
105 | } | 105 | } |
106 | 106 | ||
107 | void LauncherTabWidget::createDocLoadingWidget() | 107 | void LauncherTabWidget::createDocLoadingWidget() |
108 | { | 108 | { |
109 | // Construct the 'doc loading widget' shown when finding documents | 109 | // Construct the 'doc loading widget' shown when finding documents |
110 | 110 | ||
111 | // ### LauncherView class needs changing to be more generic so | 111 | // ### LauncherView class needs changing to be more generic so |
112 | // this widget can change its background similar to the iconviews | 112 | // this widget can change its background similar to the iconviews |
113 | // so the background for this matches | 113 | // so the background for this matches |
114 | docLoadingWidget = new LauncherView( stack ); | 114 | docLoadingWidget = new LauncherView( stack ); |
115 | docLoadingWidget->hideIcons(); | 115 | docLoadingWidget->hideIcons(); |
116 | QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); | 116 | QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); |
117 | 117 | ||
118 | docLoadingVBox->setSpacing( 20 ); | 118 | docLoadingVBox->setSpacing( 20 ); |
119 | docLoadingVBox->setMargin( 10 ); | 119 | docLoadingVBox->setMargin( 10 ); |
120 | 120 | ||
121 | QWidget *space1 = new QWidget( docLoadingVBox ); | 121 | QWidget *space1 = new QWidget( docLoadingVBox ); |
122 | docLoadingVBox->setStretchFactor( space1, 1 ); | 122 | docLoadingVBox->setStretchFactor( space1, 1 ); |
123 | 123 | ||
124 | QLabel *waitPixmap = new QLabel( docLoadingVBox ); | 124 | QLabel *waitPixmap = new QLabel( docLoadingVBox ); |
125 | waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); | 125 | waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); |
126 | waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); | 126 | waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); |
127 | waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); | 127 | waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); |
128 | 128 | ||
129 | Config cfg( "Launcher" ); | 129 | Config cfg( "Launcher" ); |
130 | cfg.setGroup( "DocTab" ); | 130 | cfg.setGroup( "DocTab" ); |
131 | bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); | 131 | bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); |
132 | 132 | ||
133 | QLabel *textLabel = new QLabel( docLoadingVBox ); | 133 | QLabel *textLabel = new QLabel( docLoadingVBox ); |
134 | textLabel->setAlignment( int( QLabel::AlignCenter ) ); | 134 | textLabel->setAlignment( int( QLabel::AlignCenter ) ); |
135 | docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); | 135 | docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); |
136 | docLoadingWidgetProgress->setProgress( 0 ); | 136 | docLoadingWidgetProgress->setProgress( 0 ); |
137 | docLoadingWidgetProgress->setCenterIndicator( TRUE ); | 137 | docLoadingWidgetProgress->setCenterIndicator( TRUE ); |
138 | docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker | 138 | docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker |
139 | setProgressStyle(); | 139 | setProgressStyle(); |
140 | 140 | ||
141 | if ( docTabEnabled ) | 141 | if ( docTabEnabled ) |
142 | { | 142 | { |
143 | textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); | 143 | textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); |
144 | } | 144 | } |
145 | else | 145 | else |
146 | { | 146 | { |
147 | textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" | 147 | textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" |
148 | "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); | 148 | "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); |
149 | docLoadingWidgetProgress->hide(); | 149 | docLoadingWidgetProgress->hide(); |
150 | docLoadingWidgetEnabled = true; | 150 | docLoadingWidgetEnabled = true; |
151 | } | 151 | } |
152 | 152 | ||
153 | QWidget *space2 = new QWidget( docLoadingVBox ); | 153 | QWidget *space2 = new QWidget( docLoadingVBox ); |
154 | docLoadingVBox->setStretchFactor( space2, 1 ); | 154 | docLoadingVBox->setStretchFactor( space2, 1 ); |
155 | 155 | ||
156 | cfg.setGroup( "Tab Documents" ); // No tr | 156 | cfg.setGroup( "Tab Documents" ); // No tr |
157 | setTabViewAppearance( docLoadingWidget, cfg ); | 157 | setTabViewAppearance( docLoadingWidget, cfg ); |
158 | 158 | ||
159 | stack->addWidget( docLoadingWidget, 0 ); | 159 | stack->addWidget( docLoadingWidget, 0 ); |
160 | } | 160 | } |
161 | 161 | ||
162 | void LauncherTabWidget::initLayout() | 162 | void LauncherTabWidget::initLayout() |
163 | { | 163 | { |
164 | layout()->activate(); | 164 | layout()->activate(); |
165 | docView()->setFocus(); | 165 | docView()->setFocus(); |
166 | categoryBar->showTab("Documents"); | 166 | categoryBar->showTab("Documents"); |
167 | } | 167 | } |
168 | 168 | ||
169 | void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) | 169 | void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) |
170 | { | 170 | { |
171 | if ( message == "nextView()" ) | 171 | if ( message == "nextView()" ) |
172 | categoryBar->nextTab(); | 172 | categoryBar->nextTab(); |
173 | } | 173 | } |
174 | 174 | ||
175 | void LauncherTabWidget::raiseTabWidget() | 175 | void LauncherTabWidget::raiseTabWidget() |
176 | { | 176 | { |
177 | if ( categoryBar->currentView() == docView() | 177 | if ( categoryBar->currentView() == docView() |
178 | && docLoadingWidgetEnabled ) { | 178 | && docLoadingWidgetEnabled ) { |
179 | stack->raiseWidget( docLoadingWidget ); | 179 | stack->raiseWidget( docLoadingWidget ); |
180 | docLoadingWidget->updateGeometry(); | 180 | docLoadingWidget->updateGeometry(); |
181 | } else { | 181 | } else { |
182 | stack->raiseWidget( categoryBar->currentView() ); | 182 | stack->raiseWidget( categoryBar->currentView() ); |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | void LauncherTabWidget::tabProperties() | 186 | void LauncherTabWidget::tabProperties() |
187 | { | 187 | { |
188 | LauncherView *view = categoryBar->currentView(); | 188 | LauncherView *view = categoryBar->currentView(); |
189 | QPopupMenu *m = new QPopupMenu( this ); | 189 | QPopupMenu *m = new QPopupMenu( this ); |
190 | m->insertItem( tr("Icon View"), LauncherView::Icon ); | 190 | m->insertItem( tr("Icon View"), LauncherView::Icon ); |
191 | m->insertItem( tr("List View"), LauncherView::List ); | 191 | m->insertItem( tr("List View"), LauncherView::List ); |
192 | m->setItemChecked( (int)view->viewMode(), TRUE ); | 192 | m->setItemChecked( (int)view->viewMode(), TRUE ); |
193 | int rv = m->exec( QCursor::pos() ); | 193 | int rv = m->exec( QCursor::pos() ); |
194 | if ( rv >= 0 && rv != view->viewMode() ) { | 194 | if ( rv >= 0 && rv != view->viewMode() ) { |
195 | view->setViewMode( (LauncherView::ViewMode)rv ); | 195 | view->setViewMode( (LauncherView::ViewMode)rv ); |
196 | } | 196 | } |
197 | 197 | ||
198 | delete m; | 198 | delete m; |
199 | } | 199 | } |
200 | 200 | ||
201 | void LauncherTabWidget::deleteView( const QString& id ) | 201 | void LauncherTabWidget::deleteView( const QString& id ) |
202 | { | 202 | { |
203 | LauncherTab *t = categoryBar->launcherTab(id); | 203 | LauncherTab *t = categoryBar->launcherTab(id); |
204 | if ( t ) { | 204 | if ( t ) { |
205 | stack->removeWidget( t->view ); | 205 | stack->removeWidget( t->view ); |
206 | delete t->view; | 206 | delete t->view; |
207 | categoryBar->removeTab( t ); | 207 | categoryBar->removeTab( t ); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 211 | LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
212 | { | 212 | { |
213 | LauncherView* view = new LauncherView( stack ); | 213 | LauncherView* view = new LauncherView( stack ); |
214 | connect( view, SIGNAL(clicked(const AppLnk*)), | 214 | connect( view, SIGNAL(clicked(const AppLnk*)), |
215 | this, SIGNAL(clicked(const AppLnk*))); | 215 | this, SIGNAL(clicked(const AppLnk*))); |
216 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 216 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
217 | this, SIGNAL(rightPressed(AppLnk*))); | 217 | this, SIGNAL(rightPressed(AppLnk*))); |
218 | 218 | ||
219 | int n = categoryBar->count(); | 219 | int n = categoryBar->count(); |
220 | stack->addWidget( view, n ); | 220 | stack->addWidget( view, n ); |
221 | 221 | ||
222 | LauncherTab *tab = new LauncherTab( id, view, pm, label ); | 222 | LauncherTab *tab = new LauncherTab( id, view, pm, label ); |
223 | categoryBar->insertTab( tab, n-1 ); | 223 | categoryBar->insertTab( tab, n-1 ); |
224 | 224 | ||
225 | if ( id == "Documents" ) | 225 | if ( id == "Documents" ) |
226 | docview = view; | 226 | docview = view; |
227 | 227 | ||
228 | odebug << "inserting " << id << " at " << n-1 << "" << oendl; | 228 | odebug << "inserting " << id << " at " << n-1 << "" << oendl; |
229 | 229 | ||
230 | Config cfg("Launcher"); | 230 | Config cfg("Launcher"); |
231 | setTabAppearance( tab, cfg ); | 231 | setTabAppearance( tab, cfg ); |
232 | 232 | ||
233 | cfg.setGroup( "GUI" ); | 233 | cfg.setGroup( "GUI" ); |
234 | view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); | 234 | view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); |
235 | 235 | ||
236 | return view; | 236 | return view; |
237 | } | 237 | } |
238 | 238 | ||
239 | LauncherView *LauncherTabWidget::view( const QString &id ) | 239 | LauncherView *LauncherTabWidget::view( const QString &id ) |
240 | { | 240 | { |
241 | LauncherTab *t = categoryBar->launcherTab(id); | 241 | LauncherTab *t = categoryBar->launcherTab(id); |
242 | if ( !t ) | 242 | if ( !t ) |
243 | return 0; | 243 | return 0; |
244 | return t->view; | 244 | return t->view; |
245 | } | 245 | } |
246 | 246 | ||
247 | LauncherView *LauncherTabWidget::docView() | 247 | LauncherView *LauncherTabWidget::docView() |
248 | { | 248 | { |
249 | return docview; | 249 | return docview; |
250 | } | 250 | } |
251 | 251 | ||
252 | void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) | 252 | void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) |
253 | { | 253 | { |
254 | if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { | 254 | if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { |
255 | docLoadingWidgetEnabled = v; | 255 | docLoadingWidgetEnabled = v; |
256 | raiseTabWidget(); | 256 | raiseTabWidget(); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | void LauncherTabWidget::setLoadingProgress( int percent ) | 260 | void LauncherTabWidget::setLoadingProgress( int percent ) |
261 | { | 261 | { |
262 | docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); | 262 | docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); |
263 | } | 263 | } |
264 | 264 | ||
265 | // ### this function could more to LauncherView | 265 | // ### this function could more to LauncherView |
266 | void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) | 266 | void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) |
267 | { | 267 | { |
268 | // View | 268 | // View |
269 | QString view = cfg.readEntry( "View", "Icon" ); | 269 | QString view = cfg.readEntry( "View", "Icon" ); |
270 | if ( view == "List" ) // No tr | 270 | if ( view == "List" ) // No tr |
271 | v->setViewMode( LauncherView::List ); | 271 | v->setViewMode( LauncherView::List ); |
272 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); | 272 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); |
273 | if ( bgType == "Image" ) { // No tr | 273 | if ( bgType == "Image" ) { // No tr |
274 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); | 274 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); |
275 | v->setBackgroundType( LauncherView::Image, pm ); | 275 | v->setBackgroundType( LauncherView::Image, pm ); |
276 | } else if ( bgType == "SolidColor" ) { | 276 | } else if ( bgType == "SolidColor" ) { |
277 | QString c = cfg.readEntry( "BackgroundColor" ); | 277 | QString c = cfg.readEntry( "BackgroundColor" ); |
278 | v->setBackgroundType( LauncherView::SolidColor, c ); | 278 | v->setBackgroundType( LauncherView::SolidColor, c ); |
279 | } else { | 279 | } else { |
280 | v->setBackgroundType( LauncherView::Ruled, QString::null ); | 280 | v->setBackgroundType( LauncherView::Ruled, QString::null ); |
281 | } | 281 | } |
282 | QString textCol = cfg.readEntry( "TextColor" ); | 282 | QString textCol = cfg.readEntry( "TextColor" ); |
283 | if ( textCol.isEmpty() ) | 283 | if ( textCol.isEmpty() ) |
284 | v->setTextColor( QColor() ); | 284 | v->setTextColor( QColor() ); |
285 | else | 285 | else |
286 | v->setTextColor( QColor(textCol) ); | 286 | v->setTextColor( QColor(textCol) ); |
287 | // bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); | 287 | // bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); |
288 | 288 | ||
289 | 289 | ||
290 | QStringList font = cfg.readListEntry( "Font", ',' ); | 290 | QStringList font = cfg.readListEntry( "Font", ',' ); |
291 | if ( font.count() == 4 ) | 291 | if ( font.count() == 4 ) |
292 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); | 292 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); |
293 | 293 | ||
294 | // ### FIXME TabColor TabTextColor | 294 | // ### FIXME TabColor TabTextColor |
295 | 295 | ||
296 | } | 296 | } |
297 | 297 | ||
298 | // ### Could move to LauncherTab | 298 | // ### Could move to LauncherTab |
299 | void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) | 299 | void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) |
300 | { | 300 | { |
301 | cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr | 301 | cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr |
302 | 302 | ||
303 | setTabViewAppearance( tab->view, cfg ); | 303 | setTabViewAppearance( tab->view, cfg ); |
304 | 304 | ||
305 | // Tabs | 305 | // Tabs |
306 | QString tabCol = cfg.readEntry( "TabColor" ); | 306 | QString tabCol = cfg.readEntry( "TabColor" ); |
307 | if ( tabCol.isEmpty() ) | 307 | if ( tabCol.isEmpty() ) |
308 | tab->bgColor = QColor(); | 308 | tab->bgColor = QColor(); |
309 | else | 309 | else |
310 | tab->bgColor = QColor(tabCol); | 310 | tab->bgColor = QColor(tabCol); |
311 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); | 311 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); |
312 | if ( tabTextCol.isEmpty() ) | 312 | if ( tabTextCol.isEmpty() ) |
313 | tab->fgColor = QColor(); | 313 | tab->fgColor = QColor(); |
314 | else | 314 | else |
315 | tab->fgColor = QColor(tabTextCol); | 315 | tab->fgColor = QColor(tabTextCol); |
316 | } | 316 | } |
317 | 317 | ||
318 | void LauncherTabWidget::paletteChange( const QPalette &p ) | 318 | void LauncherTabWidget::paletteChange( const QPalette &p ) |
319 | { | 319 | { |
320 | QVBox::paletteChange( p ); | 320 | QVBox::paletteChange( p ); |
321 | QPalette pal = palette(); | 321 | QPalette pal = palette(); |
322 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 322 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
323 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 323 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
324 | categoryBar->setPalette( pal ); | 324 | categoryBar->setPalette( pal ); |
325 | categoryBar->update(); | 325 | categoryBar->update(); |
326 | } | 326 | } |
327 | 327 | ||
328 | void LauncherTabWidget::styleChange( QStyle & ) | 328 | void LauncherTabWidget::styleChange( QStyle & ) |
329 | { | 329 | { |
330 | QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); | 330 | QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); |
331 | } | 331 | } |
332 | 332 | ||
333 | void LauncherTabWidget::setProgressStyle() | 333 | void LauncherTabWidget::setProgressStyle() |
334 | { | 334 | { |
335 | if (docLoadingWidgetProgress) { | 335 | if (docLoadingWidgetProgress) { |
336 | docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); | 336 | docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); |
337 | docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); | 337 | docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); |
338 | docLoadingWidgetProgress->setMargin( 1 ); | 338 | docLoadingWidgetProgress->setMargin( 1 ); |
339 | docLoadingWidgetProgress->setLineWidth( 1 ); | 339 | docLoadingWidgetProgress->setLineWidth( 1 ); |
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | /* | 343 | /* |
344 | * FIXME | 344 | * FIXME |
345 | * The following NULL check is triggered by inserting, then removing a tab on the fly | 345 | * The following NULL check is triggered by inserting, then removing a tab on the fly |
346 | * as you would if you had removable media (which I do). Without this check | 346 | * as you would if you had removable media (which I do). Without this check |
347 | * the first app launched after a tab removal causes qpe to Segfault. | 347 | * the first app launched after a tab removal causes qpe to Segfault. |
348 | * This obviously has a more sinister cause, but this works around it with no | 348 | * This obviously has a more sinister cause, but this works around it with no |
349 | * obvious adverse effects. Please FIXME | 349 | * obvious adverse effects. Please FIXME |
350 | * bkc - 17/6/2004 | 350 | * bkc - 17/6/2004 |
351 | * | 351 | * |
352 | */ | 352 | */ |
353 | 353 | ||
354 | void LauncherTabWidget::setBusy(bool on) | 354 | void LauncherTabWidget::setBusy(bool on) |
355 | { | 355 | { |
356 | if ( on ) | 356 | if ( on ) |
357 | currentView()->setBusy(TRUE); | 357 | currentView()->setBusy(TRUE); |
358 | else { | 358 | else { |
359 | for ( int i = 0; i < categoryBar->count(); i++ ) { | 359 | for ( int i = 0; i < categoryBar->count(); i++ ) { |
360 | if (categoryBar->tab(i)) { | 360 | if (categoryBar->tab(i)) { |
361 | LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; | 361 | LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; |
362 | view->setBusy( FALSE ); | 362 | view->setBusy( FALSE ); |
363 | } else { | 363 | } else { |
364 | odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl; | 364 | odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl; |
365 | } | 365 | } |
366 | } | 366 | } |
367 | } | 367 | } |
368 | } | 368 | } |
369 | 369 | ||
370 | void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { | 370 | void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { |
371 | for (int i = 0; i < categoryBar->count(); i++ ) { | 371 | for (int i = 0; i < categoryBar->count(); i++ ) { |
372 | LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; | 372 | LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; |
373 | view->setBusyIndicatorType( str ); | 373 | view->setBusyIndicatorType( str ); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | 376 | ||
377 | LauncherView *LauncherTabWidget::currentView(void) | 377 | LauncherView *LauncherTabWidget::currentView(void) |
378 | { | 378 | { |
379 | return (LauncherView*)stack->visibleWidget(); | 379 | return (LauncherView*)stack->visibleWidget(); |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | 383 | ||
384 | void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) | 384 | void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) |
385 | { | 385 | { |
386 | QDataStream stream( data, IO_ReadOnly ); | 386 | QDataStream stream( data, IO_ReadOnly ); |
387 | if ( msg == "setTabView(QString,int)" ) { | 387 | if ( msg == "setTabView(QString,int)" ) { |
388 | QString id; | 388 | QString id; |
389 | stream >> id; | 389 | stream >> id; |
390 | int mode; | 390 | int mode; |
391 | stream >> mode; | 391 | stream >> mode; |
392 | if ( view(id) ) | 392 | if ( view(id) ) |
393 | view(id)->setViewMode( (LauncherView::ViewMode)mode ); | 393 | view(id)->setViewMode( (LauncherView::ViewMode)mode ); |
394 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { | 394 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { |
395 | QString id; | 395 | QString id; |
396 | stream >> id; | 396 | stream >> id; |
397 | int mode; | 397 | int mode; |
398 | stream >> mode; | 398 | stream >> mode; |
399 | QString pixmapOrColor; | 399 | QString pixmapOrColor; |
400 | stream >> pixmapOrColor; | 400 | stream >> pixmapOrColor; |
401 | if ( view(id) ) | 401 | if ( view(id) ) |
402 | view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 402 | view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
403 | if ( id == "Documents" ) | 403 | if ( id == "Documents" ) |
404 | docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 404 | docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
405 | } else if ( msg == "setTextColor(QString,QString)" ) { | 405 | } else if ( msg == "setTextColor(QString,QString)" ) { |
406 | QString id; | 406 | QString id; |
407 | stream >> id; | 407 | stream >> id; |
408 | QString color; | 408 | QString color; |
409 | stream >> color; | 409 | stream >> color; |
410 | if ( view(id) ) | 410 | if ( view(id) ) |
411 | view(id)->setTextColor( QColor(color) ); | 411 | view(id)->setTextColor( QColor(color) ); |
412 | if ( id == "Documents" ) | 412 | if ( id == "Documents" ) |
413 | docLoadingWidget->setTextColor( QColor(color) ); | 413 | docLoadingWidget->setTextColor( QColor(color) ); |
414 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { | 414 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { |
415 | QString id; | 415 | QString id; |
416 | stream >> id; | 416 | stream >> id; |
417 | QString fam; | 417 | QString fam; |
418 | stream >> fam; | 418 | stream >> fam; |
419 | int size; | 419 | int size; |
420 | stream >> size; | 420 | stream >> size; |
421 | int weight; | 421 | int weight; |
422 | stream >> weight; | 422 | stream >> weight; |
423 | int italic; | 423 | int italic; |
424 | stream >> italic; | 424 | stream >> italic; |
425 | if ( view(id) ) { | 425 | if ( view(id) ) { |
426 | if ( !fam.isEmpty() ) { | 426 | if ( !fam.isEmpty() ) { |
427 | view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); | 427 | view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); |
428 | odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; | 428 | odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; |
429 | } else { | 429 | } else { |
430 | view(id)->clearViewFont(); | 430 | view(id)->clearViewFont(); |
431 | } | 431 | } |
432 | } | 432 | } |
433 | }else if ( msg == "setBusyIndicatorType(QString)" ) { | 433 | }else if ( msg == "setBusyIndicatorType(QString)" ) { |
434 | QString type; | 434 | QString type; |
435 | stream >> type; | 435 | stream >> type; |
436 | setBusyIndicatorType( type ); | 436 | setBusyIndicatorType( type ); |
437 | }else if ( msg == "home()" ) { | 437 | }else if ( msg == "home()" ) { |
438 | if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { | 438 | if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { |
439 | if (categoryBar) | 439 | if (categoryBar) |
440 | categoryBar->nextTab(); | 440 | categoryBar->nextTab(); |
441 | }else | 441 | }else |
442 | static_cast<QWidget*>(parent())->raise(); | 442 | static_cast<QWidget*>(parent())->raise(); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | 447 | ||
448 | //--------------------------------------------------------------------------- | 448 | //--------------------------------------------------------------------------- |
449 | 449 | ||
450 | Launcher::Launcher() | 450 | Launcher::Launcher() |
451 | : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) | 451 | : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) |
452 | { | 452 | { |
453 | tabs = 0; | 453 | tabs = 0; |
454 | tb = 0; | 454 | tb = 0; |
455 | Config cfg( "Launcher" ); | 455 | Config cfg( "Launcher" ); |
456 | cfg.setGroup( "DocTab" ); | 456 | cfg.setGroup( "DocTab" ); |
457 | docTabEnabled = cfg.readBoolEntry( "Enable", true ); | 457 | docTabEnabled = cfg.readBoolEntry( "Enable", true ); |
458 | } | 458 | } |
459 | 459 | ||
460 | void Launcher::createGUI() | 460 | void Launcher::createGUI() |
461 | { | 461 | { |
462 | setCaption( tr("Launcher") ); | 462 | setCaption( tr("Launcher") ); |
463 | 463 | ||
464 | // we have a pretty good idea how big we'll be | 464 | // we have a pretty good idea how big we'll be |
465 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 465 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
466 | 466 | ||
467 | tb = new TaskBar; | 467 | tb = new TaskBar; |
468 | tabs = new LauncherTabWidget( this ); | 468 | tabs = new LauncherTabWidget( this ); |
469 | setCentralWidget( tabs ); | 469 | setCentralWidget( tabs ); |
470 | 470 | ||
471 | ServerInterface::dockWidget( tb, ServerInterface::Bottom ); | 471 | ServerInterface::dockWidget( tb, ServerInterface::Bottom ); |
472 | tb->show(); | 472 | tb->show(); |
473 | 473 | ||
474 | qApp->installEventFilter( this ); | 474 | qApp->installEventFilter( this ); |
475 | 475 | ||
476 | connect( tb, SIGNAL(tabSelected(const QString&)), | 476 | connect( tb, SIGNAL(tabSelected(const QString&)), |
477 | this, SLOT(showTab(const QString&)) ); | 477 | this, SLOT(showTab(const QString&)) ); |
478 | connect( tabs, SIGNAL(selected(const QString&)), | 478 | connect( tabs, SIGNAL(selected(const QString&)), |
479 | this, SLOT(viewSelected(const QString&)) ); | 479 | this, SLOT(viewSelected(const QString&)) ); |
480 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 480 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
481 | this, SLOT(select(const AppLnk*))); | 481 | this, SLOT(select(const AppLnk*))); |
482 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 482 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
483 | this, SLOT(properties(AppLnk*))); | 483 | this, SLOT(properties(AppLnk*))); |
484 | 484 | ||
485 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 485 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
486 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 486 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
487 | connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 487 | connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
488 | this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); | 488 | this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); |
489 | #endif | 489 | #endif |
490 | 490 | ||
491 | // all documents | 491 | // all documents |
492 | QImage img( Resource::loadImage( "DocsIcon" ) ); | 492 | QImage img( Resource::loadImage( "DocsIcon" ) ); |
493 | QPixmap pm; | 493 | QPixmap pm; |
494 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 494 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
495 | // It could add this itself if it handles docs | 495 | // It could add this itself if it handles docs |
496 | 496 | ||
497 | tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); | 497 | tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); |
498 | 498 | ||
499 | QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); | 499 | QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); |
500 | qApp->setMainWidget( this ); | 500 | qApp->setMainWidget( this ); |
501 | QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); | 501 | QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); |
502 | } | 502 | } |
503 | 503 | ||
504 | Launcher::~Launcher() | 504 | Launcher::~Launcher() |
505 | { | 505 | { |
506 | if ( tb ) | 506 | if ( tb ) |
507 | destroyGUI(); | 507 | destroyGUI(); |
508 | } | 508 | } |
509 | 509 | ||
510 | bool Launcher::requiresDocuments() const | 510 | bool Launcher::requiresDocuments() const |
511 | { | 511 | { |
512 | Config cfg( "Launcher" ); | 512 | Config cfg( "Launcher" ); |
513 | cfg.setGroup( "DocTab" ); | 513 | cfg.setGroup( "DocTab" ); |
514 | return cfg.readBoolEntry( "Enable", true ); | 514 | return cfg.readBoolEntry( "Enable", true ); |
515 | } | 515 | } |
516 | 516 | ||
517 | void Launcher::makeVisible() | 517 | void Launcher::makeVisible() |
518 | { | 518 | { |
519 | showMaximized(); | 519 | showMaximized(); |
520 | } | 520 | } |
521 | 521 | ||
522 | void Launcher::destroyGUI() | 522 | void Launcher::destroyGUI() |
523 | { | 523 | { |
524 | delete tb; | 524 | delete tb; |
525 | tb = 0; | 525 | tb = 0; |
526 | delete tabs; | 526 | delete tabs; |
527 | tabs =0; | 527 | tabs =0; |
528 | } | 528 | } |
529 | 529 | ||
530 | bool Launcher::eventFilter( QObject*, QEvent *ev ) | 530 | bool Launcher::eventFilter( QObject*, QEvent *ev ) |
531 | { | 531 | { |
532 | #ifdef QT_QWS_CUSTOM | 532 | #ifdef QT_QWS_CUSTOM |
533 | if ( ev->type() == QEvent::KeyPress ) { | 533 | if ( ev->type() == QEvent::KeyPress ) { |
534 | QKeyEvent *ke = (QKeyEvent *)ev; | 534 | QKeyEvent *ke = (QKeyEvent *)ev; |
535 | if ( ke->key() == Qt::Key_F11 ) { // menu key | 535 | if ( ke->key() == Qt::Key_F11 ) { // menu key |
536 | QWidget *active = qApp->activeWindow(); | 536 | QWidget *active = qApp->activeWindow(); |
537 | if ( active && active->isPopup() ) | 537 | if ( active && active->isPopup() ) |
538 | active->close(); | 538 | active->close(); |
539 | else { | 539 | else { |
540 | Global::terminateBuiltin("calibrate"); // No tr | 540 | Global::terminateBuiltin("calibrate"); // No tr |
541 | tb->launchStartMenu(); | 541 | tb->launchStartMenu(); |
542 | } | 542 | } |
543 | return TRUE; | 543 | return TRUE; |
544 | } | 544 | } |
545 | } | 545 | } |
546 | #else | 546 | #else |
547 | Q_UNUSED(ev); | 547 | Q_UNUSED(ev); |
548 | #endif | 548 | #endif |
549 | return FALSE; | 549 | return FALSE; |
550 | } | 550 | } |
551 | 551 | ||
552 | static bool isVisibleWindow(int wid) | 552 | static bool isVisibleWindow(int wid) |
553 | { | 553 | { |
554 | #ifdef Q_WS_QWS | 554 | #ifdef Q_WS_QWS |
555 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 555 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
556 | QWSWindow* w; | 556 | QWSWindow* w; |
557 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 557 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
558 | if ( w->winId() == wid ) | 558 | if ( w->winId() == wid ) |
559 | return !w->isFullyObscured(); | 559 | return !w->isFullyObscured(); |
560 | } | 560 | } |
561 | #endif | 561 | #endif |
562 | return FALSE; | 562 | return FALSE; |
563 | } | 563 | } |
564 | 564 | ||
565 | void Launcher::viewSelected(const QString& s) | 565 | void Launcher::viewSelected(const QString& s) |
566 | { | 566 | { |
567 | setCaption( s + tr(" - Launcher") ); | 567 | setCaption( s + tr(" - Launcher") ); |
568 | } | 568 | } |
569 | 569 | ||
570 | void Launcher::showTab(const QString& id) | 570 | void Launcher::showTab(const QString& id) |
571 | { | 571 | { |
572 | tabs->categoryBar->showTab(id); | 572 | tabs->categoryBar->showTab(id); |
573 | raise(); | 573 | raise(); |
574 | } | 574 | } |
575 | 575 | ||
576 | void Launcher::select( const AppLnk *appLnk ) | 576 | void Launcher::select( const AppLnk *appLnk ) |
577 | { | 577 | { |
578 | if ( appLnk->type() == "Folder" ) { // No tr | 578 | if ( appLnk->type() == "Folder" ) { // No tr |
579 | // Not supported: flat is simpler for the user | 579 | // Not supported: flat is simpler for the user |
580 | } else { | 580 | } else { |
581 | if ( appLnk->exec().isNull() ) { | 581 | if ( appLnk->exec().isNull() ) { |
582 | int i = QMessageBox::information(this,tr("No application"), | 582 | int i = QMessageBox::information(this,tr("No application"), |
583 | tr("<p>No application is defined for this document." | 583 | tr("<p>No application is defined for this document." |
584 | "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); | 584 | "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); |
585 | 585 | ||
586 | /* ### Fixme */ | 586 | /* ### Fixme */ |
587 | if ( i == 1 ) | 587 | if ( i == 1 ) |
588 | Global::execute("textedit",appLnk->file()); | 588 | Global::execute("textedit",appLnk->file()); |
589 | 589 | ||
590 | return; | 590 | return; |
591 | } | 591 | } |
592 | tabs->setBusy(TRUE); | 592 | tabs->setBusy(TRUE); |
593 | emit executing( appLnk ); | 593 | emit executing( appLnk ); |
594 | appLnk->execute(); | 594 | appLnk->execute(); |
595 | } | 595 | } |
596 | } | 596 | } |
597 | 597 | ||
598 | void Launcher::properties( AppLnk *appLnk ) | 598 | void Launcher::properties( AppLnk *appLnk ) |
599 | { | 599 | { |
600 | if ( appLnk->type() == "Folder" ) { // No tr | 600 | if ( appLnk->type() == "Folder" ) { // No tr |
601 | // Not supported: flat is simpler for the user | 601 | // Not supported: flat is simpler for the user |
602 | } else { | 602 | } else { |
603 | /* ### libqtopia FIXME also moving docLnks... */ | 603 | /* ### libqtopia FIXME also moving docLnks... */ |
604 | LnkProperties prop(appLnk,0 ); | 604 | LnkProperties prop(appLnk,0 ); |
605 | 605 | ||
606 | QPEApplication::execDialog( &prop ); | 606 | if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) { |
607 | tabs->docView()->updateTools(); | ||
608 | } | ||
607 | } | 609 | } |
608 | } | 610 | } |
609 | 611 | ||
610 | void Launcher::storageChanged( const QList<FileSystem> & ) | 612 | void Launcher::storageChanged( const QList<FileSystem> & ) |
611 | { | 613 | { |
612 | // ### update combo boxes if we had a combo box for the storage type | 614 | // ### update combo boxes if we had a combo box for the storage type |
613 | } | 615 | } |
614 | 616 | ||
615 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 617 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
616 | { | 618 | { |
617 | QDataStream stream( data, IO_ReadOnly ); | 619 | QDataStream stream( data, IO_ReadOnly ); |
618 | if ( msg == "busy()" ) { | 620 | if ( msg == "busy()" ) { |
619 | tb->startWait(); | 621 | tb->startWait(); |
620 | } else if ( msg == "notBusy(QString)" ) { | 622 | } else if ( msg == "notBusy(QString)" ) { |
621 | QString app; | 623 | QString app; |
622 | stream >> app; | 624 | stream >> app; |
623 | tabs->setBusy(FALSE); | 625 | tabs->setBusy(FALSE); |
624 | tb->stopWait(app); | 626 | tb->stopWait(app); |
625 | } else if (msg == "applyStyle()") { | 627 | } else if (msg == "applyStyle()") { |
626 | tabs->currentView()->relayout(); | 628 | tabs->currentView()->relayout(); |
627 | } | 629 | } |
628 | } | 630 | } |
629 | 631 | ||
630 | // These are the update functions from the server | 632 | // These are the update functions from the server |
631 | void Launcher::typeAdded( const QString& type, const QString& name, | 633 | void Launcher::typeAdded( const QString& type, const QString& name, |
632 | const QPixmap& pixmap, const QPixmap& ) | 634 | const QPixmap& pixmap, const QPixmap& ) |
633 | { | 635 | { |
634 | tabs->newView( type, pixmap, name ); | 636 | tabs->newView( type, pixmap, name ); |
635 | ids.append( type ); | 637 | ids.append( type ); |
636 | /* this will be called in applicationScanningProgress with value 100! */ | 638 | /* this will be called in applicationScanningProgress with value 100! */ |
637 | // tb->refreshStartMenu(); | 639 | // tb->refreshStartMenu(); |
638 | 640 | ||
639 | static bool first = TRUE; | 641 | static bool first = TRUE; |
640 | if ( first ) { | 642 | if ( first ) { |
641 | first = FALSE; | 643 | first = FALSE; |
642 | tabs->categoryBar->showTab(type); | 644 | tabs->categoryBar->showTab(type); |
643 | } | 645 | } |
644 | 646 | ||
645 | tabs->view( type )->setUpdatesEnabled( FALSE ); | 647 | tabs->view( type )->setUpdatesEnabled( FALSE ); |
646 | tabs->view( type )->setSortEnabled( FALSE ); | 648 | tabs->view( type )->setSortEnabled( FALSE ); |
647 | } | 649 | } |
648 | 650 | ||
649 | void Launcher::typeRemoved( const QString& type ) | 651 | void Launcher::typeRemoved( const QString& type ) |
650 | { | 652 | { |
651 | tabs->view( type )->removeAllItems(); | 653 | tabs->view( type )->removeAllItems(); |
652 | tabs->deleteView( type ); | 654 | tabs->deleteView( type ); |
653 | ids.remove( type ); | 655 | ids.remove( type ); |
654 | /* this will be called in applicationScanningProgress with value 100! */ | 656 | /* this will be called in applicationScanningProgress with value 100! */ |
655 | // tb->refreshStartMenu(); | 657 | // tb->refreshStartMenu(); |
656 | } | 658 | } |
657 | 659 | ||
658 | void Launcher::applicationAdded( const QString& type, const AppLnk& app ) | 660 | void Launcher::applicationAdded( const QString& type, const AppLnk& app ) |
659 | { | 661 | { |
660 | if ( app.type() == "Separator" ) // No tr | 662 | if ( app.type() == "Separator" ) // No tr |
661 | return; | 663 | return; |
662 | 664 | ||
663 | LauncherView *view = tabs->view( type ); | 665 | LauncherView *view = tabs->view( type ); |
664 | if ( view ) | 666 | if ( view ) |
665 | view->addItem( new AppLnk( app ), FALSE ); | 667 | view->addItem( new AppLnk( app ), FALSE ); |
666 | else | 668 | else |
667 | owarn << "addAppLnk: No view for type " << type.latin1() << ". Can't add app " | 669 | owarn << "addAppLnk: No view for type " << type.latin1() << ". Can't add app " |
668 | << app.name().latin1() << "!", | 670 | << app.name().latin1() << "!", |
669 | 671 | ||
670 | MimeType::registerApp( app ); | 672 | MimeType::registerApp( app ); |
671 | } | 673 | } |
672 | 674 | ||
673 | void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) | 675 | void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) |
674 | { | 676 | { |
675 | LauncherView *view = tabs->view( type ); | 677 | LauncherView *view = tabs->view( type ); |
676 | if ( view ) | 678 | if ( view ) |
677 | view->removeLink( app.linkFile() ); | 679 | view->removeLink( app.linkFile() ); |
678 | else | 680 | else |
679 | owarn << "removeAppLnk: No view for " << type << "!" << oendl; | 681 | owarn << "removeAppLnk: No view for " << type << "!" << oendl; |
680 | } | 682 | } |
681 | 683 | ||
682 | void Launcher::allApplicationsRemoved() | 684 | void Launcher::allApplicationsRemoved() |
683 | { | 685 | { |
684 | MimeType::clear(); | 686 | MimeType::clear(); |
685 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) | 687 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) |
686 | tabs->view( (*it) )->removeAllItems(); | 688 | tabs->view( (*it) )->removeAllItems(); |
687 | } | 689 | } |
688 | 690 | ||
689 | void Launcher::documentAdded( const DocLnk& doc ) | 691 | void Launcher::documentAdded( const DocLnk& doc ) |
690 | { | 692 | { |
691 | tabs->docView()->addItem( new DocLnk( doc ), FALSE ); | 693 | tabs->docView()->addItem( new DocLnk( doc ), FALSE ); |
692 | } | 694 | } |
693 | 695 | ||
694 | void Launcher::aboutToAddBegin() | 696 | void Launcher::aboutToAddBegin() |
695 | { | 697 | { |
696 | tabs->docView()->setUpdatesEnabled( false ); | 698 | tabs->docView()->setUpdatesEnabled( false ); |
697 | } | 699 | } |
698 | 700 | ||
699 | void Launcher::aboutToAddEnd() | 701 | void Launcher::aboutToAddEnd() |
700 | { | 702 | { |
701 | tabs->docView()->setUpdatesEnabled( true ); | 703 | tabs->docView()->setUpdatesEnabled( true ); |
702 | } | 704 | } |
703 | 705 | ||
704 | void Launcher::showLoadingDocs() | 706 | void Launcher::showLoadingDocs() |
705 | { | 707 | { |
706 | tabs->docView()->hide(); | 708 | tabs->docView()->hide(); |
707 | } | 709 | } |
708 | 710 | ||
709 | void Launcher::showDocTab() | 711 | void Launcher::showDocTab() |
710 | { | 712 | { |
711 | if ( tabs->categoryBar->currentView() == tabs->docView() ) | 713 | if ( tabs->categoryBar->currentView() == tabs->docView() ) |
712 | tabs->docView()->show(); | 714 | tabs->docView()->show(); |
713 | } | 715 | } |
714 | 716 | ||
715 | void Launcher::documentRemoved( const DocLnk& doc ) | 717 | void Launcher::documentRemoved( const DocLnk& doc ) |
716 | { | 718 | { |
717 | tabs->docView()->removeLink( doc.linkFile() ); | 719 | tabs->docView()->removeLink( doc.linkFile() ); |
718 | } | 720 | } |
719 | 721 | ||
720 | void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) | 722 | void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) |
721 | { | 723 | { |
722 | documentRemoved( oldDoc ); | 724 | documentRemoved( oldDoc ); |
723 | documentAdded( newDoc ); | 725 | documentAdded( newDoc ); |
724 | } | 726 | } |
725 | 727 | ||
726 | void Launcher::allDocumentsRemoved() | 728 | void Launcher::allDocumentsRemoved() |
727 | { | 729 | { |
728 | tabs->docView()->removeAllItems(); | 730 | tabs->docView()->removeAllItems(); |
729 | } | 731 | } |
730 | 732 | ||
731 | void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) | 733 | void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) |
732 | { | 734 | { |
733 | tb->setApplicationState( name, state ); | 735 | tb->setApplicationState( name, state ); |
734 | } | 736 | } |
735 | 737 | ||
736 | void Launcher::applicationScanningProgress( int percent ) | 738 | void Launcher::applicationScanningProgress( int percent ) |
737 | { | 739 | { |
738 | switch ( percent ) { | 740 | switch ( percent ) { |
739 | case 0: { | 741 | case 0: { |
740 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { | 742 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { |
741 | tabs->view( (*it) )->setUpdatesEnabled( FALSE ); | 743 | tabs->view( (*it) )->setUpdatesEnabled( FALSE ); |
742 | tabs->view( (*it) )->setSortEnabled( FALSE ); | 744 | tabs->view( (*it) )->setSortEnabled( FALSE ); |
743 | } | 745 | } |
744 | break; | 746 | break; |
745 | } | 747 | } |
746 | case 100: { | 748 | case 100: { |
747 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { | 749 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { |
748 | tabs->view( (*it) )->setUpdatesEnabled( TRUE ); | 750 | tabs->view( (*it) )->setUpdatesEnabled( TRUE ); |
749 | tabs->view( (*it) )->setSortEnabled( TRUE ); | 751 | tabs->view( (*it) )->setSortEnabled( TRUE ); |
750 | } | 752 | } |
751 | tb->refreshStartMenu(); | 753 | tb->refreshStartMenu(); |
752 | break; | 754 | break; |
753 | } | 755 | } |
754 | default: | 756 | default: |
755 | break; | 757 | break; |
756 | } | 758 | } |
757 | } | 759 | } |
758 | 760 | ||
759 | void Launcher::documentScanningProgress( int percent ) | 761 | void Launcher::documentScanningProgress( int percent ) |
760 | { | 762 | { |
761 | switch ( percent ) { | 763 | switch ( percent ) { |
762 | case 0: { | 764 | case 0: { |
763 | tabs->setLoadingProgress( 0 ); | 765 | tabs->setLoadingProgress( 0 ); |
764 | tabs->setLoadingWidgetEnabled( TRUE ); | 766 | tabs->setLoadingWidgetEnabled( TRUE ); |
765 | tabs->docView()->setUpdatesEnabled( FALSE ); | 767 | tabs->docView()->setUpdatesEnabled( FALSE ); |
766 | tabs->docView()->setSortEnabled( FALSE ); | 768 | tabs->docView()->setSortEnabled( FALSE ); |
767 | break; | 769 | break; |
768 | } | 770 | } |
769 | case 100: { | 771 | case 100: { |
770 | tabs->docView()->updateTools(); | 772 | tabs->docView()->updateTools(); |
771 | tabs->docView()->setSortEnabled( TRUE ); | 773 | tabs->docView()->setSortEnabled( TRUE ); |
772 | tabs->docView()->setUpdatesEnabled( TRUE ); | 774 | tabs->docView()->setUpdatesEnabled( TRUE ); |
773 | tabs->setLoadingWidgetEnabled( FALSE ); | 775 | tabs->setLoadingWidgetEnabled( FALSE ); |
774 | break; | 776 | break; |
775 | } | 777 | } |
776 | default: | 778 | default: |
777 | tabs->setLoadingProgress( percent ); | 779 | tabs->setLoadingProgress( percent ); |
778 | break; | 780 | break; |
779 | } | 781 | } |
780 | } | 782 | } |
781 | 783 | ||
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 72313e3..ff26133 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -1,1181 +1,1174 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "launcherview.h" | 21 | #include "launcherview.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <opie2/odebug.h> | 24 | #include <opie2/odebug.h> |
25 | #include <qtopia/qpeapplication.h> | 25 | #include <qtopia/qpeapplication.h> |
26 | #include <qtopia/private/categories.h> | 26 | #include <qtopia/private/categories.h> |
27 | #include <qtopia/categoryselect.h> | 27 | #include <qtopia/categoryselect.h> |
28 | #include <qtopia/mimetype.h> | 28 | #include <qtopia/mimetype.h> |
29 | #include <qtopia/resource.h> | 29 | #include <qtopia/resource.h> |
30 | using namespace Opie::Core; | 30 | using namespace Opie::Core; |
31 | 31 | ||
32 | #include <qpe/qcopenvelope_qws.h> | 32 | #include <qpe/qcopenvelope_qws.h> |
33 | 33 | ||
34 | /* QT */ | 34 | /* QT */ |
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qfileinfo.h> | 36 | #include <qfileinfo.h> |
37 | #include <qiconview.h> | 37 | #include <qiconview.h> |
38 | #include <qobjectlist.h> | 38 | #include <qobjectlist.h> |
39 | 39 | ||
40 | 40 | ||
41 | // These define how the busy icon is animated and highlighted | 41 | // These define how the busy icon is animated and highlighted |
42 | #define BRIGHTEN_BUSY_ICON | 42 | #define BRIGHTEN_BUSY_ICON |
43 | //#define ALPHA_FADE_BUSY_ICON | 43 | //#define ALPHA_FADE_BUSY_ICON |
44 | //#define USE_ANIMATED_BUSY_ICON_OVERLAY | 44 | //#define USE_ANIMATED_BUSY_ICON_OVERLAY |
45 | #define BOUNCE_BUSY_ICON | 45 | #define BOUNCE_BUSY_ICON |
46 | 46 | ||
47 | 47 | ||
48 | class BgPixmap | 48 | class BgPixmap |
49 | { | 49 | { |
50 | public: | 50 | public: |
51 | BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} | 51 | BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} |
52 | QPixmap pm; | 52 | QPixmap pm; |
53 | int ref; | 53 | int ref; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | 56 | ||
57 | static QMap<QString,BgPixmap*> *bgCache = 0; | 57 | static QMap<QString,BgPixmap*> *bgCache = 0; |
58 | 58 | ||
59 | static void cleanup_cache() | 59 | static void cleanup_cache() |
60 | { | 60 | { |
61 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); | 61 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); |
62 | while ( it != bgCache->end() ) { | 62 | while ( it != bgCache->end() ) { |
63 | QMap<QString,BgPixmap*>::Iterator curr = it; | 63 | QMap<QString,BgPixmap*>::Iterator curr = it; |
64 | ++it; | 64 | ++it; |
65 | delete (*curr); | 65 | delete (*curr); |
66 | bgCache->remove( curr ); | 66 | bgCache->remove( curr ); |
67 | } | 67 | } |
68 | delete bgCache; | 68 | delete bgCache; |
69 | bgCache = 0; | 69 | bgCache = 0; |
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | class LauncherItem : public QIconViewItem | 73 | class LauncherItem : public QIconViewItem |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | enum iconstate_t { | 76 | enum iconstate_t { |
77 | BASE_ICON, | 77 | BASE_ICON, |
78 | WAITING_ICON, | 78 | WAITING_ICON, |
79 | EYE_ICON | 79 | EYE_ICON |
80 | }; | 80 | }; |
81 | 81 | ||
82 | LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); | 82 | LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); |
83 | ~LauncherItem(); | 83 | ~LauncherItem(); |
84 | 84 | ||
85 | AppLnk *appLnk() const { return app; } | 85 | AppLnk *appLnk() const { return app; } |
86 | AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } | 86 | AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } |
87 | 87 | ||
88 | void animateIcon(); | 88 | void animateIcon(); |
89 | void resetIcon(); | 89 | void resetIcon(); |
90 | bool isEyeImage()const{return m_EyeImage;} | 90 | bool isEyeImage()const{return m_EyeImage;} |
91 | 91 | ||
92 | virtual int compare ( QIconViewItem * i ) const; | 92 | virtual int compare ( QIconViewItem * i ) const; |
93 | void paintItem( QPainter *p, const QColorGroup &cg ); | 93 | void paintItem( QPainter *p, const QColorGroup &cg ); |
94 | 94 | ||
95 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } | 95 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } |
96 | void setEyePixmap(const QPixmap&aIcon); | 96 | void setEyePixmap(const QPixmap&aIcon); |
97 | virtual QPixmap*pixmap()const; | 97 | virtual QPixmap*pixmap()const; |
98 | 98 | ||
99 | protected: | 99 | protected: |
100 | bool isBigIcon; | 100 | bool isBigIcon; |
101 | int iteration; | 101 | int iteration; |
102 | AppLnk* app; | 102 | AppLnk* app; |
103 | 103 | ||
104 | private: | 104 | private: |
105 | void paintAnimatedIcon( QPainter *p ); | 105 | void paintAnimatedIcon( QPainter *p ); |
106 | BusyIndicatorType busyType; | 106 | BusyIndicatorType busyType; |
107 | int psize; | 107 | int psize; |
108 | QPixmap m_iPixmap; | 108 | QPixmap m_iPixmap; |
109 | bool m_EyeImage; | 109 | bool m_EyeImage; |
110 | iconstate_t m_EyeImageSet; | 110 | iconstate_t m_EyeImageSet; |
111 | }; | 111 | }; |
112 | 112 | ||
113 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) | 113 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) |
114 | : QIconViewItem( parent, applnk->name(), | 114 | : QIconViewItem( parent, applnk->name(), |
115 | bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), | 115 | bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), |
116 | isBigIcon( bigIcon ), | 116 | isBigIcon( bigIcon ), |
117 | iteration(0), | 117 | iteration(0), |
118 | app(applnk), // Takes ownership | 118 | app(applnk), // Takes ownership |
119 | psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), | 119 | psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), |
120 | m_iPixmap(), | 120 | m_iPixmap(), |
121 | m_EyeImage(false), | 121 | m_EyeImage(false), |
122 | m_EyeImageSet(BASE_ICON) | 122 | m_EyeImageSet(BASE_ICON) |
123 | { | 123 | { |
124 | if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { | 124 | if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { |
125 | m_EyeImage = true; | 125 | m_EyeImage = true; |
126 | m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); | 126 | m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | LauncherItem::~LauncherItem() | 130 | LauncherItem::~LauncherItem() |
131 | { | 131 | { |
132 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 132 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
133 | if ( liv->busyItem() == this ) | 133 | if ( liv->busyItem() == this ) |
134 | liv->setBusy(FALSE); | 134 | liv->setBusy(FALSE); |
135 | delete app; | 135 | delete app; |
136 | } | 136 | } |
137 | 137 | ||
138 | QPixmap*LauncherItem::pixmap()const | 138 | QPixmap*LauncherItem::pixmap()const |
139 | { | 139 | { |
140 | if (m_EyeImage && m_EyeImageSet == BASE_ICON) { | 140 | if (m_EyeImage && m_EyeImageSet == BASE_ICON) { |
141 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 141 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
142 | liv->requestEyePix(this); | 142 | liv->requestEyePix(this); |
143 | } | 143 | } |
144 | return QIconViewItem::pixmap(); | 144 | return QIconViewItem::pixmap(); |
145 | } | 145 | } |
146 | 146 | ||
147 | int LauncherItem::compare ( QIconViewItem * i ) const | 147 | int LauncherItem::compare ( QIconViewItem * i ) const |
148 | { | 148 | { |
149 | LauncherIconView* view = (LauncherIconView*)iconView(); | 149 | LauncherIconView* view = (LauncherIconView*)iconView(); |
150 | return view->compare(app,((LauncherItem *)i)->appLnk()); | 150 | return view->compare(app,((LauncherItem *)i)->appLnk()); |
151 | } | 151 | } |
152 | 152 | ||
153 | void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) | 153 | void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) |
154 | { | 154 | { |
155 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 155 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
156 | QBrush oldBrush( liv->itemTextBackground() ); | 156 | QBrush oldBrush( liv->itemTextBackground() ); |
157 | QColorGroup mycg( cg ); | 157 | QColorGroup mycg( cg ); |
158 | if ( liv->currentItem() == this ) { | 158 | if ( liv->currentItem() == this ) { |
159 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); | 159 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); |
160 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); | 160 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); |
161 | } | 161 | } |
162 | 162 | ||
163 | QIconViewItem::paintItem(p,mycg); | 163 | QIconViewItem::paintItem(p,mycg); |
164 | 164 | ||
165 | // Paint animation overlay | 165 | // Paint animation overlay |
166 | if ( liv->busyItem() == this ) | 166 | if ( liv->busyItem() == this ) |
167 | paintAnimatedIcon(p); | 167 | paintAnimatedIcon(p); |
168 | 168 | ||
169 | if ( liv->currentItem() == this ) | 169 | if ( liv->currentItem() == this ) |
170 | liv->setItemTextBackground( oldBrush ); | 170 | liv->setItemTextBackground( oldBrush ); |
171 | } | 171 | } |
172 | 172 | ||
173 | void LauncherItem::paintAnimatedIcon( QPainter *p ) | 173 | void LauncherItem::paintAnimatedIcon( QPainter *p ) |
174 | { | 174 | { |
175 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 175 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
176 | int pic = iteration % 16; | 176 | int pic = iteration % 16; |
177 | int w = pixmap()->width(), h = pixmap()->height(); | 177 | int w = pixmap()->width(), h = pixmap()->height(); |
178 | QPixmap dblBuf( w, h + 4 ); | 178 | QPixmap dblBuf( w, h + 4 ); |
179 | QPainter p2( &dblBuf ); | 179 | QPainter p2( &dblBuf ); |
180 | int x1, y1; | 180 | int x1, y1; |
181 | if ( liv->itemTextPos() == QIconView::Bottom ) { | 181 | if ( liv->itemTextPos() == QIconView::Bottom ) { |
182 | x1 = x() + (width() - w) / 2 - liv->contentsX(); | 182 | x1 = x() + (width() - w) / 2 - liv->contentsX(); |
183 | y1 = y() - liv->contentsY(); | 183 | y1 = y() - liv->contentsY(); |
184 | } else { | 184 | } else { |
185 | x1 = x() - liv->contentsX(); | 185 | x1 = x() - liv->contentsX(); |
186 | y1 = y() + (height() - h) / 2 - liv->contentsY(); | 186 | y1 = y() + (height() - h) / 2 - liv->contentsY(); |
187 | } | 187 | } |
188 | y1 -= 2; | 188 | y1 -= 2; |
189 | p2.translate(-x1,-y1); | 189 | p2.translate(-x1,-y1); |
190 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); | 190 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); |
191 | int bounceY = 2; | 191 | int bounceY = 2; |
192 | #ifdef BOUNCE_BUSY_ICON | 192 | #ifdef BOUNCE_BUSY_ICON |
193 | if ( busyType == BIT_Animated ) { | 193 | if ( busyType == BIT_Animated ) { |
194 | bounceY = 4 - ((iteration+2)%8); | 194 | bounceY = 4 - ((iteration+2)%8); |
195 | bounceY = bounceY < 0 ? -bounceY : bounceY; | 195 | bounceY = bounceY < 0 ? -bounceY : bounceY; |
196 | } | 196 | } |
197 | #endif | 197 | #endif |
198 | p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); | 198 | p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); |
199 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 199 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
200 | p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); | 200 | p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); |
201 | #else | 201 | #else |
202 | Q_UNUSED( pic ) | 202 | Q_UNUSED( pic ) |
203 | #endif | 203 | #endif |
204 | p->drawPixmap( x1, y1, dblBuf ); | 204 | p->drawPixmap( x1, y1, dblBuf ); |
205 | } | 205 | } |
206 | 206 | ||
207 | void LauncherItem::animateIcon() | 207 | void LauncherItem::animateIcon() |
208 | { | 208 | { |
209 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 209 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
210 | 210 | ||
211 | if ( liv->busyItem() != this || !app ) | 211 | if ( liv->busyItem() != this || !app ) |
212 | return; | 212 | return; |
213 | 213 | ||
214 | // Highlight the icon | 214 | // Highlight the icon |
215 | if ( iteration == 0 ) { | 215 | if ( iteration == 0 ) { |
216 | QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())); | 216 | QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())); |
217 | QImage img = src.convertToImage(); | 217 | QImage img = src.convertToImage(); |
218 | QRgb *rgb; | 218 | QRgb *rgb; |
219 | int count; | 219 | int count; |
220 | if ( img.depth() == 32 ) { | 220 | if ( img.depth() == 32 ) { |
221 | rgb = (QRgb*)img.bits(); | 221 | rgb = (QRgb*)img.bits(); |
222 | count = img.bytesPerLine()/sizeof(QRgb)*img.height(); | 222 | count = img.bytesPerLine()/sizeof(QRgb)*img.height(); |
223 | } else { | 223 | } else { |
224 | rgb = img.colorTable(); | 224 | rgb = img.colorTable(); |
225 | count = img.numColors(); | 225 | count = img.numColors(); |
226 | } | 226 | } |
227 | for ( int r = 0; r < count; r++, rgb++ ) { | 227 | for ( int r = 0; r < count; r++, rgb++ ) { |
228 | #if defined(BRIGHTEN_BUSY_ICON) | 228 | #if defined(BRIGHTEN_BUSY_ICON) |
229 | QColor c(*rgb); | 229 | QColor c(*rgb); |
230 | int h, s, v; | 230 | int h, s, v; |
231 | c.hsv(&h,&s,&v); | 231 | c.hsv(&h,&s,&v); |
232 | c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); | 232 | c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); |
233 | *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); | 233 | *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); |
234 | #elif defined(ALPHA_FADE_BUSY_ICON) | 234 | #elif defined(ALPHA_FADE_BUSY_ICON) |
235 | *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); | 235 | *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); |
236 | #endif | 236 | #endif |
237 | } | 237 | } |
238 | src.convertFromImage( img ); | 238 | src.convertFromImage( img ); |
239 | setPixmap( src ); | 239 | setPixmap( src ); |
240 | } | 240 | } |
241 | 241 | ||
242 | iteration++; | 242 | iteration++; |
243 | 243 | ||
244 | // Paint animation overlay | 244 | // Paint animation overlay |
245 | QPainter p( liv->viewport() ); | 245 | QPainter p( liv->viewport() ); |
246 | paintAnimatedIcon( &p ); | 246 | paintAnimatedIcon( &p ); |
247 | } | 247 | } |
248 | 248 | ||
249 | void LauncherItem::resetIcon() | 249 | void LauncherItem::resetIcon() |
250 | { | 250 | { |
251 | iteration = 0; | 251 | iteration = 0; |
252 | setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()))); | 252 | setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()))); |
253 | } | 253 | } |
254 | 254 | ||
255 | void LauncherItem::setEyePixmap(const QPixmap&aIcon) | 255 | void LauncherItem::setEyePixmap(const QPixmap&aIcon) |
256 | { | 256 | { |
257 | if (!isEyeImage()) return; | 257 | if (!isEyeImage()) return; |
258 | m_iPixmap = aIcon; | 258 | m_iPixmap = aIcon; |
259 | setPixmap(aIcon); | 259 | setPixmap(aIcon); |
260 | m_EyeImageSet = EYE_ICON; | 260 | m_EyeImageSet = EYE_ICON; |
261 | } | 261 | } |
262 | 262 | ||
263 | //=========================================================================== | 263 | //=========================================================================== |
264 | // Implemantation of LauncherIconview start | 264 | // Implemantation of LauncherIconview start |
265 | //=========================================================================== | 265 | //=========================================================================== |
266 | LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) | 266 | LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) |
267 | : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) | 267 | : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) |
268 | { | 268 | { |
269 | m_EyeCallBack = 0; | 269 | m_EyeCallBack = 0; |
270 | sortmeth = Name; | 270 | sortmeth = Name; |
271 | hidden.setAutoDelete(TRUE); | 271 | hidden.setAutoDelete(TRUE); |
272 | ike = FALSE; | 272 | ike = FALSE; |
273 | calculateGrid( Bottom ); | 273 | calculateGrid( Bottom ); |
274 | connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); | 274 | connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); |
275 | } | 275 | } |
276 | 276 | ||
277 | LauncherIconView::~LauncherIconView() | 277 | LauncherIconView::~LauncherIconView() |
278 | { | 278 | { |
279 | odebug << "LauncherIconView::~LauncherIconView()" << oendl; | ||
279 | #if 0 // debuggery | 280 | #if 0 // debuggery |
280 | QListIterator<AppLnk> it(hidden); | 281 | QListIterator<AppLnk> it(hidden); |
281 | AppLnk* l; | 282 | AppLnk* l; |
282 | while ((l=it.current())) { | 283 | while ((l=it.current())) { |
283 | ++it; | 284 | ++it; |
284 | //odebug << "" << l << ": hidden (should remove)" << oendl; | 285 | //odebug << "" << l << ": hidden (should remove)" << oendl; |
285 | } | 286 | } |
286 | #endif | 287 | #endif |
287 | } | 288 | } |
288 | 289 | ||
289 | int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) | 290 | int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) |
290 | { | 291 | { |
291 | switch (sortmeth) { | 292 | switch (sortmeth) { |
292 | case Name: | 293 | case Name: |
293 | return a->name().lower().compare(b->name().lower()); | 294 | return a->name().lower().compare(b->name().lower()); |
294 | case Date: { | 295 | case Date: { |
295 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); | 296 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); |
296 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); | 297 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); |
297 | return fa.lastModified().secsTo(fb.lastModified()); | 298 | return fa.lastModified().secsTo(fb.lastModified()); |
298 | } | 299 | } |
299 | case Type: | 300 | case Type: |
300 | return a->type().compare(b->type()); | 301 | return a->type().compare(b->type()); |
301 | } | 302 | } |
302 | return 0; | 303 | return 0; |
303 | } | 304 | } |
304 | 305 | ||
305 | void LauncherIconView::setSortMethod( SortMethod m ) | 306 | void LauncherIconView::setSortMethod( SortMethod m ) |
306 | { | 307 | { |
307 | if ( sortmeth != m ) { | 308 | if ( sortmeth != m ) { |
308 | sortmeth = m; | 309 | sortmeth = m; |
309 | sort(); | 310 | sort(); |
310 | } | 311 | } |
311 | } | 312 | } |
312 | 313 | ||
313 | void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) | 314 | void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) |
314 | { | 315 | { |
315 | Categories cat; | 316 | Categories cat; |
316 | cat.load( categoryFileName() ); | 317 | cat.load( categoryFileName() ); |
317 | QString str; | 318 | QString str; |
318 | if ( catfilter == -2 ) | 319 | if ( catfilter == -2 ) |
319 | cf = 0; | 320 | cf = 0; |
320 | else | 321 | else |
321 | cf = catfilter; | 322 | cf = catfilter; |
322 | hideOrShowItems(resort); | 323 | hideOrShowItems(resort); |
323 | } | 324 | } |
324 | 325 | ||
325 | void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) | 326 | void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) |
326 | { | 327 | { |
327 | tf = QRegExp(typefilter,FALSE,TRUE); | 328 | tf = QRegExp(typefilter,FALSE,TRUE); |
328 | hideOrShowItems(resort); | 329 | hideOrShowItems(resort); |
329 | } | 330 | } |
330 | 331 | ||
331 | void LauncherIconView::setItemTextPos( ItemTextPos pos ) | 332 | void LauncherIconView::setItemTextPos( ItemTextPos pos ) |
332 | { | 333 | { |
333 | calculateGrid( pos ); | 334 | calculateGrid( pos ); |
334 | QIconView::setItemTextPos( pos ); | 335 | QIconView::setItemTextPos( pos ); |
335 | } | 336 | } |
336 | 337 | ||
337 | void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) | 338 | void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) |
338 | { | 339 | { |
339 | if ( !bgPixmap.isNull() ) { | 340 | if ( !bgPixmap.isNull() ) { |
340 | p->drawTiledPixmap( r, bgPixmap, | 341 | p->drawTiledPixmap( r, bgPixmap, |
341 | QPoint( (r.x() + contentsX()) % bgPixmap.width(), | 342 | QPoint( (r.x() + contentsX()) % bgPixmap.width(), |
342 | (r.y() + contentsY()) % bgPixmap.height() ) ); | 343 | (r.y() + contentsY()) % bgPixmap.height() ) ); |
343 | } else { | 344 | } else { |
344 | p->fillRect( r, bgColor ); | 345 | p->fillRect( r, bgColor ); |
345 | } | 346 | } |
346 | } | 347 | } |
347 | 348 | ||
348 | void LauncherIconView::addCatsAndMimes(AppLnk* app) | 349 | void LauncherIconView::addCatsAndMimes(AppLnk* app) |
349 | { | 350 | { |
350 | // QStringList c = app->categories(); | 351 | // QStringList c = app->categories(); |
351 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { | 352 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { |
352 | // cats.replace(*cit,(void*)1); | 353 | // cats.replace(*cit,(void*)1); |
353 | // } | 354 | // } |
354 | QString maj=app->type(); | 355 | QString maj=app->type(); |
355 | int sl=maj.find('/'); | 356 | int sl=maj.find('/'); |
356 | if (sl>=0) { | 357 | if (sl>=0) { |
357 | QString k; | 358 | QString k; |
358 | k = maj.left(12) == "application/" ? maj : maj.left(sl); | 359 | k = maj.left(12) == "application/" ? maj : maj.left(sl); |
359 | mimes.replace(k,(void*)1); | 360 | mimes.replace(k,(void*)1); |
360 | } | 361 | } |
361 | } | 362 | } |
362 | 363 | ||
363 | void LauncherIconView::setBusy(bool on) | 364 | void LauncherIconView::setBusy(bool on) |
364 | { | 365 | { |
365 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 366 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
366 | if ( busyPix.isNull() ) { | 367 | if ( busyPix.isNull() ) { |
367 | int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 368 | int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
368 | busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); | 369 | busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); |
369 | } | 370 | } |
370 | #endif | 371 | #endif |
371 | 372 | ||
372 | if ( on ) { | 373 | if ( on ) { |
373 | busyTimer = startTimer( 100 ); | 374 | busyTimer = startTimer( 100 ); |
374 | } else { | 375 | } else { |
375 | if ( busyTimer ) { | 376 | if ( busyTimer ) { |
376 | killTimer( busyTimer ); | 377 | killTimer( busyTimer ); |
377 | busyTimer = 0; | 378 | busyTimer = 0; |
378 | } | 379 | } |
379 | } | 380 | } |
380 | 381 | ||
381 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; | 382 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; |
382 | 383 | ||
383 | if ( bsy != c ) { | 384 | if ( bsy != c ) { |
384 | LauncherItem *oldBusy = bsy; | 385 | LauncherItem *oldBusy = bsy; |
385 | bsy = c; | 386 | bsy = c; |
386 | if ( oldBusy ) { | 387 | if ( oldBusy ) { |
387 | oldBusy->resetIcon(); | 388 | oldBusy->resetIcon(); |
388 | } | 389 | } |
389 | if ( bsy ) { | 390 | if ( bsy ) { |
390 | bsy->setBusyIndicatorType( busyType ) ; | 391 | bsy->setBusyIndicatorType( busyType ) ; |
391 | bsy->animateIcon(); | 392 | bsy->animateIcon(); |
392 | } | 393 | } |
393 | } | 394 | } |
394 | } | 395 | } |
395 | 396 | ||
396 | void LauncherIconView::clear() | 397 | void LauncherIconView::clear() |
397 | { | 398 | { |
398 | mimes.clear(); | 399 | mimes.clear(); |
399 | cats.clear(); | 400 | cats.clear(); |
400 | QIconView::clear(); | 401 | QIconView::clear(); |
401 | hidden.clear(); | 402 | hidden.clear(); |
402 | } | 403 | } |
403 | 404 | ||
404 | QStringList LauncherIconView::mimeTypes() const | 405 | QStringList LauncherIconView::mimeTypes() const |
405 | { | 406 | { |
406 | QStringList r; | 407 | QStringList r; |
407 | QDictIterator<void> it(mimes); | 408 | QDictIterator<void> it(mimes); |
408 | while (it.current()) { | 409 | while (it.current()) { |
409 | r.append(it.currentKey()); | 410 | r.append(it.currentKey()); |
410 | ++it; | 411 | ++it; |
411 | } | 412 | } |
412 | r.sort(); | 413 | r.sort(); |
413 | return r; | 414 | return r; |
414 | } | 415 | } |
415 | 416 | ||
416 | LauncherItem*LauncherIconView::findDocItem(const QString&fname) | 417 | LauncherItem*LauncherIconView::findDocItem(const QString&fname) |
417 | { | 418 | { |
418 | LauncherItem* item = (LauncherItem*)firstItem(); | 419 | LauncherItem* item = (LauncherItem*)firstItem(); |
419 | while (item) { | 420 | while (item) { |
420 | if (item->appLnk()->file()==fname) { | 421 | if (item->appLnk()->file()==fname) { |
421 | break; | 422 | break; |
422 | } | 423 | } |
423 | item = (LauncherItem*)item->nextItem(); | 424 | item = (LauncherItem*)item->nextItem(); |
424 | } | 425 | } |
425 | return item; | 426 | return item; |
426 | } | 427 | } |
427 | 428 | ||
428 | void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) | 429 | void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) |
429 | { | 430 | { |
430 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 431 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
431 | if (s!=width) return; | 432 | if (s!=width) return; |
432 | LauncherItem*item = 0; | 433 | LauncherItem*item = findDocItem(aFile); |
433 | QMap<QString,LauncherItem*>::Iterator it; | ||
434 | if ( ( it = m_itemCache.find(aFile))!=m_itemCache.end()) { | ||
435 | item = it.data(); | ||
436 | m_itemCache.remove(it); | ||
437 | } else { | ||
438 | item = findDocItem(aFile); | ||
439 | } | ||
440 | if (!item||!item->isEyeImage()) return; | 434 | if (!item||!item->isEyeImage()) return; |
441 | item->setEyePixmap(aPixmap); | 435 | item->setEyePixmap(aPixmap); |
442 | } | 436 | } |
443 | 437 | ||
444 | void LauncherIconView::checkCallback() | 438 | void LauncherIconView::checkCallback() |
445 | { | 439 | { |
446 | if (!m_EyeCallBack) { | 440 | if (!m_EyeCallBack) { |
447 | m_EyeCallBack = new LauncherThumbReceiver(); | 441 | m_EyeCallBack = new LauncherThumbReceiver(); |
448 | connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), | 442 | connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), |
449 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); | 443 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); |
450 | m_eyeTimer.changeInterval(600000); | 444 | m_eyeTimer.changeInterval(600000); |
451 | } | 445 | } |
452 | } | 446 | } |
453 | 447 | ||
454 | void LauncherIconView::addCheckItem(AppLnk* app) | 448 | void LauncherIconView::addCheckItem(AppLnk* app) |
455 | { | 449 | { |
456 | LauncherItem*item = new LauncherItem( this, app, bigIcns ); | 450 | LauncherItem*item = new LauncherItem( this, app, bigIcns ); |
457 | if (item->isEyeImage()) { | 451 | if (item->isEyeImage()) { |
458 | checkCallback(); | 452 | checkCallback(); |
459 | } | 453 | } |
460 | } | 454 | } |
461 | 455 | ||
462 | void LauncherIconView::requestEyePix(const LauncherItem*item) | 456 | void LauncherIconView::requestEyePix(const LauncherItem*item) |
463 | { | 457 | { |
464 | if (!item) return; | 458 | if (!item) return; |
465 | if (item->isEyeImage()) { | 459 | if (item->isEyeImage()) { |
466 | checkCallback(); | 460 | checkCallback(); |
467 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 461 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
468 | m_itemCache[item->appLnk()->file()]=(LauncherItem*)item; | ||
469 | m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); | 462 | m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); |
470 | } | 463 | } |
471 | } | 464 | } |
472 | 465 | ||
473 | void LauncherIconView::stopEyeTimer() | 466 | void LauncherIconView::stopEyeTimer() |
474 | { | 467 | { |
475 | if (m_EyeCallBack) { | 468 | if (m_EyeCallBack) { |
476 | delete m_EyeCallBack; | 469 | delete m_EyeCallBack; |
477 | m_EyeCallBack=0; | 470 | m_EyeCallBack=0; |
478 | } | 471 | } |
479 | m_itemCache.clear(); | ||
480 | m_eyeTimer.stop(); | 472 | m_eyeTimer.stop(); |
481 | } | 473 | } |
482 | 474 | ||
483 | void LauncherIconView::addItem(AppLnk* app, bool resort) | 475 | void LauncherIconView::addItem(AppLnk* app, bool resort) |
484 | { | 476 | { |
485 | addCatsAndMimes(app); | 477 | addCatsAndMimes(app); |
486 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) | 478 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) |
487 | && (cf == 0 || app->categories().contains(cf) | 479 | && (cf == 0 || app->categories().contains(cf) |
488 | || cf == -1 && app->categories().count() == 0 ) ) { | 480 | || cf == -1 && app->categories().count() == 0 ) ) { |
489 | addCheckItem(app); | 481 | addCheckItem(app); |
490 | } else { | 482 | } else { |
491 | hidden.append(app); | 483 | hidden.append(app); |
492 | } | 484 | } |
493 | if ( resort ){ | 485 | if ( resort ){ |
494 | sort(); | 486 | sort(); |
495 | } | 487 | } |
496 | } | 488 | } |
497 | 489 | ||
498 | void LauncherIconView::updateCategoriesAndMimeTypes() | 490 | void LauncherIconView::updateCategoriesAndMimeTypes() |
499 | { | 491 | { |
500 | mimes.clear(); | 492 | mimes.clear(); |
501 | cats.clear(); | 493 | cats.clear(); |
502 | LauncherItem* item = (LauncherItem*)firstItem(); | 494 | LauncherItem* item = (LauncherItem*)firstItem(); |
503 | while (item) { | 495 | while (item) { |
504 | addCatsAndMimes(item->appLnk()); | 496 | addCatsAndMimes(item->appLnk()); |
505 | item = (LauncherItem*)item->nextItem(); | 497 | item = (LauncherItem*)item->nextItem(); |
506 | } | 498 | } |
507 | QListIterator<AppLnk> it(hidden); | 499 | QListIterator<AppLnk> it(hidden); |
508 | AppLnk* l; | 500 | AppLnk* l; |
509 | while ((l=it.current())) { | 501 | while ((l=it.current())) { |
510 | addCatsAndMimes(l); | 502 | addCatsAndMimes(l); |
511 | ++it; | 503 | ++it; |
512 | } | 504 | } |
513 | } | 505 | } |
514 | 506 | ||
515 | void LauncherIconView::hideOrShowItems(bool resort) | 507 | void LauncherIconView::hideOrShowItems(bool resort) |
516 | { | 508 | { |
517 | viewport()->setUpdatesEnabled( FALSE ); | 509 | viewport()->setUpdatesEnabled( FALSE ); |
518 | hidden.setAutoDelete(FALSE); | 510 | hidden.setAutoDelete(FALSE); |
519 | QList<AppLnk> links=hidden; | 511 | QList<AppLnk> links=hidden; |
520 | hidden.clear(); | 512 | hidden.clear(); |
521 | hidden.setAutoDelete(TRUE); | 513 | hidden.setAutoDelete(TRUE); |
522 | LauncherItem* item = (LauncherItem*)firstItem(); | 514 | LauncherItem* item = (LauncherItem*)firstItem(); |
523 | while (item) { | 515 | while (item) { |
524 | links.append(item->takeAppLnk()); | 516 | links.append(item->takeAppLnk()); |
525 | item = (LauncherItem*)item->nextItem(); | 517 | item = (LauncherItem*)item->nextItem(); |
526 | } | 518 | } |
527 | clear(); | 519 | clear(); |
528 | QListIterator<AppLnk> it(links); | 520 | QListIterator<AppLnk> it(links); |
529 | AppLnk* l; | 521 | AppLnk* l; |
530 | while ((l=it.current())) { | 522 | while ((l=it.current())) { |
531 | addItem(l,FALSE); | 523 | addItem(l,FALSE); |
532 | ++it; | 524 | ++it; |
533 | } | 525 | } |
534 | if ( resort && !autoArrange() ) | 526 | if ( resort && !autoArrange() ) |
535 | sort(); | 527 | sort(); |
536 | viewport()->setUpdatesEnabled( TRUE ); | 528 | viewport()->setUpdatesEnabled( TRUE ); |
537 | } | 529 | } |
538 | 530 | ||
539 | bool LauncherIconView::removeLink(const QString& linkfile) | 531 | bool LauncherIconView::removeLink(const QString& linkfile) |
540 | { | 532 | { |
541 | LauncherItem* item = (LauncherItem*)firstItem(); | 533 | LauncherItem* item = (LauncherItem*)firstItem(); |
542 | AppLnk* l; | 534 | AppLnk* l; |
543 | bool did = FALSE; | 535 | bool did = FALSE; |
544 | DocLnk dl(linkfile); | 536 | DocLnk dl(linkfile); |
545 | while (item) { | 537 | while (item) { |
546 | l = item->appLnk(); | 538 | l = item->appLnk(); |
547 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); | 539 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); |
548 | if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && | 540 | if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && |
549 | ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { | 541 | ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { |
550 | delete item; | 542 | delete item; |
551 | did = TRUE; | 543 | did = TRUE; |
552 | } | 544 | } |
553 | item = nextItem; | 545 | item = nextItem; |
554 | } | 546 | } |
555 | QListIterator<AppLnk> it(hidden); | 547 | QListIterator<AppLnk> it(hidden); |
556 | while ((l=it.current())) { | 548 | while ((l=it.current())) { |
557 | ++it; | 549 | ++it; |
558 | if ( l->linkFileKnown() && l->linkFile() == linkfile | 550 | if ( l->linkFileKnown() && l->linkFile() == linkfile |
559 | || l->file() == linkfile | 551 | || l->file() == linkfile |
560 | || dl.isValid() && dl.file() == l->file() ) { | 552 | || dl.isValid() && dl.file() == l->file() ) { |
561 | hidden.removeRef(l); | 553 | hidden.removeRef(l); |
562 | did = TRUE; | 554 | did = TRUE; |
563 | } | 555 | } |
564 | } | 556 | } |
565 | return did; | 557 | return did; |
566 | } | 558 | } |
567 | 559 | ||
568 | void LauncherIconView::timerEvent( QTimerEvent *te ) | 560 | void LauncherIconView::timerEvent( QTimerEvent *te ) |
569 | { | 561 | { |
570 | if ( te->timerId() == busyTimer ) { | 562 | if ( te->timerId() == busyTimer ) { |
571 | if ( bsy ) | 563 | if ( bsy ) |
572 | bsy->animateIcon(); | 564 | bsy->animateIcon(); |
573 | } else { | 565 | } else { |
574 | QIconView::timerEvent( te ); | 566 | QIconView::timerEvent( te ); |
575 | } | 567 | } |
576 | } | 568 | } |
577 | 569 | ||
578 | void LauncherIconView::setBigIcons( bool bi ) | 570 | void LauncherIconView::setBigIcons( bool bi ) |
579 | { | 571 | { |
580 | bigIcns = bi; | 572 | bigIcns = bi; |
581 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 573 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
582 | busyPix.resize(0,0); | 574 | busyPix.resize(0,0); |
583 | #endif | 575 | #endif |
584 | } | 576 | } |
585 | 577 | ||
586 | QIconViewItem* LauncherIconView::busyItem() const | 578 | QIconViewItem* LauncherIconView::busyItem() const |
587 | { | 579 | { |
588 | return bsy; | 580 | return bsy; |
589 | } | 581 | } |
590 | 582 | ||
591 | void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } | 583 | void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } |
592 | 584 | ||
593 | void LauncherIconView::calculateGrid( ItemTextPos pos ) | 585 | void LauncherIconView::calculateGrid( ItemTextPos pos ) |
594 | { | 586 | { |
595 | int dw = QApplication::desktop()->width(); | 587 | int dw = QApplication::desktop()->width(); |
596 | int viewerWidth = dw-style().scrollBarExtent().width(); | 588 | int viewerWidth = dw-style().scrollBarExtent().width(); |
597 | if ( pos == Bottom ) { | 589 | if ( pos == Bottom ) { |
598 | int cols = 3; | 590 | int cols = 3; |
599 | if ( viewerWidth <= 200 ) | 591 | if ( viewerWidth <= 200 ) |
600 | cols = 2; | 592 | cols = 2; |
601 | else if ( viewerWidth >= 400 ) | 593 | else if ( viewerWidth >= 400 ) |
602 | cols = viewerWidth/96; | 594 | cols = viewerWidth/96; |
603 | setSpacing( 4 ); | 595 | setSpacing( 4 ); |
604 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | 596 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); |
605 | setGridY( fontMetrics().height()*2+24 ); | 597 | setGridY( fontMetrics().height()*2+24 ); |
606 | } else { | 598 | } else { |
607 | int cols = 2; | 599 | int cols = 2; |
608 | if ( viewerWidth < 150 ) | 600 | if ( viewerWidth < 150 ) |
609 | cols = 1; | 601 | cols = 1; |
610 | else if ( viewerWidth >= 400 ) | 602 | else if ( viewerWidth >= 400 ) |
611 | cols = viewerWidth/150; | 603 | cols = viewerWidth/150; |
612 | setSpacing( 2 ); | 604 | setSpacing( 2 ); |
613 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | 605 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); |
614 | setGridY( fontMetrics().height()+2 ); | 606 | setGridY( fontMetrics().height()+2 ); |
615 | } | 607 | } |
616 | } | 608 | } |
617 | 609 | ||
618 | void LauncherIconView::styleChange( QStyle &old ) | 610 | void LauncherIconView::styleChange( QStyle &old ) |
619 | { | 611 | { |
620 | QIconView::styleChange( old ); | 612 | QIconView::styleChange( old ); |
621 | calculateGrid( itemTextPos() ); | 613 | calculateGrid( itemTextPos() ); |
622 | } | 614 | } |
623 | 615 | ||
624 | void LauncherIconView::keyPressEvent(QKeyEvent* e) | 616 | void LauncherIconView::keyPressEvent(QKeyEvent* e) |
625 | { | 617 | { |
626 | ike = TRUE; | 618 | ike = TRUE; |
627 | if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { | 619 | if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { |
628 | if ( (e->state() & ShiftButton) ) | 620 | if ( (e->state() & ShiftButton) ) |
629 | emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); | 621 | emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); |
630 | else | 622 | else |
631 | returnPressed(currentItem()); | 623 | returnPressed(currentItem()); |
632 | } | 624 | } |
633 | 625 | ||
634 | QIconView::keyPressEvent(e); | 626 | QIconView::keyPressEvent(e); |
635 | ike = FALSE; | 627 | ike = FALSE; |
636 | } | 628 | } |
637 | 629 | ||
638 | //=========================================================================== | 630 | //=========================================================================== |
639 | // Implemantation of LauncherIconview end | 631 | // Implemantation of LauncherIconview end |
640 | //=========================================================================== | 632 | //=========================================================================== |
641 | 633 | ||
642 | 634 | ||
643 | //=========================================================================== | 635 | //=========================================================================== |
644 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) | 636 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) |
645 | : QVBox( parent, name, fl ) | 637 | : QVBox( parent, name, fl ) |
646 | { | 638 | { |
647 | catmb = 0; | 639 | catmb = 0; |
648 | icons = new LauncherIconView( this ); | 640 | icons = new LauncherIconView( this ); |
649 | setFocusProxy(icons); | 641 | setFocusProxy(icons); |
650 | QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); | 642 | QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); |
651 | 643 | ||
652 | icons->setItemsMovable( FALSE ); | 644 | icons->setItemsMovable( FALSE ); |
653 | icons->setAutoArrange( TRUE ); | 645 | icons->setAutoArrange( TRUE ); |
654 | icons->setSorting( TRUE ); | 646 | icons->setSorting( TRUE ); |
655 | icons->setFrameStyle( QFrame::NoFrame ); | 647 | icons->setFrameStyle( QFrame::NoFrame ); |
656 | icons->setMargin( 0 ); | 648 | icons->setMargin( 0 ); |
657 | icons->setSelectionMode( QIconView::NoSelection ); | 649 | icons->setSelectionMode( QIconView::NoSelection ); |
658 | icons->setBackgroundMode( PaletteBase ); | 650 | icons->setBackgroundMode( PaletteBase ); |
659 | icons->setResizeMode( QIconView::Fixed ); | 651 | icons->setResizeMode( QIconView::Fixed ); |
660 | vmode = (ViewMode)-1; | 652 | vmode = (ViewMode)-1; |
661 | setViewMode( Icon ); | 653 | setViewMode( Icon ); |
662 | 654 | ||
663 | connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), | 655 | connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), |
664 | SLOT(itemClicked(int,QIconViewItem*)) ); | 656 | SLOT(itemClicked(int,QIconViewItem*)) ); |
665 | connect( icons, SIGNAL(selectionChanged()), | 657 | connect( icons, SIGNAL(selectionChanged()), |
666 | SLOT(selectionChanged()) ); | 658 | SLOT(selectionChanged()) ); |
667 | connect( icons, SIGNAL(returnPressed(QIconViewItem*)), | 659 | connect( icons, SIGNAL(returnPressed(QIconViewItem*)), |
668 | SLOT(returnPressed(QIconViewItem*)) ); | 660 | SLOT(returnPressed(QIconViewItem*)) ); |
669 | connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), | 661 | connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), |
670 | SLOT(itemPressed(int,QIconViewItem*)) ); | 662 | SLOT(itemPressed(int,QIconViewItem*)) ); |
671 | 663 | ||
672 | tools = 0; | 664 | tools = 0; |
673 | setBackgroundType( Ruled, QString::null ); | 665 | setBackgroundType( Ruled, QString::null ); |
674 | } | 666 | } |
675 | 667 | ||
676 | LauncherView::~LauncherView() | 668 | LauncherView::~LauncherView() |
677 | { | 669 | { |
678 | if ( bgCache && bgCache->contains( bgName ) ) | 670 | if ( bgCache && bgCache->contains( bgName ) ) |
679 | (*bgCache)[bgName]->ref--; | 671 | (*bgCache)[bgName]->ref--; |
680 | } | 672 | } |
681 | 673 | ||
682 | 674 | ||
683 | bool LauncherView::bsy=FALSE; | 675 | bool LauncherView::bsy=FALSE; |
684 | 676 | ||
685 | void LauncherView::setBusy(bool on) | 677 | void LauncherView::setBusy(bool on) |
686 | { | 678 | { |
687 | icons->setBusy(on); | 679 | icons->setBusy(on); |
688 | } | 680 | } |
689 | 681 | ||
690 | void LauncherView::setBusyIndicatorType( const QString& type ) { | 682 | void LauncherView::setBusyIndicatorType( const QString& type ) { |
691 | if ( type. lower ( ) == "animated" ) | 683 | if ( type. lower ( ) == "animated" ) |
692 | icons->setBusyIndicatorType( BIT_Animated ) ; | 684 | icons->setBusyIndicatorType( BIT_Animated ) ; |
693 | else | 685 | else |
694 | icons->setBusyIndicatorType( BIT_Normal ) ; | 686 | icons->setBusyIndicatorType( BIT_Normal ) ; |
695 | } | 687 | } |
696 | 688 | ||
697 | void LauncherView::hideIcons() | 689 | void LauncherView::hideIcons() |
698 | { | 690 | { |
699 | icons->hide(); | 691 | icons->hide(); |
700 | } | 692 | } |
701 | 693 | ||
702 | void LauncherView::setToolsEnabled(bool y) | 694 | void LauncherView::setToolsEnabled(bool y) |
703 | { | 695 | { |
704 | if ( !y != !tools ) { | 696 | if ( !y != !tools ) { |
705 | if ( y ) { | 697 | if ( y ) { |
706 | tools = new QHBox(this); | 698 | tools = new QHBox(this); |
707 | 699 | // Type filter | |
708 | // Type filter | 700 | typemb = new QComboBox(tools); |
709 | typemb = new QComboBox(tools); | 701 | QSizePolicy p = typemb->sizePolicy(); |
710 | QSizePolicy p = typemb->sizePolicy(); | 702 | p.setHorData(QSizePolicy::Expanding); |
711 | p.setHorData(QSizePolicy::Expanding); | 703 | typemb->setSizePolicy(p); |
712 | typemb->setSizePolicy(p); | 704 | // Category filter |
713 | 705 | updateTools(); | |
714 | // Category filter | 706 | tools->show(); |
715 | updateTools(); | 707 | } else { |
716 | tools->show(); | 708 | delete tools; |
717 | 709 | tools = 0; | |
718 | } else { | 710 | } |
719 | delete tools; | ||
720 | tools = 0; | ||
721 | } | ||
722 | } | 711 | } |
723 | } | 712 | } |
724 | 713 | ||
725 | void LauncherView::updateTools() | 714 | void LauncherView::updateTools() |
726 | { | 715 | { |
727 | disconnect( typemb, SIGNAL(activated(int)), | 716 | disconnect( typemb, SIGNAL(activated(int)), |
728 | this, SLOT(showType(int)) ); | 717 | this, SLOT(showType(int)) ); |
729 | if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), | 718 | if ( catmb ) { |
730 | this, SLOT(showCategory(int)) ); | 719 | disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int))); |
720 | } | ||
731 | 721 | ||
732 | // ### I want to remove this | 722 | // ### I want to remove this |
733 | icons->updateCategoriesAndMimeTypes(); | 723 | icons->updateCategoriesAndMimeTypes(); |
734 | 724 | ||
735 | QString prev; | 725 | QString prev; |
736 | 726 | ||
737 | // Type filter | 727 | // Type filter |
738 | QStringList types; | 728 | QStringList types; |
739 | typelist = icons->mimeTypes(); | 729 | typelist = icons->mimeTypes(); |
740 | for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { | 730 | for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { |
741 | QString t = *it; | 731 | QString t = *it; |
742 | if ( t.left(12) == "application/" ) { | 732 | if ( t.left(12) == "application/" ) { |
743 | MimeType mt(t); | 733 | MimeType mt(t); |
744 | const AppLnk* app = mt.application(); | 734 | const AppLnk* app = mt.application(); |
745 | if ( app ) | 735 | if ( app ) |
746 | t = app->name(); | 736 | t = app->name(); |
747 | else | 737 | else |
748 | t = t.mid(12); | 738 | t = t.mid(12); |
749 | } else { | 739 | } else { |
750 | t[0] = t[0].upper(); | 740 | t[0] = t[0].upper(); |
751 | } | 741 | } |
752 | types += t; | 742 | types += t; |
753 | } | 743 | } |
754 | types << tr("All types"); | 744 | types << tr("All types"); |
755 | prev = typemb->currentText(); | 745 | prev = typemb->currentText(); |
756 | typemb->clear(); | 746 | typemb->clear(); |
757 | typemb->insertStringList(types); | 747 | typemb->insertStringList(types); |
758 | for (int i=0; i<typemb->count(); i++) { | 748 | for (int i=0; i<typemb->count(); i++) { |
759 | if ( typemb->text(i) == prev ) { | 749 | if ( typemb->text(i) == prev ) { |
760 | typemb->setCurrentItem(i); | 750 | typemb->setCurrentItem(i); |
761 | break; | 751 | break; |
752 | } | ||
762 | } | 753 | } |
754 | if ( prev.isNull() ) { | ||
755 | typemb->setCurrentItem(typemb->count()-1); | ||
763 | } | 756 | } |
764 | if ( prev.isNull() ) | ||
765 | typemb->setCurrentItem(typemb->count()-1); | ||
766 | 757 | ||
767 | int pcat = catmb ? catmb->currentCategory() : -2; | 758 | int pcat = catmb ? catmb->currentCategory() : -2; |
768 | if ( !catmb ) | 759 | if ( !catmb ) |
769 | catmb = new CategorySelect(tools); | 760 | catmb = new CategorySelect(tools); |
770 | Categories cats( 0 ); | 761 | Categories cats( 0 ); |
771 | cats.load( categoryFileName() ); | 762 | cats.load( categoryFileName() ); |
772 | QArray<int> vl( 0 ); | 763 | QArray<int> vl( 0 ); |
773 | catmb->setCategories( vl, "Document View", // No tr | 764 | catmb->setCategories( vl, "Document View", // No tr |
774 | tr("Document View") ); | 765 | tr("Document View") ); |
775 | catmb->setRemoveCategoryEdit( TRUE ); | 766 | catmb->setRemoveCategoryEdit( TRUE ); |
776 | catmb->setAllCategories( TRUE ); | 767 | catmb->setAllCategories( TRUE ); |
777 | catmb->setCurrentCategory(pcat); | 768 | catmb->setCurrentCategory(pcat); |
778 | 769 | ||
779 | // if type has changed we need to redisplay | 770 | // if type has changed we need to redisplay |
780 | if ( typemb->currentText() != prev ) | 771 | if ( typemb->currentText() != prev ) |
781 | showType( typemb->currentItem() ); | 772 | showType( typemb->currentItem() ); |
782 | 773 | ||
783 | connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); | 774 | connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); |
784 | connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); | 775 | connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); |
785 | } | 776 | } |
786 | 777 | ||
787 | void LauncherView::sortBy(int s) | 778 | void LauncherView::sortBy(int s) |
788 | { | 779 | { |
789 | icons->setSortMethod((LauncherIconView::SortMethod)s); | 780 | icons->setSortMethod((LauncherIconView::SortMethod)s); |
790 | } | 781 | } |
791 | 782 | ||
792 | void LauncherView::showType(int t) | 783 | void LauncherView::showType(int t) |
793 | { | 784 | { |
794 | if ( t >= (int)typelist.count() ) { | 785 | if ( t >= (int)typelist.count() ) { |
795 | icons->setTypeFilter("",TRUE); | 786 | icons->setTypeFilter("",TRUE); |
796 | } else { | 787 | } else { |
797 | QString ty = typelist[t]; | 788 | QString ty = typelist[t]; |
798 | if ( !ty.contains('/') ) | 789 | if ( !ty.contains('/') ) |
799 | ty += "/*"; | 790 | ty += "/*"; |
800 | icons->setTypeFilter(ty,TRUE); | 791 | icons->setTypeFilter(ty,TRUE); |
801 | } | 792 | } |
802 | } | 793 | } |
803 | 794 | ||
804 | void LauncherView::showCategory( int c ) | 795 | void LauncherView::showCategory( int c ) |
805 | { | 796 | { |
806 | icons->setCategoryFilter( c, TRUE ); | 797 | icons->setCategoryFilter( c, TRUE ); |
807 | } | 798 | } |
808 | 799 | ||
809 | void LauncherView::setViewMode( ViewMode m ) | 800 | void LauncherView::setViewMode( ViewMode m ) |
810 | { | 801 | { |
802 | odebug << "LauncherView::setViewMode( ViewMode m )" << oendl; | ||
811 | if ( vmode != m ) { | 803 | if ( vmode != m ) { |
812 | bool bigIcons = m == Icon; | 804 | bool bigIcons = m == Icon; |
813 | icons->viewport()->setUpdatesEnabled( FALSE ); | 805 | icons->viewport()->setUpdatesEnabled( FALSE ); |
814 | icons->setBigIcons( bigIcons ); | 806 | icons->setBigIcons( bigIcons ); |
815 | switch ( m ) { | 807 | switch ( m ) { |
816 | case List: | 808 | case List: |
817 | icons->setItemTextPos( QIconView::Right ); | 809 | icons->setItemTextPos( QIconView::Right ); |
818 | break; | 810 | break; |
819 | case Icon: | 811 | case Icon: |
820 | icons->setItemTextPos( QIconView::Bottom ); | 812 | icons->setItemTextPos( QIconView::Bottom ); |
821 | break; | 813 | break; |
822 | } | 814 | } |
823 | icons->hideOrShowItems( FALSE ); | 815 | icons->hideOrShowItems( FALSE ); |
824 | icons->viewport()->setUpdatesEnabled( TRUE ); | 816 | icons->viewport()->setUpdatesEnabled( TRUE ); |
825 | vmode = m; | 817 | vmode = m; |
826 | } | 818 | } |
827 | } | 819 | } |
828 | 820 | ||
829 | // | 821 | // |
830 | // User images may require scaling. | 822 | // User images may require scaling. |
831 | // | 823 | // |
832 | QImage LauncherView::loadBackgroundImage(QString &bgName) | 824 | QImage LauncherView::loadBackgroundImage(QString &bgName) |
833 | { | 825 | { |
834 | QImageIO imgio; | 826 | QImageIO imgio; |
835 | QSize ds = qApp->desktop()->size(); // should be launcher, not desktop | 827 | QSize ds = qApp->desktop()->size(); // should be launcher, not desktop |
836 | bool further_scaling = TRUE; | 828 | bool further_scaling = TRUE; |
837 | 829 | ||
838 | imgio.setFileName( bgName ); | 830 | imgio.setFileName( bgName ); |
839 | imgio.setParameters("GetHeaderInformation"); | 831 | imgio.setParameters("GetHeaderInformation"); |
840 | 832 | ||
841 | if (imgio.read() == FALSE) { | 833 | if (imgio.read() == FALSE) { |
842 | return imgio.image(); | 834 | return imgio.image(); |
843 | } | 835 | } |
844 | 836 | ||
845 | if (imgio.image().width() < ds.width() && | 837 | if (imgio.image().width() < ds.width() && |
846 | imgio.image().height() < ds.height()) { | 838 | imgio.image().height() < ds.height()) { |
847 | further_scaling = FALSE; | 839 | further_scaling = FALSE; |
848 | } | 840 | } |
849 | 841 | ||
850 | if (!imgio.image().bits()) { | 842 | if (!imgio.image().bits()) { |
851 | // | 843 | // |
852 | // Scale and load. Note we don't scale up. | 844 | // Scale and load. Note we don't scale up. |
853 | // | 845 | // |
854 | QString param( "Scale( %1, %2, ScaleMin )" ); // No tr | 846 | QString param( "Scale( %1, %2, ScaleMin )" ); // No tr |
855 | imgio.setParameters(further_scaling ? | 847 | imgio.setParameters(further_scaling ? |
856 | param.arg(ds.width()).arg(ds.height()).latin1() : | 848 | param.arg(ds.width()).arg(ds.height()).latin1() : |
857 | ""); | 849 | ""); |
858 | imgio.read(); | 850 | imgio.read(); |
859 | } else { | 851 | } else { |
860 | if (further_scaling) { | 852 | if (further_scaling) { |
861 | int t1 = imgio.image().width() * ds.height(); | 853 | int t1 = imgio.image().width() * ds.height(); |
862 | int t2 = imgio.image().height() * ds.width(); | 854 | int t2 = imgio.image().height() * ds.width(); |
863 | int dsth = ds.height(); | 855 | int dsth = ds.height(); |
864 | int dstw = ds.width(); | 856 | int dstw = ds.width(); |
865 | 857 | ||
866 | if (t1 > t2) { | 858 | if (t1 > t2) { |
867 | dsth = t2 / imgio.image().width(); | 859 | dsth = t2 / imgio.image().width(); |
868 | } else { | 860 | } else { |
869 | dstw = t1 / imgio.image().height(); | 861 | dstw = t1 / imgio.image().height(); |
870 | } | 862 | } |
871 | 863 | ||
872 | // | 864 | // |
873 | // Loader didn't scale for us. Do it manually. | 865 | // Loader didn't scale for us. Do it manually. |
874 | // | 866 | // |
875 | return imgio.image().smoothScale(dstw, dsth); | 867 | return imgio.image().smoothScale(dstw, dsth); |
876 | } | 868 | } |
877 | } | 869 | } |
878 | 870 | ||
879 | return imgio.image(); | 871 | return imgio.image(); |
880 | } | 872 | } |
881 | 873 | ||
882 | void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) | 874 | void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) |
883 | { | 875 | { |
884 | if ( !bgCache ) { | 876 | if ( !bgCache ) { |
885 | bgCache = new QMap<QString,BgPixmap*>; | 877 | bgCache = new QMap<QString,BgPixmap*>; |
886 | qAddPostRoutine( cleanup_cache ); | 878 | qAddPostRoutine( cleanup_cache ); |
887 | } | 879 | } |
888 | 880 | ||
889 | if ( bgCache->contains( bgName ) ) | 881 | if ( bgCache->contains( bgName ) ) |
890 | (*bgCache)[bgName]->ref--; | 882 | (*bgCache)[bgName]->ref--; |
891 | bgName = ""; | 883 | bgName = ""; |
892 | 884 | ||
893 | QPixmap bg; | 885 | QPixmap bg; |
894 | 886 | ||
895 | switch ( t ) { | 887 | switch ( t ) { |
896 | case Ruled: { | 888 | case Ruled: { |
897 | bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr | 889 | bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr |
898 | if ( bgCache->contains( bgName ) ) { | 890 | if ( bgCache->contains( bgName ) ) { |
899 | (*bgCache)[bgName]->ref++; | 891 | (*bgCache)[bgName]->ref++; |
900 | bg = (*bgCache)[bgName]->pm; | 892 | bg = (*bgCache)[bgName]->pm; |
901 | } else { | 893 | } else { |
902 | bg.resize( width(), 9 ); | 894 | bg.resize( width(), 9 ); |
903 | QPainter painter( &bg ); | 895 | QPainter painter( &bg ); |
904 | for ( int i = 0; i < 3; i++ ) { | 896 | for ( int i = 0; i < 3; i++ ) { |
905 | painter.setPen( white ); | 897 | painter.setPen( white ); |
906 | painter.drawLine( 0, i*3, width()-1, i*3 ); | 898 | painter.drawLine( 0, i*3, width()-1, i*3 ); |
907 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); | 899 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); |
908 | painter.setPen( colorGroup().background().light(105) ); | 900 | painter.setPen( colorGroup().background().light(105) ); |
909 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); | 901 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); |
910 | } | 902 | } |
911 | painter.end(); | 903 | painter.end(); |
912 | bgCache->insert( bgName, new BgPixmap(bg) ); | 904 | bgCache->insert( bgName, new BgPixmap(bg) ); |
913 | } | 905 | } |
914 | break; | 906 | break; |
915 | } | 907 | } |
916 | 908 | ||
917 | case Image: | 909 | case Image: |
918 | if (!val.isEmpty()) { | 910 | if (!val.isEmpty()) { |
919 | bgName = val; | 911 | bgName = val; |
920 | if ( bgCache->contains( bgName ) ) { | 912 | if ( bgCache->contains( bgName ) ) { |
921 | (*bgCache)[bgName]->ref++; | 913 | (*bgCache)[bgName]->ref++; |
922 | bg = (*bgCache)[bgName]->pm; | 914 | bg = (*bgCache)[bgName]->pm; |
923 | } else { | 915 | } else { |
924 | QString imgFile = bgName; | 916 | QString imgFile = bgName; |
925 | bool tile = FALSE; | 917 | bool tile = FALSE; |
926 | if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { | 918 | if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { |
927 | imgFile = Resource::findPixmap( imgFile ); | 919 | imgFile = Resource::findPixmap( imgFile ); |
928 | tile = TRUE; | 920 | tile = TRUE; |
929 | } | 921 | } |
930 | QImage img = loadBackgroundImage(imgFile); | 922 | QImage img = loadBackgroundImage(imgFile); |
931 | 923 | ||
932 | 924 | ||
933 | if ( img.depth() == 1 ) | 925 | if ( img.depth() == 1 ) |
934 | img = img.convertDepth(8); | 926 | img = img.convertDepth(8); |
935 | img.setAlphaBuffer(FALSE); | 927 | img.setAlphaBuffer(FALSE); |
936 | bg.convertFromImage(img); | 928 | bg.convertFromImage(img); |
937 | bgCache->insert( bgName, new BgPixmap(bg) ); | 929 | bgCache->insert( bgName, new BgPixmap(bg) ); |
938 | } | 930 | } |
939 | } | 931 | } |
940 | break; | 932 | break; |
941 | 933 | ||
942 | case SolidColor: | 934 | case SolidColor: |
943 | default: | 935 | default: |
944 | break; | 936 | break; |
945 | } | 937 | } |
946 | 938 | ||
947 | const QObjectList *list = queryList( "QWidget", 0, FALSE ); | 939 | const QObjectList *list = queryList( "QWidget", 0, FALSE ); |
948 | QObject *obj; | 940 | QObject *obj; |
949 | for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { | 941 | for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { |
950 | if ( obj->isWidgetType() ) { | 942 | if ( obj->isWidgetType() ) { |
951 | QWidget *w = (QWidget*)obj; | 943 | QWidget *w = (QWidget*)obj; |
952 | w->setBackgroundPixmap( bg ); | 944 | w->setBackgroundPixmap( bg ); |
953 | if ( bgName.isEmpty() ) { | 945 | if ( bgName.isEmpty() ) { |
954 | // Solid Color | 946 | // Solid Color |
955 | if ( val.isEmpty() ) | 947 | if ( val.isEmpty() ) |
956 | w->setBackgroundColor( colorGroup().base() ); | 948 | w->setBackgroundColor( colorGroup().base() ); |
957 | else | 949 | else |
958 | w->setBackgroundColor( val ); | 950 | w->setBackgroundColor( val ); |
959 | } else { | 951 | } else { |
960 | // Ruled or Image pixmap | 952 | // Ruled or Image pixmap |
961 | w->setBackgroundOrigin( ParentOrigin ); | 953 | w->setBackgroundOrigin( ParentOrigin ); |
962 | } | 954 | } |
963 | } | 955 | } |
964 | } | 956 | } |
965 | delete list; | 957 | delete list; |
966 | 958 | ||
967 | bgType = t; | 959 | bgType = t; |
968 | icons->viewport()->update(); | 960 | icons->viewport()->update(); |
969 | 961 | ||
970 | QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); | 962 | QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); |
971 | } | 963 | } |
972 | 964 | ||
973 | void LauncherView::setTextColor( const QColor &tc ) | 965 | void LauncherView::setTextColor( const QColor &tc ) |
974 | { | 966 | { |
975 | textCol = tc; | 967 | textCol = tc; |
976 | QColorGroup cg = icons->colorGroup(); | 968 | QColorGroup cg = icons->colorGroup(); |
977 | cg.setColor( QColorGroup::Text, tc ); | 969 | cg.setColor( QColorGroup::Text, tc ); |
978 | icons->setPalette( QPalette(cg,cg,cg) ); | 970 | icons->setPalette( QPalette(cg,cg,cg) ); |
979 | icons->viewport()->update(); | 971 | icons->viewport()->update(); |
980 | } | 972 | } |
981 | 973 | ||
982 | void LauncherView::setViewFont( const QFont &f ) | 974 | void LauncherView::setViewFont( const QFont &f ) |
983 | { | 975 | { |
984 | icons->setFont( f ); | 976 | icons->setFont( f ); |
985 | icons->hideOrShowItems( FALSE ); | 977 | icons->hideOrShowItems( FALSE ); |
986 | } | 978 | } |
987 | 979 | ||
988 | void LauncherView::clearViewFont() | 980 | void LauncherView::clearViewFont() |
989 | { | 981 | { |
990 | icons->unsetFont(); | 982 | icons->unsetFont(); |
991 | icons->hideOrShowItems( FALSE ); | 983 | icons->hideOrShowItems( FALSE ); |
992 | } | 984 | } |
993 | 985 | ||
994 | void LauncherView::resizeEvent(QResizeEvent *e) | 986 | void LauncherView::resizeEvent(QResizeEvent *e) |
995 | { | 987 | { |
996 | // qDebug("LauncherView resize event"); | 988 | // qDebug("LauncherView resize event"); |
997 | QVBox::resizeEvent( e ); | 989 | QVBox::resizeEvent( e ); |
998 | // commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere... | 990 | // commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere... |
999 | // if ( e->size().width() != e->oldSize().width() ) | 991 | // if ( e->size().width() != e->oldSize().width() ) |
1000 | sort(); | 992 | sort(); |
1001 | } | 993 | } |
1002 | 994 | ||
1003 | void LauncherView::selectionChanged() | 995 | void LauncherView::selectionChanged() |
1004 | { | 996 | { |
1005 | QIconViewItem* item = icons->currentItem(); | 997 | QIconViewItem* item = icons->currentItem(); |
1006 | if ( item && item->isSelected() ) { | 998 | if ( item && item->isSelected() ) { |
1007 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 999 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
1008 | if ( icons->inKeyEvent() ) // not for mouse press | 1000 | if ( icons->inKeyEvent() ) // not for mouse press |
1009 | emit clicked( appLnk ); | 1001 | emit clicked( appLnk ); |
1010 | item->setSelected(FALSE); | 1002 | item->setSelected(FALSE); |
1011 | } | 1003 | } |
1012 | } | 1004 | } |
1013 | 1005 | ||
1014 | void LauncherView::returnPressed( QIconViewItem *item ) | 1006 | void LauncherView::returnPressed( QIconViewItem *item ) |
1015 | { | 1007 | { |
1016 | if ( item ) { | 1008 | if ( item ) { |
1017 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 1009 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
1018 | emit clicked( appLnk ); | 1010 | emit clicked( appLnk ); |
1019 | } | 1011 | } |
1020 | } | 1012 | } |
1021 | 1013 | ||
1022 | void LauncherView::itemClicked( int btn, QIconViewItem *item ) | 1014 | void LauncherView::itemClicked( int btn, QIconViewItem *item ) |
1023 | { | 1015 | { |
1024 | if ( item ) { | 1016 | if ( item ) { |
1025 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 1017 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
1026 | if ( btn == LeftButton ) { | 1018 | if ( btn == LeftButton ) { |
1027 | // Make sure it's the item we execute that gets highlighted | 1019 | // Make sure it's the item we execute that gets highlighted |
1028 | icons->setCurrentItem( item ); | 1020 | icons->setCurrentItem( item ); |
1029 | emit clicked( appLnk ); | 1021 | emit clicked( appLnk ); |
1030 | } | 1022 | } |
1031 | item->setSelected(FALSE); | 1023 | item->setSelected(FALSE); |
1032 | } | 1024 | } |
1033 | } | 1025 | } |
1034 | 1026 | ||
1035 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) | 1027 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) |
1036 | { | 1028 | { |
1037 | if ( item ) { | 1029 | if ( item ) { |
1038 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 1030 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
1039 | if ( btn == RightButton ) | 1031 | if ( btn == RightButton ) |
1040 | emit rightPressed( appLnk ); | 1032 | emit rightPressed( appLnk ); |
1041 | else if ( btn == ShiftButton ) | 1033 | else if ( btn == ShiftButton ) |
1042 | emit rightPressed( appLnk ); | 1034 | emit rightPressed( appLnk ); |
1043 | item->setSelected(FALSE); | 1035 | item->setSelected(FALSE); |
1044 | } | 1036 | } |
1045 | } | 1037 | } |
1046 | 1038 | ||
1047 | void LauncherView::removeAllItems() | 1039 | void LauncherView::removeAllItems() |
1048 | { | 1040 | { |
1041 | odebug << "LauncherView::removeAllItems()" << oendl; | ||
1049 | icons->clear(); | 1042 | icons->clear(); |
1050 | } | 1043 | } |
1051 | 1044 | ||
1052 | bool LauncherView::removeLink(const QString& linkfile) | 1045 | bool LauncherView::removeLink(const QString& linkfile) |
1053 | { | 1046 | { |
1054 | return icons->removeLink(linkfile); | 1047 | return icons->removeLink(linkfile); |
1055 | } | 1048 | } |
1056 | 1049 | ||
1057 | void LauncherView::setSortEnabled( bool v ) | 1050 | void LauncherView::setSortEnabled( bool v ) |
1058 | { | 1051 | { |
1059 | icons->setSorting( v ); | 1052 | icons->setSorting( v ); |
1060 | if ( v ) | 1053 | if ( v ) |
1061 | sort(); | 1054 | sort(); |
1062 | } | 1055 | } |
1063 | 1056 | ||
1064 | void LauncherView::setUpdatesEnabled( bool u ) | 1057 | void LauncherView::setUpdatesEnabled( bool u ) |
1065 | { | 1058 | { |
1066 | icons->setUpdatesEnabled( u ); | 1059 | icons->setUpdatesEnabled( u ); |
1067 | } | 1060 | } |
1068 | 1061 | ||
1069 | void LauncherView::sort() | 1062 | void LauncherView::sort() |
1070 | { | 1063 | { |
1071 | icons->sort(); | 1064 | icons->sort(); |
1072 | } | 1065 | } |
1073 | 1066 | ||
1074 | void LauncherView::addItem(AppLnk* app, bool resort) | 1067 | void LauncherView::addItem(AppLnk* app, bool resort) |
1075 | { | 1068 | { |
1076 | icons->addItem(app,resort); | 1069 | icons->addItem(app,resort); |
1077 | } | 1070 | } |
1078 | 1071 | ||
1079 | void LauncherView::paletteChange( const QPalette &p ) | 1072 | void LauncherView::paletteChange( const QPalette &p ) |
1080 | { | 1073 | { |
1081 | icons->unsetPalette(); | 1074 | icons->unsetPalette(); |
1082 | QVBox::paletteChange( p ); | 1075 | QVBox::paletteChange( p ); |
1083 | if ( bgType == Ruled ) | 1076 | if ( bgType == Ruled ) |
1084 | setBackgroundType( Ruled, QString::null ); | 1077 | setBackgroundType( Ruled, QString::null ); |
1085 | QColorGroup cg = icons->colorGroup(); | 1078 | QColorGroup cg = icons->colorGroup(); |
1086 | cg.setColor( QColorGroup::Text, textCol ); | 1079 | cg.setColor( QColorGroup::Text, textCol ); |
1087 | icons->setPalette( QPalette(cg,cg,cg) ); | 1080 | icons->setPalette( QPalette(cg,cg,cg) ); |
1088 | } | 1081 | } |
1089 | 1082 | ||
1090 | void LauncherView::fontChanged(const QFont&) | 1083 | void LauncherView::fontChanged(const QFont&) |
1091 | { | 1084 | { |
1092 | odebug << "LauncherView::fontChanged()" << oendl; | 1085 | odebug << "LauncherView::fontChanged()" << oendl; |
1093 | icons->hideOrShowItems( FALSE ); | 1086 | icons->hideOrShowItems( FALSE ); |
1094 | } | 1087 | } |
1095 | 1088 | ||
1096 | void LauncherView::relayout(void) | 1089 | void LauncherView::relayout(void) |
1097 | { | 1090 | { |
1098 | icons->hideOrShowItems(FALSE); | 1091 | icons->hideOrShowItems(FALSE); |
1099 | } | 1092 | } |
1100 | 1093 | ||
1101 | void LauncherView::flushBgCache() | 1094 | void LauncherView::flushBgCache() |
1102 | { | 1095 | { |
1103 | if ( !bgCache ) | 1096 | if ( !bgCache ) |
1104 | return; | 1097 | return; |
1105 | // remove unreferenced backgrounds. | 1098 | // remove unreferenced backgrounds. |
1106 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); | 1099 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); |
1107 | while ( it != bgCache->end() ) { | 1100 | while ( it != bgCache->end() ) { |
1108 | QMap<QString,BgPixmap*>::Iterator curr = it; | 1101 | QMap<QString,BgPixmap*>::Iterator curr = it; |
1109 | ++it; | 1102 | ++it; |
1110 | if ( (*curr)->ref == 0 ) { | 1103 | if ( (*curr)->ref == 0 ) { |
1111 | delete (*curr); | 1104 | delete (*curr); |
1112 | bgCache->remove( curr ); | 1105 | bgCache->remove( curr ); |
1113 | } | 1106 | } |
1114 | } | 1107 | } |
1115 | } | 1108 | } |
1116 | 1109 | ||
1117 | /* | 1110 | /* |
1118 | * Launcherthumbnail handling for image files | 1111 | * Launcherthumbnail handling for image files |
1119 | */ | 1112 | */ |
1120 | 1113 | ||
1121 | /* special image handling - based on opie eye */ | 1114 | /* special image handling - based on opie eye */ |
1122 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { | 1115 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { |
1123 | s >> inf.file >> inf.pixmap >> inf.width >> inf.height; | 1116 | s >> inf.file >> inf.pixmap >> inf.width >> inf.height; |
1124 | return s; | 1117 | return s; |
1125 | } | 1118 | } |
1126 | 1119 | ||
1127 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { | 1120 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { |
1128 | return s << inf.file << inf.width << inf.height; | 1121 | return s << inf.file << inf.width << inf.height; |
1129 | } | 1122 | } |
1130 | 1123 | ||
1131 | LauncherThumbReceiver::LauncherThumbReceiver() | 1124 | LauncherThumbReceiver::LauncherThumbReceiver() |
1132 | :QObject() | 1125 | :QObject() |
1133 | { | 1126 | { |
1134 | QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); | 1127 | QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); |
1135 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), | 1128 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), |
1136 | this, SLOT(recieve(const QCString&,const QByteArray&)) ); | 1129 | this, SLOT(recieve(const QCString&,const QByteArray&)) ); |
1137 | 1130 | ||
1138 | { | 1131 | { |
1139 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 1132 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
1140 | } | 1133 | } |
1141 | } | 1134 | } |
1142 | 1135 | ||
1143 | LauncherThumbReceiver::~LauncherThumbReceiver() | 1136 | LauncherThumbReceiver::~LauncherThumbReceiver() |
1144 | { | 1137 | { |
1145 | { | 1138 | { |
1146 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 1139 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
1147 | } | 1140 | } |
1148 | } | 1141 | } |
1149 | 1142 | ||
1150 | void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) | 1143 | void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) |
1151 | { | 1144 | { |
1152 | PixmapInfos pixinfos; | 1145 | PixmapInfos pixinfos; |
1153 | QDataStream stream( at, IO_ReadOnly ); | 1146 | QDataStream stream( at, IO_ReadOnly ); |
1154 | 1147 | ||
1155 | /* we are just interested in thumbmails */ | 1148 | /* we are just interested in thumbmails */ |
1156 | if ( str == "pixmapsHandled(PixmapList)" ) | 1149 | if ( str == "pixmapsHandled(PixmapList)" ) |
1157 | stream >> pixinfos; | 1150 | stream >> pixinfos; |
1158 | 1151 | ||
1159 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { | 1152 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { |
1160 | emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); | 1153 | emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); |
1161 | } | 1154 | } |
1162 | } | 1155 | } |
1163 | 1156 | ||
1164 | void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) | 1157 | void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) |
1165 | { | 1158 | { |
1166 | PixmapInfo rItem; | 1159 | PixmapInfo rItem; |
1167 | rItem.file = file; | 1160 | rItem.file = file; |
1168 | rItem.width = width; | 1161 | rItem.width = width; |
1169 | rItem.height = height; | 1162 | rItem.height = height; |
1170 | m_inThumbNail.append(rItem); | 1163 | m_inThumbNail.append(rItem); |
1171 | QTimer::singleShot(0, this, SLOT(sendRequest())); | 1164 | QTimer::singleShot(2, this, SLOT(sendRequest())); |
1172 | } | 1165 | } |
1173 | 1166 | ||
1174 | void LauncherThumbReceiver::sendRequest() | 1167 | void LauncherThumbReceiver::sendRequest() |
1175 | { | 1168 | { |
1176 | if (m_inThumbNail.count()>0) { | 1169 | if (m_inThumbNail.count()>0) { |
1177 | QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); | 1170 | QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); |
1178 | env << m_inThumbNail; | 1171 | env << m_inThumbNail; |
1179 | m_inThumbNail.clear(); | 1172 | m_inThumbNail.clear(); |
1180 | } | 1173 | } |
1181 | } | 1174 | } |
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h index 94c367c..6d94539 100644 --- a/core/launcher/launcherview.h +++ b/core/launcher/launcherview.h | |||
@@ -1,246 +1,245 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LAUNCHERVIEW_H | 20 | #ifndef LAUNCHERVIEW_H |
21 | #define LAUNCHERVIEW_H | 21 | #define LAUNCHERVIEW_H |
22 | 22 | ||
23 | #include <qtopia/storage.h> | 23 | #include <qtopia/storage.h> |
24 | #include <qtopia/applnk.h> | 24 | #include <qtopia/applnk.h> |
25 | 25 | ||
26 | #include <qvbox.h> | 26 | #include <qvbox.h> |
27 | #include <qiconview.h> | 27 | #include <qiconview.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qmap.h> | 29 | #include <qmap.h> |
30 | 30 | ||
31 | class CategorySelect; | 31 | class CategorySelect; |
32 | class LauncherIconView; | 32 | class LauncherIconView; |
33 | class LauncherItem; | 33 | class LauncherItem; |
34 | class QIconViewItem; | 34 | class QIconViewItem; |
35 | class QLabel; | 35 | class QLabel; |
36 | class QWidgetStack; | 36 | class QWidgetStack; |
37 | class MenuButton; | 37 | class MenuButton; |
38 | class QComboBox; | 38 | class QComboBox; |
39 | 39 | ||
40 | 40 | ||
41 | 41 | ||
42 | enum BusyIndicatorType { | 42 | enum BusyIndicatorType { |
43 | BIT_Normal = 0, | 43 | BIT_Normal = 0, |
44 | BIT_Animated | 44 | BIT_Animated |
45 | }; | 45 | }; |
46 | 46 | ||
47 | class LauncherView : public QVBox | 47 | class LauncherView : public QVBox |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | 50 | ||
51 | public: | 51 | public: |
52 | LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 52 | LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
53 | ~LauncherView(); | 53 | ~LauncherView(); |
54 | 54 | ||
55 | void hideIcons(); | 55 | void hideIcons(); |
56 | 56 | ||
57 | bool removeLink(const QString& linkfile); | 57 | bool removeLink(const QString& linkfile); |
58 | void addItem(AppLnk* app, bool resort=TRUE); | 58 | void addItem(AppLnk* app, bool resort=TRUE); |
59 | void removeAllItems(); | 59 | void removeAllItems(); |
60 | void setSortEnabled(bool); | 60 | void setSortEnabled(bool); |
61 | void setUpdatesEnabled(bool); | 61 | void setUpdatesEnabled(bool); |
62 | void sort(); | 62 | void sort(); |
63 | 63 | ||
64 | void setToolsEnabled(bool); | 64 | void setToolsEnabled(bool); |
65 | void updateTools(); | 65 | void updateTools(); |
66 | 66 | ||
67 | void setBusy(bool); | 67 | void setBusy(bool); |
68 | void setBusyIndicatorType( const QString& ); | 68 | void setBusyIndicatorType( const QString& ); |
69 | 69 | ||
70 | enum ViewMode { Icon, List }; | 70 | enum ViewMode { Icon, List }; |
71 | void setViewMode( ViewMode m ); | 71 | void setViewMode( ViewMode m ); |
72 | ViewMode viewMode() const { return vmode; } | 72 | ViewMode viewMode() const { return vmode; } |
73 | 73 | ||
74 | enum BackgroundType { Ruled, SolidColor, Image }; | 74 | enum BackgroundType { Ruled, SolidColor, Image }; |
75 | void setBackgroundType( BackgroundType t, const QString & ); | 75 | void setBackgroundType( BackgroundType t, const QString & ); |
76 | BackgroundType backgroundType() const { return bgType; } | 76 | BackgroundType backgroundType() const { return bgType; } |
77 | 77 | ||
78 | void setTextColor( const QColor & ); | 78 | void setTextColor( const QColor & ); |
79 | QColor textColor() const { return textCol; } | 79 | QColor textColor() const { return textCol; } |
80 | 80 | ||
81 | void setViewFont( const QFont & ); | 81 | void setViewFont( const QFont & ); |
82 | void clearViewFont(); | 82 | void clearViewFont(); |
83 | 83 | ||
84 | void relayout(void); | 84 | void relayout(void); |
85 | 85 | ||
86 | signals: | 86 | signals: |
87 | void clicked( const AppLnk * ); | 87 | void clicked( const AppLnk * ); |
88 | void rightPressed( AppLnk * ); | 88 | void rightPressed( AppLnk * ); |
89 | 89 | ||
90 | protected slots: | 90 | protected slots: |
91 | void selectionChanged(); | 91 | void selectionChanged(); |
92 | void returnPressed( QIconViewItem *item ); | 92 | void returnPressed( QIconViewItem *item ); |
93 | void itemClicked( int, QIconViewItem * ); | 93 | void itemClicked( int, QIconViewItem * ); |
94 | void itemPressed( int, QIconViewItem * ); | 94 | void itemPressed( int, QIconViewItem * ); |
95 | void sortBy(int); | 95 | void sortBy(int); |
96 | void showType(int); | 96 | void showType(int); |
97 | void showCategory( int ); | 97 | void showCategory( int ); |
98 | void resizeEvent(QResizeEvent *); | 98 | void resizeEvent(QResizeEvent *); |
99 | void flushBgCache(); | 99 | void flushBgCache(); |
100 | 100 | ||
101 | protected: | 101 | protected: |
102 | void paletteChange( const QPalette & ); | 102 | void paletteChange( const QPalette & ); |
103 | 103 | ||
104 | void fontChanged(const QFont &); | 104 | void fontChanged(const QFont &); |
105 | 105 | ||
106 | private: | 106 | private: |
107 | static bool bsy; | 107 | static bool bsy; |
108 | QWidget* tools; | 108 | QWidget* tools; |
109 | LauncherIconView* icons; | 109 | LauncherIconView* icons; |
110 | QComboBox *typemb; | 110 | QComboBox *typemb; |
111 | QStringList typelist; | 111 | QStringList typelist; |
112 | CategorySelect *catmb; | 112 | CategorySelect *catmb; |
113 | ViewMode vmode; | 113 | ViewMode vmode; |
114 | BackgroundType bgType; | 114 | BackgroundType bgType; |
115 | QString bgName; | 115 | QString bgName; |
116 | QColor textCol; | 116 | QColor textCol; |
117 | 117 | ||
118 | QImage loadBackgroundImage(QString &fname); | 118 | QImage loadBackgroundImage(QString &fname); |
119 | 119 | ||
120 | }; | 120 | }; |
121 | 121 | ||
122 | /* from opie-eye */ | 122 | /* from opie-eye */ |
123 | struct PixmapInfo { | 123 | struct PixmapInfo { |
124 | PixmapInfo() : width( -1 ), height( -1 ) {} | 124 | PixmapInfo() : width( -1 ), height( -1 ) {} |
125 | bool operator==( const PixmapInfo& r ) { | 125 | bool operator==( const PixmapInfo& r ) { |
126 | if ( width != r.width ) return false; | 126 | if ( width != r.width ) return false; |
127 | if ( height != r.height ) return false; | 127 | if ( height != r.height ) return false; |
128 | if ( file != r.file ) return false; | 128 | if ( file != r.file ) return false; |
129 | return true; | 129 | return true; |
130 | } | 130 | } |
131 | int width, height; | 131 | int width, height; |
132 | QString file; | 132 | QString file; |
133 | QPixmap pixmap; | 133 | QPixmap pixmap; |
134 | }; | 134 | }; |
135 | 135 | ||
136 | class LauncherThumbReceiver:public QObject | 136 | class LauncherThumbReceiver:public QObject |
137 | { | 137 | { |
138 | Q_OBJECT | 138 | Q_OBJECT |
139 | typedef QValueList<PixmapInfo> PixmapInfos; | 139 | typedef QValueList<PixmapInfo> PixmapInfos; |
140 | public: | 140 | public: |
141 | LauncherThumbReceiver(); | 141 | LauncherThumbReceiver(); |
142 | ~LauncherThumbReceiver(); | 142 | ~LauncherThumbReceiver(); |
143 | void requestThumb(const QString&file,int width,int height); | 143 | void requestThumb(const QString&file,int width,int height); |
144 | 144 | ||
145 | public slots: | 145 | public slots: |
146 | void recieve( const QCString&, const QByteArray& ); | 146 | void recieve( const QCString&, const QByteArray& ); |
147 | protected slots: | 147 | protected slots: |
148 | virtual void sendRequest(); | 148 | virtual void sendRequest(); |
149 | 149 | ||
150 | signals: | 150 | signals: |
151 | void sig_Thumbnail(const QPixmap&,const QString&,int); | 151 | void sig_Thumbnail(const QPixmap&,const QString&,int); |
152 | 152 | ||
153 | protected: | 153 | protected: |
154 | PixmapInfos m_inThumbNail; | 154 | PixmapInfos m_inThumbNail; |
155 | }; | 155 | }; |
156 | 156 | ||
157 | class LauncherIconView : public QIconView { | 157 | class LauncherIconView : public QIconView { |
158 | Q_OBJECT | 158 | Q_OBJECT |
159 | public: | 159 | public: |
160 | LauncherIconView( QWidget* parent, const char* name=0 ); | 160 | LauncherIconView( QWidget* parent, const char* name=0 ); |
161 | ~LauncherIconView(); | 161 | ~LauncherIconView(); |
162 | QIconViewItem* busyItem() const; | 162 | QIconViewItem* busyItem() const; |
163 | 163 | ||
164 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 164 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
165 | QPixmap busyPixmap() const { return busyPix; } | 165 | QPixmap busyPixmap() const { return busyPix; } |
166 | #endif | 166 | #endif |
167 | void setBigIcons( bool bi ); | 167 | void setBigIcons( bool bi ); |
168 | void updateCategoriesAndMimeTypes(); | 168 | void updateCategoriesAndMimeTypes(); |
169 | void setBusyIndicatorType ( BusyIndicatorType t ); | 169 | void setBusyIndicatorType ( BusyIndicatorType t ); |
170 | void doAutoScroll() | 170 | void doAutoScroll() |
171 | { | 171 | { |
172 | // We don't want rubberbanding (yet) | 172 | // We don't want rubberbanding (yet) |
173 | } | 173 | } |
174 | 174 | ||
175 | void setBusy(bool on); | 175 | void setBusy(bool on); |
176 | bool inKeyEvent() const { return ike; } | 176 | bool inKeyEvent() const { return ike; } |
177 | 177 | ||
178 | void addItem(AppLnk* app, bool resort=TRUE); | 178 | void addItem(AppLnk* app, bool resort=TRUE); |
179 | bool removeLink(const QString& linkfile); | 179 | bool removeLink(const QString& linkfile); |
180 | 180 | ||
181 | QStringList mimeTypes() const; | 181 | QStringList mimeTypes() const; |
182 | QStringList categories() const; | 182 | QStringList categories() const; |
183 | void clear(); | 183 | void clear(); |
184 | void addCatsAndMimes(AppLnk* app); | 184 | void addCatsAndMimes(AppLnk* app); |
185 | 185 | ||
186 | void setBackgroundOrigin( QWidget::BackgroundOrigin ) {} | 186 | void setBackgroundOrigin( QWidget::BackgroundOrigin ) {} |
187 | 187 | ||
188 | void setBackgroundPixmap( const QPixmap &pm ) { | 188 | void setBackgroundPixmap( const QPixmap &pm ) { |
189 | bgPixmap = pm; | 189 | bgPixmap = pm; |
190 | } | 190 | } |
191 | 191 | ||
192 | void setBackgroundColor( const QColor &c ) { | 192 | void setBackgroundColor( const QColor &c ) { |
193 | bgColor = c; | 193 | bgColor = c; |
194 | } | 194 | } |
195 | 195 | ||
196 | void drawBackground( QPainter *p, const QRect &r ); | 196 | void drawBackground( QPainter *p, const QRect &r ); |
197 | void setItemTextPos( ItemTextPos pos ); | 197 | void setItemTextPos( ItemTextPos pos ); |
198 | void hideOrShowItems(bool resort); | 198 | void hideOrShowItems(bool resort); |
199 | 199 | ||
200 | void setTypeFilter(const QString& typefilter, bool resort); | 200 | void setTypeFilter(const QString& typefilter, bool resort); |
201 | void setCategoryFilter( int catfilter, bool resort ); | 201 | void setCategoryFilter( int catfilter, bool resort ); |
202 | 202 | ||
203 | enum SortMethod { Name, Date, Type }; | 203 | enum SortMethod { Name, Date, Type }; |
204 | 204 | ||
205 | void setSortMethod( SortMethod m ); | 205 | void setSortMethod( SortMethod m ); |
206 | int compare(const AppLnk* a, const AppLnk* b); | 206 | int compare(const AppLnk* a, const AppLnk* b); |
207 | void requestEyePix(const LauncherItem*which); | 207 | void requestEyePix(const LauncherItem*which); |
208 | 208 | ||
209 | protected: | 209 | protected: |
210 | virtual void timerEvent( QTimerEvent *te ); | 210 | virtual void timerEvent( QTimerEvent *te ); |
211 | void styleChange( QStyle &old ); | 211 | void styleChange( QStyle &old ); |
212 | void calculateGrid( ItemTextPos pos ); | 212 | void calculateGrid( ItemTextPos pos ); |
213 | void focusInEvent( QFocusEvent * ) {} | 213 | void focusInEvent( QFocusEvent * ) {} |
214 | void focusOutEvent( QFocusEvent * ) {} | 214 | void focusOutEvent( QFocusEvent * ) {} |
215 | LauncherItem*findDocItem(const QString&); | 215 | LauncherItem*findDocItem(const QString&); |
216 | void addCheckItem(AppLnk* app); | 216 | void addCheckItem(AppLnk* app); |
217 | void checkCallback(); | 217 | void checkCallback(); |
218 | virtual void keyPressEvent(QKeyEvent* e); | 218 | virtual void keyPressEvent(QKeyEvent* e); |
219 | 219 | ||
220 | protected slots: | 220 | protected slots: |
221 | void setEyePixmap(const QPixmap&,const QString&,int width); | 221 | void setEyePixmap(const QPixmap&,const QString&,int width); |
222 | void stopEyeTimer(); | 222 | void stopEyeTimer(); |
223 | 223 | ||
224 | private: | 224 | private: |
225 | QList<AppLnk> hidden; | 225 | QList<AppLnk> hidden; |
226 | QDict<void> mimes; | 226 | QDict<void> mimes; |
227 | QDict<void> cats; | 227 | QDict<void> cats; |
228 | SortMethod sortmeth; | 228 | SortMethod sortmeth; |
229 | QRegExp tf; | 229 | QRegExp tf; |
230 | int cf; | 230 | int cf; |
231 | LauncherItem* bsy; | 231 | LauncherItem* bsy; |
232 | int busyTimer; | 232 | int busyTimer; |
233 | bool ike; | 233 | bool ike; |
234 | bool bigIcns; | 234 | bool bigIcns; |
235 | QPixmap bgPixmap; | 235 | QPixmap bgPixmap; |
236 | QColor bgColor; | 236 | QColor bgColor; |
237 | LauncherThumbReceiver*m_EyeCallBack; | 237 | LauncherThumbReceiver*m_EyeCallBack; |
238 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 238 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
239 | QPixmap busyPix; | 239 | QPixmap busyPix; |
240 | #endif | 240 | #endif |
241 | BusyIndicatorType busyType; | 241 | BusyIndicatorType busyType; |
242 | QTimer m_eyeTimer; | 242 | QTimer m_eyeTimer; |
243 | QMap<QString,LauncherItem*> m_itemCache; | ||
244 | }; | 243 | }; |
245 | 244 | ||
246 | #endif // LAUNCHERVIEW_H | 245 | #endif // LAUNCHERVIEW_H |