-rw-r--r-- | core/launcher/launcher.cpp | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 8fe41f7..222592b 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -1,840 +1,875 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (c) 2002 Holger zecke Freyther | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 4 | ** |
4 | ** This file is part of Qtopia Environment. | 5 | ** This file is part of Qtopia Environment. |
5 | ** | 6 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 7 | ** 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 | 8 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 10 | ** packaging of this file. |
10 | ** | 11 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** 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. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 14 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 16 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 18 | ** not clear to you. |
18 | ** | 19 | ** |
19 | **********************************************************************/ | 20 | **********************************************************************/ |
20 | 21 | ||
21 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT | 22 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT |
22 | // have this class. | 23 | // have this class. |
23 | #define QTOPIA_INTERNAL_FSLP | 24 | #define QTOPIA_INTERNAL_FSLP |
24 | 25 | ||
26 | #include <opie/oconfig.h> | ||
25 | #include <qpe/qcopenvelope_qws.h> | 27 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
27 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
28 | #include <qpe/config.h> | 30 | #include <qpe/config.h> |
29 | #include <qpe/global.h> | 31 | #include <qpe/global.h> |
30 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
31 | #include <qpe/mimetype.h> | 33 | #include <qpe/mimetype.h> |
32 | #include <qpe/storage.h> | 34 | #include <qpe/storage.h> |
33 | #include <qpe/palmtoprecord.h> | 35 | #include <qpe/palmtoprecord.h> |
34 | 36 | ||
37 | #include <qdatetime.h> | ||
35 | #include <qdir.h> | 38 | #include <qdir.h> |
36 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
37 | #include <qtimer.h> | 40 | #include <qtimer.h> |
38 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
39 | #include <qvbox.h> | 42 | #include <qvbox.h> |
40 | #include <qlayout.h> | 43 | #include <qlayout.h> |
41 | #include <qstyle.h> | 44 | #include <qstyle.h> |
42 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
43 | #include <qtabbar.h> | 46 | #include <qtabbar.h> |
44 | #include <qwidgetstack.h> | 47 | #include <qwidgetstack.h> |
45 | #include <qlayout.h> | 48 | #include <qlayout.h> |
46 | #include <qregexp.h> | 49 | #include <qregexp.h> |
47 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
48 | #include <qframe.h> | 51 | #include <qframe.h> |
49 | #include <qpainter.h> | 52 | #include <qpainter.h> |
50 | #include <qlabel.h> | 53 | #include <qlabel.h> |
51 | #include <qtextstream.h> | 54 | #include <qtextstream.h> |
52 | 55 | ||
53 | #include "launcherview.h" | 56 | #include "launcherview.h" |
54 | #include "launcher.h" | 57 | #include "launcher.h" |
55 | #include "syncdialog.h" | 58 | #include "syncdialog.h" |
56 | #include "desktop.h" | 59 | #include "desktop.h" |
57 | #include <qpe/lnkproperties.h> | 60 | #include <qpe/lnkproperties.h> |
58 | #include "mrulist.h" | 61 | #include "mrulist.h" |
59 | #include "qrsync.h" | 62 | #include "qrsync.h" |
60 | #include <stdlib.h> | 63 | #include <stdlib.h> |
61 | #include <unistd.h> | 64 | #include <unistd.h> |
62 | 65 | ||
63 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 66 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
64 | #include <stdio.h> | 67 | #include <stdio.h> |
65 | #include <sys/vfs.h> | 68 | #include <sys/vfs.h> |
66 | #include <mntent.h> | 69 | #include <mntent.h> |
67 | #endif | 70 | #endif |
68 | 71 | ||
72 | #include <qpe/storage.h> | ||
73 | #include "mediummountgui.h" | ||
69 | //#define SHOW_ALL | 74 | //#define SHOW_ALL |
70 | 75 | ||
71 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : | 76 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : |
72 | QVBox( parent ) | 77 | QVBox( parent ) |
73 | { | 78 | { |
74 | categoryBar = 0; | 79 | categoryBar = 0; |
75 | stack = 0; | 80 | stack = 0; |
76 | } | 81 | } |
77 | 82 | ||
78 | void CategoryTabWidget::prevTab() | 83 | void CategoryTabWidget::prevTab() |
79 | { | 84 | { |
80 | if ( categoryBar ) { | 85 | if ( categoryBar ) { |
81 | int n = categoryBar->count(); | 86 | int n = categoryBar->count(); |
82 | int tab = categoryBar->currentTab(); | 87 | int tab = categoryBar->currentTab(); |
83 | if ( tab >= 0 ) | 88 | if ( tab >= 0 ) |
84 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); | 89 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); |
85 | } | 90 | } |
86 | } | 91 | } |
87 | 92 | ||
88 | void CategoryTabWidget::nextTab() | 93 | void CategoryTabWidget::nextTab() |
89 | { | 94 | { |
90 | if ( categoryBar ) { | 95 | if ( categoryBar ) { |
91 | int n = categoryBar->count(); | 96 | int n = categoryBar->count(); |
92 | int tab = categoryBar->currentTab(); | 97 | int tab = categoryBar->currentTab(); |
93 | categoryBar->setCurrentTab( (tab + 1)%n ); | 98 | categoryBar->setCurrentTab( (tab + 1)%n ); |
94 | } | 99 | } |
95 | } | 100 | } |
96 | 101 | ||
97 | void CategoryTabWidget::addItem( const QString& linkfile ) | 102 | void CategoryTabWidget::addItem( const QString& linkfile ) |
98 | { | 103 | { |
99 | int i=0; | 104 | int i=0; |
100 | AppLnk *app = new AppLnk(linkfile); | 105 | AppLnk *app = new AppLnk(linkfile); |
101 | if ( !app->isValid() ) { | 106 | if ( !app->isValid() ) { |
102 | delete app; | 107 | delete app; |
103 | return; | 108 | return; |
104 | } | 109 | } |
105 | if ( !app->file().isEmpty() ) { | 110 | if ( !app->file().isEmpty() ) { |
106 | // A document | 111 | // A document |
107 | delete app; | 112 | delete app; |
108 | app = new DocLnk(linkfile); | 113 | app = new DocLnk(linkfile); |
109 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); | 114 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); |
110 | return; | 115 | return; |
111 | } | 116 | } |
112 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { | 117 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { |
113 | if ( !(*it).isEmpty() ) { | 118 | if ( !(*it).isEmpty() ) { |
114 | QRegExp tf(*it,FALSE,TRUE); | 119 | QRegExp tf(*it,FALSE,TRUE); |
115 | if ( tf.match(app->type()) >= 0 ) { | 120 | if ( tf.match(app->type()) >= 0 ) { |
116 | ((LauncherView*)stack->widget(i))->addItem(app); | 121 | ((LauncherView*)stack->widget(i))->addItem(app); |
117 | return; | 122 | return; |
118 | } | 123 | } |
119 | i++; | 124 | i++; |
120 | } | 125 | } |
121 | } | 126 | } |
122 | } | 127 | } |
123 | 128 | ||
124 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | 129 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, |
125 | AppLnkSet* docFolder, const QList<FileSystem> &fs) | 130 | AppLnkSet* docFolder, const QList<FileSystem> &fs) |
126 | { | 131 | { |
127 | delete categoryBar; | 132 | delete categoryBar; |
128 | categoryBar = new CategoryTabBar( this ); | 133 | categoryBar = new CategoryTabBar( this ); |
129 | QPalette pal = categoryBar->palette(); | 134 | QPalette pal = categoryBar->palette(); |
130 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 135 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
131 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 136 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
132 | categoryBar->setPalette( pal ); | 137 | categoryBar->setPalette( pal ); |
133 | 138 | ||
134 | delete stack; | 139 | delete stack; |
135 | stack = new QWidgetStack(this); | 140 | stack = new QWidgetStack(this); |
136 | tabs=0; | 141 | tabs=0; |
137 | 142 | ||
138 | ids.clear(); | 143 | ids.clear(); |
139 | 144 | ||
140 | QStringList types = rootFolder->types(); | 145 | QStringList types = rootFolder->types(); |
141 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 146 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
142 | if ( !(*it).isEmpty() ) { | 147 | if ( !(*it).isEmpty() ) { |
143 | newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); | 148 | newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); |
144 | } | 149 | } |
145 | } | 150 | } |
146 | QListIterator<AppLnk> it( rootFolder->children() ); | 151 | QListIterator<AppLnk> it( rootFolder->children() ); |
147 | AppLnk* l; | 152 | AppLnk* l; |
148 | while ( (l=it.current()) ) { | 153 | while ( (l=it.current()) ) { |
149 | if ( l->type() == "Separator" ) { | 154 | if ( l->type() == "Separator" ) { |
150 | rootFolder->remove(l); | 155 | rootFolder->remove(l); |
151 | delete l; | 156 | delete l; |
152 | } else { | 157 | } else { |
153 | int i=0; | 158 | int i=0; |
154 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 159 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
155 | if ( *it == l->type() ) | 160 | if ( *it == l->type() ) |
156 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); | 161 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); |
157 | i++; | 162 | i++; |
158 | } | 163 | } |
159 | } | 164 | } |
160 | ++it; | 165 | ++it; |
161 | } | 166 | } |
162 | rootFolder->detachChildren(); | 167 | rootFolder->detachChildren(); |
163 | for (int i=0; i<tabs; i++) | 168 | for (int i=0; i<tabs; i++) |
164 | ((LauncherView*)stack->widget(i))->sort(); | 169 | ((LauncherView*)stack->widget(i))->sort(); |
165 | 170 | ||
166 | // all documents | 171 | // all documents |
167 | docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); | 172 | docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); |
168 | docview->populate( docFolder, QString::null ); | 173 | docview->populate( docFolder, QString::null ); |
169 | docFolder->detachChildren(); | 174 | docFolder->detachChildren(); |
170 | docview->setFileSystems(fs); | 175 | docview->setFileSystems(fs); |
171 | docview->setToolsEnabled(TRUE); | 176 | docview->setToolsEnabled(TRUE); |
172 | 177 | ||
173 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); | 178 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); |
174 | 179 | ||
175 | ((LauncherView*)stack->widget(0))->setFocus(); | 180 | ((LauncherView*)stack->widget(0))->setFocus(); |
176 | 181 | ||
177 | categoryBar->show(); | 182 | categoryBar->show(); |
178 | stack->show(); | 183 | stack->show(); |
179 | } | 184 | } |
180 | 185 | ||
181 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) | 186 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) |
182 | { | 187 | { |
183 | docview->populate( docFolder, QString::null ); | 188 | docview->populate( docFolder, QString::null ); |
184 | docFolder->detachChildren(); | 189 | docFolder->detachChildren(); |
185 | docview->setFileSystems(fs); | 190 | docview->setFileSystems(fs); |
186 | docview->updateTools(); | 191 | docview->updateTools(); |
187 | } | 192 | } |
188 | 193 | ||
189 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 194 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
190 | { | 195 | { |
191 | LauncherView* view = new LauncherView( stack ); | 196 | LauncherView* view = new LauncherView( stack ); |
192 | connect( view, SIGNAL(clicked(const AppLnk*)), | 197 | connect( view, SIGNAL(clicked(const AppLnk*)), |
193 | this, SIGNAL(clicked(const AppLnk*))); | 198 | this, SIGNAL(clicked(const AppLnk*))); |
194 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 199 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
195 | this, SIGNAL(rightPressed(AppLnk*))); | 200 | this, SIGNAL(rightPressed(AppLnk*))); |
196 | ids.append(id); | 201 | ids.append(id); |
197 | categoryBar->addTab( new QTab( pm, label ) ); | 202 | categoryBar->addTab( new QTab( pm, label ) ); |
198 | stack->addWidget( view, tabs++ ); | 203 | stack->addWidget( view, tabs++ ); |
199 | return view; | 204 | return view; |
200 | } | 205 | } |
201 | 206 | ||
202 | void CategoryTabWidget::updateLink(const QString& linkfile) | 207 | void CategoryTabWidget::updateLink(const QString& linkfile) |
203 | { | 208 | { |
204 | int i=0; | 209 | int i=0; |
205 | LauncherView* view; | 210 | LauncherView* view; |
206 | while ((view = (LauncherView*)stack->widget(i++))) { | 211 | while ((view = (LauncherView*)stack->widget(i++))) { |
207 | if ( view->removeLink(linkfile) ) | 212 | if ( view->removeLink(linkfile) ) |
208 | break; | 213 | break; |
209 | } | 214 | } |
210 | addItem(linkfile); | 215 | addItem(linkfile); |
211 | docview->updateTools(); | 216 | docview->updateTools(); |
212 | } | 217 | } |
213 | 218 | ||
214 | void CategoryTabWidget::paletteChange( const QPalette &p ) | 219 | void CategoryTabWidget::paletteChange( const QPalette &p ) |
215 | { | 220 | { |
216 | QVBox::paletteChange( p ); | 221 | QVBox::paletteChange( p ); |
217 | QPalette pal = palette(); | 222 | QPalette pal = palette(); |
218 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 223 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
219 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 224 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
220 | categoryBar->setPalette( pal ); | 225 | categoryBar->setPalette( pal ); |
221 | categoryBar->update(); | 226 | categoryBar->update(); |
222 | } | 227 | } |
223 | 228 | ||
224 | void CategoryTabWidget::setBusy(bool on) | 229 | void CategoryTabWidget::setBusy(bool on) |
225 | { | 230 | { |
226 | if ( on ) | 231 | if ( on ) |
227 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); | 232 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); |
228 | else | 233 | else |
229 | for (int i=0; i<tabs; i++) | 234 | for (int i=0; i<tabs; i++) |
230 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); | 235 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); |
231 | } | 236 | } |
232 | 237 | ||
233 | 238 | ||
234 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) | 239 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) |
235 | : QTabBar( parent, name ) | 240 | : QTabBar( parent, name ) |
236 | { | 241 | { |
237 | setFocusPolicy( NoFocus ); | 242 | setFocusPolicy( NoFocus ); |
238 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); | 243 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); |
239 | } | 244 | } |
240 | 245 | ||
241 | CategoryTabBar::~CategoryTabBar() | 246 | CategoryTabBar::~CategoryTabBar() |
242 | { | 247 | { |
243 | } | 248 | } |
244 | 249 | ||
245 | void CategoryTabBar::layoutTabs() | 250 | void CategoryTabBar::layoutTabs() |
246 | { | 251 | { |
247 | if ( !count() ) | 252 | if ( !count() ) |
248 | return; | 253 | return; |
249 | 254 | ||
250 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; | 255 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; |
251 | int hiddenTabWidth = -12; | 256 | int hiddenTabWidth = -12; |
252 | int middleTab = currentTab(); | 257 | int middleTab = currentTab(); |
253 | int hframe, vframe, overlap; | 258 | int hframe, vframe, overlap; |
254 | style().tabbarMetrics( this, hframe, vframe, overlap ); | 259 | style().tabbarMetrics( this, hframe, vframe, overlap ); |
255 | QFontMetrics fm = fontMetrics(); | 260 | QFontMetrics fm = fontMetrics(); |
256 | int x = 0; | 261 | int x = 0; |
257 | QRect r; | 262 | QRect r; |
258 | QTab *t; | 263 | QTab *t; |
259 | int available = width()-1; | 264 | int available = width()-1; |
260 | int required = 0; | 265 | int required = 0; |
261 | for ( int i = 0; i < count(); i++ ) { | 266 | for ( int i = 0; i < count(); i++ ) { |
262 | t = tab(i); | 267 | t = tab(i); |
263 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 268 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { |
264 | if ( i != middleTab ) { | 269 | if ( i != middleTab ) { |
265 | // required += hiddenTabWidth + hframe - overlap; | 270 | // required += hiddenTabWidth + hframe - overlap; |
266 | available -= hiddenTabWidth + hframe - overlap; | 271 | available -= hiddenTabWidth + hframe - overlap; |
267 | if ( t->iconSet() != 0 ) | 272 | if ( t->iconSet() != 0 ) |
268 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 273 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
269 | } else { | 274 | } else { |
270 | required += fm.width( t->text() ) + hframe - overlap; | 275 | required += fm.width( t->text() ) + hframe - overlap; |
271 | if ( t->iconSet() != 0 ) | 276 | if ( t->iconSet() != 0 ) |
272 | required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 277 | required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
273 | } | 278 | } |
274 | } | 279 | } |
275 | for ( int i = 0; i < count(); i++ ) { | 280 | for ( int i = 0; i < count(); i++ ) { |
276 | t = tab(i); | 281 | t = tab(i); |
277 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 282 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { |
278 | if ( i != middleTab ) { | 283 | if ( i != middleTab ) { |
279 | int w = hiddenTabWidth; | 284 | int w = hiddenTabWidth; |
280 | int ih = 0; | 285 | int ih = 0; |
281 | if ( t->iconSet() != 0 ) { | 286 | if ( t->iconSet() != 0 ) { |
282 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 287 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
283 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 288 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
284 | } | 289 | } |
285 | int h = QMAX( fm.height(), ih ); | 290 | int h = QMAX( fm.height(), ih ); |
286 | h = QMAX( h, QApplication::globalStrut().height() ); | 291 | h = QMAX( h, QApplication::globalStrut().height() ); |
287 | 292 | ||
288 | h += vframe; | 293 | h += vframe; |
289 | w += hframe; | 294 | w += hframe; |
290 | 295 | ||
291 | t->setRect( QRect(x, 0, w, h) ); | 296 | t->setRect( QRect(x, 0, w, h) ); |
292 | x += t->rect().width() - overlap; | 297 | x += t->rect().width() - overlap; |
293 | r = r.unite( t->rect() ); | 298 | r = r.unite( t->rect() ); |
294 | } else { | 299 | } else { |
295 | int w = fm.width( t->text() ); | 300 | int w = fm.width( t->text() ); |
296 | int ih = 0; | 301 | int ih = 0; |
297 | if ( t->iconSet() != 0 ) { | 302 | if ( t->iconSet() != 0 ) { |
298 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 303 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
299 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 304 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
300 | } | 305 | } |
301 | int h = QMAX( fm.height(), ih ); | 306 | int h = QMAX( fm.height(), ih ); |
302 | h = QMAX( h, QApplication::globalStrut().height() ); | 307 | h = QMAX( h, QApplication::globalStrut().height() ); |
303 | 308 | ||
304 | h += vframe; | 309 | h += vframe; |
305 | w += hframe; | 310 | w += hframe; |
306 | 311 | ||
307 | // t->setRect( QRect(x, 0, w * available/required, h) ); | 312 | // t->setRect( QRect(x, 0, w * available/required, h) ); |
308 | t->setRect( QRect(x, 0, available, h) ); | 313 | t->setRect( QRect(x, 0, available, h) ); |
309 | x += t->rect().width() - overlap; | 314 | x += t->rect().width() - overlap; |
310 | r = r.unite( t->rect() ); | 315 | r = r.unite( t->rect() ); |
311 | } | 316 | } |
312 | } | 317 | } |
313 | 318 | ||
314 | QRect rr = tab(count()-1)->rect(); | 319 | QRect rr = tab(count()-1)->rect(); |
315 | rr.setRight(width()-1); | 320 | rr.setRight(width()-1); |
316 | tab(count()-1)->setRect( rr ); | 321 | tab(count()-1)->setRect( rr ); |
317 | 322 | ||
318 | for ( t = tabList()->first(); t; t = tabList()->next() ) { | 323 | for ( t = tabList()->first(); t; t = tabList()->next() ) { |
319 | QRect tr = t->rect(); | 324 | QRect tr = t->rect(); |
320 | tr.setHeight( r.height() ); | 325 | tr.setHeight( r.height() ); |
321 | t->setRect( tr ); | 326 | t->setRect( tr ); |
322 | } | 327 | } |
323 | 328 | ||
324 | update(); | 329 | update(); |
325 | } | 330 | } |
326 | 331 | ||
327 | 332 | ||
328 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const | 333 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const |
329 | { | 334 | { |
330 | #if QT_VERSION >= 300 | 335 | #if QT_VERSION >= 300 |
331 | QStyle::SFlags flags = QStyle::Style_Default; | 336 | QStyle::SFlags flags = QStyle::Style_Default; |
332 | if ( selected ) | 337 | if ( selected ) |
333 | flags |= QStyle::Style_Selected; | 338 | flags |= QStyle::Style_Selected; |
334 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), | 339 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), |
335 | colorGroup(), flags, QStyleOption(t) ); | 340 | colorGroup(), flags, QStyleOption(t) ); |
336 | #else | 341 | #else |
337 | style().drawTab( p, this, t, selected ); | 342 | style().drawTab( p, this, t, selected ); |
338 | #endif | 343 | #endif |
339 | 344 | ||
340 | QRect r( t->rect() ); | 345 | QRect r( t->rect() ); |
341 | QFont f( font() ); | 346 | QFont f( font() ); |
342 | if ( selected ) | 347 | if ( selected ) |
343 | f.setBold( TRUE ); | 348 | f.setBold( TRUE ); |
344 | p->setFont( f ); | 349 | p->setFont( f ); |
345 | 350 | ||
346 | int iw = 0; | 351 | int iw = 0; |
347 | int ih = 0; | 352 | int ih = 0; |
348 | if ( t->iconSet() != 0 ) { | 353 | if ( t->iconSet() != 0 ) { |
349 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; | 354 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; |
350 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 355 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
351 | } | 356 | } |
352 | int w = iw + p->fontMetrics().width( t->text() ) + 4; | 357 | int w = iw + p->fontMetrics().width( t->text() ) + 4; |
353 | int h = QMAX(p->fontMetrics().height() + 4, ih ); | 358 | int h = QMAX(p->fontMetrics().height() + 4, ih ); |
354 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, | 359 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, |
355 | r.top() + (r.height()-h)/2, w, h ), t, | 360 | r.top() + (r.height()-h)/2, w, h ), t, |
356 | #if QT_VERSION >= 300 | 361 | #if QT_VERSION >= 300 |
357 | t->identifier() == keyboardFocusTab() | 362 | t->identifier() == keyboardFocusTab() |
358 | #else | 363 | #else |
359 | t->identitifer() == keyboardFocusTab() | 364 | t->identitifer() == keyboardFocusTab() |
360 | #endif | 365 | #endif |
361 | ); | 366 | ); |
362 | } | 367 | } |
363 | 368 | ||
364 | 369 | ||
365 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, | 370 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, |
366 | QTab* t, bool has_focus ) const | 371 | QTab* t, bool has_focus ) const |
367 | { | 372 | { |
368 | QRect r = t->rect(); | 373 | QRect r = t->rect(); |
369 | // if ( t->id != currentTab() ) | 374 | // if ( t->id != currentTab() ) |
370 | //r.moveBy( 1, 1 ); | 375 | //r.moveBy( 1, 1 ); |
371 | // | 376 | // |
372 | if ( t->iconSet() ) { | 377 | if ( t->iconSet() ) { |
373 | // the tab has an iconset, draw it in the right mode | 378 | // the tab has an iconset, draw it in the right mode |
374 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; | 379 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; |
375 | if ( mode == QIconSet::Normal && has_focus ) | 380 | if ( mode == QIconSet::Normal && has_focus ) |
376 | mode = QIconSet::Active; | 381 | mode = QIconSet::Active; |
377 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); | 382 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); |
378 | int pixw = pixmap.width(); | 383 | int pixw = pixmap.width(); |
379 | int pixh = pixmap.height(); | 384 | int pixh = pixmap.height(); |
380 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); | 385 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); |
381 | r.setLeft( r.left() + pixw + 5 ); | 386 | r.setLeft( r.left() + pixw + 5 ); |
382 | } | 387 | } |
383 | 388 | ||
384 | QRect tr = r; | 389 | QRect tr = r; |
385 | 390 | ||
386 | if ( r.width() < 20 ) | 391 | if ( r.width() < 20 ) |
387 | return; | 392 | return; |
388 | 393 | ||
389 | if ( t->isEnabled() && isEnabled() ) { | 394 | if ( t->isEnabled() && isEnabled() ) { |
390 | #if defined(_WS_WIN32_) | 395 | #if defined(_WS_WIN32_) |
391 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) | 396 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) |
392 | p->setPen( colorGroup().buttonText() ); | 397 | p->setPen( colorGroup().buttonText() ); |
393 | else | 398 | else |
394 | p->setPen( colorGroup().foreground() ); | 399 | p->setPen( colorGroup().foreground() ); |
395 | #else | 400 | #else |
396 | p->setPen( colorGroup().foreground() ); | 401 | p->setPen( colorGroup().foreground() ); |
397 | #endif | 402 | #endif |
398 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 403 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
399 | } else { | 404 | } else { |
400 | p->setPen( palette().disabled().foreground() ); | 405 | p->setPen( palette().disabled().foreground() ); |
401 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 406 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
402 | } | 407 | } |
403 | } | 408 | } |
404 | 409 | ||
405 | //--------------------------------------------------------------------------- | 410 | //--------------------------------------------------------------------------- |
406 | 411 | ||
407 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | 412 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) |
408 | : QMainWindow( parent, name, fl ) | 413 | : QMainWindow( parent, name, fl ) |
409 | { | 414 | { |
410 | setCaption( tr("Launcher") ); | 415 | setCaption( tr("Launcher") ); |
411 | 416 | ||
412 | syncDialog = 0; | 417 | syncDialog = 0; |
413 | 418 | ||
414 | // we have a pretty good idea how big we'll be | 419 | // we have a pretty good idea how big we'll be |
415 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 420 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
416 | 421 | ||
417 | tabs = 0; | 422 | tabs = 0; |
418 | rootFolder = 0; | 423 | rootFolder = 0; |
419 | docsFolder = 0; | 424 | docsFolder = 0; |
425 | m_timeStamp = QDateTime::currentDateTime().toString(); | ||
420 | 426 | ||
421 | tabs = new CategoryTabWidget( this ); | 427 | tabs = new CategoryTabWidget( this ); |
422 | tabs->setMaximumWidth( qApp->desktop()->width() ); | 428 | tabs->setMaximumWidth( qApp->desktop()->width() ); |
423 | setCentralWidget( tabs ); | 429 | setCentralWidget( tabs ); |
424 | 430 | ||
425 | connect( tabs, SIGNAL(selected(const QString&)), | 431 | connect( tabs, SIGNAL(selected(const QString&)), |
426 | this, SLOT(viewSelected(const QString&)) ); | 432 | this, SLOT(viewSelected(const QString&)) ); |
427 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 433 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
428 | this, SLOT(select(const AppLnk*))); | 434 | this, SLOT(select(const AppLnk*))); |
429 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 435 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
430 | this, SLOT(properties(AppLnk*))); | 436 | this, SLOT(properties(AppLnk*))); |
431 | 437 | ||
432 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 438 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
433 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 439 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
434 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 440 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
435 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); | 441 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); |
436 | #endif | 442 | #endif |
437 | 443 | ||
438 | storage = new StorageInfo( this ); | 444 | storage = new StorageInfo( this ); |
439 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); | 445 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); |
440 | 446 | ||
441 | updateTabs(); | 447 | updateTabs(); |
442 | 448 | ||
443 | preloadApps(); | 449 | preloadApps(); |
444 | 450 | ||
445 | in_lnk_props = FALSE; | 451 | in_lnk_props = FALSE; |
446 | got_lnk_change = FALSE; | 452 | got_lnk_change = FALSE; |
447 | } | 453 | } |
448 | 454 | ||
449 | Launcher::~Launcher() | 455 | Launcher::~Launcher() |
450 | { | 456 | { |
451 | } | 457 | } |
452 | 458 | ||
453 | static bool isVisibleWindow(int wid) | 459 | static bool isVisibleWindow(int wid) |
454 | { | 460 | { |
455 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 461 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
456 | QWSWindow* w; | 462 | QWSWindow* w; |
457 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 463 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
458 | if ( w->winId() == wid ) | 464 | if ( w->winId() == wid ) |
459 | return !w->isFullyObscured(); | 465 | return !w->isFullyObscured(); |
460 | } | 466 | } |
461 | return FALSE; | 467 | return FALSE; |
462 | } | 468 | } |
463 | 469 | ||
464 | void Launcher::showMaximized() | 470 | void Launcher::showMaximized() |
465 | { | 471 | { |
466 | if ( isVisibleWindow( winId() ) ) | 472 | if ( isVisibleWindow( winId() ) ) |
467 | doMaximize(); | 473 | doMaximize(); |
468 | else | 474 | else |
469 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); | 475 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); |
470 | } | 476 | } |
471 | 477 | ||
472 | void Launcher::doMaximize() | 478 | void Launcher::doMaximize() |
473 | { | 479 | { |
474 | QMainWindow::showMaximized(); | 480 | QMainWindow::showMaximized(); |
475 | } | 481 | } |
476 | 482 | ||
477 | void Launcher::updateMimeTypes() | 483 | void Launcher::updateMimeTypes() |
478 | { | 484 | { |
479 | MimeType::clear(); | 485 | MimeType::clear(); |
480 | updateMimeTypes(rootFolder); | 486 | updateMimeTypes(rootFolder); |
481 | } | 487 | } |
482 | 488 | ||
483 | void Launcher::updateMimeTypes(AppLnkSet* folder) | 489 | void Launcher::updateMimeTypes(AppLnkSet* folder) |
484 | { | 490 | { |
485 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { | 491 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { |
486 | AppLnk *app = it.current(); | 492 | AppLnk *app = it.current(); |
487 | if ( app->type() == "Folder" ) | 493 | if ( app->type() == "Folder" ) |
488 | updateMimeTypes((AppLnkSet *)app); | 494 | updateMimeTypes((AppLnkSet *)app); |
489 | else { | 495 | else { |
490 | MimeType::registerApp(*app); | 496 | MimeType::registerApp(*app); |
491 | } | 497 | } |
492 | } | 498 | } |
493 | } | 499 | } |
494 | 500 | ||
495 | void Launcher::loadDocs() | 501 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: |
496 | { | 502 | { |
497 | delete docsFolder; | 503 | delete docsFolder; |
498 | docsFolder = new DocLnkSet; | 504 | docsFolder = new DocLnkSet; |
499 | Global::findDocuments(docsFolder); | 505 | // find out wich filesystems are new in this round |
506 | // We will do this by having a timestamp inside each mountpoint | ||
507 | // if the current timestamp doesn't match this is a new file system and | ||
508 | // come up with our MediumMountGui :) let the hacking begin | ||
509 | QString newStamp = QDateTime::currentDateTime().toString(); | ||
510 | StorageInfo storage; | ||
511 | const QList<FileSystem> &fileSystems = storage.fileSystems(); | ||
512 | QListIterator<FileSystem> it ( fileSystems ); | ||
513 | for ( ; it.current(); ++it ) { | ||
514 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | ||
515 | OConfig cfg( (*it)->path() + "/.opiestorage.cf"); | ||
516 | cfg.setGroup("main"); | ||
517 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); | ||
518 | if( stamp == m_timeStamp ){ // ok we know this card | ||
519 | cfg.writeEntry("timestamp", newStamp ); | ||
520 | // we need to scan the list now. Hopefully the cache will be there | ||
521 | }else{ // come up with the gui | ||
522 | MediumMountGui medium((*it)->path() + "/.opiestorage.cf" ); | ||
523 | if( medium.check() ){ | ||
524 | if( medium.exec() ){ //ok | ||
525 | // speicher | ||
526 | } | ||
527 | }else{ | ||
528 | // do something different see what we need to do | ||
529 | } | ||
530 | } | ||
531 | } | ||
532 | } | ||
533 | Global::findDocuments(docsFolder); // get rid of this call later | ||
534 | m_timeStamp = newStamp; | ||
500 | } | 535 | } |
501 | 536 | ||
502 | void Launcher::updateTabs() | 537 | void Launcher::updateTabs() |
503 | { | 538 | { |
504 | MimeType::updateApplications(); // ### reads all applnks twice | 539 | MimeType::updateApplications(); // ### reads all applnks twice |
505 | 540 | ||
506 | delete rootFolder; | 541 | delete rootFolder; |
507 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); | 542 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); |
508 | 543 | ||
509 | loadDocs(); | 544 | loadDocs(); |
510 | 545 | ||
511 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); | 546 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); |
512 | } | 547 | } |
513 | 548 | ||
514 | void Launcher::updateDocs() | 549 | void Launcher::updateDocs() |
515 | { | 550 | { |
516 | loadDocs(); | 551 | loadDocs(); |
517 | tabs->updateDocs(docsFolder,storage->fileSystems()); | 552 | tabs->updateDocs(docsFolder,storage->fileSystems()); |
518 | } | 553 | } |
519 | 554 | ||
520 | void Launcher::viewSelected(const QString& s) | 555 | void Launcher::viewSelected(const QString& s) |
521 | { | 556 | { |
522 | setCaption( s + tr(" - Launcher") ); | 557 | setCaption( s + tr(" - Launcher") ); |
523 | } | 558 | } |
524 | 559 | ||
525 | void Launcher::nextView() | 560 | void Launcher::nextView() |
526 | { | 561 | { |
527 | tabs->nextTab(); | 562 | tabs->nextTab(); |
528 | } | 563 | } |
529 | 564 | ||
530 | 565 | ||
531 | void Launcher::select( const AppLnk *appLnk ) | 566 | void Launcher::select( const AppLnk *appLnk ) |
532 | { | 567 | { |
533 | if ( appLnk->type() == "Folder" ) { | 568 | if ( appLnk->type() == "Folder" ) { |
534 | // Not supported: flat is simpler for the user | 569 | // Not supported: flat is simpler for the user |
535 | } else { | 570 | } else { |
536 | if ( appLnk->exec().isNull() ) { | 571 | if ( appLnk->exec().isNull() ) { |
537 | QMessageBox::information(this,tr("No application"), | 572 | QMessageBox::information(this,tr("No application"), |
538 | tr("<p>No application is defined for this document." | 573 | tr("<p>No application is defined for this document." |
539 | "<p>Type is %1.").arg(appLnk->type())); | 574 | "<p>Type is %1.").arg(appLnk->type())); |
540 | return; | 575 | return; |
541 | } | 576 | } |
542 | tabs->setBusy(TRUE); | 577 | tabs->setBusy(TRUE); |
543 | emit executing( appLnk ); | 578 | emit executing( appLnk ); |
544 | appLnk->execute(); | 579 | appLnk->execute(); |
545 | } | 580 | } |
546 | } | 581 | } |
547 | 582 | ||
548 | void Launcher::externalSelected(const AppLnk *appLnk) | 583 | void Launcher::externalSelected(const AppLnk *appLnk) |
549 | { | 584 | { |
550 | tabs->setBusy(TRUE); | 585 | tabs->setBusy(TRUE); |
551 | emit executing( appLnk ); | 586 | emit executing( appLnk ); |
552 | } | 587 | } |
553 | 588 | ||
554 | void Launcher::properties( AppLnk *appLnk ) | 589 | void Launcher::properties( AppLnk *appLnk ) |
555 | { | 590 | { |
556 | if ( appLnk->type() == "Folder" ) { | 591 | if ( appLnk->type() == "Folder" ) { |
557 | // Not supported: flat is simpler for the user | 592 | // Not supported: flat is simpler for the user |
558 | } else { | 593 | } else { |
559 | in_lnk_props = TRUE; | 594 | in_lnk_props = TRUE; |
560 | got_lnk_change = FALSE; | 595 | got_lnk_change = FALSE; |
561 | LnkProperties prop(appLnk); | 596 | LnkProperties prop(appLnk); |
562 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 597 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
563 | prop.showMaximized(); | 598 | prop.showMaximized(); |
564 | prop.exec(); | 599 | prop.exec(); |
565 | in_lnk_props = FALSE; | 600 | in_lnk_props = FALSE; |
566 | if ( got_lnk_change ) { | 601 | if ( got_lnk_change ) { |
567 | updateLink(lnk_change); | 602 | updateLink(lnk_change); |
568 | } | 603 | } |
569 | } | 604 | } |
570 | } | 605 | } |
571 | 606 | ||
572 | void Launcher::updateLink(const QString& link) | 607 | void Launcher::updateLink(const QString& link) |
573 | { | 608 | { |
574 | if (link.isNull()) | 609 | if (link.isNull()) |
575 | updateTabs(); | 610 | updateTabs(); |
576 | else if (link.isEmpty()) | 611 | else if (link.isEmpty()) |
577 | updateDocs(); | 612 | updateDocs(); |
578 | else | 613 | else |
579 | tabs->updateLink(link); | 614 | tabs->updateLink(link); |
580 | } | 615 | } |
581 | 616 | ||
582 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 617 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
583 | { | 618 | { |
584 | QDataStream stream( data, IO_ReadOnly ); | 619 | QDataStream stream( data, IO_ReadOnly ); |
585 | if ( msg == "linkChanged(QString)" ) { | 620 | if ( msg == "linkChanged(QString)" ) { |
586 | QString link; | 621 | QString link; |
587 | stream >> link; | 622 | stream >> link; |
588 | if ( in_lnk_props ) { | 623 | if ( in_lnk_props ) { |
589 | got_lnk_change = TRUE; | 624 | got_lnk_change = TRUE; |
590 | lnk_change = link; | 625 | lnk_change = link; |
591 | } else { | 626 | } else { |
592 | updateLink(link); | 627 | updateLink(link); |
593 | } | 628 | } |
594 | } else if ( msg == "busy()" ) { | 629 | } else if ( msg == "busy()" ) { |
595 | emit busy(); | 630 | emit busy(); |
596 | } else if ( msg == "notBusy(QString)" ) { | 631 | } else if ( msg == "notBusy(QString)" ) { |
597 | QString app; | 632 | QString app; |
598 | stream >> app; | 633 | stream >> app; |
599 | tabs->setBusy(FALSE); | 634 | tabs->setBusy(FALSE); |
600 | emit notBusy(app); | 635 | emit notBusy(app); |
601 | } else if ( msg == "mkdir(QString)" ) { | 636 | } else if ( msg == "mkdir(QString)" ) { |
602 | QString dir; | 637 | QString dir; |
603 | stream >> dir; | 638 | stream >> dir; |
604 | if ( !dir.isEmpty() ) | 639 | if ( !dir.isEmpty() ) |
605 | mkdir( dir ); | 640 | mkdir( dir ); |
606 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 641 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
607 | QString baseFile, sigFile; | 642 | QString baseFile, sigFile; |
608 | stream >> baseFile >> sigFile; | 643 | stream >> baseFile >> sigFile; |
609 | QRsync::generateSignature( baseFile, sigFile ); | 644 | QRsync::generateSignature( baseFile, sigFile ); |
610 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 645 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
611 | QString baseFile, sigFile, deltaFile; | 646 | QString baseFile, sigFile, deltaFile; |
612 | stream >> baseFile >> sigFile >> deltaFile; | 647 | stream >> baseFile >> sigFile >> deltaFile; |
613 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 648 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
614 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 649 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
615 | QString baseFile, deltaFile; | 650 | QString baseFile, deltaFile; |
616 | stream >> baseFile >> deltaFile; | 651 | stream >> baseFile >> deltaFile; |
617 | if ( !QFile::exists( baseFile ) ) { | 652 | if ( !QFile::exists( baseFile ) ) { |
618 | QFile f( baseFile ); | 653 | QFile f( baseFile ); |
619 | f.open( IO_WriteOnly ); | 654 | f.open( IO_WriteOnly ); |
620 | f.close(); | 655 | f.close(); |
621 | } | 656 | } |
622 | QRsync::applyDiff( baseFile, deltaFile ); | 657 | QRsync::applyDiff( baseFile, deltaFile ); |
623 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 658 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
624 | e << baseFile; | 659 | e << baseFile; |
625 | } else if ( msg == "rdiffCleanup()" ) { | 660 | } else if ( msg == "rdiffCleanup()" ) { |
626 | mkdir( "/tmp/rdiff" ); | 661 | mkdir( "/tmp/rdiff" ); |
627 | QDir dir; | 662 | QDir dir; |
628 | dir.setPath( "/tmp/rdiff" ); | 663 | dir.setPath( "/tmp/rdiff" ); |
629 | QStringList entries = dir.entryList(); | 664 | QStringList entries = dir.entryList(); |
630 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 665 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
631 | dir.remove( *it ); | 666 | dir.remove( *it ); |
632 | } else if ( msg == "sendHandshakeInfo()" ) { | 667 | } else if ( msg == "sendHandshakeInfo()" ) { |
633 | QString home = getenv( "HOME" ); | 668 | QString home = getenv( "HOME" ); |
634 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 669 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
635 | e << home; | 670 | e << home; |
636 | int locked = (int) Desktop::screenLocked(); | 671 | int locked = (int) Desktop::screenLocked(); |
637 | e << locked; | 672 | e << locked; |
638 | // register an app for autostart | 673 | // register an app for autostart |
639 | // if clear is send the list is cleared. | 674 | // if clear is send the list is cleared. |
640 | } else if ( msg == "autoStart(QString)" ) { | 675 | } else if ( msg == "autoStart(QString)" ) { |
641 | QString appName; | 676 | QString appName; |
642 | stream >> appName; | 677 | stream >> appName; |
643 | Config cfg( "autostart" ); | 678 | Config cfg( "autostart" ); |
644 | cfg.setGroup( "AutoStart" ); | 679 | cfg.setGroup( "AutoStart" ); |
645 | if ( appName.compare("clear") == 0){ | 680 | if ( appName.compare("clear") == 0){ |
646 | cfg.writeEntry("Apps", ""); | 681 | cfg.writeEntry("Apps", ""); |
647 | } | 682 | } |
648 | } else if ( msg == "autoStart(QString,QString)" ) { | 683 | } else if ( msg == "autoStart(QString,QString)" ) { |
649 | QString modifier, appName; | 684 | QString modifier, appName; |
650 | stream >> modifier >> appName; | 685 | stream >> modifier >> appName; |
651 | Config cfg( "autostart" ); | 686 | Config cfg( "autostart" ); |
652 | cfg.setGroup( "AutoStart" ); | 687 | cfg.setGroup( "AutoStart" ); |
653 | if ( modifier.compare("add") == 0 ){ | 688 | if ( modifier.compare("add") == 0 ){ |
654 | // only add it appname is entered | 689 | // only add it appname is entered |
655 | if (!appName.isEmpty()) { | 690 | if (!appName.isEmpty()) { |
656 | cfg.writeEntry("Apps", appName); | 691 | cfg.writeEntry("Apps", appName); |
657 | } | 692 | } |
658 | } else if (modifier.compare("remove") == 0 ) { | 693 | } else if (modifier.compare("remove") == 0 ) { |
659 | // need to change for multiple entries | 694 | // need to change for multiple entries |
660 | // actually remove is right now simular to clear, but in future there | 695 | // actually remove is right now simular to clear, but in future there |
661 | // should be multiple apps in autostart possible. | 696 | // should be multiple apps in autostart possible. |
662 | QString checkName; | 697 | QString checkName; |
663 | checkName = cfg.readEntry("Apps", ""); | 698 | checkName = cfg.readEntry("Apps", ""); |
664 | if (checkName == appName) { | 699 | if (checkName == appName) { |
665 | cfg.writeEntry("Apps", ""); | 700 | cfg.writeEntry("Apps", ""); |
666 | } | 701 | } |
667 | } | 702 | } |
668 | } else if ( msg == "sendCardInfo()" ) { | 703 | } else if ( msg == "sendCardInfo()" ) { |
669 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 704 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
670 | const QList<FileSystem> &fs = storage->fileSystems(); | 705 | const QList<FileSystem> &fs = storage->fileSystems(); |
671 | QListIterator<FileSystem> it ( fs ); | 706 | QListIterator<FileSystem> it ( fs ); |
672 | QString s; | 707 | QString s; |
673 | QString homeDir = getenv("HOME"); | 708 | QString homeDir = getenv("HOME"); |
674 | QString hardDiskHome; | 709 | QString hardDiskHome; |
675 | for ( ; it.current(); ++it ) { | 710 | for ( ; it.current(); ++it ) { |
676 | if ( (*it)->isRemovable() ) | 711 | if ( (*it)->isRemovable() ) |
677 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " | 712 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " |
678 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 713 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
679 | + " " + (*it)->options() + ";"; | 714 | + " " + (*it)->options() + ";"; |
680 | else if ( (*it)->disk() == "/dev/mtdblock1" || | 715 | else if ( (*it)->disk() == "/dev/mtdblock1" || |
681 | (*it)->disk() == "/dev/mtdblock/1" ) | 716 | (*it)->disk() == "/dev/mtdblock/1" ) |
682 | s += (*it)->name() + "=" + homeDir + "/Documents " | 717 | s += (*it)->name() + "=" + homeDir + "/Documents " |
683 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 718 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
684 | + " " + (*it)->options() + ";"; | 719 | + " " + (*it)->options() + ";"; |
685 | else if ( (*it)->name().contains( "Hard Disk") && | 720 | else if ( (*it)->name().contains( "Hard Disk") && |
686 | homeDir.contains( (*it)->path() ) && | 721 | homeDir.contains( (*it)->path() ) && |
687 | (*it)->path().length() > hardDiskHome.length() ) | 722 | (*it)->path().length() > hardDiskHome.length() ) |
688 | hardDiskHome = | 723 | hardDiskHome = |
689 | (*it)->name() + "=" + homeDir + "/Documents " | 724 | (*it)->name() + "=" + homeDir + "/Documents " |
690 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 725 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
691 | + " " + (*it)->options() + ";"; | 726 | + " " + (*it)->options() + ";"; |
692 | } | 727 | } |
693 | if ( !hardDiskHome.isEmpty() ) | 728 | if ( !hardDiskHome.isEmpty() ) |
694 | s += hardDiskHome; | 729 | s += hardDiskHome; |
695 | 730 | ||
696 | e << s; | 731 | e << s; |
697 | } else if ( msg == "sendSyncDate(QString)" ) { | 732 | } else if ( msg == "sendSyncDate(QString)" ) { |
698 | QString app; | 733 | QString app; |
699 | stream >> app; | 734 | stream >> app; |
700 | Config cfg( "qpe" ); | 735 | Config cfg( "qpe" ); |
701 | cfg.setGroup("SyncDate"); | 736 | cfg.setGroup("SyncDate"); |
702 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 737 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
703 | e << app << cfg.readEntry( app ); | 738 | e << app << cfg.readEntry( app ); |
704 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 739 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), |
705 | //cfg.readEntry( app ).latin1() ); | 740 | //cfg.readEntry( app ).latin1() ); |
706 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 741 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
707 | QString app, date; | 742 | QString app, date; |
708 | stream >> app >> date; | 743 | stream >> app >> date; |
709 | Config cfg( "qpe" ); | 744 | Config cfg( "qpe" ); |
710 | cfg.setGroup("SyncDate"); | 745 | cfg.setGroup("SyncDate"); |
711 | cfg.writeEntry( app, date ); | 746 | cfg.writeEntry( app, date ); |
712 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 747 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
713 | } else if ( msg == "startSync(QString)" ) { | 748 | } else if ( msg == "startSync(QString)" ) { |
714 | QString what; | 749 | QString what; |
715 | stream >> what; | 750 | stream >> what; |
716 | delete syncDialog; syncDialog = 0; | 751 | delete syncDialog; syncDialog = 0; |
717 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, | 752 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, |
718 | WStyle_Tool | WStyle_Customize | | 753 | WStyle_Tool | WStyle_Customize | |
719 | Qt::WStyle_StaysOnTop ); | 754 | Qt::WStyle_StaysOnTop ); |
720 | syncDialog->showMaximized(); | 755 | syncDialog->showMaximized(); |
721 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); | 756 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); |
722 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), | 757 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), |
723 | SLOT( cancelSync() ) ); | 758 | SLOT( cancelSync() ) ); |
724 | } | 759 | } |
725 | else if ( msg == "stopSync()") { | 760 | else if ( msg == "stopSync()") { |
726 | delete syncDialog; syncDialog = 0; | 761 | delete syncDialog; syncDialog = 0; |
727 | } else if ( msg == "getAllDocLinks()" ) { | 762 | } else if ( msg == "getAllDocLinks()" ) { |
728 | loadDocs(); | 763 | loadDocs(); |
729 | 764 | ||
730 | QString contents; | 765 | QString contents; |
731 | 766 | ||
732 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { | 767 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { |
733 | DocLnk *doc = it.current(); | 768 | DocLnk *doc = it.current(); |
734 | QFileInfo fi( doc->file() ); | 769 | QFileInfo fi( doc->file() ); |
735 | if ( !fi.exists() ) | 770 | if ( !fi.exists() ) |
736 | continue; | 771 | continue; |
737 | 772 | ||
738 | bool fake = !doc->linkFileKnown(); | 773 | bool fake = !doc->linkFileKnown(); |
739 | if ( !fake ) { | 774 | if ( !fake ) { |
740 | QFile f( doc->linkFile() ); | 775 | QFile f( doc->linkFile() ); |
741 | if ( f.open( IO_ReadOnly ) ) { | 776 | if ( f.open( IO_ReadOnly ) ) { |
742 | QTextStream ts( &f ); | 777 | QTextStream ts( &f ); |
743 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 778 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
744 | contents += ts.read(); | 779 | contents += ts.read(); |
745 | f.close(); | 780 | f.close(); |
746 | } else | 781 | } else |
747 | fake = TRUE; | 782 | fake = TRUE; |
748 | } | 783 | } |
749 | if (fake) { | 784 | if (fake) { |
750 | contents += "[Desktop Entry]\n"; | 785 | contents += "[Desktop Entry]\n"; |
751 | contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; | 786 | contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; |
752 | contents += "File = "+doc->file()+"\n"; | 787 | contents += "File = "+doc->file()+"\n"; |
753 | contents += "Name = "+doc->name()+"\n"; | 788 | contents += "Name = "+doc->name()+"\n"; |
754 | contents += "Type = "+doc->type()+"\n"; | 789 | contents += "Type = "+doc->type()+"\n"; |
755 | } | 790 | } |
756 | contents += QString("Size = %1\n").arg( fi.size() ); | 791 | contents += QString("Size = %1\n").arg( fi.size() ); |
757 | } | 792 | } |
758 | 793 | ||
759 | //qDebug( "sending length %d", contents.length() ); | 794 | //qDebug( "sending length %d", contents.length() ); |
760 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 795 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
761 | e << contents; | 796 | e << contents; |
762 | 797 | ||
763 | qDebug( "================ \n\n%s\n\n===============", | 798 | qDebug( "================ \n\n%s\n\n===============", |
764 | contents.latin1() ); | 799 | contents.latin1() ); |
765 | 800 | ||
766 | delete docsFolder; | 801 | delete docsFolder; |
767 | docsFolder = 0; | 802 | docsFolder = 0; |
768 | } | 803 | } |
769 | } | 804 | } |
770 | 805 | ||
771 | void Launcher::cancelSync() | 806 | void Launcher::cancelSync() |
772 | { | 807 | { |
773 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 808 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
774 | } | 809 | } |
775 | 810 | ||
776 | void Launcher::storageChanged() | 811 | void Launcher::storageChanged() |
777 | { | 812 | { |
778 | if ( in_lnk_props ) { | 813 | if ( in_lnk_props ) { |
779 | got_lnk_change = TRUE; | 814 | got_lnk_change = TRUE; |
780 | lnk_change = ""; | 815 | lnk_change = ""; |
781 | } else { | 816 | } else { |
782 | updateDocs(); | 817 | updateDocs(); |
783 | } | 818 | } |
784 | } | 819 | } |
785 | 820 | ||
786 | 821 | ||
787 | bool Launcher::mkdir(const QString &localPath) | 822 | bool Launcher::mkdir(const QString &localPath) |
788 | { | 823 | { |
789 | QDir fullDir(localPath); | 824 | QDir fullDir(localPath); |
790 | if (fullDir.exists()) | 825 | if (fullDir.exists()) |
791 | return true; | 826 | return true; |
792 | 827 | ||
793 | // at this point the directory doesn't exist | 828 | // at this point the directory doesn't exist |
794 | // go through the directory tree and start creating the direcotories | 829 | // go through the directory tree and start creating the direcotories |
795 | // that don't exist; if we can't create the directories, return false | 830 | // that don't exist; if we can't create the directories, return false |
796 | 831 | ||
797 | QString dirSeps = "/"; | 832 | QString dirSeps = "/"; |
798 | int dirIndex = localPath.find(dirSeps); | 833 | int dirIndex = localPath.find(dirSeps); |
799 | QString checkedPath; | 834 | QString checkedPath; |
800 | 835 | ||
801 | // didn't find any seps; weird, use the cur dir instead | 836 | // didn't find any seps; weird, use the cur dir instead |
802 | if (dirIndex == -1) { | 837 | if (dirIndex == -1) { |
803 | //qDebug("No seperators found in path %s", localPath.latin1()); | 838 | //qDebug("No seperators found in path %s", localPath.latin1()); |
804 | checkedPath = QDir::currentDirPath(); | 839 | checkedPath = QDir::currentDirPath(); |
805 | } | 840 | } |
806 | 841 | ||
807 | while (checkedPath != localPath) { | 842 | while (checkedPath != localPath) { |
808 | // no more seperators found, use the local path | 843 | // no more seperators found, use the local path |
809 | if (dirIndex == -1) | 844 | if (dirIndex == -1) |
810 | checkedPath = localPath; | 845 | checkedPath = localPath; |
811 | else { | 846 | else { |
812 | // the next directory to check | 847 | // the next directory to check |
813 | checkedPath = localPath.left(dirIndex) + "/"; | 848 | checkedPath = localPath.left(dirIndex) + "/"; |
814 | // advance the iterator; the next dir seperator | 849 | // advance the iterator; the next dir seperator |
815 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 850 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
816 | } | 851 | } |
817 | 852 | ||
818 | QDir checkDir(checkedPath); | 853 | QDir checkDir(checkedPath); |
819 | if (!checkDir.exists()) { | 854 | if (!checkDir.exists()) { |
820 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 855 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
821 | 856 | ||
822 | if (!checkDir.mkdir(checkedPath)) { | 857 | if (!checkDir.mkdir(checkedPath)) { |
823 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 858 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
824 | return FALSE; | 859 | return FALSE; |
825 | } | 860 | } |
826 | } | 861 | } |
827 | 862 | ||
828 | } | 863 | } |
829 | return TRUE; | 864 | return TRUE; |
830 | } | 865 | } |
831 | 866 | ||
832 | void Launcher::preloadApps() | 867 | void Launcher::preloadApps() |
833 | { | 868 | { |
834 | Config cfg("Launcher"); | 869 | Config cfg("Launcher"); |
835 | cfg.setGroup("Preload"); | 870 | cfg.setGroup("Preload"); |
836 | QStringList apps = cfg.readListEntry("Apps",','); | 871 | QStringList apps = cfg.readListEntry("Apps",','); |
837 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 872 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
838 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 873 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
839 | } | 874 | } |
840 | } | 875 | } |