summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-01-11 17:32:06 (UTC)
committer mickeyl <mickeyl>2005-01-11 17:32:06 (UTC)
commitf8fd8556da5649f54af740a5dbb9a8c1ead2bcfc (patch) (unidiff)
treedb41b30ad733fc476746e1a9c7576a5a083240fa
parentf82173157bdba4fa99afde9cc999bfe9b511ce07 (diff)
downloadopie-f8fd8556da5649f54af740a5dbb9a8c1ead2bcfc.zip
opie-f8fd8556da5649f54af740a5dbb9a8c1ead2bcfc.tar.gz
opie-f8fd8556da5649f54af740a5dbb9a8c1ead2bcfc.tar.bz2
finish per-tab column setting. it now works on the fly and is persistent
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp7
-rw-r--r--core/launcher/launcherview.cpp2
-rw-r--r--core/settings/launcher/tabconfig.h1
-rw-r--r--core/settings/launcher/tabdialog.cpp1
-rw-r--r--core/settings/launcher/tabssettings.cpp6
5 files changed, 15 insertions, 2 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 4f81076..4255b44 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -1,812 +1,819 @@
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 "startmenu.h" 21#include "startmenu.h"
22#include "taskbar.h" 22#include "taskbar.h"
23#include "serverinterface.h" 23#include "serverinterface.h"
24#include "launcherview.h" 24#include "launcherview.h"
25#include "launcher.h" 25#include "launcher.h"
26#include "server.h" 26#include "server.h"
27 27
28/* OPIE */ 28/* OPIE */
29#include <opie2/odebug.h> 29#include <opie2/odebug.h>
30#include <qtopia/global.h> 30#include <qtopia/global.h>
31#ifdef Q_WS_QWS 31#ifdef Q_WS_QWS
32#include <qtopia/qcopenvelope_qws.h> 32#include <qtopia/qcopenvelope_qws.h>
33#endif 33#endif
34#include <qtopia/resource.h> 34#include <qtopia/resource.h>
35#include <qtopia/applnk.h> 35#include <qtopia/applnk.h>
36#include <qtopia/config.h> 36#include <qtopia/config.h>
37#include <qtopia/qpeapplication.h> 37#include <qtopia/qpeapplication.h>
38#include <qtopia/mimetype.h> 38#include <qtopia/mimetype.h>
39#include <qtopia/private/categories.h> 39#include <qtopia/private/categories.h>
40#define QTOPIA_INTERNAL_FSLP 40#define QTOPIA_INTERNAL_FSLP
41#include <qtopia/lnkproperties.h> 41#include <qtopia/lnkproperties.h>
42 42
43/* QT */ 43/* QT */
44#include <qdir.h> 44#include <qdir.h>
45#ifdef Q_WS_QWS 45#ifdef Q_WS_QWS
46#include <qkeyboard_qws.h> 46#include <qkeyboard_qws.h>
47#include <qwindowsystem_qws.h> 47#include <qwindowsystem_qws.h>
48#endif 48#endif
49#include <qtimer.h> 49#include <qtimer.h>
50#include <qcombobox.h> 50#include <qcombobox.h>
51#include <qvbox.h> 51#include <qvbox.h>
52#include <qlayout.h> 52#include <qlayout.h>
53#include <qstyle.h> 53#include <qstyle.h>
54#include <qpushbutton.h> 54#include <qpushbutton.h>
55#include <qtabbar.h> 55#include <qtabbar.h>
56#include <qwidgetstack.h> 56#include <qwidgetstack.h>
57#include <qregexp.h> 57#include <qregexp.h>
58#include <qmessagebox.h> 58#include <qmessagebox.h>
59#include <qframe.h> 59#include <qframe.h>
60#include <qpainter.h> 60#include <qpainter.h>
61#include <qlabel.h> 61#include <qlabel.h>
62#include <qtextstream.h> 62#include <qtextstream.h>
63#include <qpopupmenu.h> 63#include <qpopupmenu.h>
64 64
65/* STD */ 65/* STD */
66#include <stdlib.h> 66#include <stdlib.h>
67#include <assert.h> 67#include <assert.h>
68#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 68#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
69#include <unistd.h> 69#include <unistd.h>
70#include <stdio.h> 70#include <stdio.h>
71#include <sys/vfs.h> 71#include <sys/vfs.h>
72#include <mntent.h> 72#include <mntent.h>
73#endif 73#endif
74 74
75 75
76static bool isVisibleWindow( int ); 76static bool isVisibleWindow( int );
77//=========================================================================== 77//===========================================================================
78 78
79LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : 79LauncherTabWidget::LauncherTabWidget( Launcher* parent ) :
80 QVBox( parent ), docview( 0 ),docTabEnabled(true),m_DocumentTabId(0) 80 QVBox( parent ), docview( 0 ),docTabEnabled(true),m_DocumentTabId(0)
81{ 81{
82 docLoadingWidgetEnabled = false; 82 docLoadingWidgetEnabled = false;
83 docLoadingWidget = 0; 83 docLoadingWidget = 0;
84 docLoadingWidgetProgress = 0; 84 docLoadingWidgetProgress = 0;
85 launcher = parent; 85 launcher = parent;
86 categoryBar = new LauncherTabBar( this ); 86 categoryBar = new LauncherTabBar( this );
87 QPalette pal = categoryBar->palette(); 87 QPalette pal = categoryBar->palette();
88 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 88 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
89 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 89 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
90 categoryBar->setPalette( pal ); 90 categoryBar->setPalette( pal );
91 stack = new QWidgetStack(this); 91 stack = new QWidgetStack(this);
92 connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); 92 connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) );
93 categoryBar->show(); 93 categoryBar->show();
94 stack->show(); 94 stack->show();
95 95
96#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 96#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
97 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); 97 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
98 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 98 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
99 this, SLOT(launcherMessage(const QCString&,const QByteArray&)) ); 99 this, SLOT(launcherMessage(const QCString&,const QByteArray&)) );
100 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), 100 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
101 this, SLOT(appMessage(const QCString&,const QByteArray&))); 101 this, SLOT(appMessage(const QCString&,const QByteArray&)));
102#endif 102#endif
103 103
104 createDocLoadingWidget(); 104 createDocLoadingWidget();
105} 105}
106 106
107void LauncherTabWidget::createDocLoadingWidget() 107void 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 docTabEnabled = cfg.readBoolEntry( "Enable", true ); 131 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
162void LauncherTabWidget::initLayout() 162void 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
169void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) 169void 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
175void LauncherTabWidget::raiseTabWidget() 175void 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
186void LauncherTabWidget::tabProperties() 186void 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
201void LauncherTabWidget::deleteView( const QString& id ) 201void 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
211LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 211LauncherView* 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 219
220 int n = categoryBar->count(); 220 int n = categoryBar->count();
221 221
222 stack->addWidget( view, n ); 222 stack->addWidget( view, n );
223 223
224 LauncherTab *tab = new LauncherTab( id, view, pm, label ); 224 LauncherTab *tab = new LauncherTab( id, view, pm, label );
225 categoryBar->insertTab( tab, n-1 ); 225 categoryBar->insertTab( tab, n-1 );
226 if ( id == "Documents" ) { 226 if ( id == "Documents" ) {
227 docview = view; 227 docview = view;
228 m_DocumentTabId = n; 228 m_DocumentTabId = n;
229 } 229 }
230 230
231 odebug << "inserting " << id << " at " << n-1 << "" << oendl; 231 odebug << "inserting " << id << " at " << n-1 << "" << oendl;
232 232
233 Config cfg("Launcher"); 233 Config cfg("Launcher");
234 setTabAppearance( tab, cfg ); 234 setTabAppearance( tab, cfg );
235 235
236 cfg.setGroup( "GUI" ); 236 cfg.setGroup( "GUI" );
237 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); 237 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) );
238 238
239 return view; 239 return view;
240} 240}
241 241
242LauncherView *LauncherTabWidget::view( const QString &id ) 242LauncherView *LauncherTabWidget::view( const QString &id )
243{ 243{
244 LauncherTab *t = categoryBar->launcherTab(id); 244 LauncherTab *t = categoryBar->launcherTab(id);
245 if ( !t ) 245 if ( !t )
246 return 0; 246 return 0;
247 return t->view; 247 return t->view;
248} 248}
249 249
250LauncherView *LauncherTabWidget::docView() 250LauncherView *LauncherTabWidget::docView()
251{ 251{
252 return docview; 252 return docview;
253} 253}
254 254
255void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) 255void LauncherTabWidget::setLoadingWidgetEnabled( bool v )
256{ 256{
257 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { 257 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) {
258 docLoadingWidgetEnabled = v; 258 docLoadingWidgetEnabled = v;
259 raiseTabWidget(); 259 raiseTabWidget();
260 } 260 }
261} 261}
262 262
263void LauncherTabWidget::setLoadingProgress( int percent ) 263void LauncherTabWidget::setLoadingProgress( int percent )
264{ 264{
265 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); 265 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 );
266} 266}
267 267
268// ### this function could more to LauncherView 268// ### this function could more to LauncherView
269void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) 269void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg )
270{ 270{
271 // View 271 // View
272 QString view = cfg.readEntry( "View", "Icon" ); 272 QString view = cfg.readEntry( "View", "Icon" );
273 if ( view == "List" ) // No tr 273 if ( view == "List" ) // No tr
274 v->setViewMode( LauncherView::List ); 274 v->setViewMode( LauncherView::List );
275 QString bgType = cfg.readEntry( "BackgroundType", "Image" ); 275 QString bgType = cfg.readEntry( "BackgroundType", "Image" );
276 if ( bgType == "Image" ) { // No tr 276 if ( bgType == "Image" ) { // No tr
277 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); 277 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" );
278 v->setBackgroundType( LauncherView::Image, pm ); 278 v->setBackgroundType( LauncherView::Image, pm );
279 } else if ( bgType == "SolidColor" ) { 279 } else if ( bgType == "SolidColor" ) {
280 QString c = cfg.readEntry( "BackgroundColor" ); 280 QString c = cfg.readEntry( "BackgroundColor" );
281 v->setBackgroundType( LauncherView::SolidColor, c ); 281 v->setBackgroundType( LauncherView::SolidColor, c );
282 } else { 282 } else {
283 v->setBackgroundType( LauncherView::Ruled, QString::null ); 283 v->setBackgroundType( LauncherView::Ruled, QString::null );
284 } 284 }
285 QString textCol = cfg.readEntry( "TextColor" ); 285 QString textCol = cfg.readEntry( "TextColor" );
286 if ( textCol.isEmpty() ) 286 if ( textCol.isEmpty() )
287 v->setTextColor( QColor() ); 287 v->setTextColor( QColor() );
288 else 288 else
289 v->setTextColor( QColor(textCol) ); 289 v->setTextColor( QColor(textCol) );
290// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); 290// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE );
291 291
292 v->setColNumber( cfg.readNumEntry( "Columns", 0 ) ); 292 v->setColNumber( cfg.readNumEntry( "Columns", 0 ) );
293 293
294 QStringList font = cfg.readListEntry( "Font", ',' ); 294 QStringList font = cfg.readListEntry( "Font", ',' );
295 if ( font.count() == 4 ) 295 if ( font.count() == 4 )
296 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); 296 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) );
297 297
298 // ### FIXME TabColor TabTextColor 298 // ### FIXME TabColor TabTextColor
299 299
300} 300}
301 301
302// ### Could move to LauncherTab 302// ### Could move to LauncherTab
303void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) 303void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg )
304{ 304{
305 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr 305 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr
306 306
307 setTabViewAppearance( tab->view, cfg ); 307 setTabViewAppearance( tab->view, cfg );
308 308
309 // Tabs 309 // Tabs
310 QString tabCol = cfg.readEntry( "TabColor" ); 310 QString tabCol = cfg.readEntry( "TabColor" );
311 if ( tabCol.isEmpty() ) 311 if ( tabCol.isEmpty() )
312 tab->bgColor = QColor(); 312 tab->bgColor = QColor();
313 else 313 else
314 tab->bgColor = QColor(tabCol); 314 tab->bgColor = QColor(tabCol);
315 QString tabTextCol = cfg.readEntry( "TabTextColor" ); 315 QString tabTextCol = cfg.readEntry( "TabTextColor" );
316 if ( tabTextCol.isEmpty() ) 316 if ( tabTextCol.isEmpty() )
317 tab->fgColor = QColor(); 317 tab->fgColor = QColor();
318 else 318 else
319 tab->fgColor = QColor(tabTextCol); 319 tab->fgColor = QColor(tabTextCol);
320} 320}
321 321
322void LauncherTabWidget::paletteChange( const QPalette &p ) 322void LauncherTabWidget::paletteChange( const QPalette &p )
323{ 323{
324 QVBox::paletteChange( p ); 324 QVBox::paletteChange( p );
325 QPalette pal = palette(); 325 QPalette pal = palette();
326 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 326 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
327 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 327 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
328 categoryBar->setPalette( pal ); 328 categoryBar->setPalette( pal );
329 categoryBar->update(); 329 categoryBar->update();
330} 330}
331 331
332void LauncherTabWidget::styleChange( QStyle & ) 332void LauncherTabWidget::styleChange( QStyle & )
333{ 333{
334 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); 334 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) );
335} 335}
336 336
337void LauncherTabWidget::setProgressStyle() 337void LauncherTabWidget::setProgressStyle()
338{ 338{
339 if (docLoadingWidgetProgress) { 339 if (docLoadingWidgetProgress) {
340 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); 340 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box );
341 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); 341 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain );
342 docLoadingWidgetProgress->setMargin( 1 ); 342 docLoadingWidgetProgress->setMargin( 1 );
343 docLoadingWidgetProgress->setLineWidth( 1 ); 343 docLoadingWidgetProgress->setLineWidth( 1 );
344 } 344 }
345} 345}
346 346
347/* 347/*
348 * FIXME 348 * FIXME
349 * The following NULL check is triggered by inserting, then removing a tab on the fly 349 * The following NULL check is triggered by inserting, then removing a tab on the fly
350 * as you would if you had removable media (which I do). Without this check 350 * as you would if you had removable media (which I do). Without this check
351 * the first app launched after a tab removal causes qpe to Segfault. 351 * the first app launched after a tab removal causes qpe to Segfault.
352 * This obviously has a more sinister cause, but this works around it with no 352 * This obviously has a more sinister cause, but this works around it with no
353 * obvious adverse effects. Please FIXME 353 * obvious adverse effects. Please FIXME
354 * bkc - 17/6/2004 354 * bkc - 17/6/2004
355 * 355 *
356 */ 356 */
357 357
358void LauncherTabWidget::setBusy(bool on) 358void LauncherTabWidget::setBusy(bool on)
359{ 359{
360 if ( on ) 360 if ( on )
361 currentView()->setBusy(TRUE); 361 currentView()->setBusy(TRUE);
362 else { 362 else {
363 for ( int i = 0; i < categoryBar->count(); i++ ) { 363 for ( int i = 0; i < categoryBar->count(); i++ ) {
364 if (categoryBar->tab(i)) { 364 if (categoryBar->tab(i)) {
365 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; 365 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view;
366 view->setBusy( FALSE ); 366 view->setBusy( FALSE );
367 } else { 367 } else {
368 odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl; 368 odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl;
369 } 369 }
370 } 370 }
371 } 371 }
372} 372}
373 373
374void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { 374void LauncherTabWidget::setBusyIndicatorType( const QString& str ) {
375 for (int i = 0; i < categoryBar->count(); i++ ) { 375 for (int i = 0; i < categoryBar->count(); i++ ) {
376 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; 376 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view;
377 view->setBusyIndicatorType( str ); 377 view->setBusyIndicatorType( str );
378 } 378 }
379} 379}
380 380
381LauncherView *LauncherTabWidget::currentView(void) 381LauncherView *LauncherTabWidget::currentView(void)
382{ 382{
383 return (LauncherView*)stack->visibleWidget(); 383 return (LauncherView*)stack->visibleWidget();
384} 384}
385 385
386 386
387 387
388void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) 388void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data)
389{ 389{
390 QDataStream stream( data, IO_ReadOnly ); 390 QDataStream stream( data, IO_ReadOnly );
391 if ( msg == "setTabView(QString,int)" ) { 391 if ( msg == "setTabView(QString,int)" ) {
392 QString id; 392 QString id;
393 stream >> id; 393 stream >> id;
394 int mode; 394 int mode;
395 stream >> mode; 395 stream >> mode;
396 if ( view(id) ) 396 if ( view(id) )
397 view(id)->setViewMode( (LauncherView::ViewMode)mode ); 397 view(id)->setViewMode( (LauncherView::ViewMode)mode );
398 } else if ( msg == "setTabBackground(QString,int,QString)" ) { 398 } else if ( msg == "setTabBackground(QString,int,QString)" ) {
399 QString id; 399 QString id;
400 stream >> id; 400 stream >> id;
401 int mode; 401 int mode;
402 stream >> mode; 402 stream >> mode;
403 QString pixmapOrColor; 403 QString pixmapOrColor;
404 stream >> pixmapOrColor; 404 stream >> pixmapOrColor;
405 if ( view(id) ) 405 if ( view(id) )
406 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 406 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
407 if ( id == "Documents" ) 407 if ( id == "Documents" )
408 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 408 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
409 } else if ( msg == "setTextColor(QString,QString)" ) { 409 } else if ( msg == "setTextColor(QString,QString)" ) {
410 QString id; 410 QString id;
411 stream >> id; 411 stream >> id;
412 QString color; 412 QString color;
413 stream >> color; 413 stream >> color;
414 if ( view(id) ) 414 if ( view(id) )
415 view(id)->setTextColor( QColor(color) ); 415 view(id)->setTextColor( QColor(color) );
416 if ( id == "Documents" ) 416 if ( id == "Documents" )
417 docLoadingWidget->setTextColor( QColor(color) ); 417 docLoadingWidget->setTextColor( QColor(color) );
418 } else if ( msg == "setIconColumns(QString,int)" ) {
419 QString id;
420 stream >> id;
421 int number;
422 stream >> number;
423 if ( view(id ) )
424 view(id)->setColNumber( number );
418 } else if ( msg == "setFont(QString,QString,int,int,int)" ) { 425 } else if ( msg == "setFont(QString,QString,int,int,int)" ) {
419 QString id; 426 QString id;
420 stream >> id; 427 stream >> id;
421 QString fam; 428 QString fam;
422 stream >> fam; 429 stream >> fam;
423 int size; 430 int size;
424 stream >> size; 431 stream >> size;
425 int weight; 432 int weight;
426 stream >> weight; 433 stream >> weight;
427 int italic; 434 int italic;
428 stream >> italic; 435 stream >> italic;
429 if ( view(id) ) { 436 if ( view(id) ) {
430 if ( !fam.isEmpty() ) { 437 if ( !fam.isEmpty() ) {
431 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); 438 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
432 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; 439 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl;
433 } else { 440 } else {
434 view(id)->clearViewFont(); 441 view(id)->clearViewFont();
435 } 442 }
436 } 443 }
437 }else if ( msg == "setBusyIndicatorType(QString)" ) { 444 }else if ( msg == "setBusyIndicatorType(QString)" ) {
438 QString type; 445 QString type;
439 stream >> type; 446 stream >> type;
440 setBusyIndicatorType( type ); 447 setBusyIndicatorType( type );
441 }else if ( msg == "home()" ) { 448 }else if ( msg == "home()" ) {
442 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { 449 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) {
443 if (categoryBar) 450 if (categoryBar)
444 categoryBar->nextTab(); 451 categoryBar->nextTab();
445 }else { 452 }else {
446 static_cast<QWidget*>(parent())->raise(); 453 static_cast<QWidget*>(parent())->raise();
447 } 454 }
448 } else if (msg=="doctabEnabled(int)") { 455 } else if (msg=="doctabEnabled(int)") {
449 int id; stream >> id; 456 int id; stream >> id;
450 odebug << "Doctab enabled " << id << oendl; 457 odebug << "Doctab enabled " << id << oendl;
451 reCheckDoctab(id); 458 reCheckDoctab(id);
452 } 459 }
453} 460}
454 461
455void LauncherTabWidget::reCheckDoctab(int how) 462void LauncherTabWidget::reCheckDoctab(int how)
456{ 463{
457 if ((bool)how == docTabEnabled) { 464 if ((bool)how == docTabEnabled) {
458 /* nothing to do */ 465 /* nothing to do */
459 return; 466 return;
460 } 467 }
461 if (docLoadingWidget) { 468 if (docLoadingWidget) {
462 stack->removeWidget(docLoadingWidget); 469 stack->removeWidget(docLoadingWidget);
463 delete docLoadingWidget; 470 delete docLoadingWidget;
464 docLoadingWidget = 0; 471 docLoadingWidget = 0;
465 } 472 }
466 createDocLoadingWidget(); 473 createDocLoadingWidget();
467 { 474 {
468 QCopEnvelope( "QPE/System", "reforceDocuments()" ); 475 QCopEnvelope( "QPE/System", "reforceDocuments()" );
469 odebug << "Sending doc rescan" << oendl; 476 odebug << "Sending doc rescan" << oendl;
470 } 477 }
471} 478}
472 479
473//--------------------------------------------------------------------------- 480//---------------------------------------------------------------------------
474 481
475Launcher::Launcher() 482Launcher::Launcher()
476 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) 483 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader )
477{ 484{
478 tabs = 0; 485 tabs = 0;
479 tb = 0; 486 tb = 0;
480 Config cfg( "Launcher" ); 487 Config cfg( "Launcher" );
481 cfg.setGroup( "DocTab" ); 488 cfg.setGroup( "DocTab" );
482 docTabEnabled = cfg.readBoolEntry( "Enable", true ); 489 docTabEnabled = cfg.readBoolEntry( "Enable", true );
483} 490}
484 491
485void Launcher::createGUI() 492void Launcher::createGUI()
486{ 493{
487 setCaption( tr("Launcher") ); 494 setCaption( tr("Launcher") );
488 495
489 // we have a pretty good idea how big we'll be 496 // we have a pretty good idea how big we'll be
490 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 497 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
491 498
492 tb = new TaskBar; 499 tb = new TaskBar;
493 tabs = new LauncherTabWidget( this ); 500 tabs = new LauncherTabWidget( this );
494 setCentralWidget( tabs ); 501 setCentralWidget( tabs );
495 502
496 ServerInterface::dockWidget( tb, ServerInterface::Bottom ); 503 ServerInterface::dockWidget( tb, ServerInterface::Bottom );
497 tb->show(); 504 tb->show();
498 505
499 qApp->installEventFilter( this ); 506 qApp->installEventFilter( this );
500 507
501 connect( tb, SIGNAL(tabSelected(const QString&)), 508 connect( tb, SIGNAL(tabSelected(const QString&)),
502 this, SLOT(showTab(const QString&)) ); 509 this, SLOT(showTab(const QString&)) );
503 connect( tabs, SIGNAL(selected(const QString&)), 510 connect( tabs, SIGNAL(selected(const QString&)),
504 this, SLOT(viewSelected(const QString&)) ); 511 this, SLOT(viewSelected(const QString&)) );
505 connect( tabs, SIGNAL(clicked(const AppLnk*)), 512 connect( tabs, SIGNAL(clicked(const AppLnk*)),
506 this, SLOT(select(const AppLnk*))); 513 this, SLOT(select(const AppLnk*)));
507 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 514 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
508 this, SLOT(properties(AppLnk*))); 515 this, SLOT(properties(AppLnk*)));
509 516
510#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 517#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
511 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 518 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
512 connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), 519 connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)),
513 this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); 520 this, SLOT(systemMessage(const QCString&,const QByteArray&)) );
514#endif 521#endif
515 522
516 // all documents 523 // all documents
517 QImage img( Resource::loadImage( "DocsIcon" ) ); 524 QImage img( Resource::loadImage( "DocsIcon" ) );
518 QPixmap pm; 525 QPixmap pm;
519 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 526 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
520 // It could add this itself if it handles docs 527 // It could add this itself if it handles docs
521 528
522 tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); 529 tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE );
523 530
524 QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); 531 QTimer::singleShot( 0, tabs, SLOT( initLayout() ) );
525 qApp->setMainWidget( this ); 532 qApp->setMainWidget( this );
526 QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); 533 QTimer::singleShot( 500, this, SLOT( makeVisible() ) );
527} 534}
528 535
529Launcher::~Launcher() 536Launcher::~Launcher()
530{ 537{
531 if ( tb ) 538 if ( tb )
532 destroyGUI(); 539 destroyGUI();
533} 540}
534 541
535 bool Launcher::requiresDocuments() const 542 bool Launcher::requiresDocuments() const
536 { 543 {
537 Config cfg( "Launcher" ); 544 Config cfg( "Launcher" );
538 cfg.setGroup( "DocTab" ); 545 cfg.setGroup( "DocTab" );
539 return cfg.readBoolEntry( "Enable", true ); 546 return cfg.readBoolEntry( "Enable", true );
540} 547}
541 548
542void Launcher::makeVisible() 549void Launcher::makeVisible()
543{ 550{
544 showMaximized(); 551 showMaximized();
545} 552}
546 553
547void Launcher::destroyGUI() 554void Launcher::destroyGUI()
548{ 555{
549 delete tb; 556 delete tb;
550 tb = 0; 557 tb = 0;
551 delete tabs; 558 delete tabs;
552 tabs =0; 559 tabs =0;
553} 560}
554 561
555bool Launcher::eventFilter( QObject*, QEvent *ev ) 562bool Launcher::eventFilter( QObject*, QEvent *ev )
556{ 563{
557#ifdef QT_QWS_CUSTOM 564#ifdef QT_QWS_CUSTOM
558 if ( ev->type() == QEvent::KeyPress ) { 565 if ( ev->type() == QEvent::KeyPress ) {
559 QKeyEvent *ke = (QKeyEvent *)ev; 566 QKeyEvent *ke = (QKeyEvent *)ev;
560 if ( ke->key() == Qt::Key_F11 ) { // menu key 567 if ( ke->key() == Qt::Key_F11 ) { // menu key
561 QWidget *active = qApp->activeWindow(); 568 QWidget *active = qApp->activeWindow();
562 if ( active && active->isPopup() ) 569 if ( active && active->isPopup() )
563 active->close(); 570 active->close();
564 else { 571 else {
565 Global::terminateBuiltin("calibrate"); // No tr 572 Global::terminateBuiltin("calibrate"); // No tr
566 tb->launchStartMenu(); 573 tb->launchStartMenu();
567 } 574 }
568 return TRUE; 575 return TRUE;
569 } 576 }
570 } 577 }
571#else 578#else
572 Q_UNUSED(ev); 579 Q_UNUSED(ev);
573#endif 580#endif
574 return FALSE; 581 return FALSE;
575} 582}
576 583
577static bool isVisibleWindow(int wid) 584static bool isVisibleWindow(int wid)
578{ 585{
579#ifdef Q_WS_QWS 586#ifdef Q_WS_QWS
580 const QList<QWSWindow> &list = qwsServer->clientWindows(); 587 const QList<QWSWindow> &list = qwsServer->clientWindows();
581 QWSWindow* w; 588 QWSWindow* w;
582 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 589 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
583 if ( w->winId() == wid ) 590 if ( w->winId() == wid )
584 return !w->isFullyObscured(); 591 return !w->isFullyObscured();
585 } 592 }
586#endif 593#endif
587 return FALSE; 594 return FALSE;
588} 595}
589 596
590void Launcher::viewSelected(const QString& s) 597void Launcher::viewSelected(const QString& s)
591{ 598{
592 setCaption( s + tr(" - Launcher") ); 599 setCaption( s + tr(" - Launcher") );
593} 600}
594 601
595void Launcher::showTab(const QString& id) 602void Launcher::showTab(const QString& id)
596{ 603{
597 tabs->categoryBar->showTab(id); 604 tabs->categoryBar->showTab(id);
598 raise(); 605 raise();
599} 606}
600 607
601void Launcher::select( const AppLnk *appLnk ) 608void Launcher::select( const AppLnk *appLnk )
602{ 609{
603 if ( appLnk->type() == "Folder" ) { // No tr 610 if ( appLnk->type() == "Folder" ) { // No tr
604 // Not supported: flat is simpler for the user 611 // Not supported: flat is simpler for the user
605 } else { 612 } else {
606 if ( appLnk->exec().isNull() ) { 613 if ( appLnk->exec().isNull() ) {
607 int i = QMessageBox::information(this,tr("No application"), 614 int i = QMessageBox::information(this,tr("No application"),
608 tr("<p>No application is defined for this document." 615 tr("<p>No application is defined for this document."
609 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); 616 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1);
610 617
611 /* ### Fixme */ 618 /* ### Fixme */
612 if ( i == 1 ) 619 if ( i == 1 )
613 Global::execute("textedit",appLnk->file()); 620 Global::execute("textedit",appLnk->file());
614 621
615 return; 622 return;
616 } 623 }
617 tabs->setBusy(TRUE); 624 tabs->setBusy(TRUE);
618 emit executing( appLnk ); 625 emit executing( appLnk );
619 appLnk->execute(); 626 appLnk->execute();
620 } 627 }
621} 628}
622 629
623void Launcher::properties( AppLnk *appLnk ) 630void Launcher::properties( AppLnk *appLnk )
624{ 631{
625 if ( appLnk->type() == "Folder" ) { // No tr 632 if ( appLnk->type() == "Folder" ) { // No tr
626 // Not supported: flat is simpler for the user 633 // Not supported: flat is simpler for the user
627 } else { 634 } else {
628/* ### libqtopia FIXME also moving docLnks... */ 635/* ### libqtopia FIXME also moving docLnks... */
629 LnkProperties prop(appLnk,0 ); 636 LnkProperties prop(appLnk,0 );
630 637
631 if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) { 638 if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) {
632 } 639 }
633 } 640 }
634} 641}
635 642
636void Launcher::storageChanged( const QList<FileSystem> & ) 643void Launcher::storageChanged( const QList<FileSystem> & )
637{ 644{
638 // ### update combo boxes if we had a combo box for the storage type 645 // ### update combo boxes if we had a combo box for the storage type
639} 646}
640 647
641void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 648void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
642{ 649{
643 QDataStream stream( data, IO_ReadOnly ); 650 QDataStream stream( data, IO_ReadOnly );
644 if ( msg == "busy()" ) { 651 if ( msg == "busy()" ) {
645 tb->startWait(); 652 tb->startWait();
646 } else if ( msg == "notBusy(QString)" ) { 653 } else if ( msg == "notBusy(QString)" ) {
647 QString app; 654 QString app;
648 stream >> app; 655 stream >> app;
649 tabs->setBusy(FALSE); 656 tabs->setBusy(FALSE);
650 tb->stopWait(app); 657 tb->stopWait(app);
651 } else if (msg == "applyStyle()") { 658 } else if (msg == "applyStyle()") {
652 tabs->currentView()->relayout(); 659 tabs->currentView()->relayout();
653 } 660 }
654} 661}
655 662
656// These are the update functions from the server 663// These are the update functions from the server
657void Launcher::typeAdded( const QString& type, const QString& name, 664void Launcher::typeAdded( const QString& type, const QString& name,
658 const QPixmap& pixmap, const QPixmap& ) 665 const QPixmap& pixmap, const QPixmap& )
659{ 666{
660 tabs->newView( type, pixmap, name ); 667 tabs->newView( type, pixmap, name );
661 ids.append( type ); 668 ids.append( type );
662 /* this will be called in applicationScanningProgress with value 100! */ 669 /* this will be called in applicationScanningProgress with value 100! */
663// tb->refreshStartMenu(); 670// tb->refreshStartMenu();
664 671
665 static bool first = TRUE; 672 static bool first = TRUE;
666 if ( first ) { 673 if ( first ) {
667 first = FALSE; 674 first = FALSE;
668 tabs->categoryBar->showTab(type); 675 tabs->categoryBar->showTab(type);
669 } 676 }
670 677
671 tabs->view( type )->setUpdatesEnabled( FALSE ); 678 tabs->view( type )->setUpdatesEnabled( FALSE );
672 tabs->view( type )->setSortEnabled( FALSE ); 679 tabs->view( type )->setSortEnabled( FALSE );
673} 680}
674 681
675void Launcher::typeRemoved( const QString& type ) 682void Launcher::typeRemoved( const QString& type )
676{ 683{
677 tabs->view( type )->removeAllItems(); 684 tabs->view( type )->removeAllItems();
678 tabs->deleteView( type ); 685 tabs->deleteView( type );
679 ids.remove( type ); 686 ids.remove( type );
680 /* this will be called in applicationScanningProgress with value 100! */ 687 /* this will be called in applicationScanningProgress with value 100! */
681// tb->refreshStartMenu(); 688// tb->refreshStartMenu();
682} 689}
683 690
684void Launcher::applicationAdded( const QString& type, const AppLnk& app ) 691void Launcher::applicationAdded( const QString& type, const AppLnk& app )
685{ 692{
686 if ( app.type() == "Separator" ) // No tr 693 if ( app.type() == "Separator" ) // No tr
687 return; 694 return;
688 695
689 LauncherView *view = tabs->view( type ); 696 LauncherView *view = tabs->view( type );
690 if ( view ) 697 if ( view )
691 view->addItem( new AppLnk( app ), FALSE ); 698 view->addItem( new AppLnk( app ), FALSE );
692 else 699 else
693 owarn << "addAppLnk: No view for type " << type.latin1() << ". Can't add app " 700 owarn << "addAppLnk: No view for type " << type.latin1() << ". Can't add app "
694 << app.name().latin1() << "!", 701 << app.name().latin1() << "!",
695 702
696 MimeType::registerApp( app ); 703 MimeType::registerApp( app );
697} 704}
698 705
699void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) 706void Launcher::applicationRemoved( const QString& type, const AppLnk& app )
700{ 707{
701 LauncherView *view = tabs->view( type ); 708 LauncherView *view = tabs->view( type );
702 if ( view ) 709 if ( view )
703 view->removeLink( app.linkFile() ); 710 view->removeLink( app.linkFile() );
704 else 711 else
705 owarn << "removeAppLnk: No view for " << type << "!" << oendl; 712 owarn << "removeAppLnk: No view for " << type << "!" << oendl;
706} 713}
707 714
708void Launcher::allApplicationsRemoved() 715void Launcher::allApplicationsRemoved()
709{ 716{
710 MimeType::clear(); 717 MimeType::clear();
711 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) 718 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it)
712 tabs->view( (*it) )->removeAllItems(); 719 tabs->view( (*it) )->removeAllItems();
713} 720}
714 721
715void Launcher::documentAdded( const DocLnk& doc ) 722void Launcher::documentAdded( const DocLnk& doc )
716{ 723{
717 tabs->docView()->addItem( new DocLnk( doc ), FALSE ); 724 tabs->docView()->addItem( new DocLnk( doc ), FALSE );
718} 725}
719 726
720void Launcher::aboutToAddBegin() 727void Launcher::aboutToAddBegin()
721{ 728{
722 tabs->docView()->setUpdatesEnabled( false ); 729 tabs->docView()->setUpdatesEnabled( false );
723} 730}
724 731
725void Launcher::aboutToAddEnd() 732void Launcher::aboutToAddEnd()
726{ 733{
727 tabs->docView()->setUpdatesEnabled( true ); 734 tabs->docView()->setUpdatesEnabled( true );
728} 735}
729 736
730void Launcher::showLoadingDocs() 737void Launcher::showLoadingDocs()
731{ 738{
732 tabs->docView()->hide(); 739 tabs->docView()->hide();
733} 740}
734 741
735void Launcher::showDocTab() 742void Launcher::showDocTab()
736{ 743{
737 if ( tabs->categoryBar->currentView() == tabs->docView() ) 744 if ( tabs->categoryBar->currentView() == tabs->docView() )
738 tabs->docView()->show(); 745 tabs->docView()->show();
739} 746}
740 747
741void Launcher::documentRemoved( const DocLnk& doc ) 748void Launcher::documentRemoved( const DocLnk& doc )
742{ 749{
743 tabs->docView()->removeLink( doc.linkFile() ); 750 tabs->docView()->removeLink( doc.linkFile() );
744} 751}
745 752
746void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) 753void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc )
747{ 754{
748#if 0 755#if 0
749 documentRemoved( oldDoc ); 756 documentRemoved( oldDoc );
750 documentAdded( newDoc ); 757 documentAdded( newDoc );
751// tabs->docView()->updateTools(); 758// tabs->docView()->updateTools();
752#else 759#else
753 tabs->docView()->changeItem(oldDoc,new DocLnk(newDoc)); 760 tabs->docView()->changeItem(oldDoc,new DocLnk(newDoc));
754#endif 761#endif
755} 762}
756 763
757void Launcher::allDocumentsRemoved() 764void Launcher::allDocumentsRemoved()
758{ 765{
759 tabs->docView()->removeAllItems(); 766 tabs->docView()->removeAllItems();
760} 767}
761 768
762void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) 769void Launcher::applicationStateChanged( const QString& name, ApplicationState state )
763{ 770{
764 tb->setApplicationState( name, state ); 771 tb->setApplicationState( name, state );
765} 772}
766 773
767void Launcher::applicationScanningProgress( int percent ) 774void Launcher::applicationScanningProgress( int percent )
768{ 775{
769 switch ( percent ) { 776 switch ( percent ) {
770 case 0: { 777 case 0: {
771 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 778 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
772 tabs->view( (*it) )->setUpdatesEnabled( FALSE ); 779 tabs->view( (*it) )->setUpdatesEnabled( FALSE );
773 tabs->view( (*it) )->setSortEnabled( FALSE ); 780 tabs->view( (*it) )->setSortEnabled( FALSE );
774 } 781 }
775 break; 782 break;
776 } 783 }
777 case 100: { 784 case 100: {
778 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 785 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
779 tabs->view( (*it) )->setUpdatesEnabled( TRUE ); 786 tabs->view( (*it) )->setUpdatesEnabled( TRUE );
780 tabs->view( (*it) )->setSortEnabled( TRUE ); 787 tabs->view( (*it) )->setSortEnabled( TRUE );
781 } 788 }
782 tb->refreshStartMenu(); 789 tb->refreshStartMenu();
783 break; 790 break;
784 } 791 }
785 default: 792 default:
786 break; 793 break;
787 } 794 }
788} 795}
789 796
790void Launcher::documentScanningProgress( int percent ) 797void Launcher::documentScanningProgress( int percent )
791{ 798{
792 switch ( percent ) { 799 switch ( percent ) {
793 case 0: { 800 case 0: {
794 tabs->setLoadingProgress( 0 ); 801 tabs->setLoadingProgress( 0 );
795 tabs->setLoadingWidgetEnabled( TRUE ); 802 tabs->setLoadingWidgetEnabled( TRUE );
796 tabs->docView()->setUpdatesEnabled( FALSE ); 803 tabs->docView()->setUpdatesEnabled( FALSE );
797 tabs->docView()->setSortEnabled( FALSE ); 804 tabs->docView()->setSortEnabled( FALSE );
798 break; 805 break;
799 } 806 }
800 case 100: { 807 case 100: {
801 tabs->docView()->updateTools(); 808 tabs->docView()->updateTools();
802 tabs->docView()->setSortEnabled( TRUE ); 809 tabs->docView()->setSortEnabled( TRUE );
803 tabs->docView()->setUpdatesEnabled( TRUE ); 810 tabs->docView()->setUpdatesEnabled( TRUE );
804 tabs->setLoadingWidgetEnabled( FALSE ); 811 tabs->setLoadingWidgetEnabled( FALSE );
805 break; 812 break;
806 } 813 }
807 default: 814 default:
808 tabs->setLoadingProgress( percent ); 815 tabs->setLoadingProgress( percent );
809 break; 816 break;
810 } 817 }
811} 818}
812 819
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 9d78c0d..2b34cc5 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -1,1233 +1,1233 @@
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 <qpe/config.h> 25#include <qpe/config.h>
26#include <qtopia/qpeapplication.h> 26#include <qtopia/qpeapplication.h>
27#include <qtopia/private/categories.h> 27#include <qtopia/private/categories.h>
28#include <qtopia/categoryselect.h> 28#include <qtopia/categoryselect.h>
29#include <qtopia/mimetype.h> 29#include <qtopia/mimetype.h>
30#include <qtopia/resource.h> 30#include <qtopia/resource.h>
31using namespace Opie::Core; 31using namespace Opie::Core;
32 32
33#include <qpe/qcopenvelope_qws.h> 33#include <qpe/qcopenvelope_qws.h>
34 34
35/* QT */ 35/* QT */
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qfileinfo.h> 37#include <qfileinfo.h>
38#include <qiconview.h> 38#include <qiconview.h>
39#include <qobjectlist.h> 39#include <qobjectlist.h>
40 40
41 41
42// These define how the busy icon is animated and highlighted 42// These define how the busy icon is animated and highlighted
43#define BRIGHTEN_BUSY_ICON 43#define BRIGHTEN_BUSY_ICON
44//#define ALPHA_FADE_BUSY_ICON 44//#define ALPHA_FADE_BUSY_ICON
45//#define USE_ANIMATED_BUSY_ICON_OVERLAY 45//#define USE_ANIMATED_BUSY_ICON_OVERLAY
46#define BOUNCE_BUSY_ICON 46#define BOUNCE_BUSY_ICON
47 47
48typedef QMap<QString,QPixmap>::Iterator pixiter; 48typedef QMap<QString,QPixmap>::Iterator pixiter;
49 49
50class BgPixmap 50class BgPixmap
51{ 51{
52public: 52public:
53 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} 53 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
54 QPixmap pm; 54 QPixmap pm;
55 int ref; 55 int ref;
56}; 56};
57 57
58 58
59static QMap<QString,BgPixmap*> *bgCache = 0; 59static QMap<QString,BgPixmap*> *bgCache = 0;
60 60
61static void cleanup_cache() 61static void cleanup_cache()
62{ 62{
63 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 63 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
64 while ( it != bgCache->end() ) { 64 while ( it != bgCache->end() ) {
65 QMap<QString,BgPixmap*>::Iterator curr = it; 65 QMap<QString,BgPixmap*>::Iterator curr = it;
66 ++it; 66 ++it;
67 delete (*curr); 67 delete (*curr);
68 bgCache->remove( curr ); 68 bgCache->remove( curr );
69 } 69 }
70 delete bgCache; 70 delete bgCache;
71 bgCache = 0; 71 bgCache = 0;
72} 72}
73 73
74 74
75class LauncherItem : public QIconViewItem 75class LauncherItem : public QIconViewItem
76{ 76{
77public: 77public:
78 enum iconstate_t { 78 enum iconstate_t {
79 BASE_ICON, 79 BASE_ICON,
80 WAITING_ICON, 80 WAITING_ICON,
81 EYE_ICON 81 EYE_ICON
82 }; 82 };
83 83
84 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); 84 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE );
85 ~LauncherItem(); 85 ~LauncherItem();
86 86
87 AppLnk *appLnk() const { return app; } 87 AppLnk *appLnk() const { return app; }
88 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } 88 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; }
89 89
90 void animateIcon(); 90 void animateIcon();
91 void resetIcon(); 91 void resetIcon();
92 bool isEyeImage()const{return m_EyeImage;} 92 bool isEyeImage()const{return m_EyeImage;}
93 93
94 virtual int compare ( QIconViewItem * i ) const; 94 virtual int compare ( QIconViewItem * i ) const;
95 void paintItem( QPainter *p, const QColorGroup &cg ); 95 void paintItem( QPainter *p, const QColorGroup &cg );
96 96
97 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 97 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
98 void setEyePixmap(const QPixmap&aIcon); 98 void setEyePixmap(const QPixmap&aIcon);
99 virtual QPixmap*pixmap()const; 99 virtual QPixmap*pixmap()const;
100 100
101protected: 101protected:
102 bool isBigIcon; 102 bool isBigIcon;
103 int iteration; 103 int iteration;
104 AppLnk* app; 104 AppLnk* app;
105 105
106private: 106private:
107 void paintAnimatedIcon( QPainter *p ); 107 void paintAnimatedIcon( QPainter *p );
108 BusyIndicatorType busyType; 108 BusyIndicatorType busyType;
109 int psize; 109 int psize;
110 bool m_EyeImage; 110 bool m_EyeImage;
111 iconstate_t m_EyeImageSet; 111 iconstate_t m_EyeImageSet;
112}; 112};
113 113
114LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 114LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
115 : QIconViewItem( parent, applnk->name(), 115 : QIconViewItem( parent, applnk->name(),
116 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), 116 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
117 isBigIcon( bigIcon ), 117 isBigIcon( bigIcon ),
118 iteration(0), 118 iteration(0),
119 app(applnk), // Takes ownership 119 app(applnk), // Takes ownership
120 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), 120 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ),
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 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file()); 126 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file());
127 if (it != LauncherIconView::sm_EyeCache->end()) { 127 if (it != LauncherIconView::sm_EyeCache->end()) {
128 m_EyeImageSet = EYE_ICON; 128 m_EyeImageSet = EYE_ICON;
129 setPixmap(*it); 129 setPixmap(*it);
130 } 130 }
131 } 131 }
132} 132}
133 133
134LauncherItem::~LauncherItem() 134LauncherItem::~LauncherItem()
135{ 135{
136 LauncherIconView* liv = (LauncherIconView*)iconView(); 136 LauncherIconView* liv = (LauncherIconView*)iconView();
137 if ( liv->busyItem() == this ) 137 if ( liv->busyItem() == this )
138 liv->setBusy(FALSE); 138 liv->setBusy(FALSE);
139 delete app; 139 delete app;
140} 140}
141 141
142QPixmap*LauncherItem::pixmap()const 142QPixmap*LauncherItem::pixmap()const
143{ 143{
144 if (m_EyeImage && m_EyeImageSet == BASE_ICON) { 144 if (m_EyeImage && m_EyeImageSet == BASE_ICON) {
145 LauncherIconView* liv = (LauncherIconView*)iconView(); 145 LauncherIconView* liv = (LauncherIconView*)iconView();
146 liv->requestEyePix(this); 146 liv->requestEyePix(this);
147 } 147 }
148 return QIconViewItem::pixmap(); 148 return QIconViewItem::pixmap();
149} 149}
150 150
151int LauncherItem::compare ( QIconViewItem * i ) const 151int LauncherItem::compare ( QIconViewItem * i ) const
152{ 152{
153 LauncherIconView* view = (LauncherIconView*)iconView(); 153 LauncherIconView* view = (LauncherIconView*)iconView();
154 return view->compare(app,((LauncherItem *)i)->appLnk()); 154 return view->compare(app,((LauncherItem *)i)->appLnk());
155} 155}
156 156
157void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) 157void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg )
158{ 158{
159 LauncherIconView* liv = (LauncherIconView*)iconView(); 159 LauncherIconView* liv = (LauncherIconView*)iconView();
160 QBrush oldBrush( liv->itemTextBackground() ); 160 QBrush oldBrush( liv->itemTextBackground() );
161 QColorGroup mycg( cg ); 161 QColorGroup mycg( cg );
162 if ( liv->currentItem() == this ) { 162 if ( liv->currentItem() == this ) {
163 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 163 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
164 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 164 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
165 } 165 }
166 166
167 QIconViewItem::paintItem(p,mycg); 167 QIconViewItem::paintItem(p,mycg);
168 168
169 // Paint animation overlay 169 // Paint animation overlay
170 if ( liv->busyItem() == this ) 170 if ( liv->busyItem() == this )
171 paintAnimatedIcon(p); 171 paintAnimatedIcon(p);
172 172
173 if ( liv->currentItem() == this ) 173 if ( liv->currentItem() == this )
174 liv->setItemTextBackground( oldBrush ); 174 liv->setItemTextBackground( oldBrush );
175} 175}
176 176
177void LauncherItem::paintAnimatedIcon( QPainter *p ) 177void LauncherItem::paintAnimatedIcon( QPainter *p )
178{ 178{
179 LauncherIconView* liv = (LauncherIconView*)iconView(); 179 LauncherIconView* liv = (LauncherIconView*)iconView();
180 int pic = iteration % 16; 180 int pic = iteration % 16;
181 int w = pixmap()->width(), h = pixmap()->height(); 181 int w = pixmap()->width(), h = pixmap()->height();
182 QPixmap dblBuf( w, h + 4 ); 182 QPixmap dblBuf( w, h + 4 );
183 QPainter p2( &dblBuf ); 183 QPainter p2( &dblBuf );
184 int x1, y1; 184 int x1, y1;
185 if ( liv->itemTextPos() == QIconView::Bottom ) { 185 if ( liv->itemTextPos() == QIconView::Bottom ) {
186 x1 = x() + (width() - w) / 2 - liv->contentsX(); 186 x1 = x() + (width() - w) / 2 - liv->contentsX();
187 y1 = y() - liv->contentsY(); 187 y1 = y() - liv->contentsY();
188 } else { 188 } else {
189 x1 = x() - liv->contentsX(); 189 x1 = x() - liv->contentsX();
190 y1 = y() + (height() - h) / 2 - liv->contentsY(); 190 y1 = y() + (height() - h) / 2 - liv->contentsY();
191 } 191 }
192 y1 -= 2; 192 y1 -= 2;
193 p2.translate(-x1,-y1); 193 p2.translate(-x1,-y1);
194 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); 194 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) );
195 int bounceY = 2; 195 int bounceY = 2;
196#ifdef BOUNCE_BUSY_ICON 196#ifdef BOUNCE_BUSY_ICON
197 if ( busyType == BIT_Animated ) { 197 if ( busyType == BIT_Animated ) {
198 bounceY = 4 - ((iteration+2)%8); 198 bounceY = 4 - ((iteration+2)%8);
199 bounceY = bounceY < 0 ? -bounceY : bounceY; 199 bounceY = bounceY < 0 ? -bounceY : bounceY;
200 } 200 }
201#endif 201#endif
202 p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); 202 p2.drawPixmap( x1, y1 + bounceY, *pixmap() );
203#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 203#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
204 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); 204 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h );
205#else 205#else
206 Q_UNUSED( pic ) 206 Q_UNUSED( pic )
207#endif 207#endif
208 p->drawPixmap( x1, y1, dblBuf ); 208 p->drawPixmap( x1, y1, dblBuf );
209} 209}
210 210
211void LauncherItem::animateIcon() 211void LauncherItem::animateIcon()
212{ 212{
213 LauncherIconView* liv = (LauncherIconView*)iconView(); 213 LauncherIconView* liv = (LauncherIconView*)iconView();
214 214
215 if ( liv->busyItem() != this || !app ) 215 if ( liv->busyItem() != this || !app )
216 return; 216 return;
217 217
218 // Highlight the icon 218 // Highlight the icon
219 if ( iteration == 0 ) { 219 if ( iteration == 0 ) {
220 QPixmap src; 220 QPixmap src;
221 pixiter it; 221 pixiter it;
222 if (isEyeImage() && (it=LauncherIconView::sm_EyeCache->find(appLnk()->file()))!=LauncherIconView::sm_EyeCache->end()) { 222 if (isEyeImage() && (it=LauncherIconView::sm_EyeCache->find(appLnk()->file()))!=LauncherIconView::sm_EyeCache->end()) {
223 src = (*it); 223 src = (*it);
224 } else { 224 } else {
225 src = ((isBigIcon ? app->bigPixmap() : app->pixmap())); 225 src = ((isBigIcon ? app->bigPixmap() : app->pixmap()));
226 } 226 }
227 QImage img = src.convertToImage(); 227 QImage img = src.convertToImage();
228 QRgb *rgb; 228 QRgb *rgb;
229 int count; 229 int count;
230 if ( img.depth() == 32 ) { 230 if ( img.depth() == 32 ) {
231 rgb = (QRgb*)img.bits(); 231 rgb = (QRgb*)img.bits();
232 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 232 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
233 } else { 233 } else {
234 rgb = img.colorTable(); 234 rgb = img.colorTable();
235 count = img.numColors(); 235 count = img.numColors();
236 } 236 }
237 for ( int r = 0; r < count; r++, rgb++ ) { 237 for ( int r = 0; r < count; r++, rgb++ ) {
238#if defined(BRIGHTEN_BUSY_ICON) 238#if defined(BRIGHTEN_BUSY_ICON)
239 QColor c(*rgb); 239 QColor c(*rgb);
240 int h, s, v; 240 int h, s, v;
241 c.hsv(&h,&s,&v); 241 c.hsv(&h,&s,&v);
242 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); 242 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255));
243 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); 243 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb));
244#elif defined(ALPHA_FADE_BUSY_ICON) 244#elif defined(ALPHA_FADE_BUSY_ICON)
245 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); 245 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2);
246#endif 246#endif
247 } 247 }
248 src.convertFromImage( img ); 248 src.convertFromImage( img );
249 setPixmap( src ); 249 setPixmap( src );
250 } 250 }
251 251
252 iteration++; 252 iteration++;
253 253
254 // Paint animation overlay 254 // Paint animation overlay
255 QPainter p( liv->viewport() ); 255 QPainter p( liv->viewport() );
256 paintAnimatedIcon( &p ); 256 paintAnimatedIcon( &p );
257} 257}
258 258
259void LauncherItem::resetIcon() 259void LauncherItem::resetIcon()
260{ 260{
261 iteration = 0; 261 iteration = 0;
262 if (isEyeImage()) { 262 if (isEyeImage()) {
263 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file()); 263 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file());
264 if (it != LauncherIconView::sm_EyeCache->end()) { 264 if (it != LauncherIconView::sm_EyeCache->end()) {
265 setPixmap(*it); 265 setPixmap(*it);
266 return; 266 return;
267 } 267 }
268 } 268 }
269 setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap()); 269 setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap());
270} 270}
271 271
272void LauncherItem::setEyePixmap(const QPixmap&aIcon) 272void LauncherItem::setEyePixmap(const QPixmap&aIcon)
273{ 273{
274 if (!isEyeImage()) return; 274 if (!isEyeImage()) return;
275 setPixmap(aIcon); 275 setPixmap(aIcon);
276 m_EyeImageSet = EYE_ICON; 276 m_EyeImageSet = EYE_ICON;
277} 277}
278 278
279//=========================================================================== 279//===========================================================================
280// Implemantation of LauncherIconview start 280// Implemantation of LauncherIconview start
281//=========================================================================== 281//===========================================================================
282 282
283QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0; 283QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0;
284 284
285LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) 285LauncherIconView::LauncherIconView( QWidget* parent, const char* name )
286 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white),numColumns(0) 286 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white),numColumns(0)
287{ 287{
288 m_EyeCallBack = 0; 288 m_EyeCallBack = 0;
289 if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>(); 289 if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>();
290 sortmeth = Name; 290 sortmeth = Name;
291 hidden.setAutoDelete(TRUE); 291 hidden.setAutoDelete(TRUE);
292 ike = FALSE; 292 ike = FALSE;
293 calculateGrid( Bottom ); 293 calculateGrid( Bottom );
294 connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); 294 connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer()));
295} 295}
296 296
297LauncherIconView::~LauncherIconView() 297LauncherIconView::~LauncherIconView()
298{ 298{
299 odebug << "LauncherIconView::~LauncherIconView()" << oendl; 299 odebug << "LauncherIconView::~LauncherIconView()" << oendl;
300#if 0 // debuggery 300#if 0 // debuggery
301 QListIterator<AppLnk> it(hidden); 301 QListIterator<AppLnk> it(hidden);
302 AppLnk* l; 302 AppLnk* l;
303 while ((l=it.current())) { 303 while ((l=it.current())) {
304 ++it; 304 ++it;
305 //odebug << "" << l << ": hidden (should remove)" << oendl; 305 //odebug << "" << l << ": hidden (should remove)" << oendl;
306 } 306 }
307#endif 307#endif
308} 308}
309 309
310int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) 310int LauncherIconView::compare(const AppLnk* a, const AppLnk* b)
311{ 311{
312 switch (sortmeth) { 312 switch (sortmeth) {
313 case Name: 313 case Name:
314 return a->name().lower().compare(b->name().lower()); 314 return a->name().lower().compare(b->name().lower());
315 case Date: { 315 case Date: {
316 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 316 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
317 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 317 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
318 return fa.lastModified().secsTo(fb.lastModified()); 318 return fa.lastModified().secsTo(fb.lastModified());
319 } 319 }
320 case Type: 320 case Type:
321 return a->type().compare(b->type()); 321 return a->type().compare(b->type());
322 } 322 }
323 return 0; 323 return 0;
324} 324}
325 325
326void LauncherIconView::setSortMethod( SortMethod m ) 326void LauncherIconView::setSortMethod( SortMethod m )
327{ 327{
328 if ( sortmeth != m ) { 328 if ( sortmeth != m ) {
329 sortmeth = m; 329 sortmeth = m;
330 sort(); 330 sort();
331 } 331 }
332} 332}
333 333
334void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) 334void LauncherIconView::setCategoryFilter( int catfilter, bool resort )
335{ 335{
336 if ( catfilter == -2 ) 336 if ( catfilter == -2 )
337 cf = 0; 337 cf = 0;
338 else 338 else
339 cf = catfilter; 339 cf = catfilter;
340 hideOrShowItems(resort); 340 hideOrShowItems(resort);
341} 341}
342 342
343void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) 343void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort)
344{ 344{
345 tf = QRegExp(typefilter,FALSE,TRUE); 345 tf = QRegExp(typefilter,FALSE,TRUE);
346 hideOrShowItems(resort); 346 hideOrShowItems(resort);
347} 347}
348 348
349void LauncherIconView::setItemTextPos( ItemTextPos pos ) 349void LauncherIconView::setItemTextPos( ItemTextPos pos )
350{ 350{
351 calculateGrid( pos ); 351 calculateGrid( pos );
352 QIconView::setItemTextPos( pos ); 352 QIconView::setItemTextPos( pos );
353} 353}
354 354
355void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) 355void LauncherIconView::drawBackground( QPainter *p, const QRect &r )
356{ 356{
357 if ( !bgPixmap.isNull() ) { 357 if ( !bgPixmap.isNull() ) {
358 p->drawTiledPixmap( r, bgPixmap, 358 p->drawTiledPixmap( r, bgPixmap,
359 QPoint( (r.x() + contentsX()) % bgPixmap.width(), 359 QPoint( (r.x() + contentsX()) % bgPixmap.width(),
360 (r.y() + contentsY()) % bgPixmap.height() ) ); 360 (r.y() + contentsY()) % bgPixmap.height() ) );
361 } else { 361 } else {
362 p->fillRect( r, bgColor ); 362 p->fillRect( r, bgColor );
363 } 363 }
364} 364}
365 365
366void LauncherIconView::addCatsAndMimes(AppLnk* app) 366void LauncherIconView::addCatsAndMimes(AppLnk* app)
367 { 367 {
368 // QStringList c = app->categories(); 368 // QStringList c = app->categories();
369 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 369 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
370 // cats.replace(*cit,(void*)1); 370 // cats.replace(*cit,(void*)1);
371 // } 371 // }
372 QString maj=app->type(); 372 QString maj=app->type();
373 int sl=maj.find('/'); 373 int sl=maj.find('/');
374 if (sl>=0) { 374 if (sl>=0) {
375 QString k; 375 QString k;
376 k = maj.left(12) == "application/" ? maj : maj.left(sl); 376 k = maj.left(12) == "application/" ? maj : maj.left(sl);
377 mimes.replace(k,(void*)1); 377 mimes.replace(k,(void*)1);
378 } 378 }
379} 379}
380 380
381void LauncherIconView::setBusy(bool on) 381void LauncherIconView::setBusy(bool on)
382{ 382{
383#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 383#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
384 if ( busyPix.isNull() ) { 384 if ( busyPix.isNull() ) {
385 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 385 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
386 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); 386 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) );
387 } 387 }
388#endif 388#endif
389 389
390 if ( on ) { 390 if ( on ) {
391 busyTimer = startTimer( 100 ); 391 busyTimer = startTimer( 100 );
392 } else { 392 } else {
393 if ( busyTimer ) { 393 if ( busyTimer ) {
394 killTimer( busyTimer ); 394 killTimer( busyTimer );
395 busyTimer = 0; 395 busyTimer = 0;
396 } 396 }
397 } 397 }
398 398
399 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; 399 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0;
400 400
401 if ( bsy != c ) { 401 if ( bsy != c ) {
402 LauncherItem *oldBusy = bsy; 402 LauncherItem *oldBusy = bsy;
403 bsy = c; 403 bsy = c;
404 if ( oldBusy ) { 404 if ( oldBusy ) {
405 oldBusy->resetIcon(); 405 oldBusy->resetIcon();
406 } 406 }
407 if ( bsy ) { 407 if ( bsy ) {
408 bsy->setBusyIndicatorType( busyType ) ; 408 bsy->setBusyIndicatorType( busyType ) ;
409 bsy->animateIcon(); 409 bsy->animateIcon();
410 } 410 }
411 } 411 }
412} 412}
413 413
414void LauncherIconView::clear() 414void LauncherIconView::clear()
415{ 415{
416 mimes.clear(); 416 mimes.clear();
417 cats.clear(); 417 cats.clear();
418 QIconView::clear(); 418 QIconView::clear();
419 hidden.clear(); 419 hidden.clear();
420} 420}
421 421
422QStringList LauncherIconView::mimeTypes() const 422QStringList LauncherIconView::mimeTypes() const
423{ 423{
424 QStringList r; 424 QStringList r;
425 QDictIterator<void> it(mimes); 425 QDictIterator<void> it(mimes);
426 while (it.current()) { 426 while (it.current()) {
427 r.append(it.currentKey()); 427 r.append(it.currentKey());
428 ++it; 428 ++it;
429 } 429 }
430 r.sort(); 430 r.sort();
431 return r; 431 return r;
432} 432}
433 433
434LauncherItem*LauncherIconView::findDocItem(const QString&fname) 434LauncherItem*LauncherIconView::findDocItem(const QString&fname)
435{ 435{
436 LauncherItem* item = (LauncherItem*)firstItem(); 436 LauncherItem* item = (LauncherItem*)firstItem();
437 while (item) { 437 while (item) {
438 if (item->appLnk()->file()==fname) { 438 if (item->appLnk()->file()==fname) {
439 break; 439 break;
440 } 440 }
441 item = (LauncherItem*)item->nextItem(); 441 item = (LauncherItem*)item->nextItem();
442 } 442 }
443 return item; 443 return item;
444} 444}
445 445
446void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) 446void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width)
447{ 447{
448 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 448 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
449 if (s!=width) return; 449 if (s!=width) return;
450 LauncherItem*item = findDocItem(aFile); 450 LauncherItem*item = findDocItem(aFile);
451 if (!item||!item->isEyeImage()) return; 451 if (!item||!item->isEyeImage()) return;
452 (*sm_EyeCache)[aFile]=aPixmap; 452 (*sm_EyeCache)[aFile]=aPixmap;
453 item->setEyePixmap(aPixmap); 453 item->setEyePixmap(aPixmap);
454} 454}
455 455
456void LauncherIconView::checkCallback() 456void LauncherIconView::checkCallback()
457{ 457{
458 if (!m_EyeCallBack) { 458 if (!m_EyeCallBack) {
459 m_EyeCallBack = new LauncherThumbReceiver(); 459 m_EyeCallBack = new LauncherThumbReceiver();
460 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), 460 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
461 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); 461 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
462 } 462 }
463 m_eyeTimer.changeInterval(600000); 463 m_eyeTimer.changeInterval(600000);
464} 464}
465 465
466void LauncherIconView::addCheckItem(AppLnk* app) 466void LauncherIconView::addCheckItem(AppLnk* app)
467{ 467{
468 LauncherItem*item = new LauncherItem( this, app, bigIcns ); 468 LauncherItem*item = new LauncherItem( this, app, bigIcns );
469 if (item->isEyeImage()) { 469 if (item->isEyeImage()) {
470 checkCallback(); 470 checkCallback();
471 } 471 }
472} 472}
473 473
474void LauncherIconView::requestEyePix(const LauncherItem*item) 474void LauncherIconView::requestEyePix(const LauncherItem*item)
475{ 475{
476 if (!item) return; 476 if (!item) return;
477 if (item->isEyeImage()) { 477 if (item->isEyeImage()) {
478 checkCallback(); 478 checkCallback();
479 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 479 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
480 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); 480 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s);
481 } 481 }
482} 482}
483 483
484void LauncherIconView::stopEyeTimer() 484void LauncherIconView::stopEyeTimer()
485{ 485{
486 if (m_EyeCallBack) { 486 if (m_EyeCallBack) {
487 disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), 487 disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
488 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); 488 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
489 delete m_EyeCallBack; 489 delete m_EyeCallBack;
490 m_EyeCallBack=0; 490 m_EyeCallBack=0;
491 } 491 }
492 m_eyeTimer.stop(); 492 m_eyeTimer.stop();
493} 493}
494 494
495void LauncherIconView::updateCategoriesAndMimeTypes() 495void LauncherIconView::updateCategoriesAndMimeTypes()
496{ 496{
497 mimes.clear(); 497 mimes.clear();
498 cats.clear(); 498 cats.clear();
499 LauncherItem* item = (LauncherItem*)firstItem(); 499 LauncherItem* item = (LauncherItem*)firstItem();
500 while (item) { 500 while (item) {
501 addCatsAndMimes(item->appLnk()); 501 addCatsAndMimes(item->appLnk());
502 item = (LauncherItem*)item->nextItem(); 502 item = (LauncherItem*)item->nextItem();
503 } 503 }
504 QListIterator<AppLnk> it(hidden); 504 QListIterator<AppLnk> it(hidden);
505 AppLnk* l; 505 AppLnk* l;
506 while ((l=it.current())) { 506 while ((l=it.current())) {
507 addCatsAndMimes(l); 507 addCatsAndMimes(l);
508 ++it; 508 ++it;
509 } 509 }
510} 510}
511 511
512void LauncherIconView::hideOrShowItems(bool resort) 512void LauncherIconView::hideOrShowItems(bool resort)
513{ 513{
514 viewport()->setUpdatesEnabled( FALSE ); 514 viewport()->setUpdatesEnabled( FALSE );
515 hidden.setAutoDelete(FALSE); 515 hidden.setAutoDelete(FALSE);
516 QList<AppLnk> links=hidden; 516 QList<AppLnk> links=hidden;
517 hidden.clear(); 517 hidden.clear();
518 hidden.setAutoDelete(TRUE); 518 hidden.setAutoDelete(TRUE);
519 LauncherItem* item = (LauncherItem*)firstItem(); 519 LauncherItem* item = (LauncherItem*)firstItem();
520 while (item) { 520 while (item) {
521 links.append(item->takeAppLnk()); 521 links.append(item->takeAppLnk());
522 item = (LauncherItem*)item->nextItem(); 522 item = (LauncherItem*)item->nextItem();
523 } 523 }
524 clear(); 524 clear();
525 QListIterator<AppLnk> it(links); 525 QListIterator<AppLnk> it(links);
526 AppLnk* l; 526 AppLnk* l;
527 while ((l=it.current())) { 527 while ((l=it.current())) {
528 addItem(l,FALSE); 528 addItem(l,FALSE);
529 ++it; 529 ++it;
530 } 530 }
531 if ( resort && !autoArrange() ) 531 if ( resort && !autoArrange() )
532 sort(); 532 sort();
533 viewport()->setUpdatesEnabled( TRUE ); 533 viewport()->setUpdatesEnabled( TRUE );
534} 534}
535 535
536bool LauncherIconView::removeLink(const QString& linkfile,bool removeCache) 536bool LauncherIconView::removeLink(const QString& linkfile,bool removeCache)
537{ 537{
538 LauncherItem* item = (LauncherItem*)firstItem(); 538 LauncherItem* item = (LauncherItem*)firstItem();
539 AppLnk* l; 539 AppLnk* l;
540 bool did = FALSE; 540 bool did = FALSE;
541 DocLnk dl(linkfile); 541 DocLnk dl(linkfile);
542 while (item) { 542 while (item) {
543 l = item->appLnk(); 543 l = item->appLnk();
544 LauncherItem *nextItem = (LauncherItem *)item->nextItem(); 544 LauncherItem *nextItem = (LauncherItem *)item->nextItem();
545 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && 545 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() &&
546 ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { 546 ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) {
547 if (removeCache) sm_EyeCache->remove(l->file()); 547 if (removeCache) sm_EyeCache->remove(l->file());
548 delete item; 548 delete item;
549 did = TRUE; 549 did = TRUE;
550 } 550 }
551 item = nextItem; 551 item = nextItem;
552 } 552 }
553 QListIterator<AppLnk> it(hidden); 553 QListIterator<AppLnk> it(hidden);
554 while ((l=it.current())) { 554 while ((l=it.current())) {
555 ++it; 555 ++it;
556 if ( l->linkFileKnown() && l->linkFile() == linkfile 556 if ( l->linkFileKnown() && l->linkFile() == linkfile
557 || l->file() == linkfile 557 || l->file() == linkfile
558 || dl.isValid() && dl.file() == l->file() ) { 558 || dl.isValid() && dl.file() == l->file() ) {
559 hidden.removeRef(l); 559 hidden.removeRef(l);
560 did = TRUE; 560 did = TRUE;
561 } 561 }
562 } 562 }
563 return did; 563 return did;
564} 564}
565 565
566void LauncherIconView::addItem(AppLnk* app, bool resort) 566void LauncherIconView::addItem(AppLnk* app, bool resort)
567{ 567{
568 addCatsAndMimes(app); 568 addCatsAndMimes(app);
569 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 569 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
570 && (cf == 0 || app->categories().contains(cf) 570 && (cf == 0 || app->categories().contains(cf)
571 || cf == -1 && app->categories().count() == 0 ) ) { 571 || cf == -1 && app->categories().count() == 0 ) ) {
572 addCheckItem(app); 572 addCheckItem(app);
573 } else { 573 } else {
574 hidden.append(app); 574 hidden.append(app);
575 } 575 }
576 if ( resort ){ 576 if ( resort ){
577 sort(); 577 sort();
578 } 578 }
579} 579}
580 580
581void LauncherIconView::changeItem(const AppLnk&old,AppLnk*nlink) 581void LauncherIconView::changeItem(const AppLnk&old,AppLnk*nlink)
582{ 582{
583 QString oldfile = old.file(); 583 QString oldfile = old.file();
584 QString newfile = nlink->file(); 584 QString newfile = nlink->file();
585 585
586 if (newfile != oldfile) { 586 if (newfile != oldfile) {
587 QMap<QString,QPixmap>::Iterator it = sm_EyeCache->find(oldfile); 587 QMap<QString,QPixmap>::Iterator it = sm_EyeCache->find(oldfile);
588 if (it != sm_EyeCache->end()) { 588 if (it != sm_EyeCache->end()) {
589 (*sm_EyeCache)[newfile]=(*it); 589 (*sm_EyeCache)[newfile]=(*it);
590 } 590 }
591 removeLink(old.linkFile()); 591 removeLink(old.linkFile());
592 } else { 592 } else {
593 removeLink(old.linkFile(),false); 593 removeLink(old.linkFile(),false);
594 } 594 }
595 addItem(nlink,false); 595 addItem(nlink,false);
596} 596}
597 597
598void LauncherIconView::timerEvent( QTimerEvent *te ) 598void LauncherIconView::timerEvent( QTimerEvent *te )
599{ 599{
600 if ( te->timerId() == busyTimer ) { 600 if ( te->timerId() == busyTimer ) {
601 if ( bsy ) 601 if ( bsy )
602 bsy->animateIcon(); 602 bsy->animateIcon();
603 } else { 603 } else {
604 QIconView::timerEvent( te ); 604 QIconView::timerEvent( te );
605 } 605 }
606} 606}
607 607
608void LauncherIconView::setBigIcons( bool bi ) 608void LauncherIconView::setBigIcons( bool bi )
609{ 609{
610 sm_EyeCache->clear(); 610 sm_EyeCache->clear();
611 bigIcns = bi; 611 bigIcns = bi;
612#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 612#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
613 busyPix.resize(0,0); 613 busyPix.resize(0,0);
614#endif 614#endif
615} 615}
616 616
617QIconViewItem* LauncherIconView::busyItem() const 617QIconViewItem* LauncherIconView::busyItem() const
618{ 618{
619 return bsy; 619 return bsy;
620} 620}
621 621
622void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 622void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
623 623
624void LauncherIconView::calculateGrid( ItemTextPos pos ) 624void LauncherIconView::calculateGrid( ItemTextPos pos )
625{ 625{
626 int dw = QApplication::desktop()->width(); 626 int dw = QApplication::desktop()->width();
627 int viewerWidth = dw-style().scrollBarExtent().width(); 627 int viewerWidth = dw-style().scrollBarExtent().width();
628 if ( pos == Bottom ) { 628 if ( pos == Bottom ) {
629 if( !numColumns ) { 629 if( !numColumns ) {
630 if ( viewerWidth <= 200 ) numColumns = 2; 630 if ( viewerWidth <= 200 ) numColumns = 2;
631 else if ( viewerWidth >= 400 ) numColumns = viewerWidth/96; 631 else if ( viewerWidth >= 400 ) numColumns = viewerWidth/96;
632 else numColumns = 3; 632 else numColumns = 3;
633 } 633 }
634 setSpacing( 4 ); 634 setSpacing( 4 );
635 setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns ); 635 setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns );
636 setGridY( fontMetrics().height()*2+24 ); 636 setGridY( fontMetrics().height()*2+24 );
637 } else { 637 } else {
638 if( !numColumns ) { 638 if( !numColumns ) {
639 if ( viewerWidth < 150 ) numColumns = 1; 639 if ( viewerWidth < 150 ) numColumns = 1;
640 else if ( viewerWidth >= 400 ) numColumns = viewerWidth/150; 640 else if ( viewerWidth >= 400 ) numColumns = viewerWidth/150;
641 else numColumns = 2; 641 else numColumns = 2;
642 } 642 }
643 setSpacing( 2 ); 643 setSpacing( 2 );
644 setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns ); 644 setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns );
645 setGridY( fontMetrics().height()+2 ); 645 setGridY( fontMetrics().height()+2 );
646 } 646 }
647} 647}
648 648
649void LauncherIconView::styleChange( QStyle &old ) 649void LauncherIconView::styleChange( QStyle &old )
650{ 650{
651 QIconView::styleChange( old ); 651 QIconView::styleChange( old );
652 calculateGrid( itemTextPos() ); 652 calculateGrid( itemTextPos() );
653} 653}
654 654
655void LauncherIconView::keyPressEvent(QKeyEvent* e) 655void LauncherIconView::keyPressEvent(QKeyEvent* e)
656{ 656{
657 ike = TRUE; 657 ike = TRUE;
658 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { 658 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) {
659 if ( (e->state() & ShiftButton) ) 659 if ( (e->state() & ShiftButton) )
660 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); 660 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() );
661 else 661 else
662 returnPressed(currentItem()); 662 returnPressed(currentItem());
663 } 663 }
664 664
665 QIconView::keyPressEvent(e); 665 QIconView::keyPressEvent(e);
666 ike = FALSE; 666 ike = FALSE;
667} 667}
668 668
669//=========================================================================== 669//===========================================================================
670// Implemantation of LauncherIconview end 670// Implemantation of LauncherIconview end
671//=========================================================================== 671//===========================================================================
672 672
673 673
674//=========================================================================== 674//===========================================================================
675LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 675LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
676 : QVBox( parent, name, fl ) 676 : QVBox( parent, name, fl )
677{ 677{
678 catmb = 0; 678 catmb = 0;
679 icons = new LauncherIconView( this ); 679 icons = new LauncherIconView( this );
680 setFocusProxy(icons); 680 setFocusProxy(icons);
681 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 681 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
682 682
683 icons->setItemsMovable( FALSE ); 683 icons->setItemsMovable( FALSE );
684 icons->setAutoArrange( TRUE ); 684 icons->setAutoArrange( TRUE );
685 icons->setSorting( TRUE ); 685 icons->setSorting( TRUE );
686 icons->setFrameStyle( QFrame::NoFrame ); 686 icons->setFrameStyle( QFrame::NoFrame );
687 icons->setMargin( 0 ); 687 icons->setMargin( 0 );
688 icons->setSelectionMode( QIconView::NoSelection ); 688 icons->setSelectionMode( QIconView::NoSelection );
689 icons->setBackgroundMode( PaletteBase ); 689 icons->setBackgroundMode( PaletteBase );
690 icons->setResizeMode( QIconView::Adjust ); 690 icons->setResizeMode( QIconView::Adjust );
691 vmode = (ViewMode)-1; 691 vmode = (ViewMode)-1;
692 setViewMode( Icon ); 692 setViewMode( Icon );
693 693
694 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), 694 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)),
695 SLOT(itemClicked(int,QIconViewItem*)) ); 695 SLOT(itemClicked(int,QIconViewItem*)) );
696 connect( icons, SIGNAL(selectionChanged()), 696 connect( icons, SIGNAL(selectionChanged()),
697 SLOT(selectionChanged()) ); 697 SLOT(selectionChanged()) );
698 connect( icons, SIGNAL(returnPressed(QIconViewItem*)), 698 connect( icons, SIGNAL(returnPressed(QIconViewItem*)),
699 SLOT(returnPressed(QIconViewItem*)) ); 699 SLOT(returnPressed(QIconViewItem*)) );
700 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), 700 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)),
701 SLOT(itemPressed(int,QIconViewItem*)) ); 701 SLOT(itemPressed(int,QIconViewItem*)) );
702 702
703 tools = 0; 703 tools = 0;
704 setBackgroundType( Ruled, QString::null ); 704 setBackgroundType( Ruled, QString::null );
705} 705}
706 706
707LauncherView::~LauncherView() 707LauncherView::~LauncherView()
708{ 708{
709 if ( bgCache && bgCache->contains( bgName ) ) 709 if ( bgCache && bgCache->contains( bgName ) )
710 (*bgCache)[bgName]->ref--; 710 (*bgCache)[bgName]->ref--;
711} 711}
712 712
713 713
714bool LauncherView::bsy=FALSE; 714bool LauncherView::bsy=FALSE;
715 715
716void LauncherView::setBusy(bool on) 716void LauncherView::setBusy(bool on)
717{ 717{
718 icons->setBusy(on); 718 icons->setBusy(on);
719} 719}
720 720
721void LauncherView::setBusyIndicatorType( const QString& type ) { 721void LauncherView::setBusyIndicatorType( const QString& type ) {
722 if ( type. lower ( ) == "animated" ) 722 if ( type. lower ( ) == "animated" )
723 icons->setBusyIndicatorType( BIT_Animated ) ; 723 icons->setBusyIndicatorType( BIT_Animated ) ;
724 else 724 else
725 icons->setBusyIndicatorType( BIT_Normal ) ; 725 icons->setBusyIndicatorType( BIT_Normal ) ;
726} 726}
727 727
728void LauncherView::hideIcons() 728void LauncherView::hideIcons()
729{ 729{
730 icons->hide(); 730 icons->hide();
731} 731}
732 732
733void LauncherView::setToolsEnabled(bool y) 733void LauncherView::setToolsEnabled(bool y)
734{ 734{
735 if ( !y != !tools ) { 735 if ( !y != !tools ) {
736 if ( y ) { 736 if ( y ) {
737 tools = new QHBox(this); 737 tools = new QHBox(this);
738 // Type filter 738 // Type filter
739 typemb = new QComboBox(tools); 739 typemb = new QComboBox(tools);
740 QSizePolicy p = typemb->sizePolicy(); 740 QSizePolicy p = typemb->sizePolicy();
741 p.setHorData(QSizePolicy::Expanding); 741 p.setHorData(QSizePolicy::Expanding);
742 typemb->setSizePolicy(p); 742 typemb->setSizePolicy(p);
743 // Category filter 743 // Category filter
744 updateTools(); 744 updateTools();
745 tools->show(); 745 tools->show();
746 } else { 746 } else {
747 delete tools; 747 delete tools;
748 tools = 0; 748 tools = 0;
749 } 749 }
750 } 750 }
751} 751}
752 752
753void LauncherView::updateTools() 753void LauncherView::updateTools()
754{ 754{
755 disconnect( typemb, SIGNAL(activated(int)), 755 disconnect( typemb, SIGNAL(activated(int)),
756 this, SLOT(showType(int)) ); 756 this, SLOT(showType(int)) );
757 if ( catmb ) { 757 if ( catmb ) {
758 disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int))); 758 disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int)));
759 } 759 }
760 760
761 // ### I want to remove this 761 // ### I want to remove this
762 icons->updateCategoriesAndMimeTypes(); 762 icons->updateCategoriesAndMimeTypes();
763 763
764 QString prev; 764 QString prev;
765 765
766 // Type filter 766 // Type filter
767 QStringList types; 767 QStringList types;
768 typelist = icons->mimeTypes(); 768 typelist = icons->mimeTypes();
769 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { 769 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
770 QString t = *it; 770 QString t = *it;
771 if ( t.left(12) == "application/" ) { 771 if ( t.left(12) == "application/" ) {
772 MimeType mt(t); 772 MimeType mt(t);
773 const AppLnk* app = mt.application(); 773 const AppLnk* app = mt.application();
774 if ( app ) 774 if ( app )
775 t = app->name(); 775 t = app->name();
776 else 776 else
777 t = t.mid(12); 777 t = t.mid(12);
778 } else { 778 } else {
779 t[0] = t[0].upper(); 779 t[0] = t[0].upper();
780 } 780 }
781 types += t; 781 types += t;
782 } 782 }
783 types << tr("All types"); 783 types << tr("All types");
784 prev = typemb->currentText(); 784 prev = typemb->currentText();
785 typemb->clear(); 785 typemb->clear();
786 typemb->insertStringList(types); 786 typemb->insertStringList(types);
787 for (int i=0; i<typemb->count(); i++) { 787 for (int i=0; i<typemb->count(); i++) {
788 if ( typemb->text(i) == prev ) { 788 if ( typemb->text(i) == prev ) {
789 typemb->setCurrentItem(i); 789 typemb->setCurrentItem(i);
790 break; 790 break;
791 } 791 }
792 } 792 }
793 if ( prev.isNull() ) { 793 if ( prev.isNull() ) {
794 typemb->setCurrentItem(typemb->count()-1); 794 typemb->setCurrentItem(typemb->count()-1);
795 } 795 }
796 796
797 int pcat = catmb ? catmb->currentCategory() : -2; 797 int pcat = catmb ? catmb->currentCategory() : -2;
798 if ( !catmb ) { 798 if ( !catmb ) {
799 catmb = new CategorySelect(tools); 799 catmb = new CategorySelect(tools);
800 } else if (pcat!=-2) { 800 } else if (pcat!=-2) {
801 801
802 } 802 }
803 Categories cats( 0 ); 803 Categories cats( 0 );
804 cats.load( categoryFileName() ); 804 cats.load( categoryFileName() );
805 QArray<int> vl( 0 ); 805 QArray<int> vl( 0 );
806 catmb->setCategories( vl, "Document View", // No tr 806 catmb->setCategories( vl, "Document View", // No tr
807 tr("Document View") ); 807 tr("Document View") );
808 catmb->setRemoveCategoryEdit( TRUE ); 808 catmb->setRemoveCategoryEdit( TRUE );
809 catmb->setAllCategories( TRUE ); 809 catmb->setAllCategories( TRUE );
810 catmb->setCurrentCategory(pcat); 810 catmb->setCurrentCategory(pcat);
811 811
812 // if type has changed we need to redisplay 812 // if type has changed we need to redisplay
813 if ( typemb->currentText() != prev ) 813 if ( typemb->currentText() != prev )
814 showType( typemb->currentItem() ); 814 showType( typemb->currentItem() );
815 815
816 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); 816 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int)));
817 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 817 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
818} 818}
819 819
820void LauncherView::sortBy(int s) 820void LauncherView::sortBy(int s)
821{ 821{
822 icons->setSortMethod((LauncherIconView::SortMethod)s); 822 icons->setSortMethod((LauncherIconView::SortMethod)s);
823} 823}
824 824
825void LauncherView::showType(int t) 825void LauncherView::showType(int t)
826{ 826{
827 if ( t >= (int)typelist.count() ) { 827 if ( t >= (int)typelist.count() ) {
828 icons->setTypeFilter("",TRUE); 828 icons->setTypeFilter("",TRUE);
829 } else { 829 } else {
830 QString ty = typelist[t]; 830 QString ty = typelist[t];
831 if ( !ty.contains('/') ) 831 if ( !ty.contains('/') )
832 ty += "/*"; 832 ty += "/*";
833 icons->setTypeFilter(ty,TRUE); 833 icons->setTypeFilter(ty,TRUE);
834 } 834 }
835} 835}
836 836
837void LauncherView::showCategory( int c ) 837void LauncherView::showCategory( int c )
838{ 838{
839 icons->setCategoryFilter( c, TRUE ); 839 icons->setCategoryFilter( c, TRUE );
840} 840}
841 841
842void LauncherView::setViewMode( ViewMode m ) 842void LauncherView::setViewMode( ViewMode m )
843{ 843{
844 odebug << "LauncherView::setViewMode( ViewMode m )" << oendl; 844 odebug << "LauncherView::setViewMode( ViewMode m )" << oendl;
845 if ( vmode != m ) { 845 if ( vmode != m ) {
846 bool bigIcons = m == Icon; 846 bool bigIcons = m == Icon;
847 icons->viewport()->setUpdatesEnabled( FALSE ); 847 icons->viewport()->setUpdatesEnabled( FALSE );
848 icons->setBigIcons( bigIcons ); 848 icons->setBigIcons( bigIcons );
849 switch ( m ) { 849 switch ( m ) {
850 case List: 850 case List:
851 icons->setItemTextPos( QIconView::Right ); 851 icons->setItemTextPos( QIconView::Right );
852 break; 852 break;
853 case Icon: 853 case Icon:
854 icons->setItemTextPos( QIconView::Bottom ); 854 icons->setItemTextPos( QIconView::Bottom );
855 break; 855 break;
856 } 856 }
857 icons->hideOrShowItems( FALSE ); 857 icons->hideOrShowItems( FALSE );
858 icons->viewport()->setUpdatesEnabled( TRUE ); 858 icons->viewport()->setUpdatesEnabled( TRUE );
859 vmode = m; 859 vmode = m;
860 } 860 }
861} 861}
862 862
863// 863//
864// User images may require scaling. 864// User images may require scaling.
865// 865//
866QImage LauncherView::loadBackgroundImage(QString &bgName) 866QImage LauncherView::loadBackgroundImage(QString &bgName)
867{ 867{
868 QImageIO imgio; 868 QImageIO imgio;
869 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop 869 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop
870 bool further_scaling = TRUE; 870 bool further_scaling = TRUE;
871 871
872 imgio.setFileName( bgName ); 872 imgio.setFileName( bgName );
873 imgio.setParameters("GetHeaderInformation"); 873 imgio.setParameters("GetHeaderInformation");
874 874
875 if (imgio.read() == FALSE) { 875 if (imgio.read() == FALSE) {
876 return imgio.image(); 876 return imgio.image();
877 } 877 }
878 878
879 if (imgio.image().width() < ds.width() && 879 if (imgio.image().width() < ds.width() &&
880 imgio.image().height() < ds.height()) { 880 imgio.image().height() < ds.height()) {
881 further_scaling = FALSE; 881 further_scaling = FALSE;
882 } 882 }
883 883
884 if (!imgio.image().bits()) { 884 if (!imgio.image().bits()) {
885 // 885 //
886 // Scale and load. Note we don't scale up. 886 // Scale and load. Note we don't scale up.
887 // 887 //
888 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr 888 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr
889 imgio.setParameters(further_scaling ? 889 imgio.setParameters(further_scaling ?
890 param.arg(ds.width()).arg(ds.height()).latin1() : 890 param.arg(ds.width()).arg(ds.height()).latin1() :
891 ""); 891 "");
892 imgio.read(); 892 imgio.read();
893 } else { 893 } else {
894 if (further_scaling) { 894 if (further_scaling) {
895 int t1 = imgio.image().width() * ds.height(); 895 int t1 = imgio.image().width() * ds.height();
896 int t2 = imgio.image().height() * ds.width(); 896 int t2 = imgio.image().height() * ds.width();
897 int dsth = ds.height(); 897 int dsth = ds.height();
898 int dstw = ds.width(); 898 int dstw = ds.width();
899 899
900 if (t1 > t2) { 900 if (t1 > t2) {
901 dsth = t2 / imgio.image().width(); 901 dsth = t2 / imgio.image().width();
902 } else { 902 } else {
903 dstw = t1 / imgio.image().height(); 903 dstw = t1 / imgio.image().height();
904 } 904 }
905 905
906 // 906 //
907 // Loader didn't scale for us. Do it manually. 907 // Loader didn't scale for us. Do it manually.
908 // 908 //
909 return imgio.image().smoothScale(dstw, dsth); 909 return imgio.image().smoothScale(dstw, dsth);
910 } 910 }
911 } 911 }
912 912
913 return imgio.image(); 913 return imgio.image();
914} 914}
915 915
916void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) 916void LauncherView::setBackgroundType( BackgroundType t, const QString &val )
917{ 917{
918 if ( !bgCache ) { 918 if ( !bgCache ) {
919 bgCache = new QMap<QString,BgPixmap*>; 919 bgCache = new QMap<QString,BgPixmap*>;
920 qAddPostRoutine( cleanup_cache ); 920 qAddPostRoutine( cleanup_cache );
921 } 921 }
922 922
923 if ( bgCache->contains( bgName ) ) 923 if ( bgCache->contains( bgName ) )
924 (*bgCache)[bgName]->ref--; 924 (*bgCache)[bgName]->ref--;
925 bgName = ""; 925 bgName = "";
926 926
927 QPixmap bg; 927 QPixmap bg;
928 928
929 switch ( t ) { 929 switch ( t ) {
930 case Ruled: { 930 case Ruled: {
931 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr 931 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr
932 if ( bgCache->contains( bgName ) ) { 932 if ( bgCache->contains( bgName ) ) {
933 (*bgCache)[bgName]->ref++; 933 (*bgCache)[bgName]->ref++;
934 bg = (*bgCache)[bgName]->pm; 934 bg = (*bgCache)[bgName]->pm;
935 } else { 935 } else {
936 bg.resize( width(), 9 ); 936 bg.resize( width(), 9 );
937 QPainter painter( &bg ); 937 QPainter painter( &bg );
938 for ( int i = 0; i < 3; i++ ) { 938 for ( int i = 0; i < 3; i++ ) {
939 painter.setPen( white ); 939 painter.setPen( white );
940 painter.drawLine( 0, i*3, width()-1, i*3 ); 940 painter.drawLine( 0, i*3, width()-1, i*3 );
941 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 941 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
942 painter.setPen( colorGroup().background().light(105) ); 942 painter.setPen( colorGroup().background().light(105) );
943 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 943 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
944 } 944 }
945 painter.end(); 945 painter.end();
946 bgCache->insert( bgName, new BgPixmap(bg) ); 946 bgCache->insert( bgName, new BgPixmap(bg) );
947 } 947 }
948 break; 948 break;
949 } 949 }
950 950
951 case Image: 951 case Image:
952 if (!val.isEmpty()) { 952 if (!val.isEmpty()) {
953 bgName = val; 953 bgName = val;
954 if ( bgCache->contains( bgName ) ) { 954 if ( bgCache->contains( bgName ) ) {
955 (*bgCache)[bgName]->ref++; 955 (*bgCache)[bgName]->ref++;
956 bg = (*bgCache)[bgName]->pm; 956 bg = (*bgCache)[bgName]->pm;
957 } else { 957 } else {
958 QString imgFile = bgName; 958 QString imgFile = bgName;
959 bool tile = FALSE; 959 bool tile = FALSE;
960 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { 960 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) {
961 imgFile = Resource::findPixmap( imgFile ); 961 imgFile = Resource::findPixmap( imgFile );
962 tile = TRUE; 962 tile = TRUE;
963 } 963 }
964 QImage img = loadBackgroundImage(imgFile); 964 QImage img = loadBackgroundImage(imgFile);
965 965
966 966
967 if ( img.depth() == 1 ) 967 if ( img.depth() == 1 )
968 img = img.convertDepth(8); 968 img = img.convertDepth(8);
969 img.setAlphaBuffer(FALSE); 969 img.setAlphaBuffer(FALSE);
970 bg.convertFromImage(img); 970 bg.convertFromImage(img);
971 bgCache->insert( bgName, new BgPixmap(bg) ); 971 bgCache->insert( bgName, new BgPixmap(bg) );
972 } 972 }
973 } 973 }
974 break; 974 break;
975 975
976 case SolidColor: 976 case SolidColor:
977 default: 977 default:
978 break; 978 break;
979 } 979 }
980 980
981 const QObjectList *list = queryList( "QWidget", 0, FALSE ); 981 const QObjectList *list = queryList( "QWidget", 0, FALSE );
982 QObject *obj; 982 QObject *obj;
983 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { 983 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) {
984 if ( obj->isWidgetType() ) { 984 if ( obj->isWidgetType() ) {
985 QWidget *w = (QWidget*)obj; 985 QWidget *w = (QWidget*)obj;
986 w->setBackgroundPixmap( bg ); 986 w->setBackgroundPixmap( bg );
987 if ( bgName.isEmpty() ) { 987 if ( bgName.isEmpty() ) {
988 // Solid Color 988 // Solid Color
989 if ( val.isEmpty() ) 989 if ( val.isEmpty() )
990 w->setBackgroundColor( colorGroup().base() ); 990 w->setBackgroundColor( colorGroup().base() );
991 else 991 else
992 w->setBackgroundColor( val ); 992 w->setBackgroundColor( val );
993 } else { 993 } else {
994 // Ruled or Image pixmap 994 // Ruled or Image pixmap
995 w->setBackgroundOrigin( ParentOrigin ); 995 w->setBackgroundOrigin( ParentOrigin );
996 } 996 }
997 } 997 }
998 } 998 }
999 delete list; 999 delete list;
1000 1000
1001 bgType = t; 1001 bgType = t;
1002 icons->viewport()->update(); 1002 icons->viewport()->update();
1003 1003
1004 QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); 1004 QTimer::singleShot( 1000, this, SLOT(flushBgCache()) );
1005} 1005}
1006 1006
1007void LauncherView::setColNumber( int num ) 1007void LauncherView::setColNumber( int num )
1008{ 1008{
1009 icons->setColNumber( num ); 1009 icons->setColNumber( num );
1010} 1010}
1011 1011
1012void LauncherIconView::setColNumber( int num ) 1012void LauncherIconView::setColNumber( int num )
1013{ 1013{
1014 numColumns = num; 1014 numColumns = num;
1015 calculateGrid( Bottom ); 1015 calculateGrid( Bottom );
1016} 1016}
1017 1017
1018void LauncherView::setTextColor( const QColor &tc ) 1018void LauncherView::setTextColor( const QColor &tc )
1019{ 1019{
1020 textCol = tc; 1020 textCol = tc;
1021 QColorGroup cg = icons->colorGroup(); 1021 QColorGroup cg = icons->colorGroup();
1022 cg.setColor( QColorGroup::Text, tc ); 1022 cg.setColor( QColorGroup::Text, tc );
1023 icons->setPalette( QPalette(cg,cg,cg) ); 1023 icons->setPalette( QPalette(cg,cg,cg) );
1024 icons->viewport()->update(); 1024 icons->viewport()->update();
1025} 1025}
1026 1026
1027void LauncherView::setViewFont( const QFont &f ) 1027void LauncherView::setViewFont( const QFont &f )
1028{ 1028{
1029 icons->setFont( f ); 1029 icons->setFont( f );
1030 icons->hideOrShowItems( FALSE ); 1030 icons->hideOrShowItems( FALSE );
1031} 1031}
1032 1032
1033void LauncherView::clearViewFont() 1033void LauncherView::clearViewFont()
1034{ 1034{
1035 icons->unsetFont(); 1035 icons->unsetFont();
1036 icons->hideOrShowItems( FALSE ); 1036 icons->hideOrShowItems( FALSE );
1037} 1037}
1038 1038
1039void LauncherView::resizeEvent(QResizeEvent *e) 1039void LauncherView::resizeEvent(QResizeEvent *e)
1040{ 1040{
1041// qDebug("LauncherView resize event"); 1041// qDebug("LauncherView resize event");
1042 QVBox::resizeEvent( e ); 1042 QVBox::resizeEvent( e );
1043// commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere... 1043// commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere...
1044// if ( e->size().width() != e->oldSize().width() ) 1044// if ( e->size().width() != e->oldSize().width() )
1045 sort(); 1045 sort();
1046} 1046}
1047 1047
1048void LauncherView::selectionChanged() 1048void LauncherView::selectionChanged()
1049{ 1049{
1050 QIconViewItem* item = icons->currentItem(); 1050 QIconViewItem* item = icons->currentItem();
1051 if ( item && item->isSelected() ) { 1051 if ( item && item->isSelected() ) {
1052 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1052 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1053 if ( icons->inKeyEvent() ) // not for mouse press 1053 if ( icons->inKeyEvent() ) // not for mouse press
1054 emit clicked( appLnk ); 1054 emit clicked( appLnk );
1055 item->setSelected(FALSE); 1055 item->setSelected(FALSE);
1056 } 1056 }
1057} 1057}
1058 1058
1059void LauncherView::returnPressed( QIconViewItem *item ) 1059void LauncherView::returnPressed( QIconViewItem *item )
1060{ 1060{
1061 if ( item ) { 1061 if ( item ) {
1062 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1062 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1063 emit clicked( appLnk ); 1063 emit clicked( appLnk );
1064 } 1064 }
1065} 1065}
1066 1066
1067void LauncherView::itemClicked( int btn, QIconViewItem *item ) 1067void LauncherView::itemClicked( int btn, QIconViewItem *item )
1068{ 1068{
1069 if ( item ) { 1069 if ( item ) {
1070 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1070 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1071 if ( btn == LeftButton ) { 1071 if ( btn == LeftButton ) {
1072 // Make sure it's the item we execute that gets highlighted 1072 // Make sure it's the item we execute that gets highlighted
1073 icons->setCurrentItem( item ); 1073 icons->setCurrentItem( item );
1074 emit clicked( appLnk ); 1074 emit clicked( appLnk );
1075 } 1075 }
1076 item->setSelected(FALSE); 1076 item->setSelected(FALSE);
1077 } 1077 }
1078} 1078}
1079 1079
1080void LauncherView::itemPressed( int btn, QIconViewItem *item ) 1080void LauncherView::itemPressed( int btn, QIconViewItem *item )
1081{ 1081{
1082 if ( item ) { 1082 if ( item ) {
1083 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1083 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1084 if ( btn == RightButton ) 1084 if ( btn == RightButton )
1085 emit rightPressed( appLnk ); 1085 emit rightPressed( appLnk );
1086 else if ( btn == ShiftButton ) 1086 else if ( btn == ShiftButton )
1087 emit rightPressed( appLnk ); 1087 emit rightPressed( appLnk );
1088 item->setSelected(FALSE); 1088 item->setSelected(FALSE);
1089 } 1089 }
1090} 1090}
1091 1091
1092void LauncherView::removeAllItems() 1092void LauncherView::removeAllItems()
1093{ 1093{
1094 odebug << "LauncherView::removeAllItems()" << oendl; 1094 odebug << "LauncherView::removeAllItems()" << oendl;
1095 if (LauncherIconView::sm_EyeCache) LauncherIconView::sm_EyeCache->clear(); 1095 if (LauncherIconView::sm_EyeCache) LauncherIconView::sm_EyeCache->clear();
1096 icons->clear(); 1096 icons->clear();
1097} 1097}
1098 1098
1099bool LauncherView::removeLink(const QString& linkfile) 1099bool LauncherView::removeLink(const QString& linkfile)
1100{ 1100{
1101 return icons->removeLink(linkfile); 1101 return icons->removeLink(linkfile);
1102} 1102}
1103 1103
1104void LauncherView::addItem(AppLnk* app, bool resort) 1104void LauncherView::addItem(AppLnk* app, bool resort)
1105{ 1105{
1106 icons->addItem(app,resort); 1106 icons->addItem(app,resort);
1107} 1107}
1108 1108
1109void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink) 1109void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink)
1110{ 1110{
1111 icons->changeItem(old,nlink); 1111 icons->changeItem(old,nlink);
1112} 1112}
1113 1113
1114void LauncherView::setSortEnabled( bool v ) 1114void LauncherView::setSortEnabled( bool v )
1115{ 1115{
1116 icons->setSorting( v ); 1116 icons->setSorting( v );
1117 if ( v ) 1117 if ( v )
1118 sort(); 1118 sort();
1119} 1119}
1120 1120
1121void LauncherView::setUpdatesEnabled( bool u ) 1121void LauncherView::setUpdatesEnabled( bool u )
1122{ 1122{
1123 icons->setUpdatesEnabled( u ); 1123 icons->setUpdatesEnabled( u );
1124} 1124}
1125 1125
1126void LauncherView::sort() 1126void LauncherView::sort()
1127{ 1127{
1128 icons->sort(); 1128 icons->sort();
1129} 1129}
1130 1130
1131void LauncherView::paletteChange( const QPalette &p ) 1131void LauncherView::paletteChange( const QPalette &p )
1132{ 1132{
1133 icons->unsetPalette(); 1133 icons->unsetPalette();
1134 QVBox::paletteChange( p ); 1134 QVBox::paletteChange( p );
1135 if ( bgType == Ruled ) 1135 if ( bgType == Ruled )
1136 setBackgroundType( Ruled, QString::null ); 1136 setBackgroundType( Ruled, QString::null );
1137 QColorGroup cg = icons->colorGroup(); 1137 QColorGroup cg = icons->colorGroup();
1138 cg.setColor( QColorGroup::Text, textCol ); 1138 cg.setColor( QColorGroup::Text, textCol );
1139 icons->setPalette( QPalette(cg,cg,cg) ); 1139 icons->setPalette( QPalette(cg,cg,cg) );
1140} 1140}
1141 1141
1142void LauncherView::fontChanged(const QFont&) 1142void LauncherView::fontChanged(const QFont&)
1143{ 1143{
1144 odebug << "LauncherView::fontChanged()" << oendl; 1144 odebug << "LauncherView::fontChanged()" << oendl;
1145 icons->hideOrShowItems( FALSE ); 1145 icons->hideOrShowItems( FALSE );
1146} 1146}
1147 1147
1148void LauncherView::relayout(void) 1148void LauncherView::relayout(void)
1149{ 1149{
1150 icons->hideOrShowItems(FALSE); 1150 icons->hideOrShowItems(FALSE);
1151} 1151}
1152 1152
1153void LauncherView::flushBgCache() 1153void LauncherView::flushBgCache()
1154{ 1154{
1155 if ( !bgCache ) 1155 if ( !bgCache )
1156 return; 1156 return;
1157 // remove unreferenced backgrounds. 1157 // remove unreferenced backgrounds.
1158 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 1158 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
1159 while ( it != bgCache->end() ) { 1159 while ( it != bgCache->end() ) {
1160 QMap<QString,BgPixmap*>::Iterator curr = it; 1160 QMap<QString,BgPixmap*>::Iterator curr = it;
1161 ++it; 1161 ++it;
1162 if ( (*curr)->ref == 0 ) { 1162 if ( (*curr)->ref == 0 ) {
1163 delete (*curr); 1163 delete (*curr);
1164 bgCache->remove( curr ); 1164 bgCache->remove( curr );
1165 } 1165 }
1166 } 1166 }
1167} 1167}
1168 1168
1169/* 1169/*
1170 * Launcherthumbnail handling for image files 1170 * Launcherthumbnail handling for image files
1171 */ 1171 */
1172 1172
1173/* special image handling - based on opie eye */ 1173/* special image handling - based on opie eye */
1174QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { 1174QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
1175 s >> inf.file >> inf.pixmap >> inf.width >> inf.height; 1175 s >> inf.file >> inf.pixmap >> inf.width >> inf.height;
1176 return s; 1176 return s;
1177} 1177}
1178 1178
1179QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { 1179QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
1180 return s << inf.file << inf.width << inf.height; 1180 return s << inf.file << inf.width << inf.height;
1181} 1181}
1182 1182
1183LauncherThumbReceiver::LauncherThumbReceiver() 1183LauncherThumbReceiver::LauncherThumbReceiver()
1184 :QObject() 1184 :QObject()
1185{ 1185{
1186 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); 1186 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this );
1187 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), 1187 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)),
1188 this, SLOT(recieve(const QCString&,const QByteArray&)) ); 1188 this, SLOT(recieve(const QCString&,const QByteArray&)) );
1189 1189
1190 { 1190 {
1191 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 1191 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
1192 } 1192 }
1193} 1193}
1194 1194
1195LauncherThumbReceiver::~LauncherThumbReceiver() 1195LauncherThumbReceiver::~LauncherThumbReceiver()
1196{ 1196{
1197 { 1197 {
1198 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 1198 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
1199 } 1199 }
1200} 1200}
1201 1201
1202void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) 1202void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at )
1203{ 1203{
1204 PixmapInfos pixinfos; 1204 PixmapInfos pixinfos;
1205 QDataStream stream( at, IO_ReadOnly ); 1205 QDataStream stream( at, IO_ReadOnly );
1206 1206
1207 /* we are just interested in thumbmails */ 1207 /* we are just interested in thumbmails */
1208 if ( str == "pixmapsHandled(PixmapList)" ) 1208 if ( str == "pixmapsHandled(PixmapList)" )
1209 stream >> pixinfos; 1209 stream >> pixinfos;
1210 1210
1211 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { 1211 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) {
1212 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); 1212 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width);
1213 } 1213 }
1214} 1214}
1215 1215
1216void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) 1216void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height)
1217{ 1217{
1218 PixmapInfo rItem; 1218 PixmapInfo rItem;
1219 rItem.file = file; 1219 rItem.file = file;
1220 rItem.width = width; 1220 rItem.width = width;
1221 rItem.height = height; 1221 rItem.height = height;
1222 m_inThumbNail.append(rItem); 1222 m_inThumbNail.append(rItem);
1223 QTimer::singleShot(2, this, SLOT(sendRequest())); 1223 QTimer::singleShot(2, this, SLOT(sendRequest()));
1224} 1224}
1225 1225
1226void LauncherThumbReceiver::sendRequest() 1226void LauncherThumbReceiver::sendRequest()
1227{ 1227{
1228 if (m_inThumbNail.count()>0) { 1228 if (m_inThumbNail.count()>0) {
1229 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); 1229 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" );
1230 env << m_inThumbNail; 1230 env << m_inThumbNail;
1231 m_inThumbNail.clear(); 1231 m_inThumbNail.clear();
1232 } 1232 }
1233} 1233}
diff --git a/core/settings/launcher/tabconfig.h b/core/settings/launcher/tabconfig.h
index 7844673..9ea2418 100644
--- a/core/settings/launcher/tabconfig.h
+++ b/core/settings/launcher/tabconfig.h
@@ -1,73 +1,74 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can 5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that 12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details. 17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .: 18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU 19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file; 20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the 21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc., 22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330, 23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. 24 Boston, MA 02111-1307, USA.
25 25
26*/ 26*/
27#ifndef __TABCONFIG_H__ 27#ifndef __TABCONFIG_H__
28#define __TABCONFIG_H__ 28#define __TABCONFIG_H__
29 29
30struct TabConfig { 30struct TabConfig {
31 enum ViewMode { 31 enum ViewMode {
32 Icon, 32 Icon,
33 List 33 List
34 }; 34 };
35 enum BackgroundType { 35 enum BackgroundType {
36 Ruled, 36 Ruled,
37 SolidColor, 37 SolidColor,
38 Image 38 Image
39 }; 39 };
40 40
41 ViewMode m_view; 41 ViewMode m_view;
42 BackgroundType m_bg_type; 42 BackgroundType m_bg_type;
43 QString m_last_directory; 43 QString m_last_directory;
44 QString m_bg_image; 44 QString m_bg_image;
45 QString m_bg_color; 45 QString m_bg_color;
46 int m_iconcolumns; 46 int m_iconcolumns;
47 QString m_text_color; 47 QString m_text_color;
48 bool m_font_use; 48 bool m_font_use;
49 QString m_font_family; 49 QString m_font_family;
50 int m_font_size; 50 int m_font_size;
51 int m_font_weight; 51 int m_font_weight;
52 bool m_font_italic; 52 bool m_font_italic;
53 bool m_changed; 53 bool m_changed;
54 54
55 bool operator == ( const TabConfig &tc ) 55 bool operator == ( const TabConfig &tc )
56 { 56 {
57 return ( m_view == tc. m_view ) && 57 return ( m_view == tc. m_view ) &&
58 ( m_bg_type == tc. m_bg_type ) && 58 ( m_bg_type == tc. m_bg_type ) &&
59 ( m_bg_image == tc. m_bg_image ) && 59 ( m_bg_image == tc. m_bg_image ) &&
60 ( m_bg_color == tc. m_bg_color ) && 60 ( m_bg_color == tc. m_bg_color ) &&
61 ( m_iconcolumns == tc. m_iconcolumns ) &&
61 ( m_text_color == tc. m_text_color ) && 62 ( m_text_color == tc. m_text_color ) &&
62 ( m_font_use == tc. m_font_use ) && 63 ( m_font_use == tc. m_font_use ) &&
63 ( m_font_use ? ( 64 ( m_font_use ? (
64 ( m_font_family == tc. m_font_family ) && 65 ( m_font_family == tc. m_font_family ) &&
65 ( m_font_size == tc. m_font_size ) && 66 ( m_font_size == tc. m_font_size ) &&
66 ( m_font_weight == tc. m_font_weight ) && 67 ( m_font_weight == tc. m_font_weight ) &&
67 ( m_font_italic == tc. m_font_italic ) 68 ( m_font_italic == tc. m_font_italic )
68 ) : true ); 69 ) : true );
69 70
70 } 71 }
71}; 72};
72 73
73#endif 74#endif
diff --git a/core/settings/launcher/tabdialog.cpp b/core/settings/launcher/tabdialog.cpp
index abe310f..bd51628 100644
--- a/core/settings/launcher/tabdialog.cpp
+++ b/core/settings/launcher/tabdialog.cpp
@@ -1,534 +1,535 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can 5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that 12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details. 17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .: 18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU 19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file; 20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the 21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc., 22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330, 23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. 24 Boston, MA 02111-1307, USA.
25 25
26*/ 26*/
27 27
28#include "tabdialog.h" 28#include "tabdialog.h"
29 29
30/* OPIE */ 30/* OPIE */
31 31
32#include <opie2/ofontselector.h> 32#include <opie2/ofontselector.h>
33#include <opie2/otabwidget.h> 33#include <opie2/otabwidget.h>
34#include <opie2/ocolorbutton.h> 34#include <opie2/ocolorbutton.h>
35#include <opie2/ofiledialog.h> 35#include <opie2/ofiledialog.h>
36#include <opie2/odebug.h> 36#include <opie2/odebug.h>
37 37
38/* QPE */ 38/* QPE */
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40#include <qpe/qpeapplication.h> 40#include <qpe/qpeapplication.h>
41 41
42/* QT */ 42/* QT */
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qvbox.h> 44#include <qvbox.h>
45#include <qtabbar.h> 45#include <qtabbar.h>
46#include <qiconview.h> 46#include <qiconview.h>
47#include <qapplication.h> 47#include <qapplication.h>
48#include <qlabel.h> 48#include <qlabel.h>
49#include <qfileinfo.h> 49#include <qfileinfo.h>
50#include <qradiobutton.h> 50#include <qradiobutton.h>
51#include <qbuttongroup.h> 51#include <qbuttongroup.h>
52#include <qwhatsthis.h> 52#include <qwhatsthis.h>
53#include <qcheckbox.h> 53#include <qcheckbox.h>
54#include <qspinbox.h> 54#include <qspinbox.h>
55 55
56 56
57using namespace Opie::Ui; 57using namespace Opie::Ui;
58class SampleItem : public QIconViewItem { 58class SampleItem : public QIconViewItem {
59public: 59public:
60 SampleItem ( QIconView *v, const QString &text, const QPixmap &pix ) : QIconViewItem ( v, text ) 60 SampleItem ( QIconView *v, const QString &text, const QPixmap &pix ) : QIconViewItem ( v, text )
61 { 61 {
62 m_large = pix; 62 m_large = pix;
63 m_small. convertFromImage ( pix. convertToImage ( ). smoothScale ( pix. width ( ) / 2, pix. height ( ) / 2 )); 63 m_small. convertFromImage ( pix. convertToImage ( ). smoothScale ( pix. width ( ) / 2, pix. height ( ) / 2 ));
64 } 64 }
65 65
66 void sizeChange ( ) 66 void sizeChange ( )
67 { 67 {
68 calcRect ( ); 68 calcRect ( );
69 repaint ( ); 69 repaint ( );
70 } 70 }
71 71
72 QPixmap *pixmap ( ) const 72 QPixmap *pixmap ( ) const
73 { 73 {
74 if ( iconView ( )-> itemTextPos ( ) == QIconView::Right ) 74 if ( iconView ( )-> itemTextPos ( ) == QIconView::Right )
75 return (QPixmap *) &m_small; 75 return (QPixmap *) &m_small;
76 else 76 else
77 return (QPixmap *) &m_large; 77 return (QPixmap *) &m_large;
78 } 78 }
79 79
80private: 80private:
81 QPixmap m_large, m_small; 81 QPixmap m_large, m_small;
82}; 82};
83 83
84//FIXME: Why not derive SampleView from LauncherView ??? 84//FIXME: Why not derive SampleView from LauncherView ???
85 85
86class SampleView : public QIconView { 86class SampleView : public QIconView {
87public: 87public:
88 SampleView ( QWidget *parent = 0, const char *name = 0 ) : QIconView ( parent, name ) 88 SampleView ( QWidget *parent = 0, const char *name = 0 ) : QIconView ( parent, name )
89 { 89 {
90 setItemsMovable ( false ); 90 setItemsMovable ( false );
91 setAutoArrange ( true ); 91 setAutoArrange ( true );
92 setSorting ( true ); 92 setSorting ( true );
93 setFrameStyle ( QFrame::NoFrame ); 93 setFrameStyle ( QFrame::NoFrame );
94 setSpacing ( 4 ); 94 setSpacing ( 4 );
95 setMargin ( 0 ); 95 setMargin ( 0 );
96 setSelectionMode ( QIconView::NoSelection ); 96 setSelectionMode ( QIconView::NoSelection );
97 setBackgroundMode ( PaletteBase ); 97 setBackgroundMode ( PaletteBase );
98 setViewMode ( TabConfig::Icon ); 98 setViewMode ( TabConfig::Icon );
99 calculateGrid ( Bottom ); 99 calculateGrid ( Bottom );
100 100
101 101
102 new SampleItem ( this, QObject::tr( "Sample 1" ), Resource::loadPixmap ( "datebook/DateBook" )); 102 new SampleItem ( this, QObject::tr( "Sample 1" ), Resource::loadPixmap ( "datebook/DateBook" ));
103 new SampleItem ( this, QObject::tr( "Sample 2" ), Resource::loadPixmap ( "Calibrate" )); 103 new SampleItem ( this, QObject::tr( "Sample 2" ), Resource::loadPixmap ( "Calibrate" ));
104 new SampleItem ( this, QObject::tr( "Sample 3" ), Resource::loadPixmap ( "UnknownDocument" )); 104 new SampleItem ( this, QObject::tr( "Sample 3" ), Resource::loadPixmap ( "UnknownDocument" ));
105 105
106 setBackgroundType ( TabConfig::Ruled, QString::null ); 106 setBackgroundType ( TabConfig::Ruled, QString::null );
107 107
108 setMaximumHeight ( firstItem ( )-> height ( ) + 16 ); 108 setMaximumHeight ( firstItem ( )-> height ( ) + 16 );
109 } 109 }
110 110
111 void setViewMode ( TabConfig::ViewMode m ) 111 void setViewMode ( TabConfig::ViewMode m )
112 { 112 {
113 viewport ( )-> setUpdatesEnabled ( false ); 113 viewport ( )-> setUpdatesEnabled ( false );
114 114
115 switch ( m ) { 115 switch ( m ) {
116 case TabConfig::List: 116 case TabConfig::List:
117 setItemTextPos( QIconView::Right ); 117 setItemTextPos( QIconView::Right );
118 break; 118 break;
119 case TabConfig::Icon: 119 case TabConfig::Icon:
120 setItemTextPos( QIconView::Bottom ); 120 setItemTextPos( QIconView::Bottom );
121 break; 121 break;
122 } 122 }
123// hideOrShowItems ( false ); 123// hideOrShowItems ( false );
124 124
125 for ( QIconViewItem *it = firstItem ( ); it; it = it-> nextItem ( )) 125 for ( QIconViewItem *it = firstItem ( ); it; it = it-> nextItem ( ))
126 ((SampleItem *) it )-> sizeChange ( ); 126 ((SampleItem *) it )-> sizeChange ( );
127 arrangeItemsInGrid ( true ); 127 arrangeItemsInGrid ( true );
128 viewport ( )-> setUpdatesEnabled ( true ); 128 viewport ( )-> setUpdatesEnabled ( true );
129 update ( ); 129 update ( );
130 } 130 }
131 131
132 132
133 void setBackgroundType( TabConfig::BackgroundType t, const QString &val ) 133 void setBackgroundType( TabConfig::BackgroundType t, const QString &val )
134 { 134 {
135 switch ( t ) { 135 switch ( t ) {
136 case TabConfig::Ruled: { 136 case TabConfig::Ruled: {
137 QPixmap bg ( width ( ), 9 ); 137 QPixmap bg ( width ( ), 9 );
138 QPainter painter ( &bg ); 138 QPainter painter ( &bg );
139 for ( int i = 0; i < 3; i++ ) { 139 for ( int i = 0; i < 3; i++ ) {
140 painter. setPen ( white ); 140 painter. setPen ( white );
141 painter. drawLine ( 0, i*3, width()-1, i*3 ); 141 painter. drawLine ( 0, i*3, width()-1, i*3 );
142 painter. drawLine ( 0, i*3+1, width()-1, i*3+1 ); 142 painter. drawLine ( 0, i*3+1, width()-1, i*3+1 );
143 painter. setPen ( colorGroup().background().light(105) ); 143 painter. setPen ( colorGroup().background().light(105) );
144 painter. drawLine ( 0, i*3+2, width()-1, i*3+2 ); 144 painter. drawLine ( 0, i*3+2, width()-1, i*3+2 );
145 } 145 }
146 painter.end ( ); 146 painter.end ( );
147 setBackgroundPixmap ( bg ); 147 setBackgroundPixmap ( bg );
148 break; 148 break;
149 } 149 }
150 150
151 case TabConfig::SolidColor: { 151 case TabConfig::SolidColor: {
152 setBackgroundPixmap ( QPixmap ( )); 152 setBackgroundPixmap ( QPixmap ( ));
153 if ( val. isEmpty ( )) 153 if ( val. isEmpty ( ))
154 setBackgroundColor ( colorGroup ( ). base ( )); 154 setBackgroundColor ( colorGroup ( ). base ( ));
155 else 155 else
156 setBackgroundColor ( val ); 156 setBackgroundColor ( val );
157 break; 157 break;
158 } 158 }
159 159
160 case TabConfig::Image: { 160 case TabConfig::Image: {
161 odebug << "Loading image: " << val << "" << oendl; 161 odebug << "Loading image: " << val << "" << oendl;
162 QPixmap bg ( Resource::loadPixmap ( "wallpaper/" + val )); 162 QPixmap bg ( Resource::loadPixmap ( "wallpaper/" + val ));
163 if ( bg. isNull ( )) { 163 if ( bg. isNull ( )) {
164 QImageIO imgio; 164 QImageIO imgio;
165 imgio. setFileName ( val ); 165 imgio. setFileName ( val );
166 QSize ds = qApp-> desktop ( )-> size ( ); 166 QSize ds = qApp-> desktop ( )-> size ( );
167 QString param ( "Scale( %1, %2, ScaleMin )" ); // No tr 167 QString param ( "Scale( %1, %2, ScaleMin )" ); // No tr
168 imgio. setParameters ( param. arg ( ds. width ( )). arg ( ds. height ( )). latin1 ( )); 168 imgio. setParameters ( param. arg ( ds. width ( )). arg ( ds. height ( )). latin1 ( ));
169 imgio. read ( ); 169 imgio. read ( );
170 bg = imgio. image ( ); 170 bg = imgio. image ( );
171 } 171 }
172 setBackgroundPixmap ( bg ); 172 setBackgroundPixmap ( bg );
173 break; 173 break;
174 } 174 }
175 } 175 }
176 m_bgtype = t; 176 m_bgtype = t;
177 viewport ( )-> update ( ); 177 viewport ( )-> update ( );
178 } 178 }
179 179
180 void setTextColor ( const QColor &tc ) 180 void setTextColor ( const QColor &tc )
181 { 181 {
182 m_textcolor = tc; 182 m_textcolor = tc;
183 QColorGroup cg = colorGroup ( ); 183 QColorGroup cg = colorGroup ( );
184 cg. setColor ( QColorGroup::Text, tc ); 184 cg. setColor ( QColorGroup::Text, tc );
185 setPalette ( QPalette ( cg, cg, cg )); 185 setPalette ( QPalette ( cg, cg, cg ));
186 viewport ( )-> update ( ); 186 viewport ( )-> update ( );
187 } 187 }
188 188
189 void setViewFont ( const QFont &f ) 189 void setViewFont ( const QFont &f )
190 { 190 {
191 setFont ( f ); 191 setFont ( f );
192 } 192 }
193 193
194 void setItemTextPos ( ItemTextPos pos ) 194 void setItemTextPos ( ItemTextPos pos )
195 { 195 {
196 calculateGrid ( pos ); 196 calculateGrid ( pos );
197 QIconView::setItemTextPos( pos ); 197 QIconView::setItemTextPos( pos );
198 } 198 }
199 199
200 //FIXME: Add per-tab column handling from launcherview.cpp 200 //FIXME: Add per-tab column handling from launcherview.cpp
201 void calculateGrid ( ItemTextPos pos ) 201 void calculateGrid ( ItemTextPos pos )
202 { 202 {
203 int dw = QApplication::desktop ( )-> width ( ); 203 int dw = QApplication::desktop ( )-> width ( );
204 int viewerWidth = dw - style ( ).scrollBarExtent ( ). width ( ); 204 int viewerWidth = dw - style ( ).scrollBarExtent ( ). width ( );
205 if ( pos == Bottom ) { 205 if ( pos == Bottom ) {
206 int cols = 3; 206 int cols = 3;
207 if ( viewerWidth <= 200 ) 207 if ( viewerWidth <= 200 )
208 cols = 2; 208 cols = 2;
209 else if ( viewerWidth >= 400 ) 209 else if ( viewerWidth >= 400 )
210 cols = viewerWidth/96; 210 cols = viewerWidth/96;
211 setSpacing ( 4 ); 211 setSpacing ( 4 );
212 setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); 212 setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols );
213 setGridY ( fontMetrics ( ). height ( ) * 2 + 24 ); 213 setGridY ( fontMetrics ( ). height ( ) * 2 + 24 );
214 } 214 }
215 else { 215 else {
216 int cols = 2; 216 int cols = 2;
217 if ( viewerWidth < 150 ) 217 if ( viewerWidth < 150 )
218 cols = 1; 218 cols = 1;
219 else if ( viewerWidth >= 400 ) 219 else if ( viewerWidth >= 400 )
220 cols = viewerWidth / 150; 220 cols = viewerWidth / 150;
221 setSpacing ( 2 ); 221 setSpacing ( 2 );
222 setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols ); 222 setGridX (( viewerWidth - ( cols + 1 ) * spacing ( )) / cols );
223 setGridY ( fontMetrics ( ). height ( ) + 2 ); 223 setGridY ( fontMetrics ( ). height ( ) + 2 );
224 } 224 }
225 } 225 }
226 226
227 void paletteChange( const QPalette &p ) 227 void paletteChange( const QPalette &p )
228 { 228 {
229 static bool excllock = false; 229 static bool excllock = false;
230 230
231 if ( excllock ) 231 if ( excllock )
232 return; 232 return;
233 excllock = true; 233 excllock = true;
234 234
235 unsetPalette ( ); 235 unsetPalette ( );
236 QIconView::paletteChange ( p ); 236 QIconView::paletteChange ( p );
237 if ( m_bgtype == TabConfig::Ruled ) 237 if ( m_bgtype == TabConfig::Ruled )
238 setBackgroundType ( TabConfig::Ruled, QString::null ); 238 setBackgroundType ( TabConfig::Ruled, QString::null );
239 QColorGroup cg = colorGroup ( ); 239 QColorGroup cg = colorGroup ( );
240 cg.setColor ( QColorGroup::Text, m_textcolor ); 240 cg.setColor ( QColorGroup::Text, m_textcolor );
241 setPalette ( QPalette ( cg, cg, cg )); 241 setPalette ( QPalette ( cg, cg, cg ));
242 242
243 excllock = false; 243 excllock = false;
244 } 244 }
245 245
246 void setBackgroundPixmap ( const QPixmap &pm ) 246 void setBackgroundPixmap ( const QPixmap &pm )
247 { 247 {
248 m_bgpix = pm; 248 m_bgpix = pm;
249 } 249 }
250 250
251 void setBackgroundColor ( const QColor &c ) 251 void setBackgroundColor ( const QColor &c )
252 { 252 {
253 m_bgcolor = c; 253 m_bgcolor = c;
254 } 254 }
255 255
256 void drawBackground ( QPainter *p, const QRect &r ) 256 void drawBackground ( QPainter *p, const QRect &r )
257 { 257 {
258 if ( !m_bgpix. isNull ( )) { 258 if ( !m_bgpix. isNull ( )) {
259 p-> drawTiledPixmap ( r, m_bgpix, QPoint (( r. x ( ) + contentsX ( )) % m_bgpix. width ( ), 259 p-> drawTiledPixmap ( r, m_bgpix, QPoint (( r. x ( ) + contentsX ( )) % m_bgpix. width ( ),
260 ( r. y ( ) + contentsY ( )) % m_bgpix. height ( ))); 260 ( r. y ( ) + contentsY ( )) % m_bgpix. height ( )));
261 } 261 }
262 else 262 else
263 p-> fillRect ( r, m_bgcolor ); 263 p-> fillRect ( r, m_bgcolor );
264 } 264 }
265 265
266private: 266private:
267 QColor m_textcolor; 267 QColor m_textcolor;
268 QColor m_bgcolor; 268 QColor m_bgcolor;
269 QPixmap m_bgpix; 269 QPixmap m_bgpix;
270 TabConfig::BackgroundType m_bgtype; 270 TabConfig::BackgroundType m_bgtype;
271}; 271};
272 272
273 273
274 274
275TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig &tc, QWidget *parent, const char *dname, bool modal, WFlags fl ) 275TabDialog::TabDialog ( const QPixmap *tabicon, const QString &tabname, TabConfig &tc, QWidget *parent, const char *dname, bool modal, WFlags fl )
276 : QDialog ( parent, dname, modal, fl | WStyle_ContextHelp ), m_tc ( tc ) 276 : QDialog ( parent, dname, modal, fl | WStyle_ContextHelp ), m_tc ( tc )
277{ 277{
278 setCaption ( tr( "Edit Tab" )); 278 setCaption ( tr( "Edit Tab" ));
279 279
280 QVBoxLayout *lay = new QVBoxLayout ( this, 3, 3 ); 280 QVBoxLayout *lay = new QVBoxLayout ( this, 3, 3 );
281 281
282 OTabWidget *tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); 282 OTabWidget *tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom );
283 QWidget *bgtab; 283 QWidget *bgtab;
284 284
285 tw-> addTab ( bgtab = createBgTab ( tw ), "appearance/color", tr( "Background" )); 285 tw-> addTab ( bgtab = createBgTab ( tw ), "appearance/color", tr( "Background" ));
286 tw-> addTab ( createFontTab ( tw ), "font", tr( "Font" )); 286 tw-> addTab ( createFontTab ( tw ), "font", tr( "Font" ));
287 tw-> addTab ( createIconTab ( tw ), "pixmap", tr( "Icons" ) ); 287 tw-> addTab ( createIconTab ( tw ), "pixmap", tr( "Icons" ) );
288 288
289 tw-> setCurrentTab ( bgtab ); 289 tw-> setCurrentTab ( bgtab );
290 290
291 QWidget *sample = new QVBox ( this ); 291 QWidget *sample = new QVBox ( this );
292 QTabBar *tb = new QTabBar ( sample ); 292 QTabBar *tb = new QTabBar ( sample );
293 QString name ( tr( "Previewing %1" ). arg ( tabname )); 293 QString name ( tr( "Previewing %1" ). arg ( tabname ));
294 294
295 tb-> addTab ( tabicon ? new QTab ( *tabicon, name ) : new QTab ( name )); 295 tb-> addTab ( tabicon ? new QTab ( *tabicon, name ) : new QTab ( name ));
296 296
297 m_sample = new SampleView ( sample ); 297 m_sample = new SampleView ( sample );
298 298
299 lay-> addWidget ( tw, 10 ); 299 lay-> addWidget ( tw, 10 );
300 lay-> addWidget ( sample, 1 ); 300 lay-> addWidget ( sample, 1 );
301 301
302 m_iconsize-> setButton ( tc. m_view ); 302 m_iconsize-> setButton ( tc. m_view );
303 iconSizeClicked ( tc. m_view ); 303 iconSizeClicked ( tc. m_view );
304 //m_iconcolor-> setColor ( QColor ( m_tc. m_text_color )); 304 //m_iconcolor-> setColor ( QColor ( m_tc. m_text_color ));
305 iconColorClicked ( m_iconcolor-> color ( )); 305 iconColorClicked ( m_iconcolor-> color ( ));
306 m_bgtype-> setButton ( tc. m_bg_type ); 306 m_bgtype-> setButton ( tc. m_bg_type );
307 //m_solidcolor-> setColor ( QColor ( tc. m_bg_color )); 307 //m_solidcolor-> setColor ( QColor ( tc. m_bg_color ));
308 m_iconcolumns->setValue( tc. m_iconcolumns );
308 m_bgimage = tc. m_bg_image; 309 m_bgimage = tc. m_bg_image;
309 bgTypeClicked ( tc. m_bg_type ); 310 bgTypeClicked ( tc. m_bg_type );
310 m_fontuse-> setChecked ( tc. m_font_use ); 311 m_fontuse-> setChecked ( tc. m_font_use );
311 m_fontselect-> setSelectedFont ( QFont ( tc. m_font_family, tc. m_font_size, tc. m_font_weight, tc. m_font_italic )); 312 m_fontselect-> setSelectedFont ( QFont ( tc. m_font_family, tc. m_font_size, tc. m_font_weight, tc. m_font_italic ));
312 m_fontselect-> setEnabled ( m_fontuse-> isChecked ( )); 313 m_fontselect-> setEnabled ( m_fontuse-> isChecked ( ));
313 fontClicked ( m_fontselect-> selectedFont ( )); 314 fontClicked ( m_fontselect-> selectedFont ( ));
314 315
315 QWhatsThis::add ( sample, tr( "This is a rough preview of what the currently selected Tab will look like." )); 316 QWhatsThis::add ( sample, tr( "This is a rough preview of what the currently selected Tab will look like." ));
316} 317}
317 318
318 319
319TabDialog::~TabDialog ( ) 320TabDialog::~TabDialog ( )
320{ 321{
321} 322}
322 323
323QWidget *TabDialog::createFontTab ( QWidget *parent ) 324QWidget *TabDialog::createFontTab ( QWidget *parent )
324{ 325{
325 QWidget *tab = new QWidget ( parent, "FontTab" ); 326 QWidget *tab = new QWidget ( parent, "FontTab" );
326 QVBoxLayout *vertLayout = new QVBoxLayout ( tab, 3, 3 ); 327 QVBoxLayout *vertLayout = new QVBoxLayout ( tab, 3, 3 );
327 328
328 m_fontuse = new QCheckBox ( tr( "Use a custom font" ), tab ); 329 m_fontuse = new QCheckBox ( tr( "Use a custom font" ), tab );
329 vertLayout-> addWidget ( m_fontuse ); 330 vertLayout-> addWidget ( m_fontuse );
330 331
331 m_fontselect = new OFontSelector ( false, tab, "fontsel" ); 332 m_fontselect = new OFontSelector ( false, tab, "fontsel" );
332 vertLayout-> addWidget ( m_fontselect ); 333 vertLayout-> addWidget ( m_fontselect );
333 334
334 connect ( m_fontuse, SIGNAL( toggled(bool)), m_fontselect, SLOT( setEnabled(bool))); 335 connect ( m_fontuse, SIGNAL( toggled(bool)), m_fontselect, SLOT( setEnabled(bool)));
335 connect( m_fontselect, SIGNAL( fontSelected(const QFont&)), 336 connect( m_fontselect, SIGNAL( fontSelected(const QFont&)),
336 this, SLOT( fontClicked(const QFont&))); 337 this, SLOT( fontClicked(const QFont&)));
337 338
338 return tab; 339 return tab;
339} 340}
340 341
341QWidget *TabDialog::createBgTab ( QWidget *parent ) 342QWidget *TabDialog::createBgTab ( QWidget *parent )
342{ 343{
343 QWidget *tab = new QWidget( parent, "BgTab" ); 344 QWidget *tab = new QWidget( parent, "BgTab" );
344 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); 345 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 );
345 346
346 QGridLayout* gridLayout = new QGridLayout ( vertLayout ); 347 QGridLayout* gridLayout = new QGridLayout ( vertLayout );
347 gridLayout-> setColStretch ( 1, 10 ); 348 gridLayout-> setColStretch ( 1, 10 );
348 349
349 QLabel* label = new QLabel( tr( "Type:" ), tab ); 350 QLabel* label = new QLabel( tr( "Type:" ), tab );
350 gridLayout-> addWidget ( label, 0, 0 ); 351 gridLayout-> addWidget ( label, 0, 0 );
351 m_bgtype = new QButtonGroup( tab, "buttongroup" ); 352 m_bgtype = new QButtonGroup( tab, "buttongroup" );
352 m_bgtype-> hide ( ); 353 m_bgtype-> hide ( );
353 m_bgtype-> setExclusive ( true ); 354 m_bgtype-> setExclusive ( true );
354 355
355 QRadioButton *rb; 356 QRadioButton *rb;
356 rb = new QRadioButton( tr( "Ruled" ), tab, "ruled" ); 357 rb = new QRadioButton( tr( "Ruled" ), tab, "ruled" );
357 m_bgtype-> insert ( rb, TabConfig::Ruled ); 358 m_bgtype-> insert ( rb, TabConfig::Ruled );
358 gridLayout-> addWidget( rb, 0, 1 ); 359 gridLayout-> addWidget( rb, 0, 1 );
359 360
360 QHBoxLayout *hb = new QHBoxLayout ( ); 361 QHBoxLayout *hb = new QHBoxLayout ( );
361 hb-> setSpacing ( 3 ); 362 hb-> setSpacing ( 3 );
362 363
363 rb = new QRadioButton( tr( "Solid color" ), tab, "solid" ); 364 rb = new QRadioButton( tr( "Solid color" ), tab, "solid" );
364 m_bgtype-> insert ( rb, TabConfig::SolidColor ); 365 m_bgtype-> insert ( rb, TabConfig::SolidColor );
365 hb-> addWidget ( rb ); 366 hb-> addWidget ( rb );
366 hb-> addSpacing ( 10 ); 367 hb-> addSpacing ( 10 );
367 368
368 m_solidcolor = new Opie::OColorButton ( tab, QColor ( m_tc. m_bg_color ) ); 369 m_solidcolor = new Opie::OColorButton ( tab, QColor ( m_tc. m_bg_color ) );
369 connect ( m_solidcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( bgColorClicked(const QColor&))); 370 connect ( m_solidcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( bgColorClicked(const QColor&)));
370 hb-> addWidget ( m_solidcolor ); 371 hb-> addWidget ( m_solidcolor );
371 hb-> addStretch ( 10 ); 372 hb-> addStretch ( 10 );
372 373
373 gridLayout-> addLayout ( hb, 1, 1 ); 374 gridLayout-> addLayout ( hb, 1, 1 );
374 375
375 hb = new QHBoxLayout ( ); 376 hb = new QHBoxLayout ( );
376 hb-> setSpacing ( 3 ); 377 hb-> setSpacing ( 3 );
377 378
378 rb = new QRadioButton( tr( "Image" ), tab, "image" ); 379 rb = new QRadioButton( tr( "Image" ), tab, "image" );
379 m_bgtype-> insert ( rb, TabConfig::Image ); 380 m_bgtype-> insert ( rb, TabConfig::Image );
380 hb-> addWidget( rb ); 381 hb-> addWidget( rb );
381 hb-> addSpacing ( 10 ); 382 hb-> addSpacing ( 10 );
382 383
383 m_imagebrowse = new QPushButton ( tr( "Select..." ), tab ); 384 m_imagebrowse = new QPushButton ( tr( "Select..." ), tab );
384 connect ( m_imagebrowse, SIGNAL( clicked()), this, SLOT( bgImageClicked())); 385 connect ( m_imagebrowse, SIGNAL( clicked()), this, SLOT( bgImageClicked()));
385 hb-> addWidget ( m_imagebrowse ); 386 hb-> addWidget ( m_imagebrowse );
386 hb-> addStretch ( 10 ); 387 hb-> addStretch ( 10 );
387 388
388 gridLayout-> addLayout ( hb, 2, 1 ); 389 gridLayout-> addLayout ( hb, 2, 1 );
389 390
390 QPushButton *p = new QPushButton ( tr( "Default" ), tab ); 391 QPushButton *p = new QPushButton ( tr( "Default" ), tab );
391 connect ( p, SIGNAL( clicked()), this, SLOT( bgDefaultClicked())); 392 connect ( p, SIGNAL( clicked()), this, SLOT( bgDefaultClicked()));
392 gridLayout-> addWidget ( p, 3, 1 ); 393 gridLayout-> addWidget ( p, 3, 1 );
393 394
394 connect ( m_bgtype, SIGNAL( clicked(int)), this, SLOT( bgTypeClicked(int))); 395 connect ( m_bgtype, SIGNAL( clicked(int)), this, SLOT( bgTypeClicked(int)));
395 396
396 vertLayout-> addStretch ( 10 ); 397 vertLayout-> addStretch ( 10 );
397 398
398 return tab; 399 return tab;
399} 400}
400 401
401QWidget *TabDialog::createIconTab ( QWidget *parent ) 402QWidget *TabDialog::createIconTab ( QWidget *parent )
402{ 403{
403 QWidget *tab = new QWidget( parent, "IconTab" ); 404 QWidget *tab = new QWidget( parent, "IconTab" );
404 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); 405 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 );
405 406
406 QGridLayout* gridLayout = new QGridLayout ( vertLayout ); 407 QGridLayout* gridLayout = new QGridLayout ( vertLayout );
407 gridLayout-> setColStretch ( 1, 10 ); 408 gridLayout-> setColStretch ( 1, 10 );
408 409
409 QLabel* label = new QLabel( tr( "Size:" ), tab ); 410 QLabel* label = new QLabel( tr( "Size:" ), tab );
410 gridLayout-> addWidget ( label, 0, 0 ); 411 gridLayout-> addWidget ( label, 0, 0 );
411 m_iconsize = new QButtonGroup( tab, "buttongroup" ); 412 m_iconsize = new QButtonGroup( tab, "buttongroup" );
412 m_iconsize-> hide ( ); 413 m_iconsize-> hide ( );
413 m_iconsize-> setExclusive ( true ); 414 m_iconsize-> setExclusive ( true );
414 415
415 QRadioButton *rb; 416 QRadioButton *rb;
416 rb = new QRadioButton( tr( "Small" ), tab, "iconsmall" ); 417 rb = new QRadioButton( tr( "Small" ), tab, "iconsmall" );
417 m_iconsize-> insert ( rb, TabConfig::List ); 418 m_iconsize-> insert ( rb, TabConfig::List );
418 gridLayout-> addWidget( rb, 0, 1 ); 419 gridLayout-> addWidget( rb, 0, 1 );
419 420
420 rb = new QRadioButton( tr( "Large" ), tab, "iconlarge" ); 421 rb = new QRadioButton( tr( "Large" ), tab, "iconlarge" );
421 m_iconsize-> insert ( rb, TabConfig::Icon ); 422 m_iconsize-> insert ( rb, TabConfig::Icon );
422 gridLayout-> addWidget( rb, 1, 1 ); 423 gridLayout-> addWidget( rb, 1, 1 );
423 connect ( m_iconsize, SIGNAL( clicked(int)), this, SLOT( iconSizeClicked(int))); 424 connect ( m_iconsize, SIGNAL( clicked(int)), this, SLOT( iconSizeClicked(int)));
424 gridLayout-> addRowSpacing ( 2, 8 ); 425 gridLayout-> addRowSpacing ( 2, 8 );
425 426
426 label = new QLabel ( tr( "Color:" ), tab ); 427 label = new QLabel ( tr( "Color:" ), tab );
427 gridLayout-> addWidget ( label, 3, 0 ); 428 gridLayout-> addWidget ( label, 3, 0 );
428 gridLayout-> addRowSpacing ( 3, 8 ); 429 gridLayout-> addRowSpacing ( 3, 8 );
429 430
430 m_iconcolor = new Opie::OColorButton ( tab, QColor ( m_tc. m_text_color ) ); 431 m_iconcolor = new Opie::OColorButton ( tab, QColor ( m_tc. m_text_color ) );
431 connect ( m_iconcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( iconColorClicked(const QColor&))); 432 connect ( m_iconcolor, SIGNAL( colorSelected(const QColor&)), this, SLOT( iconColorClicked(const QColor&)));
432 gridLayout-> addWidget ( m_iconcolor, 3, 1, AlignLeft ); 433 gridLayout-> addWidget ( m_iconcolor, 3, 1, AlignLeft );
433 434
434 label = new QLabel( tr( "Columns:" ), tab ); 435 label = new QLabel( tr( "Columns:" ), tab );
435 gridLayout->addWidget( label, 4, 0 ); 436 gridLayout->addWidget( label, 4, 0 );
436 m_iconcolumns = new QSpinBox( 0, 10, 1, tab, "iconspinbox" ); 437 m_iconcolumns = new QSpinBox( 0, 10, 1, tab, "iconspinbox" );
437 m_iconcolumns->setSpecialValueText( tr( "Automatic" ) ); 438 m_iconcolumns->setSpecialValueText( tr( "Automatic" ) );
438 gridLayout->addWidget( m_iconcolumns, 4, 1, AlignLeft ); 439 gridLayout->addWidget( m_iconcolumns, 4, 1, AlignLeft );
439 440
440 vertLayout-> addStretch ( 10 ); 441 vertLayout-> addStretch ( 10 );
441 442
442 if ( m_tc.m_last_directory == QString::null ) { 443 if ( m_tc.m_last_directory == QString::null ) {
443 m_tc.m_last_directory = QPEApplication::documentDir(); 444 m_tc.m_last_directory = QPEApplication::documentDir();
444 } 445 }
445 446
446 return tab; 447 return tab;
447} 448}
448 449
449 450
450void TabDialog::iconSizeClicked ( int s ) 451void TabDialog::iconSizeClicked ( int s )
451{ 452{
452 m_sample-> setViewMode ((TabConfig::ViewMode) s ); 453 m_sample-> setViewMode ((TabConfig::ViewMode) s );
453} 454}
454 455
455void TabDialog::fontClicked ( const QFont &f ) 456void TabDialog::fontClicked ( const QFont &f )
456{ 457{
457 m_sample-> setViewFont ( f ); 458 m_sample-> setViewFont ( f );
458} 459}
459 460
460void TabDialog::bgTypeClicked ( int t ) 461void TabDialog::bgTypeClicked ( int t )
461{ 462{
462 QString s; 463 QString s;
463 464
464 if ( m_bgtype-> id ( m_bgtype-> selected ( )) != t ) 465 if ( m_bgtype-> id ( m_bgtype-> selected ( )) != t )
465 m_bgtype-> setButton ( t ); 466 m_bgtype-> setButton ( t );
466 467
467 m_solidcolor-> setEnabled ( t == TabConfig::SolidColor ); 468 m_solidcolor-> setEnabled ( t == TabConfig::SolidColor );
468 m_imagebrowse-> setEnabled ( t == TabConfig::Image ); 469 m_imagebrowse-> setEnabled ( t == TabConfig::Image );
469 470
470 if ( t == TabConfig::SolidColor ) 471 if ( t == TabConfig::SolidColor )
471 s = m_solidcolor-> color ( ). name ( ); 472 s = m_solidcolor-> color ( ). name ( );
472 else if ( t == TabConfig::Image ) 473 else if ( t == TabConfig::Image )
473 s = Resource::findPixmap ( m_bgimage ); 474 s = Resource::findPixmap ( m_bgimage );
474 475
475 m_sample-> setBackgroundType ((TabConfig::BackgroundType) t, s ); 476 m_sample-> setBackgroundType ((TabConfig::BackgroundType) t, s );
476} 477}
477 478
478void TabDialog::bgColorClicked ( const QColor & ) 479void TabDialog::bgColorClicked ( const QColor & )
479{ 480{
480 bgTypeClicked ( TabConfig::SolidColor ); 481 bgTypeClicked ( TabConfig::SolidColor );
481} 482}
482 483
483void TabDialog::iconColorClicked ( const QColor &col ) 484void TabDialog::iconColorClicked ( const QColor &col )
484{ 485{
485 m_sample-> setTextColor ( col ); 486 m_sample-> setTextColor ( col );
486} 487}
487 488
488void TabDialog::bgImageClicked ( ) 489void TabDialog::bgImageClicked ( )
489{ 490{
490 // ### use OFileSelector here ### 491 // ### use OFileSelector here ###
491 // this is just a quick c&p from the old appearance app 492 // this is just a quick c&p from the old appearance app
492 493
493 MimeTypes types; 494 MimeTypes types;
494 QStringList list; 495 QStringList list;
495 list << "image/*"; 496 list << "image/*";
496 types. insert ( "Images", list ); 497 types. insert ( "Images", list );
497 498
498 QString file = OFileDialog::getOpenFileName ( 1, m_tc.m_last_directory, QString::null, types ); 499 QString file = OFileDialog::getOpenFileName ( 1, m_tc.m_last_directory, QString::null, types );
499 500
500 if ( !file. isEmpty ( )) { 501 if ( !file. isEmpty ( )) {
501 m_tc.m_last_directory = QFileInfo( file ).dirPath(); 502 m_tc.m_last_directory = QFileInfo( file ).dirPath();
502 m_bgimage = DocLnk ( file ). file ( ); 503 m_bgimage = DocLnk ( file ). file ( );
503 bgTypeClicked ( TabConfig::Image ); 504 bgTypeClicked ( TabConfig::Image );
504 } 505 }
505} 506}
506 507
507void TabDialog::bgDefaultClicked ( ) 508void TabDialog::bgDefaultClicked ( )
508{ 509{
509 m_bgimage = "launcher/opie-background"; 510 m_bgimage = "launcher/opie-background";
510 bgTypeClicked ( TabConfig::Image ); 511 bgTypeClicked ( TabConfig::Image );
511} 512}
512 513
513void TabDialog::accept ( ) 514void TabDialog::accept ( )
514{ 515{
515 m_tc. m_view = (TabConfig::ViewMode) m_iconsize-> id ( m_iconsize-> selected ( )); 516 m_tc. m_view = (TabConfig::ViewMode) m_iconsize-> id ( m_iconsize-> selected ( ));
516 m_tc. m_bg_type = (TabConfig::BackgroundType) m_bgtype-> id ( m_bgtype-> selected ( )); 517 m_tc. m_bg_type = (TabConfig::BackgroundType) m_bgtype-> id ( m_bgtype-> selected ( ));
517 m_tc. m_bg_color = m_solidcolor-> color ( ). name ( ); 518 m_tc. m_bg_color = m_solidcolor-> color ( ). name ( );
518 m_tc. m_iconcolumns = m_iconcolumns-> value( ); 519 m_tc. m_iconcolumns = m_iconcolumns-> value( );
519 m_tc. m_bg_image = m_bgimage; 520 m_tc. m_bg_image = m_bgimage;
520 m_tc. m_text_color = m_iconcolor-> color ( ). name ( ); 521 m_tc. m_text_color = m_iconcolor-> color ( ). name ( );
521 522
522 m_tc. m_font_use = m_fontuse-> isChecked ( ); 523 m_tc. m_font_use = m_fontuse-> isChecked ( );
523 524
524 if ( m_tc. m_font_use ) { 525 if ( m_tc. m_font_use ) {
525 QFont f = m_fontselect-> selectedFont ( ); 526 QFont f = m_fontselect-> selectedFont ( );
526 527
527 m_tc. m_font_family = f. family ( ); 528 m_tc. m_font_family = f. family ( );
528 m_tc. m_font_size = f. pointSize ( ); 529 m_tc. m_font_size = f. pointSize ( );
529 m_tc. m_font_weight = f. weight ( ); 530 m_tc. m_font_weight = f. weight ( );
530 m_tc. m_font_italic = f. italic ( ); 531 m_tc. m_font_italic = f. italic ( );
531 } 532 }
532 533
533 QDialog::accept ( ); 534 QDialog::accept ( );
534} 535}
diff --git a/core/settings/launcher/tabssettings.cpp b/core/settings/launcher/tabssettings.cpp
index ab64331..42f0568 100644
--- a/core/settings/launcher/tabssettings.cpp
+++ b/core/settings/launcher/tabssettings.cpp
@@ -1,326 +1,330 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can 5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that 12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details. 17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .: 18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU 19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file; 20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the 21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc., 22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330, 23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. 24 Boston, MA 02111-1307, USA.
25 25
26*/ 26*/
27 27
28#include "tabssettings.h" 28#include "tabssettings.h"
29 29
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qpe/applnk.h> 31#include <qpe/applnk.h>
32#include <qpe/mimetype.h> 32#include <qpe/mimetype.h>
33#include <qpe/qcopenvelope_qws.h> 33#include <qpe/qcopenvelope_qws.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36 36
37#include <qlistbox.h> 37#include <qlistbox.h>
38#include <qpushbutton.h> 38#include <qpushbutton.h>
39#include <qlayout.h> 39#include <qlayout.h>
40#include <qlabel.h> 40#include <qlabel.h>
41#include <qwhatsthis.h> 41#include <qwhatsthis.h>
42#include <qcheckbox.h> 42#include <qcheckbox.h>
43 43
44#include "tabdialog.h" 44#include "tabdialog.h"
45 45
46#include <stdlib.h> 46#include <stdlib.h>
47#include <qmessagebox.h> 47#include <qmessagebox.h>
48 48
49 49
50 #define GLOBALID ".global." 50 #define GLOBALID ".global."
51 51
52 52
53TabsSettings::TabsSettings ( QWidget *parent, const char *name ) 53TabsSettings::TabsSettings ( QWidget *parent, const char *name )
54 : QWidget ( parent, name ) 54 : QWidget ( parent, name )
55{ 55{
56 QGridLayout *lay = new QGridLayout ( this, 0, 0, 4, 4 ); 56 QGridLayout *lay = new QGridLayout ( this, 0, 0, 4, 4 );
57 57
58 QLabel *l = new QLabel ( tr( "Launcher Tabs:" ), this ); 58 QLabel *l = new QLabel ( tr( "Launcher Tabs:" ), this );
59 lay-> addMultiCellWidget ( l, 0, 0, 0, 1 ); 59 lay-> addMultiCellWidget ( l, 0, 0, 0, 1 );
60 60
61 m_list = new QListBox ( this ); 61 m_list = new QListBox ( this );
62 lay-> addMultiCellWidget ( m_list, 1, 4, 0, 0 ); 62 lay-> addMultiCellWidget ( m_list, 1, 4, 0, 0 );
63 63
64 QWhatsThis::add ( m_list, tr( "foobar" )); 64 QWhatsThis::add ( m_list, tr( "foobar" ));
65 65
66 QPushButton *p1, *p2, *p3; 66 QPushButton *p1, *p2, *p3;
67 p1 = new QPushButton ( tr( "New" ), this ); 67 p1 = new QPushButton ( tr( "New" ), this );
68 lay-> addWidget ( p1, 1, 1 ); 68 lay-> addWidget ( p1, 1, 1 );
69 connect ( p1, SIGNAL( clicked()), this, SLOT( newClicked())); 69 connect ( p1, SIGNAL( clicked()), this, SLOT( newClicked()));
70 70
71 p2 = new QPushButton ( tr( "Edit" ), this ); 71 p2 = new QPushButton ( tr( "Edit" ), this );
72 lay-> addWidget ( p2, 2, 1 ); 72 lay-> addWidget ( p2, 2, 1 );
73 connect ( p2, SIGNAL( clicked()), this, SLOT( editClicked())); 73 connect ( p2, SIGNAL( clicked()), this, SLOT( editClicked()));
74 74
75 p3 = new QPushButton ( tr( "Delete" ), this ); 75 p3 = new QPushButton ( tr( "Delete" ), this );
76 lay-> addWidget ( p3, 3, 1 ); 76 lay-> addWidget ( p3, 3, 1 );
77 connect ( p3, SIGNAL( clicked()), this, SLOT( deleteClicked())); 77 connect ( p3, SIGNAL( clicked()), this, SLOT( deleteClicked()));
78 78
79 lay-> setRowStretch ( 4, 10 ); 79 lay-> setRowStretch ( 4, 10 );
80 80
81 m_bigbusy = new QCheckBox( tr( "Enable big busy indicator" ), this ); 81 m_bigbusy = new QCheckBox( tr( "Enable big busy indicator" ), this );
82 lay-> addMultiCellWidget ( m_bigbusy, 5, 5, 0, 1 ); 82 lay-> addMultiCellWidget ( m_bigbusy, 5, 5, 0, 1 );
83 83
84 m_busyani = new QCheckBox ( tr( "Enable animated busy indicator" ), this ); 84 m_busyani = new QCheckBox ( tr( "Enable animated busy indicator" ), this );
85 lay-> addMultiCellWidget ( m_busyani, 6, 6, 0, 1 ); 85 lay-> addMultiCellWidget ( m_busyani, 6, 6, 0, 1 );
86 86
87 p1-> setEnabled ( false ); 87 p1-> setEnabled ( false );
88 p3-> setEnabled ( false ); 88 p3-> setEnabled ( false );
89 89
90 init ( ); 90 init ( );
91 91
92 QWhatsThis::add ( m_list, tr( "Select the Launcher Tab you want to edit or delete." )); 92 QWhatsThis::add ( m_list, tr( "Select the Launcher Tab you want to edit or delete." ));
93 QWhatsThis::add ( p1, tr( "Adds a new Tab to the Launcher." ) + QString ( "<center><br><i>not yet implemented</i><br>Please use the tabmanager</center>." )); 93 QWhatsThis::add ( p1, tr( "Adds a new Tab to the Launcher." ) + QString ( "<center><br><i>not yet implemented</i><br>Please use the tabmanager</center>." ));
94 QWhatsThis::add ( p2, tr( "Opens a new dialog to customize the select Tab." )); 94 QWhatsThis::add ( p2, tr( "Opens a new dialog to customize the select Tab." ));
95 QWhatsThis::add ( p3, tr( "Deletes a Tab from the Launcher." ) + QString ( "<center><br><i>not yet implemented</i><br>Please use the tabmanager</center>." )); 95 QWhatsThis::add ( p3, tr( "Deletes a Tab from the Launcher." ) + QString ( "<center><br><i>not yet implemented</i><br>Please use the tabmanager</center>." ));
96 QWhatsThis::add ( m_bigbusy, tr( "Activate this, if you want a big busy indicator in the middle of the screen instead of the one in taskbar." )); 96 QWhatsThis::add ( m_bigbusy, tr( "Activate this, if you want a big busy indicator in the middle of the screen instead of the one in taskbar." ));
97 QWhatsThis::add ( m_busyani, tr( "Activate this, if you want an animatedbusy indicator for starting applications in the Launcher." )); 97 QWhatsThis::add ( m_busyani, tr( "Activate this, if you want an animatedbusy indicator for starting applications in the Launcher." ));
98} 98}
99 99
100void TabsSettings::init ( ) 100void TabsSettings::init ( )
101{ 101{
102 AppLnkSet rootFolder( MimeType::appsFolderName ( )); 102 AppLnkSet rootFolder( MimeType::appsFolderName ( ));
103 QStringList types = rootFolder. types ( ); 103 QStringList types = rootFolder. types ( );
104 104
105 m_list-> insertItem ( tr( "All Tabs" )); 105 m_list-> insertItem ( tr( "All Tabs" ));
106 m_ids << GLOBALID; 106 m_ids << GLOBALID;
107 107
108 for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) { 108 for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) {
109 m_list-> insertItem ( rootFolder. typePixmap ( *it ), rootFolder. typeName ( *it )); 109 m_list-> insertItem ( rootFolder. typePixmap ( *it ), rootFolder. typeName ( *it ));
110 m_ids << *it; 110 m_ids << *it;
111 } 111 }
112 QImage img ( Resource::loadImage ( "DocsIcon" )); 112 QImage img ( Resource::loadImage ( "DocsIcon" ));
113 QPixmap pix; 113 QPixmap pix;
114 pix = img. smoothScale ( AppLnk::smallIconSize ( ), AppLnk::smallIconSize ( )); 114 pix = img. smoothScale ( AppLnk::smallIconSize ( ), AppLnk::smallIconSize ( ));
115 m_list-> insertItem ( pix, tr( "Documents" )); 115 m_list-> insertItem ( pix, tr( "Documents" ));
116 m_ids += "Documents"; // No tr 116 m_ids += "Documents"; // No tr
117 117
118 Config cfg ( "Launcher" ); 118 Config cfg ( "Launcher" );
119 119
120 readTabSettings ( cfg ); 120 readTabSettings ( cfg );
121 121
122 cfg. setGroup ( "GUI" ); 122 cfg. setGroup ( "GUI" );
123 m_busyani-> setChecked ( cfg. readEntry ( "BusyType" ). lower ( ) == "animated" ); 123 m_busyani-> setChecked ( cfg. readEntry ( "BusyType" ). lower ( ) == "animated" );
124 m_bigbusy->setChecked( cfg. readBoolEntry ( "BigBusy" ) ); 124 m_bigbusy->setChecked( cfg. readBoolEntry ( "BigBusy" ) );
125} 125}
126 126
127 127
128void TabsSettings::readTabSettings ( Config &cfg ) 128void TabsSettings::readTabSettings ( Config &cfg )
129{ 129{
130 QString grp ( "Tab %1" ); // No tr 130 QString grp ( "Tab %1" ); // No tr
131 m_tabs. clear ( ); 131 m_tabs. clear ( );
132 132
133 TabConfig global_def; 133 TabConfig global_def;
134 global_def. m_view = TabConfig::Icon; 134 global_def. m_view = TabConfig::Icon;
135 global_def. m_bg_type = TabConfig::Ruled; 135 global_def. m_bg_type = TabConfig::Ruled;
136 global_def. m_bg_image = "launcher/opie-background"; 136 global_def. m_bg_image = "launcher/opie-background";
137 global_def. m_bg_color = colorGroup ( ). color ( QColorGroup::Base ). name ( ); 137 global_def. m_bg_color = colorGroup ( ). color ( QColorGroup::Base ). name ( );
138 global_def. m_iconcolumns = 0; // automatic 138 global_def. m_iconcolumns = 0; // automatic
139 global_def. m_text_color = colorGroup ( ). color ( QColorGroup::Text ). name ( ); 139 global_def. m_text_color = colorGroup ( ). color ( QColorGroup::Text ). name ( );
140 global_def. m_font_use = false; 140 global_def. m_font_use = false;
141 global_def. m_font_family = font ( ). family ( ); 141 global_def. m_font_family = font ( ). family ( );
142 global_def. m_font_size = font ( ). pointSize ( ); 142 global_def. m_font_size = font ( ). pointSize ( );
143 global_def. m_font_weight = 50; 143 global_def. m_font_weight = 50;
144 global_def. m_font_italic = false; 144 global_def. m_font_italic = false;
145 global_def. m_changed = false; 145 global_def. m_changed = false;
146 146
147 Config cfg2 = Config( "Launchersettings" ); 147 Config cfg2 = Config( "Launchersettings" );
148 148
149 for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { 149 for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) {
150 TabConfig tc = ( it != m_ids. begin ( )) ? m_tabs [GLOBALID] : global_def; 150 TabConfig tc = ( it != m_ids. begin ( )) ? m_tabs [GLOBALID] : global_def;
151 151
152 cfg. setGroup ( grp. arg ( *it )); 152 cfg. setGroup ( grp. arg ( *it ));
153 cfg2. setGroup( grp. arg ( *it )); 153 cfg2. setGroup( grp. arg ( *it ));
154 154
155 QString view = cfg. readEntry ( "View" ); 155 QString view = cfg. readEntry ( "View" );
156 if ( view == "Icon" ) // No tr 156 if ( view == "Icon" ) // No tr
157 tc. m_view = TabConfig::Icon; 157 tc. m_view = TabConfig::Icon;
158 if ( view == "List" ) // No tr 158 if ( view == "List" ) // No tr
159 tc. m_view = TabConfig::List; 159 tc. m_view = TabConfig::List;
160 160
161 QString bgType = cfg. readEntry ( "BackgroundType" ); 161 QString bgType = cfg. readEntry ( "BackgroundType" );
162 if ( bgType == "Image" ) 162 if ( bgType == "Image" )
163 tc. m_bg_type = TabConfig::Image; 163 tc. m_bg_type = TabConfig::Image;
164 else if ( bgType == "SolidColor" ) 164 else if ( bgType == "SolidColor" )
165 tc. m_bg_type = TabConfig::SolidColor; 165 tc. m_bg_type = TabConfig::SolidColor;
166 else if ( bgType == "Image" ) // No tr 166 else if ( bgType == "Image" ) // No tr
167 tc. m_bg_type = TabConfig::Image; 167 tc. m_bg_type = TabConfig::Image;
168 168
169 tc. m_bg_image = cfg. readEntry ( "BackgroundImage", tc. m_bg_image ); 169 tc. m_bg_image = cfg. readEntry ( "BackgroundImage", tc. m_bg_image );
170 tc. m_last_directory = cfg2.readEntry( "DefaultDir", "" ); 170 tc. m_last_directory = cfg2.readEntry( "DefaultDir", "" );
171 tc. m_bg_color = cfg. readEntry ( "BackgroundColor", tc. m_bg_color ); 171 tc. m_bg_color = cfg. readEntry ( "BackgroundColor", tc. m_bg_color );
172 tc. m_iconcolumns = cfg. readNumEntry ( "Columns", tc. m_iconcolumns ); 172 tc. m_iconcolumns = cfg. readNumEntry ( "Columns", tc. m_iconcolumns );
173 qDebug( "m_iconcolumns for %s = %d", (const char*) *it, tc.m_iconcolumns );
173 tc. m_text_color = cfg. readEntry ( "TextColor", tc. m_text_color ); 174 tc. m_text_color = cfg. readEntry ( "TextColor", tc. m_text_color );
174 QStringList f = cfg. readListEntry ( "Font", ',' ); 175 QStringList f = cfg. readListEntry ( "Font", ',' );
175 if ( f. count ( ) == 4 ) { 176 if ( f. count ( ) == 4 ) {
176 tc. m_font_use = true; 177 tc. m_font_use = true;
177 tc. m_font_family = f [0]; 178 tc. m_font_family = f [0];
178 tc. m_font_size = f [1]. toInt ( ); 179 tc. m_font_size = f [1]. toInt ( );
179 tc. m_font_weight = f [2]. toInt ( ); 180 tc. m_font_weight = f [2]. toInt ( );
180 tc. m_font_italic = ( f [3]. toInt ( )); 181 tc. m_font_italic = ( f [3]. toInt ( ));
181 } 182 }
182 m_tabs [*it] = tc; 183 m_tabs [*it] = tc;
183 } 184 }
184 185
185 // if all tabs have the same config, then initialize the GLOBALID tab to these values 186 // if all tabs have the same config, then initialize the GLOBALID tab to these values
186 187
187 TabConfig *first = 0; 188 TabConfig *first = 0;
188 bool same = true; 189 bool same = true;
189 190
190 for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { 191 for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) {
191 if ( *it == GLOBALID ) 192 if ( *it == GLOBALID )
192 continue; 193 continue;
193 else if ( !first ) 194 else if ( !first )
194 first = &m_tabs [*it]; 195 first = &m_tabs [*it];
195 else 196 else
196 same &= ( *first == m_tabs [*it] ); 197 same &= ( *first == m_tabs [*it] );
197 } 198 }
198 if ( same ) { 199 if ( same ) {
199 m_tabs [GLOBALID] = *first; 200 m_tabs [GLOBALID] = *first;
200 m_tabs [GLOBALID]. m_changed = true; 201 m_tabs [GLOBALID]. m_changed = true;
201 } 202 }
202} 203}
203 204
204 205
205void TabsSettings::accept ( ) 206void TabsSettings::accept ( )
206{ 207{
207 Config cfg ( "Launcher" ); 208 Config cfg ( "Launcher" );
208 Config cfg2 ( "Launchersettings" ); 209 Config cfg2 ( "Launchersettings" );
209 210
210 // Launcher Tab 211 // Launcher Tab
211 QString grp ( "Tab %1" ); // No tr 212 QString grp ( "Tab %1" ); // No tr
212 213
213 for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { 214 for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) {
214 TabConfig &tc = m_tabs [*it]; 215 TabConfig &tc = m_tabs [*it];
215 216
216 if ( !tc. m_changed ) 217 if ( !tc. m_changed )
217 continue; 218 continue;
218 219
219 cfg. setGroup ( grp. arg ( *it )); 220 cfg. setGroup ( grp. arg ( *it ));
220 cfg2. setGroup ( grp. arg ( *it )); 221 cfg2. setGroup ( grp. arg ( *it ));
221 switch ( tc. m_view ) { 222 switch ( tc. m_view ) {
222 case TabConfig::Icon: 223 case TabConfig::Icon:
223 cfg.writeEntry ( "View", "Icon" ); 224 cfg.writeEntry ( "View", "Icon" );
224 break; 225 break;
225 case TabConfig::List: 226 case TabConfig::List:
226 cfg.writeEntry ( "View", "List" ); 227 cfg.writeEntry ( "View", "List" );
227 break; 228 break;
228 } 229 }
229 230
230 QCopEnvelope e ( "QPE/Launcher", "setTabView(QString,int)" ); 231 QCopEnvelope e ( "QPE/Launcher", "setTabView(QString,int)" );
231 e << *it << tc. m_view; 232 e << *it << tc. m_view;
232 233
233 cfg. writeEntry ( "BackgroundImage", tc. m_bg_image ); 234 cfg. writeEntry ( "BackgroundImage", tc. m_bg_image );
234 cfg. writeEntry ( "BackgroundColor", tc. m_bg_color ); 235 cfg. writeEntry ( "BackgroundColor", tc. m_bg_color );
235 cfg. writeEntry ( "Columns", tc. m_iconcolumns ); 236 cfg. writeEntry ( "Columns", tc. m_iconcolumns );
236 cfg. writeEntry ( "TextColor", tc. m_text_color ); 237 cfg. writeEntry ( "TextColor", tc. m_text_color );
237 cfg2. writeEntry ( "DefaultDir", tc.m_last_directory ); 238 cfg2. writeEntry ( "DefaultDir", tc.m_last_directory );
238 239
239 if ( tc. m_font_use ) { 240 if ( tc. m_font_use ) {
240 QString f = tc. m_font_family + "," + QString::number ( tc. m_font_size ) + "," + QString::number ( tc. m_font_weight ) + "," + ( tc. m_font_italic ? "1" : "0" ); 241 QString f = tc. m_font_family + "," + QString::number ( tc. m_font_size ) + "," + QString::number ( tc. m_font_weight ) + "," + ( tc. m_font_italic ? "1" : "0" );
241 cfg. writeEntry ( "Font", f ); 242 cfg. writeEntry ( "Font", f );
242 } 243 }
243 else 244 else
244 cfg. removeEntry ( "Font" ); 245 cfg. removeEntry ( "Font" );
245 246
246 QCopEnvelope be ( "QPE/Launcher", "setTabBackground(QString,int,QString)" ); 247 QCopEnvelope be ( "QPE/Launcher", "setTabBackground(QString,int,QString)" );
247 248
248 switch ( tc. m_bg_type ) { 249 switch ( tc. m_bg_type ) {
249 case TabConfig::Ruled: 250 case TabConfig::Ruled:
250 cfg.writeEntry( "BackgroundType", "Ruled" ); 251 cfg.writeEntry( "BackgroundType", "Ruled" );
251 be << *it << tc. m_bg_type << QString(""); 252 be << *it << tc. m_bg_type << QString("");
252 break; 253 break;
253 case TabConfig::SolidColor: 254 case TabConfig::SolidColor:
254 cfg.writeEntry( "BackgroundType", "SolidColor" ); 255 cfg.writeEntry( "BackgroundType", "SolidColor" );
255 be << *it << tc. m_bg_type << tc. m_bg_color; 256 be << *it << tc. m_bg_type << tc. m_bg_color;
256 break; 257 break;
257 case TabConfig::Image: 258 case TabConfig::Image:
258 cfg.writeEntry( "BackgroundType", "Image" ); 259 cfg.writeEntry( "BackgroundType", "Image" );
259 be << *it << tc. m_bg_type << tc. m_bg_image; 260 be << *it << tc. m_bg_type << tc. m_bg_image;
260 break; 261 break;
261 } 262 }
262 263
263 QCopEnvelope te( "QPE/Launcher", "setTextColor(QString,QString)" ); 264 QCopEnvelope te( "QPE/Launcher", "setTextColor(QString,QString)" );
264 te << *it << tc. m_text_color; 265 te << *it << tc. m_text_color;
265 266
266 QCopEnvelope fe ( "QPE/Launcher", "setFont(QString,QString,int,int,int)" ); 267 QCopEnvelope ic( "QPE/Launcher", "setIconColumns(QString,int)" );
268 ic << *it << tc. m_iconcolumns;
269
270 QCopEnvelope fe ( "QPE/Launcher", "setFont(QString,QString,int,int,int)" );
267 fe << *it; 271 fe << *it;
268 fe << ( tc. m_font_use ? tc. m_font_family : QString::null ); 272 fe << ( tc. m_font_use ? tc. m_font_family : QString::null );
269 fe << tc. m_font_size; 273 fe << tc. m_font_size;
270 fe << tc. m_font_weight; 274 fe << tc. m_font_weight;
271 fe << ( tc. m_font_italic ? 1 : 0 ); 275 fe << ( tc. m_font_italic ? 1 : 0 );
272 276
273 tc. m_changed = false; 277 tc. m_changed = false;
274 } 278 }
275 cfg. setGroup ( "GUI" ); 279 cfg. setGroup ( "GUI" );
276 QString busytype = QString ( m_busyani-> isChecked ( ) ? "Animated" : "" ); 280 QString busytype = QString ( m_busyani-> isChecked ( ) ? "Animated" : "" );
277 cfg. writeEntry ( "BusyType", busytype ); 281 cfg. writeEntry ( "BusyType", busytype );
278 282
279 cfg. writeEntry ( "BigBusy", m_bigbusy->isChecked( ) ); 283 cfg. writeEntry ( "BigBusy", m_bigbusy->isChecked( ) );
280 284
281 { 285 {
282 QCopEnvelope e ( "QPE/Launcher", "setBusyIndicatorType(QString)" ); 286 QCopEnvelope e ( "QPE/Launcher", "setBusyIndicatorType(QString)" );
283 e << busytype; 287 e << busytype;
284 } 288 }
285} 289}
286 290
287void TabsSettings::newClicked ( ) 291void TabsSettings::newClicked ( )
288{ 292{
289 QMessageBox::information ( this, tr( "Error" ), tr( "Not implemented yet" )); 293 QMessageBox::information ( this, tr( "Error" ), tr( "Not implemented yet" ));
290} 294}
291 295
292void TabsSettings::deleteClicked ( ) 296void TabsSettings::deleteClicked ( )
293{ 297{
294 int ind = m_list-> currentItem ( ); 298 int ind = m_list-> currentItem ( );
295 299
296 if ( ind < 0 ) 300 if ( ind < 0 )
297 return; 301 return;
298 302
299 QMessageBox::information ( this, tr( "Error" ), tr( "Not implemented yet" )); 303 QMessageBox::information ( this, tr( "Error" ), tr( "Not implemented yet" ));
300} 304}
301 305
302void TabsSettings::editClicked ( ) 306void TabsSettings::editClicked ( )
303{ 307{
304 int ind = m_list-> currentItem ( ); 308 int ind = m_list-> currentItem ( );
305 309
306 if ( ind < 0 ) 310 if ( ind < 0 )
307 return; 311 return;
308 312
309 TabConfig tc = m_tabs [m_ids [ind]]; 313 TabConfig tc = m_tabs [m_ids [ind]];
310 314
311 TabDialog *d = new TabDialog ( m_list-> pixmap ( ind ), m_list-> text ( ind ), tc, this, "TabDialog", true ); 315 TabDialog *d = new TabDialog ( m_list-> pixmap ( ind ), m_list-> text ( ind ), tc, this, "TabDialog", true );
312 316
313 if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) { 317 if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) {
314 tc. m_changed = true; 318 tc. m_changed = true;
315 m_tabs [m_ids [ind]] = tc; 319 m_tabs [m_ids [ind]] = tc;
316 320
317 if ( m_ids [ind] == GLOBALID ) { 321 if ( m_ids [ind] == GLOBALID ) {
318 for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) { 322 for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) {
319 if ( *it != GLOBALID ) 323 if ( *it != GLOBALID )
320 m_tabs [*it] = tc; 324 m_tabs [*it] = tc;
321 } 325 }
322 } 326 }
323 } 327 }
324 328
325 delete d; 329 delete d;
326} 330}