author | sandman <sandman> | 2002-09-26 17:37:50 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-09-26 17:37:50 (UTC) |
commit | df3a5b9afa34fa45d06e211f415f74c38017a917 (patch) (unidiff) | |
tree | 3a5f5825badd598ba82227645cb2f00941265a07 | |
parent | e7c2c104d59ef090fbc2f7dbcb052e22e0f5d591 (diff) | |
download | opie-df3a5b9afa34fa45d06e211f415f74c38017a917.zip opie-df3a5b9afa34fa45d06e211f415f74c38017a917.tar.gz opie-df3a5b9afa34fa45d06e211f415f74c38017a917.tar.bz2 |
Qtopia 1.6 merge:
Launcher tabs can now each have their own background, icon-size and font.
-rw-r--r-- | core/launcher/launcher.cpp | 910 | ||||
-rw-r--r-- | core/launcher/launcher.h | 13 | ||||
-rw-r--r-- | core/launcher/launcherview.cpp | 770 | ||||
-rw-r--r-- | core/launcher/launcherview.h | 29 |
4 files changed, 1107 insertions, 615 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index fd89410..dc81c9e 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -1,8 +1,7 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (c) 2002 Holger zecke Freyther | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
4 | ** | 3 | ** |
5 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
6 | ** | 5 | ** |
7 | ** 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 |
8 | ** 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 |
@@ -23,8 +22,9 @@ | |||
23 | // have this class. | 22 | // have this class. |
24 | #define QTOPIA_INTERNAL_FSLP | 23 | #define QTOPIA_INTERNAL_FSLP |
25 | 24 | ||
26 | #include <qpe/config.h> | 25 | #ifdef QWS |
27 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #endif | ||
28 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
29 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
30 | #include <qpe/config.h> | 30 | #include <qpe/config.h> |
@@ -34,9 +34,12 @@ | |||
34 | #include <qpe/storage.h> | 34 | #include <qpe/storage.h> |
35 | #include <qpe/palmtoprecord.h> | 35 | #include <qpe/palmtoprecord.h> |
36 | 36 | ||
37 | #include <qdatetime.h> | 37 | #include <qpe/version.h> |
38 | |||
38 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #ifdef QWS | ||
39 | #include <qwindowsystem_qws.h> | 41 | #include <qwindowsystem_qws.h> |
42 | #endif | ||
40 | #include <qtimer.h> | 43 | #include <qtimer.h> |
41 | #include <qcombobox.h> | 44 | #include <qcombobox.h> |
42 | #include <qvbox.h> | 45 | #include <qvbox.h> |
@@ -52,6 +55,7 @@ | |||
52 | #include <qpainter.h> | 55 | #include <qpainter.h> |
53 | #include <qlabel.h> | 56 | #include <qlabel.h> |
54 | #include <qtextstream.h> | 57 | #include <qtextstream.h> |
58 | #include <qpopupmenu.h> | ||
55 | 59 | ||
56 | #include "launcherview.h" | 60 | #include "launcherview.h" |
57 | #include "launcher.h" | 61 | #include "launcher.h" |
@@ -71,11 +75,7 @@ | |||
71 | 75 | ||
72 | #include <qpe/storage.h> | 76 | #include <qpe/storage.h> |
73 | #include "mediummountgui.h" | 77 | #include "mediummountgui.h" |
74 | //#define SHOW_ALL | ||
75 | |||
76 | // uidGen | ||
77 | 78 | ||
78 | // uidGen | ||
79 | namespace { | 79 | namespace { |
80 | QStringList configToMime( Config *cfg ){ | 80 | QStringList configToMime( Config *cfg ){ |
81 | QStringList mimes; | 81 | QStringList mimes; |
@@ -108,6 +108,23 @@ namespace { | |||
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | |||
112 | //#define SHOW_ALL | ||
113 | |||
114 | class CategoryTab : public QTab | ||
115 | { | ||
116 | public: | ||
117 | CategoryTab( const QIconSet &icon, const QString &text=QString::null ) | ||
118 | : QTab( icon, text ) | ||
119 | { | ||
120 | } | ||
121 | |||
122 | QColor bgColor; | ||
123 | QColor fgColor; | ||
124 | }; | ||
125 | |||
126 | //=========================================================================== | ||
127 | |||
111 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : | 128 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : |
112 | QVBox( parent ) | 129 | QVBox( parent ) |
113 | { | 130 | { |
@@ -118,9 +135,9 @@ CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : | |||
118 | void CategoryTabWidget::prevTab() | 135 | void CategoryTabWidget::prevTab() |
119 | { | 136 | { |
120 | if ( categoryBar ) { | 137 | if ( categoryBar ) { |
121 | int n = categoryBar->count(); | 138 | int n = categoryBar->count(); |
122 | int tab = categoryBar->currentTab(); | 139 | int tab = categoryBar->currentTab(); |
123 | if ( tab >= 0 ) | 140 | if ( tab >= 0 ) |
124 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); | 141 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); |
125 | } | 142 | } |
126 | } | 143 | } |
@@ -128,9 +145,9 @@ void CategoryTabWidget::prevTab() | |||
128 | void CategoryTabWidget::nextTab() | 145 | void CategoryTabWidget::nextTab() |
129 | { | 146 | { |
130 | if ( categoryBar ) { | 147 | if ( categoryBar ) { |
131 | int n = categoryBar->count(); | 148 | int n = categoryBar->count(); |
132 | int tab = categoryBar->currentTab(); | 149 | int tab = categoryBar->currentTab(); |
133 | categoryBar->setCurrentTab( (tab + 1)%n ); | 150 | categoryBar->setCurrentTab( (tab + 1)%n ); |
134 | } | 151 | } |
135 | } | 152 | } |
136 | 153 | ||
@@ -139,30 +156,38 @@ void CategoryTabWidget::addItem( const QString& linkfile ) | |||
139 | int i=0; | 156 | int i=0; |
140 | AppLnk *app = new AppLnk(linkfile); | 157 | AppLnk *app = new AppLnk(linkfile); |
141 | if ( !app->isValid() ) { | 158 | if ( !app->isValid() ) { |
142 | delete app; | 159 | delete app; |
143 | return; | 160 | app=0; |
144 | } | 161 | } |
145 | if ( !app->file().isEmpty() ) { | 162 | if ( !app || !app->file().isEmpty() ) { |
146 | // A document | 163 | // A document |
147 | delete app; | 164 | delete app; |
148 | app = new DocLnk(linkfile); | 165 | app = new DocLnk(linkfile); |
149 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); | 166 | if ( app->fileKnown() ) { |
150 | return; | 167 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); |
168 | } else { | ||
169 | ((LauncherView*)(stack->widget(ids.count()-1)))->sort(); | ||
170 | delete app; | ||
171 | } | ||
172 | return; | ||
151 | } | 173 | } |
174 | // An application | ||
152 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { | 175 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { |
153 | if ( !(*it).isEmpty() ) { | 176 | if ( !(*it).isEmpty() ) { |
154 | QRegExp tf(*it,FALSE,TRUE); | 177 | QRegExp tf(*it,FALSE,TRUE); |
155 | if ( tf.match(app->type()) >= 0 ) { | 178 | if ( tf.match(app->type()) >= 0 ) { |
156 | ((LauncherView*)stack->widget(i))->addItem(app); | 179 | ((LauncherView*)stack->widget(i))->addItem(app); |
157 | return; | 180 | return; |
158 | } | 181 | } |
159 | i++; | 182 | i++; |
160 | } | 183 | } |
161 | } | 184 | } |
185 | |||
186 | QCopEnvelope e("QPE/TaskBar","reloadApps()"); | ||
162 | } | 187 | } |
163 | 188 | ||
164 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | 189 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, |
165 | AppLnkSet* docFolder, const QList<FileSystem> &fs) | 190 | AppLnkSet* docFolder, const QList<FileSystem> &fs) |
166 | { | 191 | { |
167 | delete categoryBar; | 192 | delete categoryBar; |
168 | categoryBar = new CategoryTabBar( this ); | 193 | categoryBar = new CategoryTabBar( this ); |
@@ -177,38 +202,46 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | |||
177 | 202 | ||
178 | ids.clear(); | 203 | ids.clear(); |
179 | 204 | ||
205 | Config cfg("Launcher"); | ||
206 | |||
180 | QStringList types = rootFolder->types(); | 207 | QStringList types = rootFolder->types(); |
181 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 208 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
182 | if ( !(*it).isEmpty() ) { | 209 | if ( !(*it).isEmpty() ) { |
183 | newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); | 210 | (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); |
184 | } | 211 | setTabAppearance( *it, cfg ); |
212 | } | ||
185 | } | 213 | } |
186 | QListIterator<AppLnk> it( rootFolder->children() ); | 214 | QListIterator<AppLnk> it( rootFolder->children() ); |
187 | AppLnk* l; | 215 | AppLnk* l; |
188 | while ( (l=it.current()) ) { | 216 | while ( (l=it.current()) ) { |
189 | if ( l->type() == "Separator" ) { | 217 | if ( l->type() == "Separator" ) { // No tr |
190 | rootFolder->remove(l); | 218 | rootFolder->remove(l); |
191 | delete l; | 219 | delete l; |
192 | } else { | 220 | } else { |
193 | int i=0; | 221 | int i=0; |
194 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 222 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
195 | if ( *it == l->type() ) | 223 | if ( *it == l->type() ) |
196 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); | 224 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); |
197 | i++; | 225 | i++; |
198 | } | 226 | } |
199 | } | 227 | } |
200 | ++it; | 228 | ++it; |
201 | } | 229 | } |
202 | rootFolder->detachChildren(); | 230 | rootFolder->detachChildren(); |
203 | for (int i=0; i<tabs; i++) | 231 | for (int i=0; i<tabs; i++) |
204 | ((LauncherView*)stack->widget(i))->sort(); | 232 | ((LauncherView*)stack->widget(i))->sort(); |
205 | 233 | ||
206 | // all documents | 234 | // all documents |
207 | docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); | 235 | QImage img( Resource::loadImage( "DocsIcon" ) ); |
236 | QPixmap pm; | ||
237 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | ||
238 | docview = newView( "Documents", // No tr | ||
239 | pm, tr("Documents")); | ||
208 | docview->populate( docFolder, QString::null ); | 240 | docview->populate( docFolder, QString::null ); |
209 | docFolder->detachChildren(); | 241 | docFolder->detachChildren(); |
210 | docview->setFileSystems(fs); | 242 | docview->setFileSystems(fs); |
211 | docview->setToolsEnabled(TRUE); | 243 | docview->setToolsEnabled(TRUE); |
244 | setTabAppearance( "Documents", cfg ); // No tr | ||
212 | 245 | ||
213 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); | 246 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); |
214 | 247 | ||
@@ -218,6 +251,48 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | |||
218 | stack->show(); | 251 | stack->show(); |
219 | } | 252 | } |
220 | 253 | ||
254 | void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) | ||
255 | { | ||
256 | QString grp( "Tab %1" ); // No tr | ||
257 | cfg.setGroup( grp.arg(id) ); | ||
258 | LauncherView *v = view( id ); | ||
259 | int idx = ids.findIndex( id ); | ||
260 | CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx ); | ||
261 | |||
262 | // View | ||
263 | QString view = cfg.readEntry( "View", "Icon" ); | ||
264 | if ( view == "List" ) // No tr | ||
265 | v->setViewMode( LauncherView::List ); | ||
266 | QString bgType = cfg.readEntry( "BackgroundType", "Ruled" ); | ||
267 | if ( bgType == "Image" ) { // No tr | ||
268 | QString pm = cfg.readEntry( "BackgroundImage", "wallpaper/marble" ); | ||
269 | v->setBackgroundType( LauncherView::Image, pm ); | ||
270 | } else if ( bgType == "SolidColor" ) { | ||
271 | QString c = cfg.readEntry( "BackgroundColor" ); | ||
272 | v->setBackgroundType( LauncherView::SolidColor, c ); | ||
273 | } | ||
274 | QString textCol = cfg.readEntry( "TextColor" ); | ||
275 | if ( textCol.isEmpty() ) | ||
276 | v->setTextColor( QColor() ); | ||
277 | else | ||
278 | v->setTextColor( QColor(textCol) ); | ||
279 | QStringList font = cfg.readListEntry( "Font", ',' ); | ||
280 | if ( font.count() == 4 ) | ||
281 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); | ||
282 | |||
283 | // Tabs | ||
284 | QString tabCol = cfg.readEntry( "TabColor" ); | ||
285 | if ( tabCol.isEmpty() ) | ||
286 | tab->bgColor = QColor(); | ||
287 | else | ||
288 | tab->bgColor = QColor(tabCol); | ||
289 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); | ||
290 | if ( tabTextCol.isEmpty() ) | ||
291 | tab->fgColor = QColor(); | ||
292 | else | ||
293 | tab->fgColor = QColor(tabTextCol); | ||
294 | } | ||
295 | |||
221 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) | 296 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) |
222 | { | 297 | { |
223 | docview->populate( docFolder, QString::null ); | 298 | docview->populate( docFolder, QString::null ); |
@@ -226,15 +301,35 @@ void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> | |||
226 | docview->updateTools(); | 301 | docview->updateTools(); |
227 | } | 302 | } |
228 | 303 | ||
304 | void CategoryTabWidget::tabProperties() | ||
305 | { | ||
306 | LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); | ||
307 | QPopupMenu *m = new QPopupMenu( this ); | ||
308 | m->insertItem( tr("Icon View"), LauncherView::Icon ); | ||
309 | m->insertItem( tr("List View"), LauncherView::List ); | ||
310 | m->setItemChecked( (int)view->viewMode(), TRUE ); | ||
311 | int rv = m->exec( QCursor::pos() ); | ||
312 | if ( rv >= 0 && rv != view->viewMode() ) { | ||
313 | view->setViewMode( (LauncherView::ViewMode)rv ); | ||
314 | } | ||
315 | |||
316 | delete m; | ||
317 | } | ||
318 | |||
319 | QString CategoryTabWidget::getAllDocLinkInfo() const | ||
320 | { | ||
321 | return docview->getAllDocLinkInfo(); | ||
322 | } | ||
323 | |||
229 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 324 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
230 | { | 325 | { |
231 | LauncherView* view = new LauncherView( stack ); | 326 | LauncherView* view = new LauncherView( stack ); |
232 | connect( view, SIGNAL(clicked(const AppLnk*)), | 327 | connect( view, SIGNAL(clicked(const AppLnk*)), |
233 | this, SIGNAL(clicked(const AppLnk*))); | 328 | this, SIGNAL(clicked(const AppLnk*))); |
234 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 329 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
235 | this, SIGNAL(rightPressed(AppLnk*))); | 330 | this, SIGNAL(rightPressed(AppLnk*))); |
236 | ids.append(id); | 331 | ids.append(id); |
237 | categoryBar->addTab( new QTab( pm, label ) ); | 332 | categoryBar->addTab( new CategoryTab( pm, label ) ); |
238 | stack->addWidget( view, tabs++ ); | 333 | stack->addWidget( view, tabs++ ); |
239 | return view; | 334 | return view; |
240 | } | 335 | } |
@@ -244,8 +339,8 @@ void CategoryTabWidget::updateLink(const QString& linkfile) | |||
244 | int i=0; | 339 | int i=0; |
245 | LauncherView* view; | 340 | LauncherView* view; |
246 | while ((view = (LauncherView*)stack->widget(i++))) { | 341 | while ((view = (LauncherView*)stack->widget(i++))) { |
247 | if ( view->removeLink(linkfile) ) | 342 | if ( view->removeLink(linkfile) ) |
248 | break; | 343 | break; |
249 | } | 344 | } |
250 | addItem(linkfile); | 345 | addItem(linkfile); |
251 | docview->updateTools(); | 346 | docview->updateTools(); |
@@ -264,12 +359,19 @@ void CategoryTabWidget::paletteChange( const QPalette &p ) | |||
264 | void CategoryTabWidget::setBusy(bool on) | 359 | void CategoryTabWidget::setBusy(bool on) |
265 | { | 360 | { |
266 | if ( on ) | 361 | if ( on ) |
267 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); | 362 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); |
268 | else | 363 | else |
269 | for (int i=0; i<tabs; i++) | 364 | for (int i=0; i<tabs; i++) |
270 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); | 365 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); |
271 | } | 366 | } |
272 | 367 | ||
368 | LauncherView *CategoryTabWidget::view( const QString &id ) | ||
369 | { | ||
370 | int idx = ids.findIndex( id ); | ||
371 | return (LauncherView *)stack->widget(idx); | ||
372 | } | ||
373 | |||
374 | //=========================================================================== | ||
273 | 375 | ||
274 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) | 376 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) |
275 | : QTabBar( parent, name ) | 377 | : QTabBar( parent, name ) |
@@ -285,70 +387,88 @@ CategoryTabBar::~CategoryTabBar() | |||
285 | void CategoryTabBar::layoutTabs() | 387 | void CategoryTabBar::layoutTabs() |
286 | { | 388 | { |
287 | if ( !count() ) | 389 | if ( !count() ) |
288 | return; | 390 | return; |
289 | 391 | ||
290 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; | 392 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; |
393 | int available = width()-1; | ||
394 | QFontMetrics fm = fontMetrics(); | ||
291 | int hiddenTabWidth = -7; | 395 | int hiddenTabWidth = -7; |
292 | int middleTab = currentTab(); | 396 | int middleTab = currentTab(); |
293 | int hframe, vframe, overlap; | 397 | int hframe, vframe, overlap; |
294 | style().tabbarMetrics( this, hframe, vframe, overlap ); | 398 | style().tabbarMetrics( this, hframe, vframe, overlap ); |
295 | QFontMetrics fm = fontMetrics(); | ||
296 | int x = 0; | 399 | int x = 0; |
297 | QRect r; | 400 | QRect r; |
298 | QTab *t; | 401 | QTab *t; |
299 | int available = width()-1; | ||
300 | int required = 0; | 402 | int required = 0; |
403 | int eventabwidth = (width()-1)/count(); | ||
404 | enum Mode { HideBackText, Pack, Even } mode=Even; | ||
301 | for ( int i = 0; i < count(); i++ ) { | 405 | for ( int i = 0; i < count(); i++ ) { |
302 | t = tab(i); | 406 | t = tab(i); |
303 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 407 | int iw = fm.width( t->text() ) + hframe - overlap; |
304 | if ( i != middleTab ) { | 408 | if ( i != middleTab ) { |
305 | // required += hiddenTabWidth + hframe - overlap; | 409 | available -= hiddenTabWidth + hframe - overlap; |
306 | available -= hiddenTabWidth + hframe - overlap; | 410 | if ( t->iconSet() != 0 ) |
307 | if ( t->iconSet() != 0 ) | 411 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
308 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 412 | } |
309 | } else { | 413 | if ( t->iconSet() != 0 ) |
310 | required += fm.width( t->text() ) + hframe - overlap; | 414 | iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
311 | if ( t->iconSet() != 0 ) | 415 | required += iw; |
312 | required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 416 | // As space gets tight, packed looks better than even. "10" must be at least 0. |
313 | } | 417 | if ( iw >= eventabwidth-10 ) |
418 | mode = Pack; | ||
314 | } | 419 | } |
420 | if ( mode == Pack && required > width()-1 ) | ||
421 | mode = HideBackText; | ||
315 | for ( int i = 0; i < count(); i++ ) { | 422 | for ( int i = 0; i < count(); i++ ) { |
316 | t = tab(i); | 423 | t = tab(i); |
317 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 424 | if ( mode != HideBackText ) { |
318 | if ( i != middleTab ) { | 425 | int w = fm.width( t->text() ); |
319 | int w = hiddenTabWidth; | 426 | int ih = 0; |
320 | int ih = 0; | 427 | if ( t->iconSet() != 0 ) { |
321 | if ( t->iconSet() != 0 ) { | 428 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
322 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 429 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
323 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 430 | } |
324 | } | 431 | int h = QMAX( fm.height(), ih ); |
325 | int h = QMAX( fm.height(), ih ); | 432 | h = QMAX( h, QApplication::globalStrut().height() ); |
326 | h = QMAX( h, QApplication::globalStrut().height() ); | 433 | |
327 | 434 | h += vframe; | |
328 | h += vframe; | 435 | w += hframe; |
329 | w += hframe; | 436 | |
330 | 437 | QRect tr(x, 0, | |
331 | t->setRect( QRect(x, 0, w, h) ); | 438 | mode == Even ? eventabwidth : w * (width()-1)/required, h); |
332 | x += t->rect().width() - overlap; | 439 | t->setRect(tr); |
333 | r = r.unite( t->rect() ); | 440 | x += tr.width() - overlap; |
334 | } else { | 441 | r = r.unite(tr); |
335 | int w = fm.width( t->text() ); | 442 | } else if ( i != middleTab ) { |
336 | int ih = 0; | 443 | int w = hiddenTabWidth; |
337 | if ( t->iconSet() != 0 ) { | 444 | int ih = 0; |
338 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 445 | if ( t->iconSet() != 0 ) { |
339 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 446 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
340 | } | 447 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
341 | int h = QMAX( fm.height(), ih ); | 448 | } |
342 | h = QMAX( h, QApplication::globalStrut().height() ); | 449 | int h = QMAX( fm.height(), ih ); |
343 | 450 | h = QMAX( h, QApplication::globalStrut().height() ); | |
344 | h += vframe; | 451 | |
345 | w += hframe; | 452 | h += vframe; |
346 | 453 | w += hframe; | |
347 | // t->setRect( QRect(x, 0, w * available/required, h) ); | 454 | |
348 | t->setRect( QRect(x, 0, available, h) ); | 455 | t->setRect( QRect(x, 0, w, h) ); |
349 | x += t->rect().width() - overlap; | 456 | x += t->rect().width() - overlap; |
350 | r = r.unite( t->rect() ); | 457 | r = r.unite( t->rect() ); |
351 | } | 458 | } else { |
459 | int ih = 0; | ||
460 | if ( t->iconSet() != 0 ) { | ||
461 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | ||
462 | } | ||
463 | int h = QMAX( fm.height(), ih ); | ||
464 | h = QMAX( h, QApplication::globalStrut().height() ); | ||
465 | |||
466 | h += vframe; | ||
467 | |||
468 | t->setRect( QRect(x, 0, available, h) ); | ||
469 | x += t->rect().width() - overlap; | ||
470 | r = r.unite( t->rect() ); | ||
471 | } | ||
352 | } | 472 | } |
353 | 473 | ||
354 | QRect rr = tab(count()-1)->rect(); | 474 | QRect rr = tab(count()-1)->rect(); |
@@ -367,6 +487,19 @@ void CategoryTabBar::layoutTabs() | |||
367 | 487 | ||
368 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const | 488 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const |
369 | { | 489 | { |
490 | CategoryTabBar *that = (CategoryTabBar *) this; | ||
491 | CategoryTab *ct = (CategoryTab *)t; | ||
492 | QPalette pal = palette(); | ||
493 | bool setPal = FALSE; | ||
494 | if ( ct->bgColor.isValid() ) { | ||
495 | pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor ); | ||
496 | pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor ); | ||
497 | pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor ); | ||
498 | pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor ); | ||
499 | that->setUpdatesEnabled( FALSE ); | ||
500 | that->setPalette( pal ); | ||
501 | setPal = TRUE; | ||
502 | } | ||
370 | #if QT_VERSION >= 300 | 503 | #if QT_VERSION >= 300 |
371 | QStyle::SFlags flags = QStyle::Style_Default; | 504 | QStyle::SFlags flags = QStyle::Style_Default; |
372 | if ( selected ) | 505 | if ( selected ) |
@@ -380,65 +513,76 @@ void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const | |||
380 | QRect r( t->rect() ); | 513 | QRect r( t->rect() ); |
381 | QFont f( font() ); | 514 | QFont f( font() ); |
382 | if ( selected ) | 515 | if ( selected ) |
383 | f.setBold( TRUE ); | 516 | f.setBold( TRUE ); |
384 | p->setFont( f ); | 517 | p->setFont( f ); |
385 | 518 | ||
519 | if ( ct->fgColor.isValid() ) { | ||
520 | pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); | ||
521 | pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); | ||
522 | that->setUpdatesEnabled( FALSE ); | ||
523 | that->setPalette( pal ); | ||
524 | setPal = TRUE; | ||
525 | } | ||
386 | int iw = 0; | 526 | int iw = 0; |
387 | int ih = 0; | 527 | int ih = 0; |
388 | if ( t->iconSet() != 0 ) { | 528 | if ( t->iconSet() != 0 ) { |
389 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; | 529 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; |
390 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 530 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
391 | } | 531 | } |
392 | int w = iw + p->fontMetrics().width( t->text() ) + 4; | 532 | int w = iw + p->fontMetrics().width( t->text() ) + 4; |
393 | int h = QMAX(p->fontMetrics().height() + 4, ih ); | 533 | int h = QMAX(p->fontMetrics().height() + 4, ih ); |
394 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, | 534 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, |
395 | r.top() + (r.height()-h)/2, w, h ), t, | 535 | r.top() + (r.height()-h)/2, w, h ), t, |
396 | #if QT_VERSION >= 300 | 536 | #if QT_VERSION >= 300 |
397 | t->identifier() == keyboardFocusTab() | 537 | t->identifier() == keyboardFocusTab() |
398 | #else | 538 | #else |
399 | t->identitifer() == keyboardFocusTab() | 539 | t->identitifer() == keyboardFocusTab() |
400 | #endif | 540 | #endif |
401 | ); | 541 | ); |
542 | if ( setPal ) { | ||
543 | that->unsetPalette(); | ||
544 | that->setUpdatesEnabled( TRUE ); | ||
545 | } | ||
402 | } | 546 | } |
403 | 547 | ||
404 | 548 | ||
405 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, | 549 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, |
406 | QTab* t, bool has_focus ) const | 550 | QTab* t, bool has_focus ) const |
407 | { | 551 | { |
408 | QRect r = t->rect(); | 552 | QRect r = t->rect(); |
409 | // if ( t->id != currentTab() ) | 553 | // if ( t->id != currentTab() ) |
410 | //r.moveBy( 1, 1 ); | 554 | //r.moveBy( 1, 1 ); |
411 | // | 555 | // |
412 | if ( t->iconSet() ) { | 556 | if ( t->iconSet() ) { |
413 | // the tab has an iconset, draw it in the right mode | 557 | // the tab has an iconset, draw it in the right mode |
414 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; | 558 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; |
415 | if ( mode == QIconSet::Normal && has_focus ) | 559 | if ( mode == QIconSet::Normal && has_focus ) |
416 | mode = QIconSet::Active; | 560 | mode = QIconSet::Active; |
417 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); | 561 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); |
418 | int pixw = pixmap.width(); | 562 | int pixw = pixmap.width(); |
419 | int pixh = pixmap.height(); | 563 | int pixh = pixmap.height(); |
420 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); | 564 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); |
421 | r.setLeft( r.left() + pixw + 5 ); | 565 | r.setLeft( r.left() + pixw + 5 ); |
422 | } | 566 | } |
423 | 567 | ||
424 | QRect tr = r; | 568 | QRect tr = r; |
425 | 569 | ||
426 | if ( r.width() < 20 ) | 570 | if ( r.width() < 20 ) |
427 | return; | 571 | return; |
428 | 572 | ||
429 | if ( t->isEnabled() && isEnabled() ) { | 573 | if ( t->isEnabled() && isEnabled() ) { |
430 | #if defined(_WS_WIN32_) | 574 | #if defined(_WS_WIN32_) |
431 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) | 575 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) |
432 | p->setPen( colorGroup().buttonText() ); | 576 | p->setPen( colorGroup().buttonText() ); |
433 | else | 577 | else |
434 | p->setPen( colorGroup().foreground() ); | 578 | p->setPen( colorGroup().foreground() ); |
435 | #else | 579 | #else |
436 | p->setPen( colorGroup().foreground() ); | 580 | p->setPen( colorGroup().foreground() ); |
437 | #endif | 581 | #endif |
438 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 582 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
439 | } else { | 583 | } else { |
440 | p->setPen( palette().disabled().foreground() ); | 584 | p->setPen( palette().disabled().foreground() ); |
441 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 585 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
442 | } | 586 | } |
443 | } | 587 | } |
444 | 588 | ||
@@ -457,25 +601,29 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | |||
457 | tabs = 0; | 601 | tabs = 0; |
458 | rootFolder = 0; | 602 | rootFolder = 0; |
459 | docsFolder = 0; | 603 | docsFolder = 0; |
604 | |||
460 | int stamp = uidgen.generate(); // this is our timestamp to see which devices we know | 605 | int stamp = uidgen.generate(); // this is our timestamp to see which devices we know |
461 | //uidgen.store( stamp ); | 606 | //uidgen.store( stamp ); |
462 | m_timeStamp = QString::number( stamp ); | 607 | m_timeStamp = QString::number( stamp ); |
463 | 608 | ||
464 | tabs = new CategoryTabWidget( this ); | 609 | tabs = new CategoryTabWidget( this ); |
465 | tabs->setMaximumWidth( qApp->desktop()->width() ); | 610 | tabs->setMaximumWidth( qApp->desktop()->width() ); |
466 | setCentralWidget( tabs ); | 611 | setCentralWidget( tabs ); |
467 | 612 | ||
468 | connect( tabs, SIGNAL(selected(const QString&)), | 613 | connect( tabs, SIGNAL(selected(const QString&)), |
469 | this, SLOT(viewSelected(const QString&)) ); | 614 | this, SLOT(viewSelected(const QString&)) ); |
470 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 615 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
471 | this, SLOT(select(const AppLnk*))); | 616 | this, SLOT(select(const AppLnk*))); |
472 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 617 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
473 | this, SLOT(properties(AppLnk*))); | 618 | this, SLOT(properties(AppLnk*))); |
474 | 619 | ||
475 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 620 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
476 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 621 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
477 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 622 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
478 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); | 623 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); |
624 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); | ||
625 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | ||
626 | this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); | ||
479 | #endif | 627 | #endif |
480 | 628 | ||
481 | storage = new StorageInfo( this ); | 629 | storage = new StorageInfo( this ); |
@@ -491,25 +639,29 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | |||
491 | 639 | ||
492 | Launcher::~Launcher() | 640 | Launcher::~Launcher() |
493 | { | 641 | { |
642 | delete rootFolder; | ||
643 | delete docsFolder; | ||
494 | } | 644 | } |
495 | 645 | ||
496 | static bool isVisibleWindow(int wid) | 646 | static bool isVisibleWindow(int wid) |
497 | { | 647 | { |
648 | #ifdef QWS | ||
498 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 649 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
499 | QWSWindow* w; | 650 | QWSWindow* w; |
500 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 651 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
501 | if ( w->winId() == wid ) | 652 | if ( w->winId() == wid ) |
502 | return !w->isFullyObscured(); | 653 | return !w->isFullyObscured(); |
503 | } | 654 | } |
655 | #endif | ||
504 | return FALSE; | 656 | return FALSE; |
505 | } | 657 | } |
506 | 658 | ||
507 | void Launcher::showMaximized() | 659 | void Launcher::showMaximized() |
508 | { | 660 | { |
509 | if ( isVisibleWindow( winId() ) ) | 661 | if ( isVisibleWindow( winId() ) ) |
510 | doMaximize(); | 662 | doMaximize(); |
511 | else | 663 | else |
512 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); | 664 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); |
513 | } | 665 | } |
514 | 666 | ||
515 | void Launcher::doMaximize() | 667 | void Launcher::doMaximize() |
@@ -526,14 +678,15 @@ void Launcher::updateMimeTypes() | |||
526 | void Launcher::updateMimeTypes(AppLnkSet* folder) | 678 | void Launcher::updateMimeTypes(AppLnkSet* folder) |
527 | { | 679 | { |
528 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { | 680 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { |
529 | AppLnk *app = it.current(); | 681 | AppLnk *app = it.current(); |
530 | if ( app->type() == "Folder" ) | 682 | if ( app->type() == "Folder" ) // No tr |
531 | updateMimeTypes((AppLnkSet *)app); | 683 | updateMimeTypes((AppLnkSet *)app); |
532 | else { | 684 | else { |
533 | MimeType::registerApp(*app); | 685 | MimeType::registerApp(*app); |
534 | } | 686 | } |
535 | } | 687 | } |
536 | } | 688 | } |
689 | |||
537 | /** This is a HACK.... | 690 | /** This is a HACK.... |
538 | * Reason: scanning huge mediums, microdirvers for examples | 691 | * Reason: scanning huge mediums, microdirvers for examples |
539 | * consomes time. To avoid that we invented the MediumMountCheck | 692 | * consomes time. To avoid that we invented the MediumMountCheck |
@@ -675,18 +828,18 @@ void Launcher::nextView() | |||
675 | 828 | ||
676 | void Launcher::select( const AppLnk *appLnk ) | 829 | void Launcher::select( const AppLnk *appLnk ) |
677 | { | 830 | { |
678 | if ( appLnk->type() == "Folder" ) { | 831 | if ( appLnk->type() == "Folder" ) { // No tr |
679 | // Not supported: flat is simpler for the user | 832 | // Not supported: flat is simpler for the user |
680 | } else { | 833 | } else { |
681 | if ( appLnk->exec().isNull() ) { | 834 | if ( appLnk->exec().isNull() ) { |
682 | QMessageBox::information(this,tr("No application"), | 835 | QMessageBox::information(this,tr("No application"), |
683 | tr("<p>No application is defined for this document." | 836 | tr("<p>No application is defined for this document." |
684 | "<p>Type is %1.").arg(appLnk->type())); | 837 | "<p>Type is %1.").arg(appLnk->type())); |
685 | return; | 838 | return; |
686 | } | 839 | } |
687 | tabs->setBusy(TRUE); | 840 | tabs->setBusy(TRUE); |
688 | emit executing( appLnk ); | 841 | emit executing( appLnk ); |
689 | appLnk->execute(); | 842 | appLnk->execute(); |
690 | } | 843 | } |
691 | } | 844 | } |
692 | 845 | ||
@@ -698,95 +851,92 @@ void Launcher::externalSelected(const AppLnk *appLnk) | |||
698 | 851 | ||
699 | void Launcher::properties( AppLnk *appLnk ) | 852 | void Launcher::properties( AppLnk *appLnk ) |
700 | { | 853 | { |
701 | if ( appLnk->type() == "Folder" ) { | 854 | if ( appLnk->type() == "Folder" ) { // No tr |
702 | // Not supported: flat is simpler for the user | 855 | // Not supported: flat is simpler for the user |
703 | } else { | 856 | } else { |
704 | in_lnk_props = TRUE; | 857 | in_lnk_props = TRUE; |
705 | got_lnk_change = FALSE; | 858 | got_lnk_change = FALSE; |
706 | LnkProperties prop(appLnk); | 859 | LnkProperties prop(appLnk); |
707 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 860 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
708 | prop.showMaximized(); | 861 | prop.showMaximized(); |
709 | prop.exec(); | 862 | prop.exec(); |
710 | in_lnk_props = FALSE; | 863 | in_lnk_props = FALSE; |
711 | if ( got_lnk_change ) { | 864 | if ( got_lnk_change ) { |
712 | updateLink(lnk_change); | 865 | updateLink(lnk_change); |
713 | } | 866 | } |
714 | } | 867 | } |
715 | } | 868 | } |
716 | 869 | ||
717 | void Launcher::updateLink(const QString& link) | 870 | void Launcher::updateLink(const QString& link) |
718 | { | 871 | { |
719 | if (link.isNull()) | 872 | if (link.isNull()) |
720 | updateTabs(); | 873 | updateTabs(); |
721 | else if (link.isEmpty()) | 874 | else if (link.isEmpty()) |
722 | updateDocs(); | 875 | updateDocs(); |
723 | else | 876 | else |
724 | tabs->updateLink(link); | 877 | tabs->updateLink(link); |
725 | } | 878 | } |
726 | 879 | ||
727 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 880 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
728 | { | 881 | { |
729 | QDataStream stream( data, IO_ReadOnly ); | 882 | QDataStream stream( data, IO_ReadOnly ); |
730 | if ( msg == "closing(QString)" ){ | 883 | if ( msg == "linkChanged(QString)" ) { |
731 | QString app; | 884 | QString link; |
732 | stream >> app; | 885 | stream >> link; |
733 | //qWarning("app closed %s", app.latin1() ); | 886 | if ( in_lnk_props ) { |
734 | // MRUList::removeTask( app ); | 887 | got_lnk_change = TRUE; |
735 | }else if ( msg == "linkChanged(QString)" ) { | 888 | lnk_change = link; |
736 | QString link; | 889 | } else { |
737 | stream >> link; | 890 | updateLink(link); |
738 | if ( in_lnk_props ) { | 891 | } |
739 | got_lnk_change = TRUE; | ||
740 | lnk_change = link; | ||
741 | } else { | ||
742 | updateLink(link); | ||
743 | } | ||
744 | } else if ( msg == "busy()" ) { | 892 | } else if ( msg == "busy()" ) { |
745 | emit busy(); | 893 | emit busy(); |
746 | } else if ( msg == "notBusy(QString)" ) { | 894 | } else if ( msg == "notBusy(QString)" ) { |
747 | QString app; | 895 | QString app; |
748 | stream >> app; | 896 | stream >> app; |
749 | tabs->setBusy(FALSE); | 897 | tabs->setBusy(FALSE); |
750 | emit notBusy(app); | 898 | emit notBusy(app); |
751 | } else if ( msg == "mkdir(QString)" ) { | 899 | } else if ( msg == "mkdir(QString)" ) { |
752 | QString dir; | 900 | QString dir; |
753 | stream >> dir; | 901 | stream >> dir; |
754 | if ( !dir.isEmpty() ) | 902 | if ( !dir.isEmpty() ) |
755 | mkdir( dir ); | 903 | mkdir( dir ); |
756 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 904 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
757 | QString baseFile, sigFile; | 905 | QString baseFile, sigFile; |
758 | stream >> baseFile >> sigFile; | 906 | stream >> baseFile >> sigFile; |
759 | QRsync::generateSignature( baseFile, sigFile ); | 907 | QRsync::generateSignature( baseFile, sigFile ); |
760 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 908 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
761 | QString baseFile, sigFile, deltaFile; | 909 | QString baseFile, sigFile, deltaFile; |
762 | stream >> baseFile >> sigFile >> deltaFile; | 910 | stream >> baseFile >> sigFile >> deltaFile; |
763 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 911 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
764 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 912 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
765 | QString baseFile, deltaFile; | 913 | QString baseFile, deltaFile; |
766 | stream >> baseFile >> deltaFile; | 914 | stream >> baseFile >> deltaFile; |
767 | if ( !QFile::exists( baseFile ) ) { | 915 | if ( !QFile::exists( baseFile ) ) { |
768 | QFile f( baseFile ); | 916 | QFile f( baseFile ); |
769 | f.open( IO_WriteOnly ); | 917 | f.open( IO_WriteOnly ); |
770 | f.close(); | 918 | f.close(); |
771 | } | 919 | } |
772 | QRsync::applyDiff( baseFile, deltaFile ); | 920 | QRsync::applyDiff( baseFile, deltaFile ); |
773 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 921 | #ifndef QT_NO_COP |
774 | e << baseFile; | 922 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
923 | e << baseFile; | ||
924 | #endif | ||
775 | } else if ( msg == "rdiffCleanup()" ) { | 925 | } else if ( msg == "rdiffCleanup()" ) { |
776 | mkdir( "/tmp/rdiff" ); | 926 | mkdir( "/tmp/rdiff" ); |
777 | QDir dir; | 927 | QDir dir; |
778 | dir.setPath( "/tmp/rdiff" ); | 928 | dir.setPath( "/tmp/rdiff" ); |
779 | QStringList entries = dir.entryList(); | 929 | QStringList entries = dir.entryList(); |
780 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 930 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
781 | dir.remove( *it ); | 931 | dir.remove( *it ); |
782 | } else if ( msg == "sendHandshakeInfo()" ) { | 932 | } else if ( msg == "sendHandshakeInfo()" ) { |
783 | QString home = getenv( "HOME" ); | 933 | QString home = getenv( "HOME" ); |
784 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 934 | #ifndef QT_NO_COP |
785 | e << home; | 935 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
786 | int locked = (int) Desktop::screenLocked(); | 936 | e << home; |
787 | e << locked; | 937 | int locked = (int) Desktop::screenLocked(); |
788 | // register an app for autostart | 938 | e << locked; |
789 | // if clear is send the list is cleared. | 939 | #endif |
790 | } else if ( msg == "autoStart(QString)" ) { | 940 | } else if ( msg == "autoStart(QString)" ) { |
791 | QString appName; | 941 | QString appName; |
792 | stream >> appName; | 942 | stream >> appName; |
@@ -829,120 +979,198 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | |||
829 | } | 979 | } |
830 | } else { | 980 | } else { |
831 | } | 981 | } |
982 | } else if ( msg == "sendVersionInfo()" ) { | ||
983 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString)" ); | ||
984 | QString v = QPE_VERSION; | ||
985 | QStringList l = QStringList::split( '.', v ); | ||
986 | QString v2 = l[0] + '.' + l[1]; | ||
987 | e << v2; | ||
988 | //qDebug("version %s\n", line.latin1()); | ||
832 | } else if ( msg == "sendCardInfo()" ) { | 989 | } else if ( msg == "sendCardInfo()" ) { |
833 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 990 | #ifndef QT_NO_COP |
834 | const QList<FileSystem> &fs = storage->fileSystems(); | 991 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
835 | QListIterator<FileSystem> it ( fs ); | 992 | #endif |
836 | QString s; | 993 | const QList<FileSystem> &fs = storage->fileSystems(); |
837 | QString homeDir = getenv("HOME"); | 994 | QListIterator<FileSystem> it ( fs ); |
838 | QString hardDiskHome; | 995 | QString s; |
839 | for ( ; it.current(); ++it ) { | 996 | QString homeDir = getenv("HOME"); |
840 | if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) | 997 | QString hardDiskHome, hardDiskHomePath; |
841 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " | 998 | for ( ; it.current(); ++it ) { |
842 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 999 | int k4 = (*it)->blockSize()/256; |
843 | + " " + (*it)->options() + ";"; | 1000 | if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs") { |
844 | else if ( (*it)->disk() == "/dev/mtdblock1" || | 1001 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " |
845 | (*it)->disk() == "/dev/mtdblock/1" ) | 1002 | + QString::number( (*it)->availBlocks() * k4/4 ) |
846 | s += (*it)->name() + "=" + homeDir + "/Documents " | 1003 | + "K " + (*it)->options() + ";"; |
847 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 1004 | } else if ( (*it)->disk() == "/dev/mtdblock1" || |
848 | + " " + (*it)->options() + ";"; | 1005 | (*it)->disk() == "/dev/mtdblock/1" ) { |
849 | else if ( (*it)->name().contains( tr("Hard Disk") ) && | 1006 | s += (*it)->name() + "=" + homeDir + "/Documents " |
850 | homeDir.contains( (*it)->path() ) && | 1007 | + QString::number( (*it)->availBlocks() * k4/4 ) |
851 | (*it)->path().length() > hardDiskHome.length() ) | 1008 | + "K " + (*it)->options() + ";"; |
852 | hardDiskHome = | 1009 | } else if ( (*it)->name().contains( "Hard Disk") && |
853 | (*it)->name() + "=" + homeDir + "/Documents " | 1010 | homeDir.contains( (*it)->path() ) && |
854 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 1011 | (*it)->path().length() > hardDiskHomePath.length() ) { |
855 | + " " + (*it)->options() + ";"; | 1012 | hardDiskHomePath = (*it)->path(); |
856 | } | 1013 | hardDiskHome = |
857 | if ( !hardDiskHome.isEmpty() ) | 1014 | (*it)->name() + "=" + homeDir + "/Documents " |
858 | s += hardDiskHome; | 1015 | + QString::number( (*it)->availBlocks() * k4/4 ) |
1016 | + "K " + (*it)->options() + ";"; | ||
1017 | } | ||
1018 | } | ||
1019 | if ( !hardDiskHome.isEmpty() ) | ||
1020 | s += hardDiskHome; | ||
859 | 1021 | ||
860 | e << s; | 1022 | #ifndef QT_NO_COP |
1023 | e << s; | ||
1024 | #endif | ||
861 | } else if ( msg == "sendSyncDate(QString)" ) { | 1025 | } else if ( msg == "sendSyncDate(QString)" ) { |
862 | QString app; | 1026 | QString app; |
863 | stream >> app; | 1027 | stream >> app; |
864 | Config cfg( "qpe" ); | 1028 | Config cfg( "qpe" ); |
865 | cfg.setGroup("SyncDate"); | 1029 | cfg.setGroup("SyncDate"); |
866 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 1030 | #ifndef QT_NO_COP |
867 | e << app << cfg.readEntry( app ); | 1031 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
868 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 1032 | e << app << cfg.readEntry( app ); |
869 | //cfg.readEntry( app ).latin1() ); | 1033 | #endif |
1034 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | ||
1035 | //cfg.readEntry( app ).latin1() ); | ||
870 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 1036 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
871 | QString app, date; | 1037 | QString app, date; |
872 | stream >> app >> date; | 1038 | stream >> app >> date; |
873 | Config cfg( "qpe" ); | 1039 | Config cfg( "qpe" ); |
874 | cfg.setGroup("SyncDate"); | 1040 | cfg.setGroup("SyncDate"); |
875 | cfg.writeEntry( app, date ); | 1041 | cfg.writeEntry( app, date ); |
876 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 1042 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
877 | } else if ( msg == "startSync(QString)" ) { | 1043 | } else if ( msg == "startSync(QString)" ) { |
878 | QString what; | 1044 | QString what; |
879 | stream >> what; | 1045 | stream >> what; |
880 | delete syncDialog; syncDialog = 0; | 1046 | delete syncDialog; syncDialog = 0; |
881 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, | 1047 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, |
882 | WStyle_Tool | WStyle_Customize | | 1048 | WStyle_Tool | WStyle_Customize | |
883 | Qt::WStyle_StaysOnTop ); | 1049 | Qt::WStyle_StaysOnTop ); |
884 | syncDialog->showMaximized(); | 1050 | syncDialog->showMaximized(); |
885 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); | 1051 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); |
886 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), | 1052 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), |
887 | SLOT( cancelSync() ) ); | 1053 | SLOT( cancelSync() ) ); |
888 | } else if ( msg == "stopSync()") { | 1054 | } else if ( msg == "stopSync()") { |
889 | delete syncDialog; syncDialog = 0; | 1055 | delete syncDialog; syncDialog = 0; |
890 | } else if ( msg == "getAllDocLinks()" ) { | 1056 | } else if ( msg == "getAllDocLinks()" ) { |
891 | loadDocs(); | 1057 | loadDocs(); |
892 | 1058 | ||
893 | QString contents; | 1059 | QString contents; |
894 | 1060 | ||
895 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { | 1061 | //Categories cats; |
896 | DocLnk *doc = it.current(); | 1062 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { |
897 | QFileInfo fi( doc->file() ); | 1063 | DocLnk *doc = it.current(); |
898 | if ( !fi.exists() ) | 1064 | QFileInfo fi( doc->file() ); |
899 | continue; | 1065 | if ( !fi.exists() ) |
900 | 1066 | continue; | |
901 | bool fake = !doc->linkFileKnown(); | 1067 | |
902 | if ( !fake ) { | 1068 | bool fake = !doc->linkFileKnown(); |
903 | QFile f( doc->linkFile() ); | 1069 | if ( !fake ) { |
904 | if ( f.open( IO_ReadOnly ) ) { | 1070 | QFile f( doc->linkFile() ); |
905 | QTextStream ts( &f ); | 1071 | if ( f.open( IO_ReadOnly ) ) { |
906 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 1072 | QTextStream ts( &f ); |
907 | contents += ts.read(); | 1073 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
908 | f.close(); | 1074 | contents += ts.read(); |
909 | } else | 1075 | f.close(); |
910 | fake = TRUE; | 1076 | } else |
911 | } | 1077 | fake = TRUE; |
912 | if (fake) { | 1078 | } |
913 | contents += "[Desktop Entry]\n"; | 1079 | if (fake) { |
914 | contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; | 1080 | contents += "[Desktop Entry]\n"; |
915 | contents += "File = "+doc->file()+"\n"; | 1081 | contents += "Categories = " + // No tr |
916 | contents += "Name = "+doc->name()+"\n"; | 1082 | // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr |
917 | contents += "Type = "+doc->type()+"\n"; | 1083 | Qtopia::Record::idsToString( doc->categories() ) + "\n"; |
918 | } | 1084 | contents += "Name = "+doc->name()+"\n"; // No tr |
919 | contents += QString("Size = %1\n").arg( fi.size() ); | 1085 | contents += "Type = "+doc->type()+"\n"; // No tr |
920 | } | 1086 | } |
921 | 1087 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) | |
922 | //qDebug( "sending length %d", contents.length() ); | 1088 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr |
923 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 1089 | } |
924 | e << contents; | ||
925 | |||
926 | qDebug( "================ \n\n%s\n\n===============", | ||
927 | contents.latin1() ); | ||
928 | 1090 | ||
929 | delete docsFolder; | 1091 | //qDebug( "sending length %d", contents.length() ); |
930 | docsFolder = 0; | 1092 | #ifndef QT_NO_COP |
1093 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | ||
1094 | e << contents; | ||
1095 | #endif | ||
1096 | |||
1097 | //qDebug( "================ \n\n%s\n\n===============", | ||
1098 | //contents.latin1() ); | ||
1099 | |||
1100 | delete docsFolder; | ||
1101 | docsFolder = 0; | ||
1102 | #ifdef QWS | ||
1103 | } else if ( msg == "setMouseProto(QString)" ) { | ||
1104 | QString mice; | ||
1105 | stream >> mice; | ||
1106 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | ||
1107 | qwsServer->openMouse(); | ||
1108 | } else if ( msg == "setKeyboard(QString)" ) { | ||
1109 | QString kb; | ||
1110 | stream >> kb; | ||
1111 | setenv("QWS_KEYBOARD",kb.latin1(),1); | ||
1112 | qwsServer->openKeyboard(); | ||
1113 | #endif | ||
931 | } | 1114 | } |
932 | } | 1115 | } |
933 | 1116 | ||
934 | void Launcher::cancelSync() | 1117 | void Launcher::cancelSync() |
935 | { | 1118 | { |
1119 | #ifndef QT_NO_COP | ||
936 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 1120 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
1121 | #endif | ||
1122 | } | ||
1123 | |||
1124 | void Launcher::launcherMessage( const QCString &msg, const QByteArray &data) | ||
1125 | { | ||
1126 | QDataStream stream( data, IO_ReadOnly ); | ||
1127 | if ( msg == "setTabView(QString,int)" ) { | ||
1128 | QString id; | ||
1129 | stream >> id; | ||
1130 | int mode; | ||
1131 | stream >> mode; | ||
1132 | if ( tabs->view(id) ) | ||
1133 | tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode ); | ||
1134 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { | ||
1135 | QString id; | ||
1136 | stream >> id; | ||
1137 | int mode; | ||
1138 | stream >> mode; | ||
1139 | QString pixmapOrColor; | ||
1140 | stream >> pixmapOrColor; | ||
1141 | if ( tabs->view(id) ) | ||
1142 | tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | ||
1143 | } else if ( msg == "setTextColor(QString,QString)" ) { | ||
1144 | QString id; | ||
1145 | stream >> id; | ||
1146 | QString color; | ||
1147 | stream >> color; | ||
1148 | if ( tabs->view(id) ) | ||
1149 | tabs->view(id)->setTextColor( QColor(color) ); | ||
1150 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { | ||
1151 | QString id; | ||
1152 | stream >> id; | ||
1153 | QString fam; | ||
1154 | stream >> fam; | ||
1155 | int size; | ||
1156 | stream >> size; | ||
1157 | int weight; | ||
1158 | stream >> weight; | ||
1159 | int italic; | ||
1160 | stream >> italic; | ||
1161 | if ( tabs->view(id) ) | ||
1162 | tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); | ||
1163 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); | ||
1164 | } | ||
937 | } | 1165 | } |
938 | 1166 | ||
939 | void Launcher::storageChanged() | 1167 | void Launcher::storageChanged() |
940 | { | 1168 | { |
941 | if ( in_lnk_props ) { | 1169 | if ( in_lnk_props ) { |
942 | got_lnk_change = TRUE; | 1170 | got_lnk_change = TRUE; |
943 | lnk_change = ""; | 1171 | lnk_change = QString::null; |
944 | } else { | 1172 | } else { |
945 | updateDocs(); | 1173 | updateLink( QString::null ); |
946 | } | 1174 | } |
947 | } | 1175 | } |
948 | 1176 | ||
@@ -951,7 +1179,7 @@ bool Launcher::mkdir(const QString &localPath) | |||
951 | { | 1179 | { |
952 | QDir fullDir(localPath); | 1180 | QDir fullDir(localPath); |
953 | if (fullDir.exists()) | 1181 | if (fullDir.exists()) |
954 | return true; | 1182 | return true; |
955 | 1183 | ||
956 | // at this point the directory doesn't exist | 1184 | // at this point the directory doesn't exist |
957 | // go through the directory tree and start creating the direcotories | 1185 | // go through the directory tree and start creating the direcotories |
@@ -963,30 +1191,30 @@ bool Launcher::mkdir(const QString &localPath) | |||
963 | 1191 | ||
964 | // didn't find any seps; weird, use the cur dir instead | 1192 | // didn't find any seps; weird, use the cur dir instead |
965 | if (dirIndex == -1) { | 1193 | if (dirIndex == -1) { |
966 | //qDebug("No seperators found in path %s", localPath.latin1()); | 1194 | //qDebug("No seperators found in path %s", localPath.latin1()); |
967 | checkedPath = QDir::currentDirPath(); | 1195 | checkedPath = QDir::currentDirPath(); |
968 | } | 1196 | } |
969 | 1197 | ||
970 | while (checkedPath != localPath) { | 1198 | while (checkedPath != localPath) { |
971 | // no more seperators found, use the local path | 1199 | // no more seperators found, use the local path |
972 | if (dirIndex == -1) | 1200 | if (dirIndex == -1) |
973 | checkedPath = localPath; | 1201 | checkedPath = localPath; |
974 | else { | 1202 | else { |
975 | // the next directory to check | 1203 | // the next directory to check |
976 | checkedPath = localPath.left(dirIndex) + "/"; | 1204 | checkedPath = localPath.left(dirIndex) + "/"; |
977 | // advance the iterator; the next dir seperator | 1205 | // advance the iterator; the next dir seperator |
978 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 1206 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
979 | } | 1207 | } |
980 | 1208 | ||
981 | QDir checkDir(checkedPath); | 1209 | QDir checkDir(checkedPath); |
982 | if (!checkDir.exists()) { | 1210 | if (!checkDir.exists()) { |
983 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 1211 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
984 | 1212 | ||
985 | if (!checkDir.mkdir(checkedPath)) { | 1213 | if (!checkDir.mkdir(checkedPath)) { |
986 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 1214 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
987 | return FALSE; | 1215 | return FALSE; |
988 | } | 1216 | } |
989 | } | 1217 | } |
990 | 1218 | ||
991 | } | 1219 | } |
992 | return TRUE; | 1220 | return TRUE; |
@@ -998,6 +1226,8 @@ void Launcher::preloadApps() | |||
998 | cfg.setGroup("Preload"); | 1226 | cfg.setGroup("Preload"); |
999 | QStringList apps = cfg.readListEntry("Apps",','); | 1227 | QStringList apps = cfg.readListEntry("Apps",','); |
1000 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 1228 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
1001 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 1229 | #ifndef QT_NO_COP |
1230 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | ||
1231 | #endif | ||
1002 | } | 1232 | } |
1003 | } | 1233 | } |
diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h index d2efa58..e3881ea 100644 --- a/core/launcher/launcher.h +++ b/core/launcher/launcher.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of 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 |
@@ -20,6 +20,7 @@ | |||
20 | #ifndef LAUNCHER_H | 20 | #ifndef LAUNCHER_H |
21 | #define LAUNCHER_H | 21 | #define LAUNCHER_H |
22 | 22 | ||
23 | #include <qpe/config.h> | ||
23 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
24 | #include <qtabbar.h> | 25 | #include <qtabbar.h> |
25 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
@@ -60,6 +61,8 @@ public: | |||
60 | void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); | 61 | void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); |
61 | void updateLink(const QString& linkfile); | 62 | void updateLink(const QString& linkfile); |
62 | void setBusy(bool on); | 63 | void setBusy(bool on); |
64 | QString getAllDocLinkInfo() const; | ||
65 | LauncherView *view( const QString &id ); | ||
63 | 66 | ||
64 | signals: | 67 | signals: |
65 | void selected(const QString&); | 68 | void selected(const QString&); |
@@ -70,7 +73,11 @@ public slots: | |||
70 | void nextTab(); | 73 | void nextTab(); |
71 | void prevTab(); | 74 | void prevTab(); |
72 | 75 | ||
76 | protected slots: | ||
77 | void tabProperties(); | ||
78 | |||
73 | protected: | 79 | protected: |
80 | void setTabAppearance( const QString &id, Config &cfg ); | ||
74 | void paletteChange( const QPalette &p ); | 81 | void paletteChange( const QPalette &p ); |
75 | 82 | ||
76 | private: | 83 | private: |
@@ -111,6 +118,7 @@ signals: | |||
111 | private slots: | 118 | private slots: |
112 | void doMaximize(); | 119 | void doMaximize(); |
113 | void systemMessage( const QCString &, const QByteArray &); | 120 | void systemMessage( const QCString &, const QByteArray &); |
121 | void launcherMessage( const QCString &, const QByteArray &); | ||
114 | void storageChanged(); | 122 | void storageChanged(); |
115 | void cancelSync(); | 123 | void cancelSync(); |
116 | 124 | ||
@@ -132,6 +140,7 @@ private: | |||
132 | bool in_lnk_props; | 140 | bool in_lnk_props; |
133 | bool got_lnk_change; | 141 | bool got_lnk_change; |
134 | QString lnk_change; | 142 | QString lnk_change; |
143 | |||
135 | QString m_timeStamp; | 144 | QString m_timeStamp; |
136 | Qtopia::UidGen uidgen; | 145 | Qtopia::UidGen uidgen; |
137 | }; | 146 | }; |
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index c54a00f..047fe45 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -1,7 +1,7 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of 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 |
@@ -23,14 +23,16 @@ | |||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/applnk.h> | 24 | #include <qpe/applnk.h> |
25 | #include <qpe/qpedebug.h> | 25 | #include <qpe/qpedebug.h> |
26 | #include <qpe/config.h> | ||
27 | #include <qpe/categories.h> | 26 | #include <qpe/categories.h> |
28 | #include <qpe/categoryselect.h> | 27 | #include <qpe/categoryselect.h> |
29 | #include <qpe/menubutton.h> | 28 | #include <qpe/menubutton.h> |
29 | #include <qpe/mimetype.h> | ||
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | #include <qpe/qpetoolbar.h> | 31 | #include <qpe/qpetoolbar.h> |
32 | //#include <qtopia/private/palmtoprecord.h> | ||
32 | 33 | ||
33 | #include <qtimer.h> | 34 | #include <qtimer.h> |
35 | #include <qtextstream.h> | ||
34 | #include <qdict.h> | 36 | #include <qdict.h> |
35 | #include <qfile.h> | 37 | #include <qfile.h> |
36 | #include <qfileinfo.h> | 38 | #include <qfileinfo.h> |
@@ -39,70 +41,102 @@ | |||
39 | #include <qpainter.h> | 41 | #include <qpainter.h> |
40 | #include <qregexp.h> | 42 | #include <qregexp.h> |
41 | #include <qtoolbutton.h> | 43 | #include <qtoolbutton.h> |
44 | #include <qimage.h> | ||
42 | 45 | ||
43 | class LauncherIconView : public QIconView { | 46 | |
47 | class BgPixmap | ||
48 | { | ||
44 | public: | 49 | public: |
45 | QColor iconText; | 50 | BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} |
46 | QColor background; | 51 | QPixmap pm; |
52 | int ref; | ||
53 | }; | ||
54 | |||
55 | static QMap<QString,BgPixmap*> *bgCache = 0; | ||
47 | 56 | ||
57 | class LauncherIconView : public QIconView { | ||
58 | public: | ||
48 | LauncherIconView( QWidget* parent, const char* name=0 ) : | 59 | LauncherIconView( QWidget* parent, const char* name=0 ) : |
49 | QIconView(parent,name), | 60 | QIconView(parent,name), |
50 | tf(""), | 61 | tf(""), |
51 | cf(0), | 62 | cf(0), |
52 | bsy(0) | 63 | bsy(0), |
64 | bigIcns(TRUE), | ||
65 | bgColor(white) | ||
53 | { | 66 | { |
54 | sortmeth = Name; | 67 | sortmeth = Name; |
55 | hidden.setAutoDelete(TRUE); | 68 | hidden.setAutoDelete(TRUE); |
56 | ike = FALSE; | 69 | ike = FALSE; |
57 | 70 | calculateGrid( Bottom ); | |
58 | Config config( "qpe" ); | ||
59 | config.setGroup( "Appearance" ); | ||
60 | iconText = QColor( config.readEntry( "LauncherIconText", "#000000" ) ); | ||
61 | background = QColor( config.readEntry( "LauncherBackground", "#FFFFFF" ) ); | ||
62 | } | 71 | } |
63 | 72 | ||
64 | ~LauncherIconView() | 73 | ~LauncherIconView() |
65 | { | 74 | { |
66 | #if 0 // debuggery | 75 | #if 0 // debuggery |
67 | QListIterator<AppLnk> it(hidden); | 76 | QListIterator<AppLnk> it(hidden); |
68 | AppLnk* l; | 77 | AppLnk* l; |
69 | while ((l=it.current())) { | 78 | while ((l=it.current())) { |
70 | ++it; | 79 | ++it; |
71 | //qDebug("%p: hidden (should remove)",l); | 80 | //qDebug("%p: hidden (should remove)",l); |
72 | } | 81 | } |
73 | #endif | 82 | #endif |
74 | } | 83 | } |
75 | 84 | ||
85 | QPixmap* busyPixmap() const { return (QPixmap*)&bpm; } | ||
76 | QIconViewItem* busyItem() const { return bsy; } | 86 | QIconViewItem* busyItem() const { return bsy; } |
87 | void setBigIcons( bool bi ) { bigIcns = bi; } | ||
77 | 88 | ||
78 | void updateCategoriesAndMimeTypes(); | 89 | void updateCategoriesAndMimeTypes(); |
79 | 90 | ||
80 | void doAutoScroll() | 91 | void doAutoScroll() |
81 | { | 92 | { |
82 | // We don't want rubberbanding (yet) | 93 | // We don't want rubberbanding (yet) |
83 | } | 94 | } |
84 | 95 | ||
85 | void setBusy(bool on) | 96 | void setBusy(bool on) |
86 | { | 97 | { |
87 | QIconViewItem *c = on ? currentItem() : 0; | 98 | QIconViewItem *c = on ? currentItem() : 0; |
88 | if ( bsy != c ) { | 99 | if ( bsy != c ) { |
89 | QIconViewItem* o = bsy; | 100 | if ( c ) { |
90 | bsy = c; | 101 | QPixmap *src = c->pixmap(); |
91 | if ( o ) o->repaint(); | 102 | QImage img = src->convertToImage(); |
92 | if ( c ) c->repaint(); | 103 | QRgb* rgb; |
93 | } | 104 | int count; |
105 | if ( img.depth() == 32 ) { | ||
106 | rgb = (QRgb*)img.bits(); | ||
107 | count = img.bytesPerLine()/sizeof(QRgb)*img.height(); | ||
108 | } else { | ||
109 | rgb = img.colorTable(); | ||
110 | count = img.numColors(); | ||
111 | } | ||
112 | int rc, gc, bc; | ||
113 | colorGroup().highlight().rgb( &rc, &gc, &bc ); | ||
114 | int ri, gi, bi; | ||
115 | for ( int r = 0; r < count; r++, rgb++ ) { | ||
116 | int ri = (rc+qRed(*rgb))/2; | ||
117 | int gi = (gc+qGreen(*rgb))/2; | ||
118 | int bi = (bc+qBlue(*rgb))/2; | ||
119 | int ai = qAlpha(*rgb); | ||
120 | *rgb = qRgba(ri,gi,bi,ai); | ||
121 | } | ||
122 | |||
123 | bpm.convertFromImage( img ); | ||
124 | } | ||
125 | QIconViewItem* o = bsy; | ||
126 | bsy = c; | ||
127 | if ( o ) o->repaint(); | ||
128 | if ( c ) c->repaint(); | ||
129 | } | ||
94 | } | 130 | } |
95 | 131 | ||
96 | bool inKeyEvent() const { return ike; } | 132 | bool inKeyEvent() const { return ike; } |
97 | void keyPressEvent(QKeyEvent* e) | 133 | void keyPressEvent(QKeyEvent* e) |
98 | { | 134 | { |
99 | ike = TRUE; | 135 | ike = TRUE; |
100 | if ( e->key() == Key_F33 ) { | 136 | if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) |
101 | // "OK" button | 137 | returnPressed(currentItem()); |
102 | returnPressed(currentItem()); | 138 | QIconView::keyPressEvent(e); |
103 | } | 139 | ike = FALSE; |
104 | QIconView::keyPressEvent(e); | ||
105 | ike = FALSE; | ||
106 | } | 140 | } |
107 | 141 | ||
108 | void addItem(AppLnk* app, bool resort=TRUE); | 142 | void addItem(AppLnk* app, bool resort=TRUE); |
@@ -113,141 +147,131 @@ public: | |||
113 | 147 | ||
114 | void clear() | 148 | void clear() |
115 | { | 149 | { |
116 | mimes.clear(); | 150 | mimes.clear(); |
117 | cats.clear(); | 151 | cats.clear(); |
118 | QIconView::clear(); | 152 | QIconView::clear(); |
119 | hidden.clear(); | 153 | hidden.clear(); |
120 | } | 154 | } |
121 | 155 | ||
122 | void addCatsAndMimes(AppLnk* app) | 156 | void addCatsAndMimes(AppLnk* app) |
123 | { | 157 | { |
124 | // QStringList c = app->categories(); | 158 | // QStringList c = app->categories(); |
125 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { | 159 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { |
126 | // cats.replace(*cit,(void*)1); | 160 | // cats.replace(*cit,(void*)1); |
127 | // } | 161 | // } |
128 | QString maj=app->type(); | 162 | QString maj=app->type(); |
129 | int sl=maj.find('/'); | 163 | int sl=maj.find('/'); |
130 | if (sl>=0) { | 164 | if (sl>=0) { |
131 | QString k = maj.left(sl); | 165 | QString k; |
132 | mimes.replace(k,(void*)1); | 166 | k = maj.left(12) == "application/" ? maj : maj.left(sl); |
133 | } | 167 | mimes.replace(k,(void*)1); |
168 | } | ||
169 | } | ||
170 | |||
171 | void setBackgroundPixmap( const QPixmap &pm ) { | ||
172 | bgPixmap = pm; | ||
173 | } | ||
174 | |||
175 | void setBackgroundColor( const QColor &c ) { | ||
176 | bgColor = c; | ||
134 | } | 177 | } |
135 | 178 | ||
136 | void drawBackground( QPainter *p, const QRect &r ) | 179 | void drawBackground( QPainter *p, const QRect &r ) |
137 | { | 180 | { |
138 | Config config("qpe"); | 181 | if ( !bgPixmap.isNull() ) { |
139 | config.setGroup("Appearance"); | 182 | p->drawTiledPixmap( r, bgPixmap, |
140 | QString backgroundImage = config.readEntry("BackgroundImage","launcher/opie-background"); | 183 | QPoint( (r.x() + contentsX()) % bgPixmap.width(), |
141 | // if (backgroundImage.isNull()) backgroundImage="launcher/opie-background"; | 184 | (r.y() + contentsY()) % bgPixmap.height() ) ); |
142 | int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0; | 185 | } else { |
143 | //int backgroundMode = 2; | 186 | p->fillRect( r, bgColor ); |
144 | 187 | } | |
145 | if ( backgroundMode == 1 ) { | 188 | } |
146 | 189 | ||
147 | // Double buffer the background | 190 | void setItemTextPos( ItemTextPos pos ) |
148 | static QPixmap *bg = NULL; | 191 | { |
149 | static QColor bgColor; | 192 | calculateGrid( pos ); |
150 | 193 | QIconView::setItemTextPos( pos ); | |
151 | if ( (bg == NULL) || (bgColor != colorGroup().button()) ) { | ||
152 | // Create a new background double buffer | ||
153 | if (bg == NULL) | ||
154 | bg = new QPixmap( width(), height() ); | ||
155 | bgColor = colorGroup().button(); | ||
156 | QPainter painter( bg ); | ||
157 | |||
158 | // painter.fillRect( QRect( 0, 0, width(), height() ), colorGroup().background().light(110)); | ||
159 | painter.fillRect( QRect( 0, 0, width(), height() ), background); | ||
160 | // Overlay the Qtopia logo in the center | ||
161 | QImage logo; | ||
162 | if (QFile::exists(backgroundImage)) { | ||
163 | logo = QImage(backgroundImage); | ||
164 | } else { | ||
165 | logo = Resource::loadImage(backgroundImage ); | ||
166 | } | ||
167 | if ( !logo.isNull() && config.readBoolEntry( "UseBackgroundImage", TRUE ) ) | ||
168 | painter.drawImage( (width() - logo.width()) / 2, | ||
169 | (height() - logo.height()) / 2, logo ); | ||
170 | } | ||
171 | |||
172 | // Draw the double buffer to the widget (it is tiled for when the icon view is large) | ||
173 | p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), | ||
174 | (r.y() + contentsY()) % bg->height() ) ); | ||
175 | } else if ( backgroundMode == 2 ) { | ||
176 | static QPixmap *bg = 0; | ||
177 | static QColor bgColor; | ||
178 | if ( !bg || (bgColor != colorGroup().background()) ) { | ||
179 | bgColor = colorGroup().background(); | ||
180 | bg = new QPixmap( width(), 9 ); | ||
181 | QPainter painter( bg ); | ||
182 | for ( int i = 0; i < 3; i++ ) { | ||
183 | painter.setPen( colorGroup().background().light(130) ); | ||
184 | painter.drawLine( 0, i*3, width()-1, i*3 ); | ||
185 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); | ||
186 | painter.setPen( colorGroup().background().light(105) ); | ||
187 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); | ||
188 | } | ||
189 | } | ||
190 | p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), | ||
191 | (r.y() + contentsY()) % bg->height() ) ); | ||
192 | } else { | ||
193 | p->fillRect( r, QBrush( colorGroup().background().light(110) ) ); | ||
194 | } | ||
195 | } | 194 | } |
196 | 195 | ||
197 | void hideOrShowItems(bool resort); | 196 | void hideOrShowItems(bool resort); |
198 | 197 | ||
199 | void setTypeFilter(const QString& typefilter, bool resort) | 198 | void setTypeFilter(const QString& typefilter, bool resort) |
200 | { | 199 | { |
201 | tf = QRegExp(typefilter,FALSE,TRUE); | 200 | tf = QRegExp(typefilter,FALSE,TRUE); |
202 | hideOrShowItems(resort); | 201 | hideOrShowItems(resort); |
203 | } | 202 | } |
204 | 203 | ||
205 | void setCategoryFilter( int catfilter, bool resort ) | 204 | void setCategoryFilter( int catfilter, bool resort ) |
206 | { | 205 | { |
207 | Categories cat; | 206 | Categories cat; |
208 | cat.load( categoryFileName() ); | 207 | cat.load( categoryFileName() ); |
209 | QString str; | 208 | QString str; |
210 | if ( catfilter == -2 ) | 209 | if ( catfilter == -2 ) |
211 | cf = 0; | 210 | cf = 0; |
212 | else | 211 | else |
213 | cf = catfilter; | 212 | cf = catfilter; |
214 | hideOrShowItems(resort); | 213 | hideOrShowItems(resort); |
215 | } | 214 | } |
216 | 215 | ||
217 | enum SortMethod { Name, Date, Type }; | 216 | enum SortMethod { Name, Date, Type }; |
218 | 217 | ||
219 | void setSortMethod( SortMethod m ) | 218 | void setSortMethod( SortMethod m ) |
220 | { | 219 | { |
221 | if ( sortmeth != m ) { | 220 | if ( sortmeth != m ) { |
222 | sortmeth = m; | 221 | sortmeth = m; |
223 | sort(); | 222 | sort(); |
224 | } | 223 | } |
225 | } | 224 | } |
226 | 225 | ||
227 | int compare(const AppLnk* a, const AppLnk* b) | 226 | int compare(const AppLnk* a, const AppLnk* b) |
228 | { | 227 | { |
229 | switch (sortmeth) { | 228 | switch (sortmeth) { |
230 | case Name: | 229 | case Name: |
231 | return a->name().compare(b->name()); | 230 | return a->name().compare(b->name()); |
232 | case Date: { | 231 | case Date: { |
233 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); | 232 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); |
234 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); | 233 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); |
235 | return fa.lastModified().secsTo(fb.lastModified()); | 234 | return fa.lastModified().secsTo(fb.lastModified()); |
236 | } | 235 | } |
237 | case Type: | 236 | case Type: |
238 | return a->type().compare(b->type()); | 237 | return a->type().compare(b->type()); |
239 | } | 238 | } |
240 | return 0; | 239 | return 0; |
241 | } | 240 | } |
242 | 241 | ||
242 | QString getAllDocLinkInfo() const; | ||
243 | |||
243 | protected: | 244 | protected: |
244 | 245 | ||
245 | void styleChange( QStyle &old ) | 246 | void styleChange( QStyle &old ) |
246 | { | 247 | { |
247 | QIconView::styleChange( old ); | 248 | QIconView::styleChange( old ); |
248 | //### duplicated code from LauncherView constructor | 249 | calculateGrid( itemTextPos() ); |
249 | int dw = QApplication::desktop()->width(); | 250 | } |
250 | setGridX( (dw-13-style().scrollBarExtent().width())/ (dw/80) ); // tweaked for 8pt+dw=176 and 10pt+dw=240 | 251 | |
252 | void calculateGrid( ItemTextPos pos ) | ||
253 | { | ||
254 | int dw = QApplication::desktop()->width(); | ||
255 | int viewerWidth = dw-style().scrollBarExtent().width(); | ||
256 | if ( pos == Bottom ) { | ||
257 | int cols = 3; | ||
258 | if ( viewerWidth <= 200 ) | ||
259 | cols = 2; | ||
260 | else if ( viewerWidth >= 400 ) | ||
261 | cols = viewerWidth/96; | ||
262 | setSpacing( 4 ); | ||
263 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | ||
264 | setGridY( fontMetrics().height()*2+24 ); | ||
265 | } else { | ||
266 | int cols = 2; | ||
267 | if ( viewerWidth < 150 ) | ||
268 | cols = 1; | ||
269 | else if ( viewerWidth >= 400 ) | ||
270 | cols = viewerWidth/150; | ||
271 | setSpacing( 2 ); | ||
272 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | ||
273 | setGridY( fontMetrics().height()+2 ); | ||
274 | } | ||
251 | } | 275 | } |
252 | 276 | ||
253 | private: | 277 | private: |
@@ -259,7 +283,10 @@ private: | |||
259 | int cf; | 283 | int cf; |
260 | QIconViewItem* bsy; | 284 | QIconViewItem* bsy; |
261 | bool ike; | 285 | bool ike; |
262 | 286 | bool bigIcns; | |
287 | QPixmap bgPixmap; | ||
288 | QPixmap bpm; | ||
289 | QColor bgColor; | ||
263 | }; | 290 | }; |
264 | 291 | ||
265 | 292 | ||
@@ -273,13 +300,13 @@ void LauncherView::setBusy(bool on) | |||
273 | class LauncherItem : public QIconViewItem | 300 | class LauncherItem : public QIconViewItem |
274 | { | 301 | { |
275 | public: | 302 | public: |
276 | LauncherItem( QIconView *parent, AppLnk* applnk ); | 303 | LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); |
277 | ~LauncherItem() | 304 | ~LauncherItem() |
278 | { | 305 | { |
279 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 306 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
280 | if ( liv->busyItem() == this ) | 307 | if ( liv->busyItem() == this ) |
281 | liv->setBusy(FALSE); | 308 | liv->setBusy(FALSE); |
282 | delete app; | 309 | delete app; |
283 | } | 310 | } |
284 | 311 | ||
285 | AppLnk* appLnk() const { return app; } | 312 | AppLnk* appLnk() const { return app; } |
@@ -289,26 +316,24 @@ public: | |||
289 | 316 | ||
290 | void paintItem( QPainter *p, const QColorGroup &cg ) | 317 | void paintItem( QPainter *p, const QColorGroup &cg ) |
291 | { | 318 | { |
292 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 319 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
293 | QBrush oldBrush( liv->itemTextBackground() ); | 320 | QBrush oldBrush( liv->itemTextBackground() ); |
294 | QColorGroup mycg( cg ); | 321 | QColorGroup mycg( cg ); |
295 | if ( liv->currentItem() == this ) { | 322 | if ( liv->currentItem() == this ) { |
296 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); | 323 | liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); |
297 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); | 324 | mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); |
298 | } | 325 | } |
299 | else { | 326 | QIconViewItem::paintItem(p,mycg); |
300 | mycg.setColor( QColorGroup::Text, liv->iconText ); | 327 | if ( liv->currentItem() == this ) |
301 | } | 328 | liv->setItemTextBackground( oldBrush ); |
302 | 329 | } | |
303 | QIconViewItem::paintItem(p,mycg); | 330 | |
304 | if ( liv->currentItem() == this ) | 331 | virtual QPixmap* pixmap () const |
305 | liv->setItemTextBackground( oldBrush ); | 332 | { |
306 | if ( liv->busyItem() == this ) { | 333 | const LauncherIconView* liv = (LauncherIconView*)iconView(); |
307 | static QPixmap* busypm=0; | 334 | if ( (const LauncherItem *)liv->busyItem() == this ) |
308 | if ( !busypm ) | 335 | return liv->busyPixmap(); |
309 | busypm = new QPixmap(Resource::loadPixmap("launching")); | 336 | return QIconViewItem::pixmap(); |
310 | p->drawPixmap(x()+(width()-busypm->width())/2, y(),*busypm); | ||
311 | } | ||
312 | } | 337 | } |
313 | 338 | ||
314 | protected: | 339 | protected: |
@@ -316,9 +341,10 @@ protected: | |||
316 | }; | 341 | }; |
317 | 342 | ||
318 | 343 | ||
319 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk ) | 344 | LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) |
320 | : QIconViewItem( parent, applnk->name(), applnk->bigPixmap() ), | 345 | : QIconViewItem( parent, applnk->name(), |
321 | app(applnk) // Takes ownership | 346 | bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), |
347 | app(applnk) // Takes ownership | ||
322 | { | 348 | { |
323 | } | 349 | } |
324 | 350 | ||
@@ -333,8 +359,8 @@ QStringList LauncherIconView::mimeTypes() const | |||
333 | QStringList r; | 359 | QStringList r; |
334 | QDictIterator<void> it(mimes); | 360 | QDictIterator<void> it(mimes); |
335 | while (it.current()) { | 361 | while (it.current()) { |
336 | r.append(it.currentKey()); | 362 | r.append(it.currentKey()); |
337 | ++it; | 363 | ++it; |
338 | } | 364 | } |
339 | r.sort(); | 365 | r.sort(); |
340 | return r; | 366 | return r; |
@@ -345,13 +371,13 @@ void LauncherIconView::addItem(AppLnk* app, bool resort) | |||
345 | addCatsAndMimes(app); | 371 | addCatsAndMimes(app); |
346 | 372 | ||
347 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) | 373 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) |
348 | && (cf == 0 || app->categories().contains(cf) | 374 | && (cf == 0 || app->categories().contains(cf) |
349 | || cf == -1 && app->categories().count() == 0 ) ) | 375 | || cf == -1 && app->categories().count() == 0 ) ) |
350 | (void) new LauncherItem( this, app ); | 376 | (void) new LauncherItem( this, app, bigIcns ); |
351 | else | 377 | else |
352 | hidden.append(app); | 378 | hidden.append(app); |
353 | if ( resort ) | 379 | if ( resort ) |
354 | sort(); | 380 | sort(); |
355 | } | 381 | } |
356 | 382 | ||
357 | void LauncherIconView::updateCategoriesAndMimeTypes() | 383 | void LauncherIconView::updateCategoriesAndMimeTypes() |
@@ -360,14 +386,14 @@ void LauncherIconView::updateCategoriesAndMimeTypes() | |||
360 | cats.clear(); | 386 | cats.clear(); |
361 | LauncherItem* item = (LauncherItem*)firstItem(); | 387 | LauncherItem* item = (LauncherItem*)firstItem(); |
362 | while (item) { | 388 | while (item) { |
363 | addCatsAndMimes(item->appLnk()); | 389 | addCatsAndMimes(item->appLnk()); |
364 | item = (LauncherItem*)item->nextItem(); | 390 | item = (LauncherItem*)item->nextItem(); |
365 | } | 391 | } |
366 | QListIterator<AppLnk> it(hidden); | 392 | QListIterator<AppLnk> it(hidden); |
367 | AppLnk* l; | 393 | AppLnk* l; |
368 | while ((l=it.current())) { | 394 | while ((l=it.current())) { |
369 | addCatsAndMimes(l); | 395 | addCatsAndMimes(l); |
370 | ++it; | 396 | ++it; |
371 | } | 397 | } |
372 | } | 398 | } |
373 | 399 | ||
@@ -379,21 +405,20 @@ void LauncherIconView::hideOrShowItems(bool resort) | |||
379 | hidden.setAutoDelete(TRUE); | 405 | hidden.setAutoDelete(TRUE); |
380 | LauncherItem* item = (LauncherItem*)firstItem(); | 406 | LauncherItem* item = (LauncherItem*)firstItem(); |
381 | while (item) { | 407 | while (item) { |
382 | links.append(item->takeAppLnk()); | 408 | links.append(item->takeAppLnk()); |
383 | item = (LauncherItem*)item->nextItem(); | 409 | item = (LauncherItem*)item->nextItem(); |
384 | } | 410 | } |
385 | bool oldAutoArrange = autoArrange(); | 411 | viewport()->setUpdatesEnabled( FALSE ); |
386 | setAutoArrange( FALSE ); | ||
387 | clear(); | 412 | clear(); |
388 | QListIterator<AppLnk> it(links); | 413 | QListIterator<AppLnk> it(links); |
389 | AppLnk* l; | 414 | AppLnk* l; |
390 | while ((l=it.current())) { | 415 | while ((l=it.current())) { |
391 | addItem(l,FALSE); | 416 | addItem(l,FALSE); |
392 | ++it; | 417 | ++it; |
393 | } | 418 | } |
394 | if ( resort ) | 419 | viewport()->setUpdatesEnabled( TRUE ); |
395 | sort(); | 420 | if ( resort && !autoArrange() ) |
396 | setAutoArrange( oldAutoArrange ); | 421 | sort(); |
397 | } | 422 | } |
398 | 423 | ||
399 | bool LauncherIconView::removeLink(const QString& linkfile) | 424 | bool LauncherIconView::removeLink(const QString& linkfile) |
@@ -403,24 +428,82 @@ bool LauncherIconView::removeLink(const QString& linkfile) | |||
403 | bool did = FALSE; | 428 | bool did = FALSE; |
404 | DocLnk dl(linkfile); | 429 | DocLnk dl(linkfile); |
405 | while (item) { | 430 | while (item) { |
406 | l = item->appLnk(); | 431 | l = item->appLnk(); |
407 | if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) { | 432 | if ( l->linkFileKnown() && l->linkFile() == linkfile |
408 | delete item; | 433 | || l->fileKnown() && ( |
409 | did = TRUE; | 434 | l->file() == linkfile |
410 | } | 435 | || dl.isValid() && dl.file() == l->file() ) ) { |
411 | item = (LauncherItem*)item->nextItem(); | 436 | delete item; |
437 | did = TRUE; | ||
438 | } | ||
439 | item = (LauncherItem*)item->nextItem(); | ||
412 | } | 440 | } |
413 | QListIterator<AppLnk> it(hidden); | 441 | QListIterator<AppLnk> it(hidden); |
414 | while ((l=it.current())) { | 442 | while ((l=it.current())) { |
415 | ++it; | 443 | ++it; |
416 | if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) { | 444 | if ( l->linkFileKnown() && l->linkFile() == linkfile |
417 | hidden.removeRef(l); | 445 | || l->file() == linkfile |
418 | did = TRUE; | 446 | || dl.isValid() && dl.file() == l->file() ) { |
419 | } | 447 | hidden.removeRef(l); |
448 | did = TRUE; | ||
449 | } | ||
420 | } | 450 | } |
421 | return did; | 451 | return did; |
422 | } | 452 | } |
423 | 453 | ||
454 | static QString docLinkInfo(const Categories& cats, DocLnk* doc) | ||
455 | { | ||
456 | QString contents; | ||
457 | |||
458 | QFileInfo fi( doc->file() ); | ||
459 | if ( !fi.exists() ) | ||
460 | return contents; | ||
461 | |||
462 | if ( doc->linkFileKnown() ) { | ||
463 | QString lfn = doc->linkFile(); | ||
464 | QFile f( lfn ); | ||
465 | if ( f.open( IO_ReadOnly ) ) { | ||
466 | QTextStream ts( &f ); | ||
467 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | ||
468 | contents += ts.read(); | ||
469 | f.close(); | ||
470 | goto calcsize; | ||
471 | } | ||
472 | } | ||
473 | |||
474 | contents += "[Desktop Entry]\n"; | ||
475 | contents += "Categories = " // No tr | ||
476 | + cats.labels("Document View", doc->categories()).join(";") + "\n"; // No tr | ||
477 | contents += "File = "+doc->file()+"\n"; // No tr | ||
478 | contents += "Name = "+doc->name()+"\n"; // No tr | ||
479 | contents += "Type = "+doc->type()+"\n"; // No tr | ||
480 | |||
481 | calcsize: | ||
482 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr | ||
483 | return contents; | ||
484 | } | ||
485 | |||
486 | QString LauncherIconView::getAllDocLinkInfo() const | ||
487 | { | ||
488 | QString contents; | ||
489 | LauncherItem* item = (LauncherItem*)firstItem(); | ||
490 | Categories cats; | ||
491 | while (item) { | ||
492 | DocLnk* doc = (DocLnk*)item->appLnk(); | ||
493 | contents += docLinkInfo(cats,doc); | ||
494 | item = (LauncherItem*)item->nextItem(); | ||
495 | } | ||
496 | QListIterator<AppLnk> it(hidden); | ||
497 | DocLnk* doc; | ||
498 | while ((doc=(DocLnk*)it.current())) { | ||
499 | contents += docLinkInfo(cats,doc); | ||
500 | ++it; | ||
501 | } | ||
502 | return contents; | ||
503 | } | ||
504 | |||
505 | //=========================================================================== | ||
506 | |||
424 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) | 507 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) |
425 | : QVBox( parent, name, fl ) | 508 | : QVBox( parent, name, fl ) |
426 | { | 509 | { |
@@ -428,28 +511,28 @@ LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) | |||
428 | setFocusProxy(icons); | 511 | setFocusProxy(icons); |
429 | QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); | 512 | QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); |
430 | 513 | ||
431 | int dw = QApplication::desktop()->width(); | ||
432 | icons->setItemsMovable( FALSE ); | 514 | icons->setItemsMovable( FALSE ); |
433 | icons->setAutoArrange( TRUE ); | 515 | icons->setAutoArrange( TRUE ); |
434 | icons->setSorting( TRUE ); | 516 | icons->setSorting( TRUE ); |
435 | icons->setGridX( (dw-13-style().scrollBarExtent().width())/ (dw/80) ); // tweaked for 8pt+dw=176 and 10pt+dw=240 | ||
436 | icons->setGridY( fontMetrics().height()*2+24 ); | ||
437 | icons->setFrameStyle( QFrame::NoFrame ); | 517 | icons->setFrameStyle( QFrame::NoFrame ); |
438 | icons->setSpacing( 4 ); | ||
439 | icons->setMargin( 0 ); | 518 | icons->setMargin( 0 ); |
440 | icons->setSelectionMode( QIconView::Multi ); | 519 | icons->setSelectionMode( QIconView::NoSelection ); |
441 | icons->setBackgroundMode( PaletteBase ); | 520 | icons->setBackgroundMode( PaletteBase ); |
521 | icons->setResizeMode( QIconView::Fixed ); | ||
522 | vmode = (ViewMode)-1; | ||
523 | setViewMode( Icon ); | ||
442 | 524 | ||
443 | connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), | 525 | connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), |
444 | SLOT(itemClicked(int, QIconViewItem *)) ); | 526 | SLOT(itemClicked(int, QIconViewItem *)) ); |
445 | connect( icons, SIGNAL(selectionChanged()), | 527 | connect( icons, SIGNAL(selectionChanged()), |
446 | SLOT(selectionChanged()) ); | 528 | SLOT(selectionChanged()) ); |
447 | connect( icons, SIGNAL(returnPressed(QIconViewItem *)), | 529 | connect( icons, SIGNAL(returnPressed(QIconViewItem *)), |
448 | SLOT(returnPressed(QIconViewItem *)) ); | 530 | SLOT(returnPressed(QIconViewItem *)) ); |
449 | connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), | 531 | connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), |
450 | SLOT(itemPressed(int, QIconViewItem *)) ); | 532 | SLOT(itemPressed(int, QIconViewItem *)) ); |
451 | 533 | ||
452 | tools = 0; | 534 | tools = 0; |
535 | setBackgroundType( Ruled, QString::null ); | ||
453 | } | 536 | } |
454 | 537 | ||
455 | LauncherView::~LauncherView() | 538 | LauncherView::~LauncherView() |
@@ -459,33 +542,30 @@ LauncherView::~LauncherView() | |||
459 | void LauncherView::setToolsEnabled(bool y) | 542 | void LauncherView::setToolsEnabled(bool y) |
460 | { | 543 | { |
461 | if ( !y != !tools ) { | 544 | if ( !y != !tools ) { |
462 | if ( y ) { | 545 | if ( y ) { |
463 | tools = new QHBox(this); | 546 | tools = new QHBox(this); |
464 | 547 | ||
465 | // Type filter | 548 | // Type filter |
466 | typemb = new MenuButton(tools); | 549 | typemb = new QComboBox(tools); |
467 | typemb->setLabel(tr("Type: %1")); | ||
468 | typemb->setFixedHeight ( 20 ); | ||
469 | 550 | ||
470 | // Category filter | 551 | // Category filter |
471 | catmb = new CategorySelect(tools); | 552 | catmb = new CategorySelect(tools); |
472 | catmb->setFixedHeight ( 20 ); | ||
473 | 553 | ||
474 | updateTools(); | 554 | updateTools(); |
475 | tools->show(); | 555 | tools->show(); |
476 | } else { | 556 | } else { |
477 | delete tools; | 557 | delete tools; |
478 | tools = 0; | 558 | tools = 0; |
479 | } | 559 | } |
480 | } | 560 | } |
481 | } | 561 | } |
482 | 562 | ||
483 | void LauncherView::updateTools() | 563 | void LauncherView::updateTools() |
484 | { | 564 | { |
485 | disconnect( typemb, SIGNAL(selected(const QString&)), | 565 | disconnect( typemb, SIGNAL(activated(int)), |
486 | this, SLOT(showType(const QString&)) ); | 566 | this, SLOT(showType(int)) ); |
487 | disconnect( catmb, SIGNAL(signalSelected(int)), | 567 | disconnect( catmb, SIGNAL(signalSelected(int)), |
488 | this, SLOT(showCategory(int)) ); | 568 | this, SLOT(showCategory(int)) ); |
489 | 569 | ||
490 | icons->updateCategoriesAndMimeTypes(); | 570 | icons->updateCategoriesAndMimeTypes(); |
491 | 571 | ||
@@ -493,22 +573,43 @@ void LauncherView::updateTools() | |||
493 | 573 | ||
494 | // Type filter | 574 | // Type filter |
495 | QStringList types; | 575 | QStringList types; |
496 | types << tr("All"); | 576 | typelist = icons->mimeTypes(); |
497 | types << "--"; | 577 | for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { |
498 | types += icons->mimeTypes(); | 578 | QString t = *it; |
579 | if ( t.left(12) == "application/" ) { | ||
580 | MimeType mt(t); | ||
581 | const AppLnk* app = mt.application(); | ||
582 | if ( app ) | ||
583 | t = app->name(); | ||
584 | else | ||
585 | t = t.mid(12); | ||
586 | } else { | ||
587 | t[0] = t[0].upper(); | ||
588 | } | ||
589 | types += tr("%1 files").arg(t); | ||
590 | } | ||
591 | types << tr("All types of file"); | ||
499 | prev = typemb->currentText(); | 592 | prev = typemb->currentText(); |
500 | typemb->clear(); | 593 | typemb->clear(); |
501 | typemb->insertItems(types); | 594 | typemb->insertStringList(types); |
502 | typemb->select(prev); | 595 | for (int i=0; i<typemb->count(); i++) { |
596 | if ( typemb->text(i) == prev ) { | ||
597 | typemb->setCurrentItem(i); | ||
598 | break; | ||
599 | } | ||
600 | } | ||
601 | if ( prev.isNull() ) | ||
602 | typemb->setCurrentItem(typemb->count()-1); | ||
503 | 603 | ||
504 | Categories cats( 0 ); | 604 | Categories cats( 0 ); |
505 | cats.load( categoryFileName() ); | 605 | cats.load( categoryFileName() ); |
506 | QArray<int> vl( 0 ); | 606 | QArray<int> vl( 0 ); |
507 | catmb->setCategories( vl, "Document View", tr("Document View") ); | 607 | catmb->setCategories( vl, "Document View", // No tr |
608 | tr("Document View") ); | ||
508 | catmb->setRemoveCategoryEdit( TRUE ); | 609 | catmb->setRemoveCategoryEdit( TRUE ); |
509 | catmb->setAllCategories( TRUE ); | 610 | catmb->setAllCategories( TRUE ); |
510 | 611 | ||
511 | connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); | 612 | connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); |
512 | connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); | 613 | connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); |
513 | } | 614 | } |
514 | 615 | ||
@@ -517,12 +618,15 @@ void LauncherView::sortBy(int s) | |||
517 | icons->setSortMethod((LauncherIconView::SortMethod)s); | 618 | icons->setSortMethod((LauncherIconView::SortMethod)s); |
518 | } | 619 | } |
519 | 620 | ||
520 | void LauncherView::showType(const QString& t) | 621 | void LauncherView::showType(int t) |
521 | { | 622 | { |
522 | if ( t == tr("All") ) { | 623 | if ( t >= (int)typelist.count() ) { |
523 | icons->setTypeFilter("",TRUE); | 624 | icons->setTypeFilter("",TRUE); |
524 | } else { | 625 | } else { |
525 | icons->setTypeFilter(t+"/*",TRUE); | 626 | QString ty = typelist[t]; |
627 | if ( !ty.contains('/') ) | ||
628 | ty += "/*"; | ||
629 | icons->setTypeFilter(ty,TRUE); | ||
526 | } | 630 | } |
527 | } | 631 | } |
528 | 632 | ||
@@ -531,11 +635,124 @@ void LauncherView::showCategory( int c ) | |||
531 | icons->setCategoryFilter( c, TRUE ); | 635 | icons->setCategoryFilter( c, TRUE ); |
532 | } | 636 | } |
533 | 637 | ||
638 | void LauncherView::setViewMode( ViewMode m ) | ||
639 | { | ||
640 | if ( vmode != m ) { | ||
641 | bool bigIcons = m == Icon; | ||
642 | icons->viewport()->setUpdatesEnabled( FALSE ); | ||
643 | icons->setBigIcons( bigIcons ); | ||
644 | switch ( m ) { | ||
645 | case List: | ||
646 | icons->setItemTextPos( QIconView::Right ); | ||
647 | break; | ||
648 | case Icon: | ||
649 | icons->setItemTextPos( QIconView::Bottom ); | ||
650 | break; | ||
651 | } | ||
652 | icons->hideOrShowItems( FALSE ); | ||
653 | icons->viewport()->setUpdatesEnabled( TRUE ); | ||
654 | vmode = m; | ||
655 | } | ||
656 | } | ||
657 | |||
658 | void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) | ||
659 | { | ||
660 | if ( !bgCache ) | ||
661 | bgCache = new QMap<QString,BgPixmap*>; | ||
662 | if ( bgCache->contains( bgName ) ) | ||
663 | (*bgCache)[bgName]->ref--; | ||
664 | |||
665 | switch ( t ) { | ||
666 | case Ruled: { | ||
667 | bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr | ||
668 | QPixmap bg; | ||
669 | if ( bgCache->contains( bgName ) ) { | ||
670 | (*bgCache)[bgName]->ref++; | ||
671 | bg = (*bgCache)[bgName]->pm; | ||
672 | } else { | ||
673 | bg.resize( width(), 9 ); | ||
674 | QPainter painter( &bg ); | ||
675 | for ( int i = 0; i < 3; i++ ) { | ||
676 | painter.setPen( white ); | ||
677 | painter.drawLine( 0, i*3, width()-1, i*3 ); | ||
678 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); | ||
679 | painter.setPen( colorGroup().background().light(105) ); | ||
680 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); | ||
681 | } | ||
682 | painter.end(); | ||
683 | bgCache->insert( bgName, new BgPixmap(bg) ); | ||
684 | } | ||
685 | icons->setBackgroundPixmap( bg ); | ||
686 | break; | ||
687 | } | ||
688 | |||
689 | case SolidColor: | ||
690 | icons->setBackgroundPixmap( QPixmap() ); | ||
691 | if ( val.isEmpty() ) { | ||
692 | icons->setBackgroundColor( colorGroup().base() ); | ||
693 | } else { | ||
694 | icons->setBackgroundColor( val ); | ||
695 | } | ||
696 | bgName = ""; | ||
697 | break; | ||
698 | |||
699 | case Image: | ||
700 | bgName = val; | ||
701 | if ( bgCache->contains( bgName ) ) { | ||
702 | (*bgCache)[bgName]->ref++; | ||
703 | icons->setBackgroundPixmap( (*bgCache)[bgName]->pm ); | ||
704 | } else { | ||
705 | qDebug( "Loading image: %s", val.latin1() ); | ||
706 | QPixmap bg( Resource::loadPixmap( "wallpaper/" + val ) ); | ||
707 | if ( bg.isNull() ) { | ||
708 | QImageIO imgio; | ||
709 | imgio.setFileName( bgName ); | ||
710 | QSize ds = qApp->desktop()->size(); | ||
711 | QString param( "Scale( %1, %2, ScaleMin )" ); // No tr | ||
712 | imgio.setParameters( param.arg(ds.width()).arg(ds.height()).latin1() ); | ||
713 | imgio.read(); | ||
714 | bg = imgio.image(); | ||
715 | } | ||
716 | bgCache->insert( bgName, new BgPixmap(bg) ); | ||
717 | icons->setBackgroundPixmap( bg ); | ||
718 | } | ||
719 | break; | ||
720 | } | ||
721 | |||
722 | // remove unreferenced backgrounds. | ||
723 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); | ||
724 | while ( it != bgCache->end() ) { | ||
725 | QMap<QString,BgPixmap*>::Iterator curr = it; | ||
726 | ++it; | ||
727 | if ( (*curr)->ref == 0 ) { | ||
728 | delete (*curr); | ||
729 | bgCache->remove( curr ); | ||
730 | } | ||
731 | } | ||
732 | |||
733 | bgType = t; | ||
734 | icons->viewport()->update(); | ||
735 | } | ||
736 | |||
737 | void LauncherView::setTextColor( const QColor &tc ) | ||
738 | { | ||
739 | textCol = tc; | ||
740 | QColorGroup cg = icons->colorGroup(); | ||
741 | cg.setColor( QColorGroup::Text, tc ); | ||
742 | icons->setPalette( QPalette(cg,cg,cg) ); | ||
743 | icons->viewport()->update(); | ||
744 | } | ||
745 | |||
746 | void LauncherView::setViewFont( const QFont &f ) | ||
747 | { | ||
748 | icons->setFont( f ); | ||
749 | } | ||
750 | |||
534 | void LauncherView::resizeEvent(QResizeEvent *e) | 751 | void LauncherView::resizeEvent(QResizeEvent *e) |
535 | { | 752 | { |
536 | QVBox::resizeEvent( e ); | 753 | QVBox::resizeEvent( e ); |
537 | if ( e->size().width() != e->oldSize().width() ) | 754 | if ( e->size().width() != e->oldSize().width() ) |
538 | sort(); | 755 | sort(); |
539 | } | 756 | } |
540 | 757 | ||
541 | void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) | 758 | void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) |
@@ -544,49 +761,54 @@ void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) | |||
544 | internalPopulate( folder, typefilter ); | 761 | internalPopulate( folder, typefilter ); |
545 | } | 762 | } |
546 | 763 | ||
764 | QString LauncherView::getAllDocLinkInfo() const | ||
765 | { | ||
766 | return icons->getAllDocLinkInfo(); | ||
767 | } | ||
768 | |||
547 | void LauncherView::selectionChanged() | 769 | void LauncherView::selectionChanged() |
548 | { | 770 | { |
549 | QIconViewItem* item = icons->currentItem(); | 771 | QIconViewItem* item = icons->currentItem(); |
550 | if ( item && item->isSelected() ) { | 772 | if ( item && item->isSelected() ) { |
551 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 773 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
552 | if ( icons->inKeyEvent() ) // not for mouse press | 774 | if ( icons->inKeyEvent() ) // not for mouse press |
553 | emit clicked( appLnk ); | 775 | emit clicked( appLnk ); |
554 | item->setSelected(FALSE); | 776 | item->setSelected(FALSE); |
555 | } | 777 | } |
556 | } | 778 | } |
557 | 779 | ||
558 | void LauncherView::returnPressed( QIconViewItem *item ) | 780 | void LauncherView::returnPressed( QIconViewItem *item ) |
559 | { | 781 | { |
560 | if ( item ) { | 782 | if ( item ) { |
561 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 783 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
562 | emit clicked( appLnk ); | 784 | emit clicked( appLnk ); |
563 | } | 785 | } |
564 | } | 786 | } |
565 | 787 | ||
566 | void LauncherView::itemClicked( int btn, QIconViewItem *item ) | 788 | void LauncherView::itemClicked( int btn, QIconViewItem *item ) |
567 | { | 789 | { |
568 | if ( item ) { | 790 | if ( item ) { |
569 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 791 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
570 | if ( btn == LeftButton ) { | 792 | if ( btn == LeftButton ) { |
571 | // Make sure it's the item we execute that gets highlighted | 793 | // Make sure it's the item we execute that gets highlighted |
572 | icons->setCurrentItem( item ); | 794 | icons->setCurrentItem( item ); |
573 | emit clicked( appLnk ); | 795 | emit clicked( appLnk ); |
574 | } | 796 | } |
575 | item->setSelected(FALSE); | 797 | item->setSelected(FALSE); |
576 | } | 798 | } |
577 | } | 799 | } |
578 | 800 | ||
579 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) | 801 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) |
580 | { | 802 | { |
581 | if ( item ) { | 803 | if ( item ) { |
582 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 804 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
583 | if ( btn == RightButton ) | 805 | if ( btn == RightButton ) |
584 | emit rightPressed( appLnk ); | 806 | emit rightPressed( appLnk ); |
585 | /* | 807 | /* |
586 | else if ( btn == LeftButton ) | 808 | else if ( btn == LeftButton ) |
587 | emit clicked( appLnk ); | 809 | emit clicked( appLnk ); |
588 | */ | 810 | */ |
589 | item->setSelected(FALSE); | 811 | item->setSelected(FALSE); |
590 | } | 812 | } |
591 | } | 813 | } |
592 | 814 | ||
@@ -596,17 +818,15 @@ void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilte | |||
596 | icons->setTypeFilter(typefilter,FALSE); | 818 | icons->setTypeFilter(typefilter,FALSE); |
597 | 819 | ||
598 | while ( it.current() ) { | 820 | while ( it.current() ) { |
599 | // show only the icons for existing files | 821 | // show only the icons for existing files |
600 | if (!QFile(it.current()->file()).exists() & it.current()->file().left(4) != "http") | 822 | if (QFile(it.current()->file()).exists() || ( it.current()->file().left(4) == "http" )) { |
601 | { | 823 | icons->addItem(*it,FALSE); |
602 | //maybe insert some .desktop file deletion code later | 824 | } |
603 | //maybe dir specific | 825 | else { |
604 | } | 826 | //maybe insert some .desktop file deletion code later |
605 | else | 827 | //maybe dir specific |
606 | { | 828 | } |
607 | icons->addItem(*it,FALSE); | 829 | ++it; |
608 | } | ||
609 | ++it; | ||
610 | } | 830 | } |
611 | 831 | ||
612 | icons->sort(); | 832 | icons->sort(); |
@@ -631,3 +851,15 @@ void LauncherView::setFileSystems(const QList<FileSystem> &) | |||
631 | { | 851 | { |
632 | // ### does nothing now... | 852 | // ### does nothing now... |
633 | } | 853 | } |
854 | |||
855 | void LauncherView::paletteChange( const QPalette &p ) | ||
856 | { | ||
857 | icons->unsetPalette(); | ||
858 | QVBox::paletteChange( p ); | ||
859 | if ( bgType == Ruled ) | ||
860 | setBackgroundType( Ruled, QString::null ); | ||
861 | QColorGroup cg = icons->colorGroup(); | ||
862 | cg.setColor( QColorGroup::Text, textCol ); | ||
863 | icons->setPalette( QPalette(cg,cg,cg) ); | ||
864 | } | ||
865 | |||
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h index 3aaef7e..2fb37b6 100644 --- a/core/launcher/launcherview.h +++ b/core/launcher/launcherview.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of 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 |
@@ -31,6 +31,7 @@ class LauncherIconView; | |||
31 | class QIconView; | 31 | class QIconView; |
32 | class QIconViewItem; | 32 | class QIconViewItem; |
33 | class MenuButton; | 33 | class MenuButton; |
34 | class QComboBox; | ||
34 | 35 | ||
35 | class LauncherView : public QVBox | 36 | class LauncherView : public QVBox |
36 | { | 37 | { |
@@ -50,6 +51,20 @@ public: | |||
50 | 51 | ||
51 | void setBusy(bool); | 52 | void setBusy(bool); |
52 | 53 | ||
54 | QString getAllDocLinkInfo() const; | ||
55 | enum ViewMode { Icon, List }; | ||
56 | void setViewMode( ViewMode m ); | ||
57 | ViewMode viewMode() const { return vmode; } | ||
58 | |||
59 | enum BackgroundType { Ruled, SolidColor, Image }; | ||
60 | void setBackgroundType( BackgroundType t, const QString & ); | ||
61 | BackgroundType backgroundType() const { return bgType; } | ||
62 | |||
63 | void setTextColor( const QColor & ); | ||
64 | QColor textColor() const { return textCol; } | ||
65 | |||
66 | void setViewFont( const QFont & ); | ||
67 | |||
53 | public slots: | 68 | public slots: |
54 | void populate( AppLnkSet *folder, const QString& categoryfilter ); | 69 | void populate( AppLnkSet *folder, const QString& categoryfilter ); |
55 | 70 | ||
@@ -63,19 +78,25 @@ protected slots: | |||
63 | void itemClicked( int, QIconViewItem * ); | 78 | void itemClicked( int, QIconViewItem * ); |
64 | void itemPressed( int, QIconViewItem * ); | 79 | void itemPressed( int, QIconViewItem * ); |
65 | void sortBy(int); | 80 | void sortBy(int); |
66 | void showType(const QString&); | 81 | void showType(int); |
67 | void showCategory( int ); | 82 | void showCategory( int ); |
68 | void resizeEvent(QResizeEvent *); | 83 | void resizeEvent(QResizeEvent *); |
69 | 84 | ||
70 | protected: | 85 | protected: |
71 | void internalPopulate( AppLnkSet *, const QString& categoryfilter ); | 86 | void internalPopulate( AppLnkSet *, const QString& categoryfilter ); |
87 | void paletteChange( const QPalette & ); | ||
72 | 88 | ||
73 | private: | 89 | private: |
74 | static bool bsy; | 90 | static bool bsy; |
75 | QWidget* tools; | 91 | QWidget* tools; |
76 | LauncherIconView* icons; | 92 | LauncherIconView* icons; |
77 | MenuButton *typemb; | 93 | QComboBox *typemb; |
94 | QStringList typelist; | ||
78 | CategorySelect *catmb; | 95 | CategorySelect *catmb; |
96 | ViewMode vmode; | ||
97 | BackgroundType bgType; | ||
98 | QString bgName; | ||
99 | QColor textCol; | ||
79 | }; | 100 | }; |
80 | 101 | ||
81 | #endif // LAUNCHERVIEW_H | 102 | #endif // LAUNCHERVIEW_H |