-rw-r--r-- | core/launcher/launcher.cpp | 34 | ||||
-rw-r--r-- | core/launcher/launcher.h | 2 |
2 files changed, 32 insertions, 4 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index fc944e1..e74301c 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -56,293 +56,314 @@ | |||
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 | |||
153 | void CategoryTabWidget::showTab(const QString& id) | ||
154 | { | ||
155 | if ( categoryBar ) { | ||
156 | int idx = ids.findIndex( id ); | ||
157 | categoryBar->setCurrentTab( idx ); | ||
158 | } | ||
159 | } | ||
160 | |||
152 | void CategoryTabWidget::addItem( const QString& linkfile ) | 161 | void CategoryTabWidget::addItem( const QString& linkfile ) |
153 | { | 162 | { |
154 | int i=0; | 163 | int i=0; |
155 | AppLnk *app = new AppLnk(linkfile); | 164 | AppLnk *app = new AppLnk(linkfile); |
156 | if ( !app->isValid() ) { | 165 | if ( !app->isValid() ) { |
157 | delete app; | 166 | delete app; |
158 | app=0; | 167 | app=0; |
159 | } | 168 | } |
160 | if ( !app || !app->file().isEmpty() ) { | 169 | if ( !app || !app->file().isEmpty() ) { |
161 | // A document | 170 | // A document |
162 | delete app; | 171 | delete app; |
163 | app = new DocLnk(linkfile); | 172 | app = new DocLnk(linkfile); |
164 | if ( app->fileKnown() ) { | 173 | if ( app->fileKnown() ) { |
165 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); | 174 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); |
166 | } else { | 175 | } else { |
167 | ((LauncherView*)(stack->widget(ids.count()-1)))->sort(); | 176 | ((LauncherView*)(stack->widget(ids.count()-1)))->sort(); |
168 | delete app; | 177 | delete app; |
169 | } | 178 | } |
170 | return; | 179 | return; |
171 | } | 180 | } |
172 | // An application | 181 | // An application |
173 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { | 182 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { |
174 | if ( !(*it).isEmpty() ) { | 183 | if ( !(*it).isEmpty() ) { |
175 | QRegExp tf(*it,FALSE,TRUE); | 184 | QRegExp tf(*it,FALSE,TRUE); |
176 | if ( tf.match(app->type()) >= 0 ) { | 185 | if ( tf.match(app->type()) >= 0 ) { |
177 | ((LauncherView*)stack->widget(i))->addItem(app); | 186 | ((LauncherView*)stack->widget(i))->addItem(app); |
178 | return; | 187 | return; |
179 | } | 188 | } |
180 | i++; | 189 | i++; |
181 | } | 190 | } |
182 | } | 191 | } |
183 | 192 | ||
184 | QCopEnvelope e("QPE/TaskBar","reloadApps()"); | 193 | QCopEnvelope e("QPE/TaskBar","reloadApps()"); |
185 | } | 194 | } |
186 | 195 | ||
187 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | 196 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, |
188 | AppLnkSet* docFolder, const QList<FileSystem> &fs) | 197 | AppLnkSet* docFolder, const QList<FileSystem> &fs) |
189 | { | 198 | { |
199 | QString current; | ||
200 | if ( categoryBar ) { | ||
201 | int c = categoryBar->currentTab(); | ||
202 | if ( c >= 0 ) current = ids[c]; | ||
203 | } | ||
204 | |||
190 | delete categoryBar; | 205 | delete categoryBar; |
191 | categoryBar = new CategoryTabBar( this ); | 206 | categoryBar = new CategoryTabBar( this ); |
192 | QPalette pal = categoryBar->palette(); | 207 | QPalette pal = categoryBar->palette(); |
193 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 208 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
194 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 209 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
195 | categoryBar->setPalette( pal ); | 210 | categoryBar->setPalette( pal ); |
196 | 211 | ||
197 | delete stack; | 212 | delete stack; |
198 | stack = new QWidgetStack(this); | 213 | stack = new QWidgetStack(this); |
199 | tabs=0; | 214 | tabs=0; |
200 | 215 | ||
201 | ids.clear(); | 216 | ids.clear(); |
202 | 217 | ||
203 | Config cfg("Launcher"); | 218 | Config cfg("Launcher"); |
204 | 219 | ||
205 | QStringList types = rootFolder->types(); | 220 | QStringList types = rootFolder->types(); |
206 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 221 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
207 | if ( !(*it).isEmpty() ) { | 222 | if ( !(*it).isEmpty() ) { |
208 | (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); | 223 | (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); |
209 | setTabAppearance( *it, cfg ); | 224 | setTabAppearance( *it, cfg ); |
210 | } | 225 | } |
211 | } | 226 | } |
212 | QListIterator<AppLnk> it( rootFolder->children() ); | 227 | QListIterator<AppLnk> it( rootFolder->children() ); |
213 | AppLnk* l; | 228 | AppLnk* l; |
214 | while ( (l=it.current()) ) { | 229 | while ( (l=it.current()) ) { |
215 | if ( l->type() == "Separator" ) { // No tr | 230 | if ( l->type() == "Separator" ) { // No tr |
216 | rootFolder->remove(l); | 231 | rootFolder->remove(l); |
217 | delete l; | 232 | delete l; |
218 | } else { | 233 | } else { |
219 | int i=0; | 234 | int i=0; |
220 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 235 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
221 | if ( *it == l->type() ) | 236 | if ( *it == l->type() ) |
222 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); | 237 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); |
223 | i++; | 238 | i++; |
224 | } | 239 | } |
225 | } | 240 | } |
226 | ++it; | 241 | ++it; |
227 | } | 242 | } |
228 | rootFolder->detachChildren(); | 243 | rootFolder->detachChildren(); |
229 | for (int i=0; i<tabs; i++) | 244 | for (int i=0; i<tabs; i++) |
230 | ((LauncherView*)stack->widget(i))->sort(); | 245 | ((LauncherView*)stack->widget(i))->sort(); |
231 | 246 | ||
232 | // all documents | 247 | // all documents |
233 | QImage img( Resource::loadImage( "DocsIcon" ) ); | 248 | QImage img( Resource::loadImage( "DocsIcon" ) ); |
234 | QPixmap pm; | 249 | QPixmap pm; |
235 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 250 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
236 | docview = newView( "Documents", // No tr | 251 | docview = newView( "Documents", // No tr |
237 | pm, tr("Documents")); | 252 | pm, tr("Documents")); |
238 | docview->populate( docFolder, QString::null ); | 253 | docview->populate( docFolder, QString::null ); |
239 | docFolder->detachChildren(); | 254 | docFolder->detachChildren(); |
240 | docview->setFileSystems(fs); | 255 | docview->setFileSystems(fs); |
241 | docview->setToolsEnabled(TRUE); | 256 | docview->setToolsEnabled(TRUE); |
242 | setTabAppearance( "Documents", cfg ); // No tr | 257 | setTabAppearance( "Documents", cfg ); // No tr |
243 | 258 | ||
244 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); | 259 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); |
245 | 260 | ||
246 | ((LauncherView*)stack->widget(0))->setFocus(); | 261 | ((LauncherView*)stack->widget(0))->setFocus(); |
247 | 262 | ||
248 | cfg. setGroup ( "GUI" ); | 263 | cfg. setGroup ( "GUI" ); |
249 | setBusyIndicatorType ( cfg. readEntry ( "BusyType", QString::null )); | 264 | setBusyIndicatorType ( cfg. readEntry ( "BusyType", QString::null )); |
250 | 265 | ||
266 | if ( !current.isNull() ) { | ||
267 | showTab(current); | ||
268 | } | ||
269 | |||
251 | categoryBar->show(); | 270 | categoryBar->show(); |
252 | stack->show(); | 271 | stack->show(); |
272 | |||
273 | QCopEnvelope e("QPE/TaskBar","reloadApps()"); | ||
253 | } | 274 | } |
254 | 275 | ||
255 | void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) | 276 | void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) |
256 | { | 277 | { |
257 | QString grp( "Tab %1" ); // No tr | 278 | QString grp( "Tab %1" ); // No tr |
258 | cfg.setGroup( grp.arg(id) ); | 279 | cfg.setGroup( grp.arg(id) ); |
259 | LauncherView *v = view( id ); | 280 | LauncherView *v = view( id ); |
260 | int idx = ids.findIndex( id ); | 281 | int idx = ids.findIndex( id ); |
261 | CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx ); | 282 | CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx ); |
262 | 283 | ||
263 | // View | 284 | // View |
264 | QString view = cfg.readEntry( "View", "Icon" ); | 285 | QString view = cfg.readEntry( "View", "Icon" ); |
265 | if ( view == "List" ) // No tr | 286 | if ( view == "List" ) // No tr |
266 | v->setViewMode( LauncherView::List ); | 287 | v->setViewMode( LauncherView::List ); |
267 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); | 288 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); |
268 | if ( bgType == "Image" ) { // No tr | 289 | if ( bgType == "Image" ) { // No tr |
269 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); | 290 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); |
270 | v->setBackgroundType( LauncherView::Image, pm ); | 291 | v->setBackgroundType( LauncherView::Image, pm ); |
271 | } else if ( bgType == "SolidColor" ) { | 292 | } else if ( bgType == "SolidColor" ) { |
272 | QString c = cfg.readEntry( "BackgroundColor" ); | 293 | QString c = cfg.readEntry( "BackgroundColor" ); |
273 | v->setBackgroundType( LauncherView::SolidColor, c ); | 294 | v->setBackgroundType( LauncherView::SolidColor, c ); |
274 | } | 295 | } |
275 | QString textCol = cfg.readEntry( "TextColor" ); | 296 | QString textCol = cfg.readEntry( "TextColor" ); |
276 | if ( textCol.isEmpty() ) | 297 | if ( textCol.isEmpty() ) |
277 | v->setTextColor( QColor() ); | 298 | v->setTextColor( QColor() ); |
278 | else | 299 | else |
279 | v->setTextColor( QColor(textCol) ); | 300 | v->setTextColor( QColor(textCol) ); |
280 | QStringList font = cfg.readListEntry( "Font", ',' ); | 301 | QStringList font = cfg.readListEntry( "Font", ',' ); |
281 | if ( font.count() == 4 ) | 302 | if ( font.count() == 4 ) |
282 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); | 303 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); |
283 | 304 | ||
284 | // Tabs | 305 | // Tabs |
285 | QString tabCol = cfg.readEntry( "TabColor" ); | 306 | QString tabCol = cfg.readEntry( "TabColor" ); |
286 | if ( tabCol.isEmpty() ) | 307 | if ( tabCol.isEmpty() ) |
287 | tab->bgColor = QColor(); | 308 | tab->bgColor = QColor(); |
288 | else | 309 | else |
289 | tab->bgColor = QColor(tabCol); | 310 | tab->bgColor = QColor(tabCol); |
290 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); | 311 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); |
291 | if ( tabTextCol.isEmpty() ) | 312 | if ( tabTextCol.isEmpty() ) |
292 | tab->fgColor = QColor(); | 313 | tab->fgColor = QColor(); |
293 | else | 314 | else |
294 | tab->fgColor = QColor(tabTextCol); | 315 | tab->fgColor = QColor(tabTextCol); |
295 | } | 316 | } |
296 | 317 | ||
297 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) | 318 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) |
298 | { | 319 | { |
299 | docview->populate( docFolder, QString::null ); | 320 | docview->populate( docFolder, QString::null ); |
300 | docFolder->detachChildren(); | 321 | docFolder->detachChildren(); |
301 | docview->setFileSystems(fs); | 322 | docview->setFileSystems(fs); |
302 | docview->updateTools(); | 323 | docview->updateTools(); |
303 | } | 324 | } |
304 | 325 | ||
305 | void CategoryTabWidget::tabProperties() | 326 | void CategoryTabWidget::tabProperties() |
306 | { | 327 | { |
307 | LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); | 328 | LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); |
308 | QPopupMenu *m = new QPopupMenu( this ); | 329 | QPopupMenu *m = new QPopupMenu( this ); |
309 | m->insertItem( tr("Icon View"), LauncherView::Icon ); | 330 | m->insertItem( tr("Icon View"), LauncherView::Icon ); |
310 | m->insertItem( tr("List View"), LauncherView::List ); | 331 | m->insertItem( tr("List View"), LauncherView::List ); |
311 | m->setItemChecked( (int)view->viewMode(), TRUE ); | 332 | m->setItemChecked( (int)view->viewMode(), TRUE ); |
312 | int rv = m->exec( QCursor::pos() ); | 333 | int rv = m->exec( QCursor::pos() ); |
313 | if ( rv >= 0 && rv != view->viewMode() ) { | 334 | if ( rv >= 0 && rv != view->viewMode() ) { |
314 | view->setViewMode( (LauncherView::ViewMode)rv ); | 335 | view->setViewMode( (LauncherView::ViewMode)rv ); |
315 | } | 336 | } |
316 | 337 | ||
317 | delete m; | 338 | delete m; |
318 | } | 339 | } |
319 | 340 | ||
320 | QString CategoryTabWidget::getAllDocLinkInfo() const | 341 | QString CategoryTabWidget::getAllDocLinkInfo() const |
321 | { | 342 | { |
322 | return docview->getAllDocLinkInfo(); | 343 | return docview->getAllDocLinkInfo(); |
323 | } | 344 | } |
324 | 345 | ||
325 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 346 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
326 | { | 347 | { |
327 | LauncherView* view = new LauncherView( stack ); | 348 | LauncherView* view = new LauncherView( stack ); |
328 | connect( view, SIGNAL(clicked(const AppLnk*)), | 349 | connect( view, SIGNAL(clicked(const AppLnk*)), |
329 | this, SIGNAL(clicked(const AppLnk*))); | 350 | this, SIGNAL(clicked(const AppLnk*))); |
330 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 351 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
331 | this, SIGNAL(rightPressed(AppLnk*))); | 352 | this, SIGNAL(rightPressed(AppLnk*))); |
332 | ids.append(id); | 353 | ids.append(id); |
333 | categoryBar->addTab( new CategoryTab( pm, label ) ); | 354 | categoryBar->addTab( new CategoryTab( pm, label ) ); |
334 | stack->addWidget( view, tabs++ ); | 355 | stack->addWidget( view, tabs++ ); |
335 | return view; | 356 | return view; |
336 | } | 357 | } |
337 | 358 | ||
338 | void CategoryTabWidget::updateLink(const QString& linkfile) | 359 | void CategoryTabWidget::updateLink(const QString& linkfile) |
339 | { | 360 | { |
340 | int i=0; | 361 | int i=0; |
341 | LauncherView* view; | 362 | LauncherView* view; |
342 | while ((view = (LauncherView*)stack->widget(i++))) { | 363 | while ((view = (LauncherView*)stack->widget(i++))) { |
343 | if ( view->removeLink(linkfile) ) | 364 | if ( view->removeLink(linkfile) ) |
344 | break; | 365 | break; |
345 | } | 366 | } |
346 | addItem(linkfile); | 367 | addItem(linkfile); |
347 | docview->updateTools(); | 368 | docview->updateTools(); |
348 | } | 369 | } |
@@ -521,468 +542,473 @@ void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const | |||
521 | QFont f( font() ); | 542 | QFont f( font() ); |
522 | if ( selected ) | 543 | if ( selected ) |
523 | f.setBold( TRUE ); | 544 | f.setBold( TRUE ); |
524 | p->setFont( f ); | 545 | p->setFont( f ); |
525 | 546 | ||
526 | if ( ct->fgColor.isValid() ) { | 547 | if ( ct->fgColor.isValid() ) { |
527 | pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); | 548 | pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); |
528 | pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); | 549 | pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); |
529 | that->setUpdatesEnabled( FALSE ); | 550 | that->setUpdatesEnabled( FALSE ); |
530 | that->setPalette( pal ); | 551 | that->setPalette( pal ); |
531 | setPal = TRUE; | 552 | setPal = TRUE; |
532 | } | 553 | } |
533 | int iw = 0; | 554 | int iw = 0; |
534 | int ih = 0; | 555 | int ih = 0; |
535 | if ( t->iconSet() != 0 ) { | 556 | if ( t->iconSet() != 0 ) { |
536 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; | 557 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; |
537 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 558 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
538 | } | 559 | } |
539 | int w = iw + p->fontMetrics().width( t->text() ) + 4; | 560 | int w = iw + p->fontMetrics().width( t->text() ) + 4; |
540 | int h = QMAX(p->fontMetrics().height() + 4, ih ); | 561 | int h = QMAX(p->fontMetrics().height() + 4, ih ); |
541 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, | 562 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, |
542 | r.top() + (r.height()-h)/2, w, h ), t, | 563 | r.top() + (r.height()-h)/2, w, h ), t, |
543 | #if QT_VERSION >= 300 | 564 | #if QT_VERSION >= 300 |
544 | t->identifier() == keyboardFocusTab() | 565 | t->identifier() == keyboardFocusTab() |
545 | #else | 566 | #else |
546 | t->identitifer() == keyboardFocusTab() | 567 | t->identitifer() == keyboardFocusTab() |
547 | #endif | 568 | #endif |
548 | ); | 569 | ); |
549 | if ( setPal ) { | 570 | if ( setPal ) { |
550 | that->unsetPalette(); | 571 | that->unsetPalette(); |
551 | that->setUpdatesEnabled( TRUE ); | 572 | that->setUpdatesEnabled( TRUE ); |
552 | } | 573 | } |
553 | } | 574 | } |
554 | 575 | ||
555 | 576 | ||
556 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, | 577 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, |
557 | QTab* t, bool has_focus ) const | 578 | QTab* t, bool has_focus ) const |
558 | { | 579 | { |
559 | QRect r = t->rect(); | 580 | QRect r = t->rect(); |
560 | // if ( t->id != currentTab() ) | 581 | // if ( t->id != currentTab() ) |
561 | //r.moveBy( 1, 1 ); | 582 | //r.moveBy( 1, 1 ); |
562 | // | 583 | // |
563 | if ( t->iconSet() ) { | 584 | if ( t->iconSet() ) { |
564 | // the tab has an iconset, draw it in the right mode | 585 | // the tab has an iconset, draw it in the right mode |
565 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; | 586 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; |
566 | if ( mode == QIconSet::Normal && has_focus ) | 587 | if ( mode == QIconSet::Normal && has_focus ) |
567 | mode = QIconSet::Active; | 588 | mode = QIconSet::Active; |
568 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); | 589 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); |
569 | int pixw = pixmap.width(); | 590 | int pixw = pixmap.width(); |
570 | int pixh = pixmap.height(); | 591 | int pixh = pixmap.height(); |
571 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); | 592 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); |
572 | r.setLeft( r.left() + pixw + 5 ); | 593 | r.setLeft( r.left() + pixw + 5 ); |
573 | } | 594 | } |
574 | 595 | ||
575 | QRect tr = r; | 596 | QRect tr = r; |
576 | 597 | ||
577 | if ( r.width() < 20 ) | 598 | if ( r.width() < 20 ) |
578 | return; | 599 | return; |
579 | 600 | ||
580 | if ( t->isEnabled() && isEnabled() ) { | 601 | if ( t->isEnabled() && isEnabled() ) { |
581 | #if defined(_WS_WIN32_) | 602 | #if defined(_WS_WIN32_) |
582 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) | 603 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) |
583 | p->setPen( colorGroup().buttonText() ); | 604 | p->setPen( colorGroup().buttonText() ); |
584 | else | 605 | else |
585 | p->setPen( colorGroup().foreground() ); | 606 | p->setPen( colorGroup().foreground() ); |
586 | #else | 607 | #else |
587 | p->setPen( colorGroup().foreground() ); | 608 | p->setPen( colorGroup().foreground() ); |
588 | #endif | 609 | #endif |
589 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 610 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
590 | } else { | 611 | } else { |
591 | p->setPen( palette().disabled().foreground() ); | 612 | p->setPen( palette().disabled().foreground() ); |
592 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 613 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
593 | } | 614 | } |
594 | } | 615 | } |
595 | 616 | ||
596 | //--------------------------------------------------------------------------- | 617 | //--------------------------------------------------------------------------- |
597 | 618 | ||
598 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | 619 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) |
599 | : QMainWindow( parent, name, fl ) | 620 | : QMainWindow( parent, name, fl ) |
600 | { | 621 | { |
601 | setCaption( tr("Launcher") ); | 622 | setCaption( tr("Launcher") ); |
602 | 623 | ||
603 | syncDialog = 0; | 624 | syncDialog = 0; |
604 | 625 | ||
605 | // we have a pretty good idea how big we'll be | 626 | // we have a pretty good idea how big we'll be |
606 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 627 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
607 | 628 | ||
608 | tabs = 0; | 629 | tabs = 0; |
609 | rootFolder = 0; | 630 | rootFolder = 0; |
610 | docsFolder = 0; | 631 | docsFolder = 0; |
611 | 632 | ||
612 | int stamp = uidgen.generate(); // this is our timestamp to see which devices we know | 633 | int stamp = uidgen.generate(); // this is our timestamp to see which devices we know |
613 | //uidgen.store( stamp ); | 634 | //uidgen.store( stamp ); |
614 | m_timeStamp = QString::number( stamp ); | 635 | m_timeStamp = QString::number( stamp ); |
615 | 636 | ||
616 | tabs = new CategoryTabWidget( this ); | 637 | tabs = new CategoryTabWidget( this ); |
617 | tabs->setMaximumWidth( qApp->desktop()->width() ); | ||
618 | setCentralWidget( tabs ); | 638 | setCentralWidget( tabs ); |
619 | 639 | ||
620 | connect( tabs, SIGNAL(selected(const QString&)), | 640 | connect( tabs, SIGNAL(selected(const QString&)), |
621 | this, SLOT(viewSelected(const QString&)) ); | 641 | this, SLOT(viewSelected(const QString&)) ); |
622 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 642 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
623 | this, SLOT(select(const AppLnk*))); | 643 | this, SLOT(select(const AppLnk*))); |
624 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 644 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
625 | this, SLOT(properties(AppLnk*))); | 645 | this, SLOT(properties(AppLnk*))); |
626 | 646 | ||
627 | #if !defined(QT_NO_COP) | 647 | #if !defined(QT_NO_COP) |
628 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 648 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
629 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 649 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
630 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); | 650 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); |
631 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); | 651 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); |
632 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 652 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
633 | this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); | 653 | this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); |
634 | #endif | 654 | #endif |
635 | 655 | ||
636 | storage = new StorageInfo( this ); | 656 | storage = new StorageInfo( this ); |
637 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); | 657 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); |
638 | 658 | ||
639 | updateTabs(); | 659 | updateTabs(); |
640 | 660 | ||
641 | preloadApps(); | 661 | preloadApps(); |
642 | 662 | ||
643 | in_lnk_props = FALSE; | 663 | in_lnk_props = FALSE; |
644 | got_lnk_change = FALSE; | 664 | got_lnk_change = FALSE; |
645 | } | 665 | } |
646 | 666 | ||
647 | Launcher::~Launcher() | 667 | Launcher::~Launcher() |
648 | { | 668 | { |
649 | delete rootFolder; | 669 | delete rootFolder; |
650 | delete docsFolder; | 670 | delete docsFolder; |
651 | } | 671 | } |
652 | 672 | ||
653 | static bool isVisibleWindow(int wid) | 673 | static bool isVisibleWindow(int wid) |
654 | { | 674 | { |
655 | #ifdef QWS | 675 | #ifdef QWS |
656 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 676 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
657 | QWSWindow* w; | 677 | QWSWindow* w; |
658 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 678 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
659 | if ( w->winId() == wid ) | 679 | if ( w->winId() == wid ) |
660 | return !w->isFullyObscured(); | 680 | return !w->isFullyObscured(); |
661 | } | 681 | } |
662 | #endif | 682 | #endif |
663 | return FALSE; | 683 | return FALSE; |
664 | } | 684 | } |
665 | 685 | ||
666 | void Launcher::showMaximized() | 686 | void Launcher::showMaximized() |
667 | { | 687 | { |
668 | if ( isVisibleWindow( winId() ) ) | 688 | if ( isVisibleWindow( winId() ) ) |
669 | doMaximize(); | 689 | doMaximize(); |
670 | else | 690 | else |
671 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); | 691 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); |
672 | } | 692 | } |
673 | 693 | ||
674 | void Launcher::doMaximize() | 694 | void Launcher::doMaximize() |
675 | { | 695 | { |
676 | QMainWindow::showMaximized(); | 696 | QMainWindow::showMaximized(); |
697 | tabs->setMaximumWidth( qApp->desktop()->width() ); | ||
677 | } | 698 | } |
678 | 699 | ||
679 | void Launcher::updateMimeTypes() | 700 | void Launcher::updateMimeTypes() |
680 | { | 701 | { |
681 | MimeType::clear(); | 702 | MimeType::clear(); |
682 | updateMimeTypes(rootFolder); | 703 | updateMimeTypes(rootFolder); |
683 | } | 704 | } |
684 | 705 | ||
685 | void Launcher::updateMimeTypes(AppLnkSet* folder) | 706 | void Launcher::updateMimeTypes(AppLnkSet* folder) |
686 | { | 707 | { |
687 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { | 708 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { |
688 | AppLnk *app = it.current(); | 709 | AppLnk *app = it.current(); |
689 | if ( app->type() == "Folder" ) // No tr | 710 | if ( app->type() == "Folder" ) // No tr |
690 | updateMimeTypes((AppLnkSet *)app); | 711 | updateMimeTypes((AppLnkSet *)app); |
691 | else { | 712 | else { |
692 | MimeType::registerApp(*app); | 713 | MimeType::registerApp(*app); |
693 | } | 714 | } |
694 | } | 715 | } |
695 | } | 716 | } |
696 | 717 | ||
697 | /** This is a HACK.... | 718 | /** This is a HACK.... |
698 | * Reason: scanning huge mediums, microdirvers for examples | 719 | * Reason: scanning huge mediums, microdirvers for examples |
699 | * consomes time. To avoid that we invented the MediumMountCheck | 720 | * consomes time. To avoid that we invented the MediumMountCheck |
700 | * | 721 | * |
701 | * a) the user globally disabled medium checking. We can ignore | 722 | * a) the user globally disabled medium checking. We can ignore |
702 | * all removable medium | 723 | * all removable medium |
703 | * b) the user enabled medium checking globally and we need to use this mimefilter | 724 | * 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 | 725 | * c) the user enabled medium checking on a per medium bases |
705 | * c1) we already checked and its not ask again turns | 726 | * c1) we already checked and its not ask again turns |
706 | * c2) we need to ask and then apply the mimefilter | 727 | * c2) we need to ask and then apply the mimefilter |
707 | */ | 728 | */ |
708 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: | 729 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: |
709 | { | 730 | { |
710 | delete docsFolder; | 731 | delete docsFolder; |
711 | docsFolder = new DocLnkSet; | 732 | docsFolder = new DocLnkSet; |
712 | 733 | ||
713 | DocLnkSet *tmp = 0; | 734 | DocLnkSet *tmp = 0; |
714 | QString home = QString(getenv("HOME")) + "/Documents"; | 735 | QString home = QString(getenv("HOME")) + "/Documents"; |
715 | tmp = new DocLnkSet( home , QString::null); | 736 | tmp = new DocLnkSet( home , QString::null); |
716 | docsFolder->appendFrom( *tmp ); | 737 | docsFolder->appendFrom( *tmp ); |
717 | delete tmp; | 738 | delete tmp; |
718 | 739 | ||
719 | // RAM documents | 740 | // RAM documents |
720 | StorageInfo storage; | 741 | StorageInfo storage; |
721 | const QList<FileSystem> &fileSystems = storage.fileSystems(); | 742 | const QList<FileSystem> &fileSystems = storage.fileSystems(); |
722 | QListIterator<FileSystem> it ( fileSystems ); | 743 | QListIterator<FileSystem> it ( fileSystems ); |
723 | 744 | ||
724 | for ( ; it.current(); ++it ) { | 745 | for ( ; it.current(); ++it ) { |
725 | if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { | 746 | if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { |
726 | tmp = new DocLnkSet( (*it)->path(), QString::null ); | 747 | tmp = new DocLnkSet( (*it)->path(), QString::null ); |
727 | docsFolder->appendFrom( *tmp ); | 748 | docsFolder->appendFrom( *tmp ); |
728 | delete tmp; | 749 | delete tmp; |
729 | } | 750 | } |
730 | } | 751 | } |
731 | 752 | ||
732 | Config mediumCfg( "medium"); | 753 | Config mediumCfg( "medium"); |
733 | mediumCfg.setGroup("main"); | 754 | mediumCfg.setGroup("main"); |
734 | // a) -zecke we don't want to check | 755 | // a) -zecke we don't want to check |
735 | if(!mediumCfg.readBoolEntry("use", true ) ) | 756 | if(!mediumCfg.readBoolEntry("use", true ) ) |
736 | return; | 757 | return; |
737 | 758 | ||
738 | // find out wich filesystems are new in this round | 759 | // find out wich filesystems are new in this round |
739 | // We will do this by having a timestamp inside each mountpoint | 760 | // 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 | 761 | // if the current timestamp doesn't match this is a new file system and |
741 | // come up with our MediumMountGui :) let the hacking begin | 762 | // come up with our MediumMountGui :) let the hacking begin |
742 | int stamp = uidgen.generate(); | 763 | int stamp = uidgen.generate(); |
743 | 764 | ||
744 | QString newStamp = QString::number( stamp ); // generates newtime Stamp | 765 | QString newStamp = QString::number( stamp ); // generates newtime Stamp |
745 | 766 | ||
746 | // b) | 767 | // b) |
747 | if( mediumCfg.readBoolEntry("global", true ) ){ | 768 | if( mediumCfg.readBoolEntry("global", true ) ){ |
748 | QString mime = configToMime(&mediumCfg).join(";"); | 769 | QString mime = configToMime(&mediumCfg).join(";"); |
749 | for( it.toFirst(); it.current(); ++it ){ | 770 | for( it.toFirst(); it.current(); ++it ){ |
750 | if( (*it)->isRemovable() ){ | 771 | if( (*it)->isRemovable() ){ |
751 | tmp = new DocLnkSet( (*it)->path(), mime ); | 772 | tmp = new DocLnkSet( (*it)->path(), mime ); |
752 | docsFolder->appendFrom( *tmp ); | 773 | docsFolder->appendFrom( *tmp ); |
753 | delete tmp; | 774 | delete tmp; |
754 | } | 775 | } |
755 | } // done | 776 | } // done |
756 | return; // save the else | 777 | return; // save the else |
757 | } | 778 | } |
758 | // c) zecke | 779 | // c) zecke |
759 | for ( it.toFirst(); it.current(); ++it ) { | 780 | for ( it.toFirst(); it.current(); ++it ) { |
760 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 781 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
761 | Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); | 782 | Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); |
762 | cfg.setGroup("main"); | 783 | cfg.setGroup("main"); |
763 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); | 784 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); |
764 | /** This medium is uptodate | 785 | /** This medium is uptodate |
765 | */ | 786 | */ |
766 | if( stamp == m_timeStamp ){ // ok we know this card | 787 | if( stamp == m_timeStamp ){ // ok we know this card |
767 | cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp | 788 | cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp |
768 | // we need to scan the list now. Hopefully the cache will be there | 789 | // we need to scan the list now. Hopefully the cache will be there |
769 | // read the mimetypes from the config and search for documents | 790 | // read the mimetypes from the config and search for documents |
770 | QStringList mimetypes = configToMime( &cfg); | 791 | QStringList mimetypes = configToMime( &cfg); |
771 | tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); | 792 | tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); |
772 | docsFolder->appendFrom( *tmp ); | 793 | docsFolder->appendFrom( *tmp ); |
773 | delete tmp; | 794 | delete tmp; |
774 | 795 | ||
775 | }else{ // come up with the gui cause this a new card | 796 | }else{ // come up with the gui cause this a new card |
776 | MediumMountGui medium(&cfg, (*it)->path() ); | 797 | MediumMountGui medium(&cfg, (*it)->path() ); |
777 | if( medium.check() ){ // we did not ask before or ask again is off | 798 | if( medium.check() ){ // we did not ask before or ask again is off |
778 | /** c2) */ | 799 | /** c2) */ |
779 | if( medium.exec() ){ // he clicked yes so search it | 800 | if( medium.exec() ){ // he clicked yes so search it |
780 | // speicher | 801 | // speicher |
781 | //cfg.read(); // cause of a race we need to reread - fixed | 802 | //cfg.read(); // cause of a race we need to reread - fixed |
782 | cfg.setGroup("main"); | 803 | cfg.setGroup("main"); |
783 | cfg.writeEntry("timestamp", newStamp ); | 804 | cfg.writeEntry("timestamp", newStamp ); |
784 | cfg.write(); | 805 | cfg.write(); |
785 | tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); | 806 | tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); |
786 | docsFolder->appendFrom( *tmp ); | 807 | docsFolder->appendFrom( *tmp ); |
787 | delete tmp; | 808 | delete tmp; |
788 | }// no else | 809 | }// no else |
789 | /** c1) */ | 810 | /** c1) */ |
790 | }else{ // we checked | 811 | }else{ // we checked |
791 | // do something different see what we need to do | 812 | // do something different see what we need to do |
792 | // let's see if we should check the device | 813 | // let's see if we should check the device |
793 | cfg.setGroup("main" ); | 814 | cfg.setGroup("main" ); |
794 | bool check = cfg.readBoolEntry("autocheck", true ); | 815 | bool check = cfg.readBoolEntry("autocheck", true ); |
795 | if( check ){ // find the documents | 816 | if( check ){ // find the documents |
796 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); | 817 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); |
797 | docsFolder->appendFrom( *tmp ); | 818 | docsFolder->appendFrom( *tmp ); |
798 | delete tmp; | 819 | delete tmp; |
799 | } | 820 | } |
800 | } | 821 | } |
801 | } | 822 | } |
802 | } | 823 | } |
803 | } | 824 | } |
804 | m_timeStamp = newStamp; | 825 | m_timeStamp = newStamp; |
805 | } | 826 | } |
806 | 827 | ||
807 | void Launcher::updateTabs() | 828 | void Launcher::updateTabs() |
808 | { | 829 | { |
809 | MimeType::updateApplications(); // ### reads all applnks twice | 830 | MimeType::updateApplications(); // ### reads all applnks twice |
810 | 831 | ||
811 | delete rootFolder; | 832 | delete rootFolder; |
812 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); | 833 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); |
813 | 834 | ||
814 | loadDocs(); | 835 | loadDocs(); |
815 | 836 | ||
816 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); | 837 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); |
817 | } | 838 | } |
818 | 839 | ||
819 | void Launcher::updateDocs() | 840 | void Launcher::updateDocs() |
820 | { | 841 | { |
821 | loadDocs(); | 842 | loadDocs(); |
822 | tabs->updateDocs(docsFolder,storage->fileSystems()); | 843 | tabs->updateDocs(docsFolder,storage->fileSystems()); |
823 | } | 844 | } |
824 | 845 | ||
825 | void Launcher::viewSelected(const QString& s) | 846 | void Launcher::viewSelected(const QString& s) |
826 | { | 847 | { |
827 | setCaption( s + tr(" - Launcher") ); | 848 | setCaption( s + tr(" - Launcher") ); |
828 | } | 849 | } |
829 | 850 | ||
830 | void Launcher::nextView() | 851 | void Launcher::nextView() |
831 | { | 852 | { |
832 | tabs->nextTab(); | 853 | tabs->nextTab(); |
833 | } | 854 | } |
834 | 855 | ||
856 | void Launcher::showTab(const QString& id) | ||
857 | { | ||
858 | tabs->showTab(id); | ||
859 | raise(); | ||
860 | } | ||
835 | 861 | ||
836 | void Launcher::select( const AppLnk *appLnk ) | 862 | void Launcher::select( const AppLnk *appLnk ) |
837 | { | 863 | { |
838 | if ( appLnk->type() == "Folder" ) { // No tr | 864 | if ( appLnk->type() == "Folder" ) { // No tr |
839 | // Not supported: flat is simpler for the user | 865 | // Not supported: flat is simpler for the user |
840 | } else { | 866 | } else { |
841 | if ( appLnk->exec().isNull() ) { | 867 | if ( appLnk->exec().isNull() ) { |
842 | QMessageBox::information(this,tr("No application"), | 868 | QMessageBox::information(this,tr("No application"), |
843 | tr("<p>No application is defined for this document." | 869 | tr("<p>No application is defined for this document." |
844 | "<p>Type is %1.").arg(appLnk->type())); | 870 | "<p>Type is %1.").arg(appLnk->type())); |
845 | return; | 871 | return; |
846 | } | 872 | } |
847 | tabs->setBusy(TRUE); | 873 | tabs->setBusy(TRUE); |
848 | emit executing( appLnk ); | 874 | emit executing( appLnk ); |
849 | appLnk->execute(); | 875 | appLnk->execute(); |
850 | } | 876 | } |
851 | } | 877 | } |
852 | 878 | ||
853 | void Launcher::externalSelected(const AppLnk *appLnk) | 879 | void Launcher::externalSelected(const AppLnk *appLnk) |
854 | { | 880 | { |
855 | tabs->setBusy(TRUE); | 881 | tabs->setBusy(TRUE); |
856 | emit executing( appLnk ); | 882 | emit executing( appLnk ); |
857 | } | 883 | } |
858 | 884 | ||
859 | void Launcher::properties( AppLnk *appLnk ) | 885 | void Launcher::properties( AppLnk *appLnk ) |
860 | { | 886 | { |
861 | if ( appLnk->type() == "Folder" ) { // No tr | 887 | if ( appLnk->type() == "Folder" ) { // No tr |
862 | // Not supported: flat is simpler for the user | 888 | // Not supported: flat is simpler for the user |
863 | } else { | 889 | } else { |
864 | in_lnk_props = TRUE; | 890 | in_lnk_props = TRUE; |
865 | got_lnk_change = FALSE; | 891 | got_lnk_change = FALSE; |
866 | LnkProperties prop(appLnk); | 892 | LnkProperties prop(appLnk); |
867 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 893 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
868 | prop.showMaximized(); | 894 | prop.showMaximized(); |
869 | prop.exec(); | 895 | prop.exec(); |
870 | in_lnk_props = FALSE; | 896 | in_lnk_props = FALSE; |
871 | if ( got_lnk_change ) { | 897 | if ( got_lnk_change ) { |
872 | updateLink(lnk_change); | 898 | updateLink(lnk_change); |
873 | } | 899 | } |
874 | } | 900 | } |
875 | } | 901 | } |
876 | 902 | ||
877 | void Launcher::updateLink(const QString& link) | 903 | void Launcher::updateLink(const QString& link) |
878 | { | 904 | { |
879 | bool notify_sm = false; | 905 | bool notify_sm = false; |
880 | 906 | ||
881 | if (link.isNull()) { | 907 | if (link.isNull()) { |
882 | updateTabs(); | 908 | updateTabs(); |
883 | notify_sm = true; | 909 | notify_sm = true; |
884 | } | 910 | } |
885 | else if (link.isEmpty()) { | 911 | else if (link.isEmpty()) { |
886 | updateDocs(); | 912 | updateDocs(); |
887 | } | 913 | } |
888 | else { | 914 | else { |
889 | tabs->updateLink(link); | 915 | tabs->updateLink(link); |
890 | notify_sm = true; | 916 | notify_sm = true; |
891 | } | 917 | } |
892 | 918 | ||
893 | if ( notify_sm ) | 919 | if ( notify_sm ) |
894 | QCopEnvelope e ( "QPE/TaskBar", "reloadApps()" ); | 920 | QCopEnvelope e ( "QPE/TaskBar", "reloadApps()" ); |
895 | } | 921 | } |
896 | 922 | ||
897 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 923 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
898 | { | 924 | { |
899 | QDataStream stream( data, IO_ReadOnly ); | 925 | QDataStream stream( data, IO_ReadOnly ); |
900 | if ( msg == "linkChanged(QString)" ) { | 926 | if ( msg == "linkChanged(QString)" ) { |
901 | QString link; | 927 | QString link; |
902 | stream >> link; | 928 | stream >> link; |
903 | if ( in_lnk_props ) { | 929 | if ( in_lnk_props ) { |
904 | got_lnk_change = TRUE; | 930 | got_lnk_change = TRUE; |
905 | lnk_change = link; | 931 | lnk_change = link; |
906 | } else { | 932 | } else { |
907 | updateLink(link); | 933 | updateLink(link); |
908 | } | 934 | } |
909 | } else if ( msg == "busy()" ) { | 935 | } else if ( msg == "busy()" ) { |
910 | emit busy(); | 936 | emit busy(); |
911 | } else if ( msg == "notBusy(QString)" ) { | 937 | } else if ( msg == "notBusy(QString)" ) { |
912 | QString app; | 938 | QString app; |
913 | stream >> app; | 939 | stream >> app; |
914 | tabs->setBusy(FALSE); | 940 | tabs->setBusy(FALSE); |
915 | emit notBusy(app); | 941 | emit notBusy(app); |
916 | } else if ( msg == "mkdir(QString)" ) { | 942 | } else if ( msg == "mkdir(QString)" ) { |
917 | QString dir; | 943 | QString dir; |
918 | stream >> dir; | 944 | stream >> dir; |
919 | if ( !dir.isEmpty() ) | 945 | if ( !dir.isEmpty() ) |
920 | mkdir( dir ); | 946 | mkdir( dir ); |
921 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 947 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
922 | QString baseFile, sigFile; | 948 | QString baseFile, sigFile; |
923 | stream >> baseFile >> sigFile; | 949 | stream >> baseFile >> sigFile; |
924 | QRsync::generateSignature( baseFile, sigFile ); | 950 | QRsync::generateSignature( baseFile, sigFile ); |
925 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 951 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
926 | QString baseFile, sigFile, deltaFile; | 952 | QString baseFile, sigFile, deltaFile; |
927 | stream >> baseFile >> sigFile >> deltaFile; | 953 | stream >> baseFile >> sigFile >> deltaFile; |
928 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 954 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
929 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 955 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
930 | QString baseFile, deltaFile; | 956 | QString baseFile, deltaFile; |
931 | stream >> baseFile >> deltaFile; | 957 | stream >> baseFile >> deltaFile; |
932 | if ( !QFile::exists( baseFile ) ) { | 958 | if ( !QFile::exists( baseFile ) ) { |
933 | QFile f( baseFile ); | 959 | QFile f( baseFile ); |
934 | f.open( IO_WriteOnly ); | 960 | f.open( IO_WriteOnly ); |
935 | f.close(); | 961 | f.close(); |
936 | } | 962 | } |
937 | QRsync::applyDiff( baseFile, deltaFile ); | 963 | QRsync::applyDiff( baseFile, deltaFile ); |
938 | #ifndef QT_NO_COP | 964 | #ifndef QT_NO_COP |
939 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 965 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
940 | e << baseFile; | 966 | e << baseFile; |
941 | #endif | 967 | #endif |
942 | } else if ( msg == "rdiffCleanup()" ) { | 968 | } else if ( msg == "rdiffCleanup()" ) { |
943 | mkdir( "/tmp/rdiff" ); | 969 | mkdir( "/tmp/rdiff" ); |
944 | QDir dir; | 970 | QDir dir; |
945 | dir.setPath( "/tmp/rdiff" ); | 971 | dir.setPath( "/tmp/rdiff" ); |
946 | QStringList entries = dir.entryList(); | 972 | QStringList entries = dir.entryList(); |
947 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 973 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
948 | dir.remove( *it ); | 974 | dir.remove( *it ); |
949 | } else if ( msg == "sendHandshakeInfo()" ) { | 975 | } else if ( msg == "sendHandshakeInfo()" ) { |
950 | QString home = getenv( "HOME" ); | 976 | QString home = getenv( "HOME" ); |
951 | #ifndef QT_NO_COP | 977 | #ifndef QT_NO_COP |
952 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 978 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
953 | e << home; | 979 | e << home; |
954 | int locked = (int) Desktop::screenLocked(); | 980 | int locked = (int) Desktop::screenLocked(); |
955 | e << locked; | 981 | e << locked; |
956 | #endif | 982 | #endif |
957 | } else if ( msg == "autoStart(QString)" ) { | 983 | } else if ( msg == "autoStart(QString)" ) { |
958 | QString appName; | 984 | QString appName; |
959 | stream >> appName; | 985 | stream >> appName; |
960 | Config cfg( "autostart" ); | 986 | Config cfg( "autostart" ); |
961 | cfg.setGroup( "AutoStart" ); | 987 | cfg.setGroup( "AutoStart" ); |
962 | if ( appName.compare("clear") == 0){ | 988 | if ( appName.compare("clear") == 0){ |
963 | cfg.writeEntry("Apps", ""); | 989 | cfg.writeEntry("Apps", ""); |
964 | } | 990 | } |
965 | } else if ( msg == "autoStart(QString,QString)" ) { | 991 | } else if ( msg == "autoStart(QString,QString)" ) { |
966 | QString modifier, appName; | 992 | QString modifier, appName; |
967 | stream >> modifier >> appName; | 993 | stream >> modifier >> appName; |
968 | Config cfg( "autostart" ); | 994 | Config cfg( "autostart" ); |
969 | cfg.setGroup( "AutoStart" ); | 995 | cfg.setGroup( "AutoStart" ); |
970 | if ( modifier.compare("add") == 0 ){ | 996 | if ( modifier.compare("add") == 0 ){ |
971 | // only add if appname is entered | 997 | // only add if appname is entered |
972 | if (!appName.isEmpty()) { | 998 | if (!appName.isEmpty()) { |
973 | cfg.writeEntry("Apps", appName); | 999 | cfg.writeEntry("Apps", appName); |
974 | } | 1000 | } |
975 | } else if (modifier.compare("remove") == 0 ) { | 1001 | } else if (modifier.compare("remove") == 0 ) { |
976 | // need to change for multiple entries | 1002 | // need to change for multiple entries |
977 | // actually remove is right now simular to clear, but in future there | 1003 | // actually remove is right now simular to clear, but in future there |
978 | // should be multiple apps in autostart possible. | 1004 | // should be multiple apps in autostart possible. |
979 | QString checkName; | 1005 | QString checkName; |
980 | checkName = cfg.readEntry("Apps", ""); | 1006 | checkName = cfg.readEntry("Apps", ""); |
981 | if (checkName == appName) { | 1007 | if (checkName == appName) { |
982 | cfg.writeEntry("Apps", ""); | 1008 | cfg.writeEntry("Apps", ""); |
983 | } | 1009 | } |
984 | } | 1010 | } |
985 | // case the autostart feature should be delayed | 1011 | // case the autostart feature should be delayed |
986 | } else if ( msg == "autoStart(QString,QString,QString)") { | 1012 | } else if ( msg == "autoStart(QString,QString,QString)") { |
987 | QString modifier, appName, delay; | 1013 | QString modifier, appName, delay; |
988 | stream >> modifier >> appName >> delay; | 1014 | stream >> modifier >> appName >> delay; |
@@ -1096,175 +1122,175 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | |||
1096 | contents += ts.read(); | 1122 | contents += ts.read(); |
1097 | f.close(); | 1123 | f.close(); |
1098 | } else | 1124 | } else |
1099 | fake = TRUE; | 1125 | fake = TRUE; |
1100 | } | 1126 | } |
1101 | if (fake) { | 1127 | if (fake) { |
1102 | contents += "[Desktop Entry]\n"; | 1128 | contents += "[Desktop Entry]\n"; |
1103 | contents += "Categories = " + // No tr | 1129 | contents += "Categories = " + // No tr |
1104 | // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr | 1130 | // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr |
1105 | Qtopia::Record::idsToString( doc->categories() ) + "\n"; | 1131 | Qtopia::Record::idsToString( doc->categories() ) + "\n"; |
1106 | contents += "Name = "+doc->name()+"\n"; // No tr | 1132 | contents += "Name = "+doc->name()+"\n"; // No tr |
1107 | contents += "Type = "+doc->type()+"\n"; // No tr | 1133 | contents += "Type = "+doc->type()+"\n"; // No tr |
1108 | } | 1134 | } |
1109 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) | 1135 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) |
1110 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr | 1136 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr |
1111 | } | 1137 | } |
1112 | 1138 | ||
1113 | //qDebug( "sending length %d", contents.length() ); | 1139 | //qDebug( "sending length %d", contents.length() ); |
1114 | #ifndef QT_NO_COP | 1140 | #ifndef QT_NO_COP |
1115 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 1141 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
1116 | e << contents; | 1142 | e << contents; |
1117 | #endif | 1143 | #endif |
1118 | 1144 | ||
1119 | //qDebug( "================ \n\n%s\n\n===============", | 1145 | //qDebug( "================ \n\n%s\n\n===============", |
1120 | //contents.latin1() ); | 1146 | //contents.latin1() ); |
1121 | 1147 | ||
1122 | delete docsFolder; | 1148 | delete docsFolder; |
1123 | docsFolder = 0; | 1149 | docsFolder = 0; |
1124 | #ifdef QWS | 1150 | #ifdef QWS |
1125 | } else if ( msg == "setMouseProto(QString)" ) { | 1151 | } else if ( msg == "setMouseProto(QString)" ) { |
1126 | QString mice; | 1152 | QString mice; |
1127 | stream >> mice; | 1153 | stream >> mice; |
1128 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | 1154 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); |
1129 | qwsServer->openMouse(); | 1155 | qwsServer->openMouse(); |
1130 | } else if ( msg == "setKeyboard(QString)" ) { | 1156 | } else if ( msg == "setKeyboard(QString)" ) { |
1131 | QString kb; | 1157 | QString kb; |
1132 | stream >> kb; | 1158 | stream >> kb; |
1133 | setenv("QWS_KEYBOARD",kb.latin1(),1); | 1159 | setenv("QWS_KEYBOARD",kb.latin1(),1); |
1134 | qwsServer->openKeyboard(); | 1160 | qwsServer->openKeyboard(); |
1135 | #endif | 1161 | #endif |
1136 | } | 1162 | } |
1137 | } | 1163 | } |
1138 | 1164 | ||
1139 | void Launcher::cancelSync() | 1165 | void Launcher::cancelSync() |
1140 | { | 1166 | { |
1141 | #ifndef QT_NO_COP | 1167 | #ifndef QT_NO_COP |
1142 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 1168 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
1143 | #endif | 1169 | #endif |
1144 | } | 1170 | } |
1145 | 1171 | ||
1146 | void Launcher::launcherMessage( const QCString &msg, const QByteArray &data) | 1172 | void Launcher::launcherMessage( const QCString &msg, const QByteArray &data) |
1147 | { | 1173 | { |
1148 | QDataStream stream( data, IO_ReadOnly ); | 1174 | QDataStream stream( data, IO_ReadOnly ); |
1149 | if ( msg == "setTabView(QString,int)" ) { | 1175 | if ( msg == "setTabView(QString,int)" ) { |
1150 | QString id; | 1176 | QString id; |
1151 | stream >> id; | 1177 | stream >> id; |
1152 | int mode; | 1178 | int mode; |
1153 | stream >> mode; | 1179 | stream >> mode; |
1154 | if ( tabs->view(id) ) | 1180 | if ( tabs->view(id) ) |
1155 | tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode ); | 1181 | tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode ); |
1156 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { | 1182 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { |
1157 | QString id; | 1183 | QString id; |
1158 | stream >> id; | 1184 | stream >> id; |
1159 | int mode; | 1185 | int mode; |
1160 | stream >> mode; | 1186 | stream >> mode; |
1161 | QString pixmapOrColor; | 1187 | QString pixmapOrColor; |
1162 | stream >> pixmapOrColor; | 1188 | stream >> pixmapOrColor; |
1163 | if ( tabs->view(id) ) | 1189 | if ( tabs->view(id) ) |
1164 | tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 1190 | tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
1165 | } else if ( msg == "setTextColor(QString,QString)" ) { | 1191 | } else if ( msg == "setTextColor(QString,QString)" ) { |
1166 | QString id; | 1192 | QString id; |
1167 | stream >> id; | 1193 | stream >> id; |
1168 | QString color; | 1194 | QString color; |
1169 | stream >> color; | 1195 | stream >> color; |
1170 | if ( tabs->view(id) ) | 1196 | if ( tabs->view(id) ) |
1171 | tabs->view(id)->setTextColor( QColor(color) ); | 1197 | tabs->view(id)->setTextColor( QColor(color) ); |
1172 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { | 1198 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { |
1173 | QString id; | 1199 | QString id; |
1174 | stream >> id; | 1200 | stream >> id; |
1175 | QString fam; | 1201 | QString fam; |
1176 | stream >> fam; | 1202 | stream >> fam; |
1177 | int size; | 1203 | int size; |
1178 | stream >> size; | 1204 | stream >> size; |
1179 | int weight; | 1205 | int weight; |
1180 | stream >> weight; | 1206 | stream >> weight; |
1181 | int italic; | 1207 | int italic; |
1182 | stream >> italic; | 1208 | stream >> italic; |
1183 | if ( tabs->view(id) ) | 1209 | if ( tabs->view(id) ) |
1184 | if ( !fam. isEmpty ( )) | 1210 | if ( !fam. isEmpty ( )) |
1185 | tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); | 1211 | tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); |
1186 | else | 1212 | else |
1187 | tabs->view(id)->unsetViewFont(); | 1213 | tabs->view(id)->unsetViewFont(); |
1188 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); | 1214 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); |
1189 | } | 1215 | } |
1190 | else if ( msg == "setBusyIndicatorType(QString)" ) { | 1216 | else if ( msg == "setBusyIndicatorType(QString)" ) { |
1191 | QString type; | 1217 | QString type; |
1192 | stream >> type; | 1218 | stream >> type; |
1193 | tabs->setBusyIndicatorType(type); | 1219 | tabs->setBusyIndicatorType(type); |
1194 | } | 1220 | } |
1195 | else if ( msg == "home()" ) { | 1221 | else if ( msg == "home()" ) { |
1196 | if ( isVisibleWindow( winId ( ))) | 1222 | if ( isVisibleWindow( winId ( ))) |
1197 | nextView ( ); | 1223 | nextView ( ); |
1198 | else | 1224 | else |
1199 | raise ( ); | 1225 | raise ( ); |
1200 | 1226 | ||
1201 | } | 1227 | } |
1202 | } | 1228 | } |
1203 | 1229 | ||
1204 | void Launcher::storageChanged() | 1230 | void Launcher::storageChanged() |
1205 | { | 1231 | { |
1206 | if ( in_lnk_props ) { | 1232 | if ( in_lnk_props ) { |
1207 | got_lnk_change = TRUE; | 1233 | got_lnk_change = TRUE; |
1208 | lnk_change = QString::null; | 1234 | lnk_change = QString::null; |
1209 | } else { | 1235 | } else { |
1210 | updateLink( QString::null ); | 1236 | updateLink( QString::null ); |
1211 | } | 1237 | } |
1212 | } | 1238 | } |
1213 | 1239 | ||
1214 | 1240 | ||
1215 | bool Launcher::mkdir(const QString &localPath) | 1241 | bool Launcher::mkdir(const QString &localPath) |
1216 | { | 1242 | { |
1217 | QDir fullDir(localPath); | 1243 | QDir fullDir(localPath); |
1218 | if (fullDir.exists()) | 1244 | if (fullDir.exists()) |
1219 | return true; | 1245 | return true; |
1220 | 1246 | ||
1221 | // at this point the directory doesn't exist | 1247 | // at this point the directory doesn't exist |
1222 | // go through the directory tree and start creating the direcotories | 1248 | // go through the directory tree and start creating the direcotories |
1223 | // that don't exist; if we can't create the directories, return false | 1249 | // that don't exist; if we can't create the directories, return false |
1224 | 1250 | ||
1225 | QString dirSeps = "/"; | 1251 | QString dirSeps = "/"; |
1226 | int dirIndex = localPath.find(dirSeps); | 1252 | int dirIndex = localPath.find(dirSeps); |
1227 | QString checkedPath; | 1253 | QString checkedPath; |
1228 | 1254 | ||
1229 | // didn't find any seps; weird, use the cur dir instead | 1255 | // didn't find any seps; weird, use the cur dir instead |
1230 | if (dirIndex == -1) { | 1256 | if (dirIndex == -1) { |
1231 | //qDebug("No seperators found in path %s", localPath.latin1()); | 1257 | //qDebug("No seperators found in path %s", localPath.latin1()); |
1232 | checkedPath = QDir::currentDirPath(); | 1258 | checkedPath = QDir::currentDirPath(); |
1233 | } | 1259 | } |
1234 | 1260 | ||
1235 | while (checkedPath != localPath) { | 1261 | while (checkedPath != localPath) { |
1236 | // no more seperators found, use the local path | 1262 | // no more seperators found, use the local path |
1237 | if (dirIndex == -1) | 1263 | if (dirIndex == -1) |
1238 | checkedPath = localPath; | 1264 | checkedPath = localPath; |
1239 | else { | 1265 | else { |
1240 | // the next directory to check | 1266 | // the next directory to check |
1241 | checkedPath = localPath.left(dirIndex) + "/"; | 1267 | checkedPath = localPath.left(dirIndex) + "/"; |
1242 | // advance the iterator; the next dir seperator | 1268 | // advance the iterator; the next dir seperator |
1243 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 1269 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
1244 | } | 1270 | } |
1245 | 1271 | ||
1246 | QDir checkDir(checkedPath); | 1272 | QDir checkDir(checkedPath); |
1247 | if (!checkDir.exists()) { | 1273 | if (!checkDir.exists()) { |
1248 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 1274 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
1249 | 1275 | ||
1250 | if (!checkDir.mkdir(checkedPath)) { | 1276 | if (!checkDir.mkdir(checkedPath)) { |
1251 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 1277 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
1252 | return FALSE; | 1278 | return FALSE; |
1253 | } | 1279 | } |
1254 | } | 1280 | } |
1255 | 1281 | ||
1256 | } | 1282 | } |
1257 | return TRUE; | 1283 | return TRUE; |
1258 | } | 1284 | } |
1259 | 1285 | ||
1260 | void Launcher::preloadApps() | 1286 | void Launcher::preloadApps() |
1261 | { | 1287 | { |
1262 | Config cfg("Launcher"); | 1288 | Config cfg("Launcher"); |
1263 | cfg.setGroup("Preload"); | 1289 | cfg.setGroup("Preload"); |
1264 | QStringList apps = cfg.readListEntry("Apps",','); | 1290 | QStringList apps = cfg.readListEntry("Apps",','); |
1265 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 1291 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
1266 | #ifndef QT_NO_COP | 1292 | #ifndef QT_NO_COP |
1267 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 1293 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
1268 | #endif | 1294 | #endif |
1269 | } | 1295 | } |
1270 | } | 1296 | } |
diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h index 89bf6f3..c92ef5d 100644 --- a/core/launcher/launcher.h +++ b/core/launcher/launcher.h | |||
@@ -1,149 +1,151 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LAUNCHER_H | 20 | #ifndef LAUNCHER_H |
21 | #define LAUNCHER_H | 21 | #define LAUNCHER_H |
22 | 22 | ||
23 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
25 | #include <qtabbar.h> | 25 | #include <qtabbar.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qlist.h> | 28 | #include <qlist.h> |
29 | #include <qpe/palmtopuidgen.h> | 29 | #include <qpe/palmtopuidgen.h> |
30 | #include "launcherview.h" | 30 | #include "launcherview.h" |
31 | 31 | ||
32 | class AppLnk; | 32 | class AppLnk; |
33 | class AppLnkSet; | 33 | class AppLnkSet; |
34 | class DocLnkSet; | 34 | class DocLnkSet; |
35 | class QWidgetStack; | 35 | class QWidgetStack; |
36 | class StorageInfo; | 36 | class StorageInfo; |
37 | class SyncDialog; | 37 | class SyncDialog; |
38 | 38 | ||
39 | class CategoryTabBar : public QTabBar | 39 | class CategoryTabBar : public QTabBar |
40 | { | 40 | { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | CategoryTabBar( QWidget *parent=0, const char *name=0 ); | 43 | CategoryTabBar( QWidget *parent=0, const char *name=0 ); |
44 | ~CategoryTabBar(); | 44 | ~CategoryTabBar(); |
45 | 45 | ||
46 | protected slots: | 46 | protected slots: |
47 | virtual void layoutTabs(); | 47 | virtual void layoutTabs(); |
48 | 48 | ||
49 | protected: | 49 | protected: |
50 | void paint ( QPainter *p, QTab *t, bool f ) const; | 50 | void paint ( QPainter *p, QTab *t, bool f ) const; |
51 | void paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const; | 51 | void paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const; |
52 | }; | 52 | }; |
53 | 53 | ||
54 | class CategoryTabWidget : public QVBox { | 54 | class CategoryTabWidget : public QVBox { |
55 | // can't use a QTabWidget, since it won't let us set the frame style. | 55 | // can't use a QTabWidget, since it won't let us set the frame style. |
56 | Q_OBJECT | 56 | Q_OBJECT |
57 | public: | 57 | public: |
58 | CategoryTabWidget( QWidget* parent ); | 58 | CategoryTabWidget( QWidget* parent ); |
59 | void initializeCategories(AppLnkSet* rootFolder, AppLnkSet* docFolder, | 59 | void initializeCategories(AppLnkSet* rootFolder, AppLnkSet* docFolder, |
60 | const QList<FileSystem> &); | 60 | const QList<FileSystem> &); |
61 | void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); | 61 | void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); |
62 | void updateLink(const QString& linkfile); | 62 | void updateLink(const QString& linkfile); |
63 | void setBusy(bool on); | 63 | void setBusy(bool on); |
64 | QString getAllDocLinkInfo() const; | 64 | QString getAllDocLinkInfo() const; |
65 | LauncherView *view( const QString &id ); | 65 | LauncherView *view( const QString &id ); |
66 | void setBusyIndicatorType ( const QString &type ); | 66 | void setBusyIndicatorType ( const QString &type ); |
67 | signals: | 67 | signals: |
68 | void selected(const QString&); | 68 | void selected(const QString&); |
69 | void clicked(const AppLnk*); | 69 | void clicked(const AppLnk*); |
70 | void rightPressed(AppLnk*); | 70 | void rightPressed(AppLnk*); |
71 | 71 | ||
72 | public slots: | 72 | public slots: |
73 | void nextTab(); | 73 | void nextTab(); |
74 | void prevTab(); | 74 | void prevTab(); |
75 | void showTab(const QString&); | ||
75 | 76 | ||
76 | protected slots: | 77 | protected slots: |
77 | void tabProperties(); | 78 | void tabProperties(); |
78 | 79 | ||
79 | protected: | 80 | protected: |
80 | void setTabAppearance( const QString &id, Config &cfg ); | 81 | void setTabAppearance( const QString &id, Config &cfg ); |
81 | void paletteChange( const QPalette &p ); | 82 | void paletteChange( const QPalette &p ); |
82 | 83 | ||
83 | private: | 84 | private: |
84 | CategoryTabBar* categoryBar; | 85 | CategoryTabBar* categoryBar; |
85 | QWidgetStack* stack; | 86 | QWidgetStack* stack; |
86 | LauncherView* docview; | 87 | LauncherView* docview; |
87 | QStringList ids; | 88 | QStringList ids; |
88 | int tabs; | 89 | int tabs; |
89 | LauncherView* newView( const QString&, const QPixmap& pm, const QString& label ); | 90 | LauncherView* newView( const QString&, const QPixmap& pm, const QString& label ); |
90 | void addItem( const QString& ); | 91 | void addItem( const QString& ); |
91 | }; | 92 | }; |
92 | 93 | ||
93 | class Launcher : public QMainWindow | 94 | class Launcher : public QMainWindow |
94 | { | 95 | { |
95 | Q_OBJECT | 96 | Q_OBJECT |
96 | friend class LauncherPrivate; | 97 | friend class LauncherPrivate; |
97 | public: | 98 | public: |
98 | Launcher( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 99 | Launcher( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
99 | ~Launcher(); | 100 | ~Launcher(); |
100 | 101 | ||
101 | static QString appsFolderName(); | 102 | static QString appsFolderName(); |
102 | 103 | ||
103 | virtual void showMaximized(); | 104 | virtual void showMaximized(); |
104 | static bool mkdir(const QString &path); | 105 | static bool mkdir(const QString &path); |
105 | 106 | ||
106 | public slots: | 107 | public slots: |
107 | void viewSelected(const QString&); | 108 | void viewSelected(const QString&); |
109 | void showTab(const QString&); | ||
108 | void select( const AppLnk * ); | 110 | void select( const AppLnk * ); |
109 | void externalSelected( const AppLnk *); | 111 | void externalSelected( const AppLnk *); |
110 | void properties( AppLnk * ); | 112 | void properties( AppLnk * ); |
111 | void nextView(); | 113 | void nextView(); |
112 | 114 | ||
113 | signals: | 115 | signals: |
114 | void executing( const AppLnk * ); | 116 | void executing( const AppLnk * ); |
115 | void busy(); | 117 | void busy(); |
116 | void notBusy(const QString&); | 118 | void notBusy(const QString&); |
117 | 119 | ||
118 | private slots: | 120 | private slots: |
119 | void doMaximize(); | 121 | void doMaximize(); |
120 | void systemMessage( const QCString &, const QByteArray &); | 122 | void systemMessage( const QCString &, const QByteArray &); |
121 | void launcherMessage( const QCString &, const QByteArray &); | 123 | void launcherMessage( const QCString &, const QByteArray &); |
122 | void storageChanged(); | 124 | void storageChanged(); |
123 | void cancelSync(); | 125 | void cancelSync(); |
124 | 126 | ||
125 | private: | 127 | private: |
126 | void updateApps(); | 128 | void updateApps(); |
127 | void loadDocs(); | 129 | void loadDocs(); |
128 | void updateDocs(); | 130 | void updateDocs(); |
129 | void updateTabs(); | 131 | void updateTabs(); |
130 | void updateMimeTypes(); | 132 | void updateMimeTypes(); |
131 | void updateMimeTypes(AppLnkSet*); | 133 | void updateMimeTypes(AppLnkSet*); |
132 | void preloadApps(); | 134 | void preloadApps(); |
133 | AppLnkSet *rootFolder; | 135 | AppLnkSet *rootFolder; |
134 | DocLnkSet *docsFolder; | 136 | DocLnkSet *docsFolder; |
135 | CategoryTabWidget *tabs; | 137 | CategoryTabWidget *tabs; |
136 | StorageInfo *storage; | 138 | StorageInfo *storage; |
137 | SyncDialog *syncDialog; | 139 | SyncDialog *syncDialog; |
138 | 140 | ||
139 | void updateLink(const QString& link); | 141 | void updateLink(const QString& link); |
140 | bool in_lnk_props; | 142 | bool in_lnk_props; |
141 | bool got_lnk_change; | 143 | bool got_lnk_change; |
142 | QString lnk_change; | 144 | QString lnk_change; |
143 | 145 | ||
144 | QString m_timeStamp; | 146 | QString m_timeStamp; |
145 | Qtopia::UidGen uidgen; | 147 | Qtopia::UidGen uidgen; |
146 | }; | 148 | }; |
147 | 149 | ||
148 | #endif // LAUNCHERVIEW_H | 150 | #endif // LAUNCHERVIEW_H |
149 | 151 | ||