author | sandman <sandman> | 2002-09-27 00:57:22 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-09-27 00:57:22 (UTC) |
commit | 6ac98209a82c5aa24ab09faf79525cd9aa5a8a1d (patch) (unidiff) | |
tree | 5a81f96aa27867e6ce30c1fe81b5004d73299cf7 | |
parent | 82012ba8a063b729dec92db60c939834530a9fa4 (diff) | |
download | opie-6ac98209a82c5aa24ab09faf79525cd9aa5a8a1d.zip opie-6ac98209a82c5aa24ab09faf79525cd9aa5a8a1d.tar.gz opie-6ac98209a82c5aa24ab09faf79525cd9aa5a8a1d.tar.bz2 |
- fixed the default bg type
-rw-r--r-- | core/launcher/launcher.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index dc81c9e..1bd1156 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -10,515 +10,515 @@ | |||
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT | 21 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT |
22 | // have this class. | 22 | // have this class. |
23 | #define QTOPIA_INTERNAL_FSLP | 23 | #define QTOPIA_INTERNAL_FSLP |
24 | 24 | ||
25 | #ifdef QWS | 25 | #ifdef QWS |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #endif | 27 | #endif |
28 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
29 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
30 | #include <qpe/config.h> | 30 | #include <qpe/config.h> |
31 | #include <qpe/global.h> | 31 | #include <qpe/global.h> |
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/mimetype.h> | 33 | #include <qpe/mimetype.h> |
34 | #include <qpe/storage.h> | 34 | #include <qpe/storage.h> |
35 | #include <qpe/palmtoprecord.h> | 35 | #include <qpe/palmtoprecord.h> |
36 | 36 | ||
37 | #include <qpe/version.h> | 37 | #include <qpe/version.h> |
38 | 38 | ||
39 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #ifdef QWS | 40 | #ifdef QWS |
41 | #include <qwindowsystem_qws.h> | 41 | #include <qwindowsystem_qws.h> |
42 | #endif | 42 | #endif |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qcombobox.h> | 44 | #include <qcombobox.h> |
45 | #include <qvbox.h> | 45 | #include <qvbox.h> |
46 | #include <qlayout.h> | 46 | #include <qlayout.h> |
47 | #include <qstyle.h> | 47 | #include <qstyle.h> |
48 | #include <qpushbutton.h> | 48 | #include <qpushbutton.h> |
49 | #include <qtabbar.h> | 49 | #include <qtabbar.h> |
50 | #include <qwidgetstack.h> | 50 | #include <qwidgetstack.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qmessagebox.h> | 53 | #include <qmessagebox.h> |
54 | #include <qframe.h> | 54 | #include <qframe.h> |
55 | #include <qpainter.h> | 55 | #include <qpainter.h> |
56 | #include <qlabel.h> | 56 | #include <qlabel.h> |
57 | #include <qtextstream.h> | 57 | #include <qtextstream.h> |
58 | #include <qpopupmenu.h> | 58 | #include <qpopupmenu.h> |
59 | 59 | ||
60 | #include "launcherview.h" | 60 | #include "launcherview.h" |
61 | #include "launcher.h" | 61 | #include "launcher.h" |
62 | #include "syncdialog.h" | 62 | #include "syncdialog.h" |
63 | #include "desktop.h" | 63 | #include "desktop.h" |
64 | #include <qpe/lnkproperties.h> | 64 | #include <qpe/lnkproperties.h> |
65 | //#include "mrulist.h" | 65 | //#include "mrulist.h" |
66 | #include "qrsync.h" | 66 | #include "qrsync.h" |
67 | #include <stdlib.h> | 67 | #include <stdlib.h> |
68 | #include <unistd.h> | 68 | #include <unistd.h> |
69 | 69 | ||
70 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 70 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
71 | #include <stdio.h> | 71 | #include <stdio.h> |
72 | #include <sys/vfs.h> | 72 | #include <sys/vfs.h> |
73 | #include <mntent.h> | 73 | #include <mntent.h> |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | #include <qpe/storage.h> | 76 | #include <qpe/storage.h> |
77 | #include "mediummountgui.h" | 77 | #include "mediummountgui.h" |
78 | 78 | ||
79 | namespace { | 79 | namespace { |
80 | QStringList configToMime( Config *cfg ){ | 80 | QStringList configToMime( Config *cfg ){ |
81 | QStringList mimes; | 81 | QStringList mimes; |
82 | bool tmpMime = true; | 82 | bool tmpMime = true; |
83 | cfg->setGroup("mimetypes" ); | 83 | cfg->setGroup("mimetypes" ); |
84 | tmpMime = cfg->readBoolEntry("all" ,true); | 84 | tmpMime = cfg->readBoolEntry("all" ,true); |
85 | if( tmpMime ){ | 85 | if( tmpMime ){ |
86 | mimes << QString::null; | 86 | mimes << QString::null; |
87 | return mimes; | 87 | return mimes; |
88 | }else{ | 88 | }else{ |
89 | tmpMime = cfg->readBoolEntry("audio", true ); | 89 | tmpMime = cfg->readBoolEntry("audio", true ); |
90 | if(tmpMime ) | 90 | if(tmpMime ) |
91 | mimes.append("audio/*" ); | 91 | mimes.append("audio/*" ); |
92 | 92 | ||
93 | tmpMime = cfg->readBoolEntry("image", true ); | 93 | tmpMime = cfg->readBoolEntry("image", true ); |
94 | if(tmpMime ) | 94 | if(tmpMime ) |
95 | mimes.append("image/*" ); | 95 | mimes.append("image/*" ); |
96 | 96 | ||
97 | tmpMime = cfg->readBoolEntry("text", true ); | 97 | tmpMime = cfg->readBoolEntry("text", true ); |
98 | if(tmpMime ) | 98 | if(tmpMime ) |
99 | mimes.append("text/*"); | 99 | mimes.append("text/*"); |
100 | 100 | ||
101 | tmpMime = cfg->readBoolEntry("video", true ); | 101 | tmpMime = cfg->readBoolEntry("video", true ); |
102 | if(tmpMime ) | 102 | if(tmpMime ) |
103 | mimes.append("video/*" ); | 103 | mimes.append("video/*" ); |
104 | } | 104 | } |
105 | return mimes; | 105 | return mimes; |
106 | } | 106 | } |
107 | 107 | ||
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | //#define SHOW_ALL | 112 | //#define SHOW_ALL |
113 | 113 | ||
114 | class CategoryTab : public QTab | 114 | class CategoryTab : public QTab |
115 | { | 115 | { |
116 | public: | 116 | public: |
117 | CategoryTab( const QIconSet &icon, const QString &text=QString::null ) | 117 | CategoryTab( const QIconSet &icon, const QString &text=QString::null ) |
118 | : QTab( icon, text ) | 118 | : QTab( icon, text ) |
119 | { | 119 | { |
120 | } | 120 | } |
121 | 121 | ||
122 | QColor bgColor; | 122 | QColor bgColor; |
123 | QColor fgColor; | 123 | QColor fgColor; |
124 | }; | 124 | }; |
125 | 125 | ||
126 | //=========================================================================== | 126 | //=========================================================================== |
127 | 127 | ||
128 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : | 128 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : |
129 | QVBox( parent ) | 129 | QVBox( parent ) |
130 | { | 130 | { |
131 | categoryBar = 0; | 131 | categoryBar = 0; |
132 | stack = 0; | 132 | stack = 0; |
133 | } | 133 | } |
134 | 134 | ||
135 | void CategoryTabWidget::prevTab() | 135 | void CategoryTabWidget::prevTab() |
136 | { | 136 | { |
137 | if ( categoryBar ) { | 137 | if ( categoryBar ) { |
138 | int n = categoryBar->count(); | 138 | int n = categoryBar->count(); |
139 | int tab = categoryBar->currentTab(); | 139 | int tab = categoryBar->currentTab(); |
140 | if ( tab >= 0 ) | 140 | if ( tab >= 0 ) |
141 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); | 141 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | void CategoryTabWidget::nextTab() | 145 | void CategoryTabWidget::nextTab() |
146 | { | 146 | { |
147 | if ( categoryBar ) { | 147 | if ( categoryBar ) { |
148 | int n = categoryBar->count(); | 148 | int n = categoryBar->count(); |
149 | int tab = categoryBar->currentTab(); | 149 | int tab = categoryBar->currentTab(); |
150 | categoryBar->setCurrentTab( (tab + 1)%n ); | 150 | categoryBar->setCurrentTab( (tab + 1)%n ); |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | void CategoryTabWidget::addItem( const QString& linkfile ) | 154 | void CategoryTabWidget::addItem( const QString& linkfile ) |
155 | { | 155 | { |
156 | int i=0; | 156 | int i=0; |
157 | AppLnk *app = new AppLnk(linkfile); | 157 | AppLnk *app = new AppLnk(linkfile); |
158 | if ( !app->isValid() ) { | 158 | if ( !app->isValid() ) { |
159 | delete app; | 159 | delete app; |
160 | app=0; | 160 | app=0; |
161 | } | 161 | } |
162 | if ( !app || !app->file().isEmpty() ) { | 162 | if ( !app || !app->file().isEmpty() ) { |
163 | // A document | 163 | // A document |
164 | delete app; | 164 | delete app; |
165 | app = new DocLnk(linkfile); | 165 | app = new DocLnk(linkfile); |
166 | if ( app->fileKnown() ) { | 166 | if ( app->fileKnown() ) { |
167 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); | 167 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); |
168 | } else { | 168 | } else { |
169 | ((LauncherView*)(stack->widget(ids.count()-1)))->sort(); | 169 | ((LauncherView*)(stack->widget(ids.count()-1)))->sort(); |
170 | delete app; | 170 | delete app; |
171 | } | 171 | } |
172 | return; | 172 | return; |
173 | } | 173 | } |
174 | // An application | 174 | // An application |
175 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { | 175 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { |
176 | if ( !(*it).isEmpty() ) { | 176 | if ( !(*it).isEmpty() ) { |
177 | QRegExp tf(*it,FALSE,TRUE); | 177 | QRegExp tf(*it,FALSE,TRUE); |
178 | if ( tf.match(app->type()) >= 0 ) { | 178 | if ( tf.match(app->type()) >= 0 ) { |
179 | ((LauncherView*)stack->widget(i))->addItem(app); | 179 | ((LauncherView*)stack->widget(i))->addItem(app); |
180 | return; | 180 | return; |
181 | } | 181 | } |
182 | i++; | 182 | i++; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | QCopEnvelope e("QPE/TaskBar","reloadApps()"); | 186 | QCopEnvelope e("QPE/TaskBar","reloadApps()"); |
187 | } | 187 | } |
188 | 188 | ||
189 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | 189 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, |
190 | AppLnkSet* docFolder, const QList<FileSystem> &fs) | 190 | AppLnkSet* docFolder, const QList<FileSystem> &fs) |
191 | { | 191 | { |
192 | delete categoryBar; | 192 | delete categoryBar; |
193 | categoryBar = new CategoryTabBar( this ); | 193 | categoryBar = new CategoryTabBar( this ); |
194 | QPalette pal = categoryBar->palette(); | 194 | QPalette pal = categoryBar->palette(); |
195 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 195 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
196 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 196 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
197 | categoryBar->setPalette( pal ); | 197 | categoryBar->setPalette( pal ); |
198 | 198 | ||
199 | delete stack; | 199 | delete stack; |
200 | stack = new QWidgetStack(this); | 200 | stack = new QWidgetStack(this); |
201 | tabs=0; | 201 | tabs=0; |
202 | 202 | ||
203 | ids.clear(); | 203 | ids.clear(); |
204 | 204 | ||
205 | Config cfg("Launcher"); | 205 | Config cfg("Launcher"); |
206 | 206 | ||
207 | QStringList types = rootFolder->types(); | 207 | QStringList types = rootFolder->types(); |
208 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 208 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
209 | if ( !(*it).isEmpty() ) { | 209 | if ( !(*it).isEmpty() ) { |
210 | (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); | 210 | (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); |
211 | setTabAppearance( *it, cfg ); | 211 | setTabAppearance( *it, cfg ); |
212 | } | 212 | } |
213 | } | 213 | } |
214 | QListIterator<AppLnk> it( rootFolder->children() ); | 214 | QListIterator<AppLnk> it( rootFolder->children() ); |
215 | AppLnk* l; | 215 | AppLnk* l; |
216 | while ( (l=it.current()) ) { | 216 | while ( (l=it.current()) ) { |
217 | if ( l->type() == "Separator" ) { // No tr | 217 | if ( l->type() == "Separator" ) { // No tr |
218 | rootFolder->remove(l); | 218 | rootFolder->remove(l); |
219 | delete l; | 219 | delete l; |
220 | } else { | 220 | } else { |
221 | int i=0; | 221 | int i=0; |
222 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 222 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
223 | if ( *it == l->type() ) | 223 | if ( *it == l->type() ) |
224 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); | 224 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); |
225 | i++; | 225 | i++; |
226 | } | 226 | } |
227 | } | 227 | } |
228 | ++it; | 228 | ++it; |
229 | } | 229 | } |
230 | rootFolder->detachChildren(); | 230 | rootFolder->detachChildren(); |
231 | for (int i=0; i<tabs; i++) | 231 | for (int i=0; i<tabs; i++) |
232 | ((LauncherView*)stack->widget(i))->sort(); | 232 | ((LauncherView*)stack->widget(i))->sort(); |
233 | 233 | ||
234 | // all documents | 234 | // all documents |
235 | QImage img( Resource::loadImage( "DocsIcon" ) ); | 235 | QImage img( Resource::loadImage( "DocsIcon" ) ); |
236 | QPixmap pm; | 236 | QPixmap pm; |
237 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 237 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
238 | docview = newView( "Documents", // No tr | 238 | docview = newView( "Documents", // No tr |
239 | pm, tr("Documents")); | 239 | pm, tr("Documents")); |
240 | docview->populate( docFolder, QString::null ); | 240 | docview->populate( docFolder, QString::null ); |
241 | docFolder->detachChildren(); | 241 | docFolder->detachChildren(); |
242 | docview->setFileSystems(fs); | 242 | docview->setFileSystems(fs); |
243 | docview->setToolsEnabled(TRUE); | 243 | docview->setToolsEnabled(TRUE); |
244 | setTabAppearance( "Documents", cfg ); // No tr | 244 | setTabAppearance( "Documents", cfg ); // No tr |
245 | 245 | ||
246 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); | 246 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); |
247 | 247 | ||
248 | ((LauncherView*)stack->widget(0))->setFocus(); | 248 | ((LauncherView*)stack->widget(0))->setFocus(); |
249 | 249 | ||
250 | categoryBar->show(); | 250 | categoryBar->show(); |
251 | stack->show(); | 251 | stack->show(); |
252 | } | 252 | } |
253 | 253 | ||
254 | void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) | 254 | void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) |
255 | { | 255 | { |
256 | QString grp( "Tab %1" ); // No tr | 256 | QString grp( "Tab %1" ); // No tr |
257 | cfg.setGroup( grp.arg(id) ); | 257 | cfg.setGroup( grp.arg(id) ); |
258 | LauncherView *v = view( id ); | 258 | LauncherView *v = view( id ); |
259 | int idx = ids.findIndex( id ); | 259 | int idx = ids.findIndex( id ); |
260 | CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx ); | 260 | CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx ); |
261 | 261 | ||
262 | // View | 262 | // View |
263 | QString view = cfg.readEntry( "View", "Icon" ); | 263 | QString view = cfg.readEntry( "View", "Icon" ); |
264 | if ( view == "List" ) // No tr | 264 | if ( view == "List" ) // No tr |
265 | v->setViewMode( LauncherView::List ); | 265 | v->setViewMode( LauncherView::List ); |
266 | QString bgType = cfg.readEntry( "BackgroundType", "Ruled" ); | 266 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); |
267 | if ( bgType == "Image" ) { // No tr | 267 | if ( bgType == "Image" ) { // No tr |
268 | QString pm = cfg.readEntry( "BackgroundImage", "wallpaper/marble" ); | 268 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); |
269 | v->setBackgroundType( LauncherView::Image, pm ); | 269 | v->setBackgroundType( LauncherView::Image, pm ); |
270 | } else if ( bgType == "SolidColor" ) { | 270 | } else if ( bgType == "SolidColor" ) { |
271 | QString c = cfg.readEntry( "BackgroundColor" ); | 271 | QString c = cfg.readEntry( "BackgroundColor" ); |
272 | v->setBackgroundType( LauncherView::SolidColor, c ); | 272 | v->setBackgroundType( LauncherView::SolidColor, c ); |
273 | } | 273 | } |
274 | QString textCol = cfg.readEntry( "TextColor" ); | 274 | QString textCol = cfg.readEntry( "TextColor" ); |
275 | if ( textCol.isEmpty() ) | 275 | if ( textCol.isEmpty() ) |
276 | v->setTextColor( QColor() ); | 276 | v->setTextColor( QColor() ); |
277 | else | 277 | else |
278 | v->setTextColor( QColor(textCol) ); | 278 | v->setTextColor( QColor(textCol) ); |
279 | QStringList font = cfg.readListEntry( "Font", ',' ); | 279 | QStringList font = cfg.readListEntry( "Font", ',' ); |
280 | if ( font.count() == 4 ) | 280 | if ( font.count() == 4 ) |
281 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); | 281 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); |
282 | 282 | ||
283 | // Tabs | 283 | // Tabs |
284 | QString tabCol = cfg.readEntry( "TabColor" ); | 284 | QString tabCol = cfg.readEntry( "TabColor" ); |
285 | if ( tabCol.isEmpty() ) | 285 | if ( tabCol.isEmpty() ) |
286 | tab->bgColor = QColor(); | 286 | tab->bgColor = QColor(); |
287 | else | 287 | else |
288 | tab->bgColor = QColor(tabCol); | 288 | tab->bgColor = QColor(tabCol); |
289 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); | 289 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); |
290 | if ( tabTextCol.isEmpty() ) | 290 | if ( tabTextCol.isEmpty() ) |
291 | tab->fgColor = QColor(); | 291 | tab->fgColor = QColor(); |
292 | else | 292 | else |
293 | tab->fgColor = QColor(tabTextCol); | 293 | tab->fgColor = QColor(tabTextCol); |
294 | } | 294 | } |
295 | 295 | ||
296 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) | 296 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) |
297 | { | 297 | { |
298 | docview->populate( docFolder, QString::null ); | 298 | docview->populate( docFolder, QString::null ); |
299 | docFolder->detachChildren(); | 299 | docFolder->detachChildren(); |
300 | docview->setFileSystems(fs); | 300 | docview->setFileSystems(fs); |
301 | docview->updateTools(); | 301 | docview->updateTools(); |
302 | } | 302 | } |
303 | 303 | ||
304 | void CategoryTabWidget::tabProperties() | 304 | void CategoryTabWidget::tabProperties() |
305 | { | 305 | { |
306 | LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); | 306 | LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); |
307 | QPopupMenu *m = new QPopupMenu( this ); | 307 | QPopupMenu *m = new QPopupMenu( this ); |
308 | m->insertItem( tr("Icon View"), LauncherView::Icon ); | 308 | m->insertItem( tr("Icon View"), LauncherView::Icon ); |
309 | m->insertItem( tr("List View"), LauncherView::List ); | 309 | m->insertItem( tr("List View"), LauncherView::List ); |
310 | m->setItemChecked( (int)view->viewMode(), TRUE ); | 310 | m->setItemChecked( (int)view->viewMode(), TRUE ); |
311 | int rv = m->exec( QCursor::pos() ); | 311 | int rv = m->exec( QCursor::pos() ); |
312 | if ( rv >= 0 && rv != view->viewMode() ) { | 312 | if ( rv >= 0 && rv != view->viewMode() ) { |
313 | view->setViewMode( (LauncherView::ViewMode)rv ); | 313 | view->setViewMode( (LauncherView::ViewMode)rv ); |
314 | } | 314 | } |
315 | 315 | ||
316 | delete m; | 316 | delete m; |
317 | } | 317 | } |
318 | 318 | ||
319 | QString CategoryTabWidget::getAllDocLinkInfo() const | 319 | QString CategoryTabWidget::getAllDocLinkInfo() const |
320 | { | 320 | { |
321 | return docview->getAllDocLinkInfo(); | 321 | return docview->getAllDocLinkInfo(); |
322 | } | 322 | } |
323 | 323 | ||
324 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 324 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
325 | { | 325 | { |
326 | LauncherView* view = new LauncherView( stack ); | 326 | LauncherView* view = new LauncherView( stack ); |
327 | connect( view, SIGNAL(clicked(const AppLnk*)), | 327 | connect( view, SIGNAL(clicked(const AppLnk*)), |
328 | this, SIGNAL(clicked(const AppLnk*))); | 328 | this, SIGNAL(clicked(const AppLnk*))); |
329 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 329 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
330 | this, SIGNAL(rightPressed(AppLnk*))); | 330 | this, SIGNAL(rightPressed(AppLnk*))); |
331 | ids.append(id); | 331 | ids.append(id); |
332 | categoryBar->addTab( new CategoryTab( pm, label ) ); | 332 | categoryBar->addTab( new CategoryTab( pm, label ) ); |
333 | stack->addWidget( view, tabs++ ); | 333 | stack->addWidget( view, tabs++ ); |
334 | return view; | 334 | return view; |
335 | } | 335 | } |
336 | 336 | ||
337 | void CategoryTabWidget::updateLink(const QString& linkfile) | 337 | void CategoryTabWidget::updateLink(const QString& linkfile) |
338 | { | 338 | { |
339 | int i=0; | 339 | int i=0; |
340 | LauncherView* view; | 340 | LauncherView* view; |
341 | while ((view = (LauncherView*)stack->widget(i++))) { | 341 | while ((view = (LauncherView*)stack->widget(i++))) { |
342 | if ( view->removeLink(linkfile) ) | 342 | if ( view->removeLink(linkfile) ) |
343 | break; | 343 | break; |
344 | } | 344 | } |
345 | addItem(linkfile); | 345 | addItem(linkfile); |
346 | docview->updateTools(); | 346 | docview->updateTools(); |
347 | } | 347 | } |
348 | 348 | ||
349 | void CategoryTabWidget::paletteChange( const QPalette &p ) | 349 | void CategoryTabWidget::paletteChange( const QPalette &p ) |
350 | { | 350 | { |
351 | QVBox::paletteChange( p ); | 351 | QVBox::paletteChange( p ); |
352 | QPalette pal = palette(); | 352 | QPalette pal = palette(); |
353 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 353 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
354 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 354 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
355 | categoryBar->setPalette( pal ); | 355 | categoryBar->setPalette( pal ); |
356 | categoryBar->update(); | 356 | categoryBar->update(); |
357 | } | 357 | } |
358 | 358 | ||
359 | void CategoryTabWidget::setBusy(bool on) | 359 | void CategoryTabWidget::setBusy(bool on) |
360 | { | 360 | { |
361 | if ( on ) | 361 | if ( on ) |
362 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); | 362 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); |
363 | else | 363 | else |
364 | for (int i=0; i<tabs; i++) | 364 | for (int i=0; i<tabs; i++) |
365 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); | 365 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); |
366 | } | 366 | } |
367 | 367 | ||
368 | LauncherView *CategoryTabWidget::view( const QString &id ) | 368 | LauncherView *CategoryTabWidget::view( const QString &id ) |
369 | { | 369 | { |
370 | int idx = ids.findIndex( id ); | 370 | int idx = ids.findIndex( id ); |
371 | return (LauncherView *)stack->widget(idx); | 371 | return (LauncherView *)stack->widget(idx); |
372 | } | 372 | } |
373 | 373 | ||
374 | //=========================================================================== | 374 | //=========================================================================== |
375 | 375 | ||
376 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) | 376 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) |
377 | : QTabBar( parent, name ) | 377 | : QTabBar( parent, name ) |
378 | { | 378 | { |
379 | setFocusPolicy( NoFocus ); | 379 | setFocusPolicy( NoFocus ); |
380 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); | 380 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); |
381 | } | 381 | } |
382 | 382 | ||
383 | CategoryTabBar::~CategoryTabBar() | 383 | CategoryTabBar::~CategoryTabBar() |
384 | { | 384 | { |
385 | } | 385 | } |
386 | 386 | ||
387 | void CategoryTabBar::layoutTabs() | 387 | void CategoryTabBar::layoutTabs() |
388 | { | 388 | { |
389 | if ( !count() ) | 389 | if ( !count() ) |
390 | return; | 390 | return; |
391 | 391 | ||
392 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; | 392 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; |
393 | int available = width()-1; | 393 | int available = width()-1; |
394 | QFontMetrics fm = fontMetrics(); | 394 | QFontMetrics fm = fontMetrics(); |
395 | int hiddenTabWidth = -7; | 395 | int hiddenTabWidth = -7; |
396 | int middleTab = currentTab(); | 396 | int middleTab = currentTab(); |
397 | int hframe, vframe, overlap; | 397 | int hframe, vframe, overlap; |
398 | style().tabbarMetrics( this, hframe, vframe, overlap ); | 398 | style().tabbarMetrics( this, hframe, vframe, overlap ); |
399 | int x = 0; | 399 | int x = 0; |
400 | QRect r; | 400 | QRect r; |
401 | QTab *t; | 401 | QTab *t; |
402 | int required = 0; | 402 | int required = 0; |
403 | int eventabwidth = (width()-1)/count(); | 403 | int eventabwidth = (width()-1)/count(); |
404 | enum Mode { HideBackText, Pack, Even } mode=Even; | 404 | enum Mode { HideBackText, Pack, Even } mode=Even; |
405 | for ( int i = 0; i < count(); i++ ) { | 405 | for ( int i = 0; i < count(); i++ ) { |
406 | t = tab(i); | 406 | t = tab(i); |
407 | int iw = fm.width( t->text() ) + hframe - overlap; | 407 | int iw = fm.width( t->text() ) + hframe - overlap; |
408 | if ( i != middleTab ) { | 408 | if ( i != middleTab ) { |
409 | available -= hiddenTabWidth + hframe - overlap; | 409 | available -= hiddenTabWidth + hframe - overlap; |
410 | if ( t->iconSet() != 0 ) | 410 | if ( t->iconSet() != 0 ) |
411 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 411 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
412 | } | 412 | } |
413 | if ( t->iconSet() != 0 ) | 413 | if ( t->iconSet() != 0 ) |
414 | iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 414 | iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
415 | required += iw; | 415 | required += iw; |
416 | // As space gets tight, packed looks better than even. "10" must be at least 0. | 416 | // As space gets tight, packed looks better than even. "10" must be at least 0. |
417 | if ( iw >= eventabwidth-10 ) | 417 | if ( iw >= eventabwidth-10 ) |
418 | mode = Pack; | 418 | mode = Pack; |
419 | } | 419 | } |
420 | if ( mode == Pack && required > width()-1 ) | 420 | if ( mode == Pack && required > width()-1 ) |
421 | mode = HideBackText; | 421 | mode = HideBackText; |
422 | for ( int i = 0; i < count(); i++ ) { | 422 | for ( int i = 0; i < count(); i++ ) { |
423 | t = tab(i); | 423 | t = tab(i); |
424 | if ( mode != HideBackText ) { | 424 | if ( mode != HideBackText ) { |
425 | int w = fm.width( t->text() ); | 425 | int w = fm.width( t->text() ); |
426 | int ih = 0; | 426 | int ih = 0; |
427 | if ( t->iconSet() != 0 ) { | 427 | if ( t->iconSet() != 0 ) { |
428 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 428 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
429 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 429 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
430 | } | 430 | } |
431 | int h = QMAX( fm.height(), ih ); | 431 | int h = QMAX( fm.height(), ih ); |
432 | h = QMAX( h, QApplication::globalStrut().height() ); | 432 | h = QMAX( h, QApplication::globalStrut().height() ); |
433 | 433 | ||
434 | h += vframe; | 434 | h += vframe; |
435 | w += hframe; | 435 | w += hframe; |
436 | 436 | ||
437 | QRect tr(x, 0, | 437 | QRect tr(x, 0, |
438 | mode == Even ? eventabwidth : w * (width()-1)/required, h); | 438 | mode == Even ? eventabwidth : w * (width()-1)/required, h); |
439 | t->setRect(tr); | 439 | t->setRect(tr); |
440 | x += tr.width() - overlap; | 440 | x += tr.width() - overlap; |
441 | r = r.unite(tr); | 441 | r = r.unite(tr); |
442 | } else if ( i != middleTab ) { | 442 | } else if ( i != middleTab ) { |
443 | int w = hiddenTabWidth; | 443 | int w = hiddenTabWidth; |
444 | int ih = 0; | 444 | int ih = 0; |
445 | if ( t->iconSet() != 0 ) { | 445 | if ( t->iconSet() != 0 ) { |
446 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 446 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
447 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 447 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
448 | } | 448 | } |
449 | int h = QMAX( fm.height(), ih ); | 449 | int h = QMAX( fm.height(), ih ); |
450 | h = QMAX( h, QApplication::globalStrut().height() ); | 450 | h = QMAX( h, QApplication::globalStrut().height() ); |
451 | 451 | ||
452 | h += vframe; | 452 | h += vframe; |
453 | w += hframe; | 453 | w += hframe; |
454 | 454 | ||
455 | t->setRect( QRect(x, 0, w, h) ); | 455 | t->setRect( QRect(x, 0, w, h) ); |
456 | x += t->rect().width() - overlap; | 456 | x += t->rect().width() - overlap; |
457 | r = r.unite( t->rect() ); | 457 | r = r.unite( t->rect() ); |
458 | } else { | 458 | } else { |
459 | int ih = 0; | 459 | int ih = 0; |
460 | if ( t->iconSet() != 0 ) { | 460 | if ( t->iconSet() != 0 ) { |
461 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 461 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
462 | } | 462 | } |
463 | int h = QMAX( fm.height(), ih ); | 463 | int h = QMAX( fm.height(), ih ); |
464 | h = QMAX( h, QApplication::globalStrut().height() ); | 464 | h = QMAX( h, QApplication::globalStrut().height() ); |
465 | 465 | ||
466 | h += vframe; | 466 | h += vframe; |
467 | 467 | ||
468 | t->setRect( QRect(x, 0, available, h) ); | 468 | t->setRect( QRect(x, 0, available, h) ); |
469 | x += t->rect().width() - overlap; | 469 | x += t->rect().width() - overlap; |
470 | r = r.unite( t->rect() ); | 470 | r = r.unite( t->rect() ); |
471 | } | 471 | } |
472 | } | 472 | } |
473 | 473 | ||
474 | QRect rr = tab(count()-1)->rect(); | 474 | QRect rr = tab(count()-1)->rect(); |
475 | rr.setRight(width()-1); | 475 | rr.setRight(width()-1); |
476 | tab(count()-1)->setRect( rr ); | 476 | tab(count()-1)->setRect( rr ); |
477 | 477 | ||
478 | for ( t = tabList()->first(); t; t = tabList()->next() ) { | 478 | for ( t = tabList()->first(); t; t = tabList()->next() ) { |
479 | QRect tr = t->rect(); | 479 | QRect tr = t->rect(); |
480 | tr.setHeight( r.height() ); | 480 | tr.setHeight( r.height() ); |
481 | t->setRect( tr ); | 481 | t->setRect( tr ); |
482 | } | 482 | } |
483 | 483 | ||
484 | update(); | 484 | update(); |
485 | } | 485 | } |
486 | 486 | ||
487 | 487 | ||
488 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const | 488 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const |
489 | { | 489 | { |
490 | CategoryTabBar *that = (CategoryTabBar *) this; | 490 | CategoryTabBar *that = (CategoryTabBar *) this; |
491 | CategoryTab *ct = (CategoryTab *)t; | 491 | CategoryTab *ct = (CategoryTab *)t; |
492 | QPalette pal = palette(); | 492 | QPalette pal = palette(); |
493 | bool setPal = FALSE; | 493 | bool setPal = FALSE; |
494 | if ( ct->bgColor.isValid() ) { | 494 | if ( ct->bgColor.isValid() ) { |
495 | pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor ); | 495 | pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor ); |
496 | pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor ); | 496 | pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor ); |
497 | pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor ); | 497 | pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor ); |
498 | pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor ); | 498 | pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor ); |
499 | that->setUpdatesEnabled( FALSE ); | 499 | that->setUpdatesEnabled( FALSE ); |
500 | that->setPalette( pal ); | 500 | that->setPalette( pal ); |
501 | setPal = TRUE; | 501 | setPal = TRUE; |
502 | } | 502 | } |
503 | #if QT_VERSION >= 300 | 503 | #if QT_VERSION >= 300 |
504 | QStyle::SFlags flags = QStyle::Style_Default; | 504 | QStyle::SFlags flags = QStyle::Style_Default; |
505 | if ( selected ) | 505 | if ( selected ) |
506 | flags |= QStyle::Style_Selected; | 506 | flags |= QStyle::Style_Selected; |
507 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), | 507 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), |
508 | colorGroup(), flags, QStyleOption(t) ); | 508 | colorGroup(), flags, QStyleOption(t) ); |
509 | #else | 509 | #else |
510 | style().drawTab( p, this, t, selected ); | 510 | style().drawTab( p, this, t, selected ); |
511 | #endif | 511 | #endif |
512 | 512 | ||
513 | QRect r( t->rect() ); | 513 | QRect r( t->rect() ); |
514 | QFont f( font() ); | 514 | QFont f( font() ); |
515 | if ( selected ) | 515 | if ( selected ) |
516 | f.setBold( TRUE ); | 516 | f.setBold( TRUE ); |
517 | p->setFont( f ); | 517 | p->setFont( f ); |
518 | 518 | ||
519 | if ( ct->fgColor.isValid() ) { | 519 | if ( ct->fgColor.isValid() ) { |
520 | pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); | 520 | pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); |
521 | pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); | 521 | pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); |
522 | that->setUpdatesEnabled( FALSE ); | 522 | that->setUpdatesEnabled( FALSE ); |
523 | that->setPalette( pal ); | 523 | that->setPalette( pal ); |
524 | setPal = TRUE; | 524 | setPal = TRUE; |