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