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