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