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