-rw-r--r-- | core/launcher/launcher.cpp | 31 | ||||
-rw-r--r-- | core/launcher/launcher.h | 2 | ||||
-rw-r--r-- | core/launcher/mediummountgui.cpp | 4 |
3 files changed, 32 insertions, 5 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index b26bd8b..dcc3ba1 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -1,726 +1,751 @@ | |||
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 | ||
77 | |||
78 | // uidGen | ||
79 | |||
76 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : | 80 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : |
77 | QVBox( parent ) | 81 | QVBox( parent ) |
78 | { | 82 | { |
79 | categoryBar = 0; | 83 | categoryBar = 0; |
80 | stack = 0; | 84 | stack = 0; |
81 | } | 85 | } |
82 | 86 | ||
83 | void CategoryTabWidget::prevTab() | 87 | void CategoryTabWidget::prevTab() |
84 | { | 88 | { |
85 | if ( categoryBar ) { | 89 | if ( categoryBar ) { |
86 | int n = categoryBar->count(); | 90 | int n = categoryBar->count(); |
87 | int tab = categoryBar->currentTab(); | 91 | int tab = categoryBar->currentTab(); |
88 | if ( tab >= 0 ) | 92 | if ( tab >= 0 ) |
89 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); | 93 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); |
90 | } | 94 | } |
91 | } | 95 | } |
92 | 96 | ||
93 | void CategoryTabWidget::nextTab() | 97 | void CategoryTabWidget::nextTab() |
94 | { | 98 | { |
95 | if ( categoryBar ) { | 99 | if ( categoryBar ) { |
96 | int n = categoryBar->count(); | 100 | int n = categoryBar->count(); |
97 | int tab = categoryBar->currentTab(); | 101 | int tab = categoryBar->currentTab(); |
98 | categoryBar->setCurrentTab( (tab + 1)%n ); | 102 | categoryBar->setCurrentTab( (tab + 1)%n ); |
99 | } | 103 | } |
100 | } | 104 | } |
101 | 105 | ||
102 | void CategoryTabWidget::addItem( const QString& linkfile ) | 106 | void CategoryTabWidget::addItem( const QString& linkfile ) |
103 | { | 107 | { |
104 | int i=0; | 108 | int i=0; |
105 | AppLnk *app = new AppLnk(linkfile); | 109 | AppLnk *app = new AppLnk(linkfile); |
106 | if ( !app->isValid() ) { | 110 | if ( !app->isValid() ) { |
107 | delete app; | 111 | delete app; |
108 | return; | 112 | return; |
109 | } | 113 | } |
110 | if ( !app->file().isEmpty() ) { | 114 | if ( !app->file().isEmpty() ) { |
111 | // A document | 115 | // A document |
112 | delete app; | 116 | delete app; |
113 | app = new DocLnk(linkfile); | 117 | app = new DocLnk(linkfile); |
114 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); | 118 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); |
115 | return; | 119 | return; |
116 | } | 120 | } |
117 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { | 121 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { |
118 | if ( !(*it).isEmpty() ) { | 122 | if ( !(*it).isEmpty() ) { |
119 | QRegExp tf(*it,FALSE,TRUE); | 123 | QRegExp tf(*it,FALSE,TRUE); |
120 | if ( tf.match(app->type()) >= 0 ) { | 124 | if ( tf.match(app->type()) >= 0 ) { |
121 | ((LauncherView*)stack->widget(i))->addItem(app); | 125 | ((LauncherView*)stack->widget(i))->addItem(app); |
122 | return; | 126 | return; |
123 | } | 127 | } |
124 | i++; | 128 | i++; |
125 | } | 129 | } |
126 | } | 130 | } |
127 | } | 131 | } |
128 | 132 | ||
129 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | 133 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, |
130 | AppLnkSet* docFolder, const QList<FileSystem> &fs) | 134 | AppLnkSet* docFolder, const QList<FileSystem> &fs) |
131 | { | 135 | { |
132 | delete categoryBar; | 136 | delete categoryBar; |
133 | categoryBar = new CategoryTabBar( this ); | 137 | categoryBar = new CategoryTabBar( this ); |
134 | QPalette pal = categoryBar->palette(); | 138 | QPalette pal = categoryBar->palette(); |
135 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 139 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
136 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 140 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
137 | categoryBar->setPalette( pal ); | 141 | categoryBar->setPalette( pal ); |
138 | 142 | ||
139 | delete stack; | 143 | delete stack; |
140 | stack = new QWidgetStack(this); | 144 | stack = new QWidgetStack(this); |
141 | tabs=0; | 145 | tabs=0; |
142 | 146 | ||
143 | ids.clear(); | 147 | ids.clear(); |
144 | 148 | ||
145 | QStringList types = rootFolder->types(); | 149 | QStringList types = rootFolder->types(); |
146 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 150 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
147 | if ( !(*it).isEmpty() ) { | 151 | if ( !(*it).isEmpty() ) { |
148 | newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); | 152 | newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); |
149 | } | 153 | } |
150 | } | 154 | } |
151 | QListIterator<AppLnk> it( rootFolder->children() ); | 155 | QListIterator<AppLnk> it( rootFolder->children() ); |
152 | AppLnk* l; | 156 | AppLnk* l; |
153 | while ( (l=it.current()) ) { | 157 | while ( (l=it.current()) ) { |
154 | if ( l->type() == "Separator" ) { | 158 | if ( l->type() == "Separator" ) { |
155 | rootFolder->remove(l); | 159 | rootFolder->remove(l); |
156 | delete l; | 160 | delete l; |
157 | } else { | 161 | } else { |
158 | int i=0; | 162 | int i=0; |
159 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 163 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
160 | if ( *it == l->type() ) | 164 | if ( *it == l->type() ) |
161 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); | 165 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); |
162 | i++; | 166 | i++; |
163 | } | 167 | } |
164 | } | 168 | } |
165 | ++it; | 169 | ++it; |
166 | } | 170 | } |
167 | rootFolder->detachChildren(); | 171 | rootFolder->detachChildren(); |
168 | for (int i=0; i<tabs; i++) | 172 | for (int i=0; i<tabs; i++) |
169 | ((LauncherView*)stack->widget(i))->sort(); | 173 | ((LauncherView*)stack->widget(i))->sort(); |
170 | 174 | ||
171 | // all documents | 175 | // all documents |
172 | docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); | 176 | docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); |
173 | docview->populate( docFolder, QString::null ); | 177 | docview->populate( docFolder, QString::null ); |
174 | docFolder->detachChildren(); | 178 | docFolder->detachChildren(); |
175 | docview->setFileSystems(fs); | 179 | docview->setFileSystems(fs); |
176 | docview->setToolsEnabled(TRUE); | 180 | docview->setToolsEnabled(TRUE); |
177 | 181 | ||
178 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); | 182 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); |
179 | 183 | ||
180 | ((LauncherView*)stack->widget(0))->setFocus(); | 184 | ((LauncherView*)stack->widget(0))->setFocus(); |
181 | 185 | ||
182 | categoryBar->show(); | 186 | categoryBar->show(); |
183 | stack->show(); | 187 | stack->show(); |
184 | } | 188 | } |
185 | 189 | ||
186 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) | 190 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) |
187 | { | 191 | { |
188 | docview->populate( docFolder, QString::null ); | 192 | docview->populate( docFolder, QString::null ); |
189 | docFolder->detachChildren(); | 193 | docFolder->detachChildren(); |
190 | docview->setFileSystems(fs); | 194 | docview->setFileSystems(fs); |
191 | docview->updateTools(); | 195 | docview->updateTools(); |
192 | } | 196 | } |
193 | 197 | ||
194 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 198 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
195 | { | 199 | { |
196 | LauncherView* view = new LauncherView( stack ); | 200 | LauncherView* view = new LauncherView( stack ); |
197 | connect( view, SIGNAL(clicked(const AppLnk*)), | 201 | connect( view, SIGNAL(clicked(const AppLnk*)), |
198 | this, SIGNAL(clicked(const AppLnk*))); | 202 | this, SIGNAL(clicked(const AppLnk*))); |
199 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 203 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
200 | this, SIGNAL(rightPressed(AppLnk*))); | 204 | this, SIGNAL(rightPressed(AppLnk*))); |
201 | ids.append(id); | 205 | ids.append(id); |
202 | categoryBar->addTab( new QTab( pm, label ) ); | 206 | categoryBar->addTab( new QTab( pm, label ) ); |
203 | stack->addWidget( view, tabs++ ); | 207 | stack->addWidget( view, tabs++ ); |
204 | return view; | 208 | return view; |
205 | } | 209 | } |
206 | 210 | ||
207 | void CategoryTabWidget::updateLink(const QString& linkfile) | 211 | void CategoryTabWidget::updateLink(const QString& linkfile) |
208 | { | 212 | { |
209 | int i=0; | 213 | int i=0; |
210 | LauncherView* view; | 214 | LauncherView* view; |
211 | while ((view = (LauncherView*)stack->widget(i++))) { | 215 | while ((view = (LauncherView*)stack->widget(i++))) { |
212 | if ( view->removeLink(linkfile) ) | 216 | if ( view->removeLink(linkfile) ) |
213 | break; | 217 | break; |
214 | } | 218 | } |
215 | addItem(linkfile); | 219 | addItem(linkfile); |
216 | docview->updateTools(); | 220 | docview->updateTools(); |
217 | } | 221 | } |
218 | 222 | ||
219 | void CategoryTabWidget::paletteChange( const QPalette &p ) | 223 | void CategoryTabWidget::paletteChange( const QPalette &p ) |
220 | { | 224 | { |
221 | QVBox::paletteChange( p ); | 225 | QVBox::paletteChange( p ); |
222 | QPalette pal = palette(); | 226 | QPalette pal = palette(); |
223 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 227 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
224 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 228 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
225 | categoryBar->setPalette( pal ); | 229 | categoryBar->setPalette( pal ); |
226 | categoryBar->update(); | 230 | categoryBar->update(); |
227 | } | 231 | } |
228 | 232 | ||
229 | void CategoryTabWidget::setBusy(bool on) | 233 | void CategoryTabWidget::setBusy(bool on) |
230 | { | 234 | { |
231 | if ( on ) | 235 | if ( on ) |
232 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); | 236 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); |
233 | else | 237 | else |
234 | for (int i=0; i<tabs; i++) | 238 | for (int i=0; i<tabs; i++) |
235 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); | 239 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); |
236 | } | 240 | } |
237 | 241 | ||
238 | 242 | ||
239 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) | 243 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) |
240 | : QTabBar( parent, name ) | 244 | : QTabBar( parent, name ) |
241 | { | 245 | { |
242 | setFocusPolicy( NoFocus ); | 246 | setFocusPolicy( NoFocus ); |
243 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); | 247 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); |
244 | } | 248 | } |
245 | 249 | ||
246 | CategoryTabBar::~CategoryTabBar() | 250 | CategoryTabBar::~CategoryTabBar() |
247 | { | 251 | { |
248 | } | 252 | } |
249 | 253 | ||
250 | void CategoryTabBar::layoutTabs() | 254 | void CategoryTabBar::layoutTabs() |
251 | { | 255 | { |
252 | if ( !count() ) | 256 | if ( !count() ) |
253 | return; | 257 | return; |
254 | 258 | ||
255 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; | 259 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; |
256 | int hiddenTabWidth = -12; | 260 | int hiddenTabWidth = -12; |
257 | int middleTab = currentTab(); | 261 | int middleTab = currentTab(); |
258 | int hframe, vframe, overlap; | 262 | int hframe, vframe, overlap; |
259 | style().tabbarMetrics( this, hframe, vframe, overlap ); | 263 | style().tabbarMetrics( this, hframe, vframe, overlap ); |
260 | QFontMetrics fm = fontMetrics(); | 264 | QFontMetrics fm = fontMetrics(); |
261 | int x = 0; | 265 | int x = 0; |
262 | QRect r; | 266 | QRect r; |
263 | QTab *t; | 267 | QTab *t; |
264 | int available = width()-1; | 268 | int available = width()-1; |
265 | int required = 0; | 269 | int required = 0; |
266 | for ( int i = 0; i < count(); i++ ) { | 270 | for ( int i = 0; i < count(); i++ ) { |
267 | t = tab(i); | 271 | t = tab(i); |
268 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 272 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { |
269 | if ( i != middleTab ) { | 273 | if ( i != middleTab ) { |
270 | // required += hiddenTabWidth + hframe - overlap; | 274 | // required += hiddenTabWidth + hframe - overlap; |
271 | available -= hiddenTabWidth + hframe - overlap; | 275 | available -= hiddenTabWidth + hframe - overlap; |
272 | if ( t->iconSet() != 0 ) | 276 | if ( t->iconSet() != 0 ) |
273 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 277 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
274 | } else { | 278 | } else { |
275 | required += fm.width( t->text() ) + hframe - overlap; | 279 | required += fm.width( t->text() ) + hframe - overlap; |
276 | if ( t->iconSet() != 0 ) | 280 | if ( t->iconSet() != 0 ) |
277 | required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 281 | required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
278 | } | 282 | } |
279 | } | 283 | } |
280 | for ( int i = 0; i < count(); i++ ) { | 284 | for ( int i = 0; i < count(); i++ ) { |
281 | t = tab(i); | 285 | t = tab(i); |
282 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 286 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { |
283 | if ( i != middleTab ) { | 287 | if ( i != middleTab ) { |
284 | int w = hiddenTabWidth; | 288 | int w = hiddenTabWidth; |
285 | int ih = 0; | 289 | int ih = 0; |
286 | if ( t->iconSet() != 0 ) { | 290 | if ( t->iconSet() != 0 ) { |
287 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 291 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
288 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 292 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
289 | } | 293 | } |
290 | int h = QMAX( fm.height(), ih ); | 294 | int h = QMAX( fm.height(), ih ); |
291 | h = QMAX( h, QApplication::globalStrut().height() ); | 295 | h = QMAX( h, QApplication::globalStrut().height() ); |
292 | 296 | ||
293 | h += vframe; | 297 | h += vframe; |
294 | w += hframe; | 298 | w += hframe; |
295 | 299 | ||
296 | t->setRect( QRect(x, 0, w, h) ); | 300 | t->setRect( QRect(x, 0, w, h) ); |
297 | x += t->rect().width() - overlap; | 301 | x += t->rect().width() - overlap; |
298 | r = r.unite( t->rect() ); | 302 | r = r.unite( t->rect() ); |
299 | } else { | 303 | } else { |
300 | int w = fm.width( t->text() ); | 304 | int w = fm.width( t->text() ); |
301 | int ih = 0; | 305 | int ih = 0; |
302 | if ( t->iconSet() != 0 ) { | 306 | if ( t->iconSet() != 0 ) { |
303 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 307 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
304 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 308 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
305 | } | 309 | } |
306 | int h = QMAX( fm.height(), ih ); | 310 | int h = QMAX( fm.height(), ih ); |
307 | h = QMAX( h, QApplication::globalStrut().height() ); | 311 | h = QMAX( h, QApplication::globalStrut().height() ); |
308 | 312 | ||
309 | h += vframe; | 313 | h += vframe; |
310 | w += hframe; | 314 | w += hframe; |
311 | 315 | ||
312 | // t->setRect( QRect(x, 0, w * available/required, h) ); | 316 | // t->setRect( QRect(x, 0, w * available/required, h) ); |
313 | t->setRect( QRect(x, 0, available, h) ); | 317 | t->setRect( QRect(x, 0, available, h) ); |
314 | x += t->rect().width() - overlap; | 318 | x += t->rect().width() - overlap; |
315 | r = r.unite( t->rect() ); | 319 | r = r.unite( t->rect() ); |
316 | } | 320 | } |
317 | } | 321 | } |
318 | 322 | ||
319 | QRect rr = tab(count()-1)->rect(); | 323 | QRect rr = tab(count()-1)->rect(); |
320 | rr.setRight(width()-1); | 324 | rr.setRight(width()-1); |
321 | tab(count()-1)->setRect( rr ); | 325 | tab(count()-1)->setRect( rr ); |
322 | 326 | ||
323 | for ( t = tabList()->first(); t; t = tabList()->next() ) { | 327 | for ( t = tabList()->first(); t; t = tabList()->next() ) { |
324 | QRect tr = t->rect(); | 328 | QRect tr = t->rect(); |
325 | tr.setHeight( r.height() ); | 329 | tr.setHeight( r.height() ); |
326 | t->setRect( tr ); | 330 | t->setRect( tr ); |
327 | } | 331 | } |
328 | 332 | ||
329 | update(); | 333 | update(); |
330 | } | 334 | } |
331 | 335 | ||
332 | 336 | ||
333 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const | 337 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const |
334 | { | 338 | { |
335 | #if QT_VERSION >= 300 | 339 | #if QT_VERSION >= 300 |
336 | QStyle::SFlags flags = QStyle::Style_Default; | 340 | QStyle::SFlags flags = QStyle::Style_Default; |
337 | if ( selected ) | 341 | if ( selected ) |
338 | flags |= QStyle::Style_Selected; | 342 | flags |= QStyle::Style_Selected; |
339 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), | 343 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), |
340 | colorGroup(), flags, QStyleOption(t) ); | 344 | colorGroup(), flags, QStyleOption(t) ); |
341 | #else | 345 | #else |
342 | style().drawTab( p, this, t, selected ); | 346 | style().drawTab( p, this, t, selected ); |
343 | #endif | 347 | #endif |
344 | 348 | ||
345 | QRect r( t->rect() ); | 349 | QRect r( t->rect() ); |
346 | QFont f( font() ); | 350 | QFont f( font() ); |
347 | if ( selected ) | 351 | if ( selected ) |
348 | f.setBold( TRUE ); | 352 | f.setBold( TRUE ); |
349 | p->setFont( f ); | 353 | p->setFont( f ); |
350 | 354 | ||
351 | int iw = 0; | 355 | int iw = 0; |
352 | int ih = 0; | 356 | int ih = 0; |
353 | if ( t->iconSet() != 0 ) { | 357 | if ( t->iconSet() != 0 ) { |
354 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; | 358 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; |
355 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 359 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
356 | } | 360 | } |
357 | int w = iw + p->fontMetrics().width( t->text() ) + 4; | 361 | int w = iw + p->fontMetrics().width( t->text() ) + 4; |
358 | int h = QMAX(p->fontMetrics().height() + 4, ih ); | 362 | int h = QMAX(p->fontMetrics().height() + 4, ih ); |
359 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, | 363 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, |
360 | r.top() + (r.height()-h)/2, w, h ), t, | 364 | r.top() + (r.height()-h)/2, w, h ), t, |
361 | #if QT_VERSION >= 300 | 365 | #if QT_VERSION >= 300 |
362 | t->identifier() == keyboardFocusTab() | 366 | t->identifier() == keyboardFocusTab() |
363 | #else | 367 | #else |
364 | t->identitifer() == keyboardFocusTab() | 368 | t->identitifer() == keyboardFocusTab() |
365 | #endif | 369 | #endif |
366 | ); | 370 | ); |
367 | } | 371 | } |
368 | 372 | ||
369 | 373 | ||
370 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, | 374 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, |
371 | QTab* t, bool has_focus ) const | 375 | QTab* t, bool has_focus ) const |
372 | { | 376 | { |
373 | QRect r = t->rect(); | 377 | QRect r = t->rect(); |
374 | // if ( t->id != currentTab() ) | 378 | // if ( t->id != currentTab() ) |
375 | //r.moveBy( 1, 1 ); | 379 | //r.moveBy( 1, 1 ); |
376 | // | 380 | // |
377 | if ( t->iconSet() ) { | 381 | if ( t->iconSet() ) { |
378 | // the tab has an iconset, draw it in the right mode | 382 | // the tab has an iconset, draw it in the right mode |
379 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; | 383 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; |
380 | if ( mode == QIconSet::Normal && has_focus ) | 384 | if ( mode == QIconSet::Normal && has_focus ) |
381 | mode = QIconSet::Active; | 385 | mode = QIconSet::Active; |
382 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); | 386 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); |
383 | int pixw = pixmap.width(); | 387 | int pixw = pixmap.width(); |
384 | int pixh = pixmap.height(); | 388 | int pixh = pixmap.height(); |
385 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); | 389 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); |
386 | r.setLeft( r.left() + pixw + 5 ); | 390 | r.setLeft( r.left() + pixw + 5 ); |
387 | } | 391 | } |
388 | 392 | ||
389 | QRect tr = r; | 393 | QRect tr = r; |
390 | 394 | ||
391 | if ( r.width() < 20 ) | 395 | if ( r.width() < 20 ) |
392 | return; | 396 | return; |
393 | 397 | ||
394 | if ( t->isEnabled() && isEnabled() ) { | 398 | if ( t->isEnabled() && isEnabled() ) { |
395 | #if defined(_WS_WIN32_) | 399 | #if defined(_WS_WIN32_) |
396 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) | 400 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) |
397 | p->setPen( colorGroup().buttonText() ); | 401 | p->setPen( colorGroup().buttonText() ); |
398 | else | 402 | else |
399 | p->setPen( colorGroup().foreground() ); | 403 | p->setPen( colorGroup().foreground() ); |
400 | #else | 404 | #else |
401 | p->setPen( colorGroup().foreground() ); | 405 | p->setPen( colorGroup().foreground() ); |
402 | #endif | 406 | #endif |
403 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 407 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
404 | } else { | 408 | } else { |
405 | p->setPen( palette().disabled().foreground() ); | 409 | p->setPen( palette().disabled().foreground() ); |
406 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 410 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
407 | } | 411 | } |
408 | } | 412 | } |
409 | 413 | ||
410 | //--------------------------------------------------------------------------- | 414 | //--------------------------------------------------------------------------- |
411 | 415 | ||
412 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | 416 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) |
413 | : QMainWindow( parent, name, fl ) | 417 | : QMainWindow( parent, name, fl ) |
414 | { | 418 | { |
415 | setCaption( tr("Launcher") ); | 419 | setCaption( tr("Launcher") ); |
416 | 420 | ||
417 | syncDialog = 0; | 421 | syncDialog = 0; |
418 | 422 | ||
419 | // we have a pretty good idea how big we'll be | 423 | // we have a pretty good idea how big we'll be |
420 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 424 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
421 | 425 | ||
422 | tabs = 0; | 426 | tabs = 0; |
423 | rootFolder = 0; | 427 | rootFolder = 0; |
424 | docsFolder = 0; | 428 | docsFolder = 0; |
425 | m_timeStamp = QDateTime::currentDateTime().toString(); | 429 | int stamp = uidgen.generate(); |
430 | uidgen.store( stamp ); | ||
431 | m_timeStamp = QString::number( stamp ); | ||
426 | 432 | ||
427 | tabs = new CategoryTabWidget( this ); | 433 | tabs = new CategoryTabWidget( this ); |
428 | tabs->setMaximumWidth( qApp->desktop()->width() ); | 434 | tabs->setMaximumWidth( qApp->desktop()->width() ); |
429 | setCentralWidget( tabs ); | 435 | setCentralWidget( tabs ); |
430 | 436 | ||
431 | connect( tabs, SIGNAL(selected(const QString&)), | 437 | connect( tabs, SIGNAL(selected(const QString&)), |
432 | this, SLOT(viewSelected(const QString&)) ); | 438 | this, SLOT(viewSelected(const QString&)) ); |
433 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 439 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
434 | this, SLOT(select(const AppLnk*))); | 440 | this, SLOT(select(const AppLnk*))); |
435 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 441 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
436 | this, SLOT(properties(AppLnk*))); | 442 | this, SLOT(properties(AppLnk*))); |
437 | 443 | ||
438 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 444 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
439 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 445 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
440 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 446 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
441 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); | 447 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); |
442 | #endif | 448 | #endif |
443 | 449 | ||
444 | storage = new StorageInfo( this ); | 450 | storage = new StorageInfo( this ); |
445 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); | 451 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); |
446 | 452 | ||
447 | updateTabs(); | 453 | updateTabs(); |
448 | 454 | ||
449 | preloadApps(); | 455 | preloadApps(); |
450 | 456 | ||
451 | in_lnk_props = FALSE; | 457 | in_lnk_props = FALSE; |
452 | got_lnk_change = FALSE; | 458 | got_lnk_change = FALSE; |
453 | } | 459 | } |
454 | 460 | ||
455 | Launcher::~Launcher() | 461 | Launcher::~Launcher() |
456 | { | 462 | { |
457 | } | 463 | } |
458 | 464 | ||
459 | static bool isVisibleWindow(int wid) | 465 | static bool isVisibleWindow(int wid) |
460 | { | 466 | { |
461 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 467 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
462 | QWSWindow* w; | 468 | QWSWindow* w; |
463 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 469 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
464 | if ( w->winId() == wid ) | 470 | if ( w->winId() == wid ) |
465 | return !w->isFullyObscured(); | 471 | return !w->isFullyObscured(); |
466 | } | 472 | } |
467 | return FALSE; | 473 | return FALSE; |
468 | } | 474 | } |
469 | 475 | ||
470 | void Launcher::showMaximized() | 476 | void Launcher::showMaximized() |
471 | { | 477 | { |
472 | if ( isVisibleWindow( winId() ) ) | 478 | if ( isVisibleWindow( winId() ) ) |
473 | doMaximize(); | 479 | doMaximize(); |
474 | else | 480 | else |
475 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); | 481 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); |
476 | } | 482 | } |
477 | 483 | ||
478 | void Launcher::doMaximize() | 484 | void Launcher::doMaximize() |
479 | { | 485 | { |
480 | QMainWindow::showMaximized(); | 486 | QMainWindow::showMaximized(); |
481 | } | 487 | } |
482 | 488 | ||
483 | void Launcher::updateMimeTypes() | 489 | void Launcher::updateMimeTypes() |
484 | { | 490 | { |
485 | MimeType::clear(); | 491 | MimeType::clear(); |
486 | updateMimeTypes(rootFolder); | 492 | updateMimeTypes(rootFolder); |
487 | } | 493 | } |
488 | 494 | ||
489 | void Launcher::updateMimeTypes(AppLnkSet* folder) | 495 | void Launcher::updateMimeTypes(AppLnkSet* folder) |
490 | { | 496 | { |
491 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { | 497 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { |
492 | AppLnk *app = it.current(); | 498 | AppLnk *app = it.current(); |
493 | if ( app->type() == "Folder" ) | 499 | if ( app->type() == "Folder" ) |
494 | updateMimeTypes((AppLnkSet *)app); | 500 | updateMimeTypes((AppLnkSet *)app); |
495 | else { | 501 | else { |
496 | MimeType::registerApp(*app); | 502 | MimeType::registerApp(*app); |
497 | } | 503 | } |
498 | } | 504 | } |
499 | } | 505 | } |
500 | 506 | ||
501 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: | 507 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: |
502 | { | 508 | { |
509 | qWarning("loading Documents" ); | ||
510 | qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() ); | ||
503 | delete docsFolder; | 511 | delete docsFolder; |
504 | docsFolder = new DocLnkSet; | 512 | docsFolder = new DocLnkSet; |
513 | qWarning("new DocLnkSet" ); | ||
505 | // find out wich filesystems are new in this round | 514 | // find out wich filesystems are new in this round |
506 | // We will do this by having a timestamp inside each mountpoint | 515 | // 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 | 516 | // if the current timestamp doesn't match this is a new file system and |
508 | // come up with our MediumMountGui :) let the hacking begin | 517 | // come up with our MediumMountGui :) let the hacking begin |
509 | QString newStamp = QDateTime::currentDateTime().toString(); | 518 | int stamp = uidgen.generate(); |
519 | |||
520 | QString newStamp = QString::number( stamp ); | ||
521 | qWarning("new time stamp is: %s", newStamp.latin1() ); | ||
510 | StorageInfo storage; | 522 | StorageInfo storage; |
511 | const QList<FileSystem> &fileSystems = storage.fileSystems(); | 523 | const QList<FileSystem> &fileSystems = storage.fileSystems(); |
524 | qWarning("QList<FileSystem>" ); | ||
512 | QListIterator<FileSystem> it ( fileSystems ); | 525 | QListIterator<FileSystem> it ( fileSystems ); |
526 | qWarning("iterator initiliazed" ); | ||
513 | for ( ; it.current(); ++it ) { | 527 | for ( ; it.current(); ++it ) { |
528 | qWarning("inside for loop" ); | ||
529 | qWarning("checking device %s", (*it)->path().latin1() ); | ||
514 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 530 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
531 | qWarning("%s is removeable", (*it)->path().latin1() ); | ||
515 | OConfig cfg( (*it)->path() + "/.opiestorage.cf"); | 532 | OConfig cfg( (*it)->path() + "/.opiestorage.cf"); |
516 | cfg.setGroup("main"); | 533 | cfg.setGroup("main"); |
517 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); | 534 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); |
518 | if( stamp == m_timeStamp ){ // ok we know this card | 535 | if( stamp == m_timeStamp ){ // ok we know this card |
536 | qWarning("time stamp match" ); | ||
519 | cfg.writeEntry("timestamp", newStamp ); | 537 | cfg.writeEntry("timestamp", newStamp ); |
520 | // we need to scan the list now. Hopefully the cache will be there | 538 | // we need to scan the list now. Hopefully the cache will be there |
521 | }else{ // come up with the gui | 539 | }else{ // come up with the gui |
522 | MediumMountGui medium((*it)->path() + "/.opiestorage.cf" ); | 540 | qWarning("time stamp doesn't match" ); |
541 | MediumMountGui medium((*it)->path() ); | ||
542 | qWarning("medium mount gui created" ); | ||
523 | if( medium.check() ){ | 543 | if( medium.check() ){ |
544 | qWarning("need to check this device" ); | ||
524 | if( medium.exec() ){ //ok | 545 | if( medium.exec() ){ //ok |
525 | // speicher | 546 | // speicher |
547 | qWarning("execed" ); | ||
526 | cfg.writeEntry("timestamp", newStamp ); | 548 | cfg.writeEntry("timestamp", newStamp ); |
527 | } | 549 | } |
528 | }else{ | 550 | }else{ |
551 | qWarning("wrong :(" ); | ||
529 | // do something different see what we need to do | 552 | // do something different see what we need to do |
530 | } | 553 | } |
531 | } | 554 | } |
532 | } | 555 | } |
533 | } | 556 | } |
557 | qWarning("findDocuments" ); | ||
534 | Global::findDocuments(docsFolder); // get rid of this call later | 558 | Global::findDocuments(docsFolder); // get rid of this call later |
559 | qWarning("done" ); | ||
535 | m_timeStamp = newStamp; | 560 | m_timeStamp = newStamp; |
536 | } | 561 | } |
537 | 562 | ||
538 | void Launcher::updateTabs() | 563 | void Launcher::updateTabs() |
539 | { | 564 | { |
540 | MimeType::updateApplications(); // ### reads all applnks twice | 565 | MimeType::updateApplications(); // ### reads all applnks twice |
541 | 566 | ||
542 | delete rootFolder; | 567 | delete rootFolder; |
543 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); | 568 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); |
544 | 569 | ||
545 | loadDocs(); | 570 | loadDocs(); |
546 | 571 | ||
547 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); | 572 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); |
548 | } | 573 | } |
549 | 574 | ||
550 | void Launcher::updateDocs() | 575 | void Launcher::updateDocs() |
551 | { | 576 | { |
552 | loadDocs(); | 577 | loadDocs(); |
553 | tabs->updateDocs(docsFolder,storage->fileSystems()); | 578 | tabs->updateDocs(docsFolder,storage->fileSystems()); |
554 | } | 579 | } |
555 | 580 | ||
556 | void Launcher::viewSelected(const QString& s) | 581 | void Launcher::viewSelected(const QString& s) |
557 | { | 582 | { |
558 | setCaption( s + tr(" - Launcher") ); | 583 | setCaption( s + tr(" - Launcher") ); |
559 | } | 584 | } |
560 | 585 | ||
561 | void Launcher::nextView() | 586 | void Launcher::nextView() |
562 | { | 587 | { |
563 | tabs->nextTab(); | 588 | tabs->nextTab(); |
564 | } | 589 | } |
565 | 590 | ||
566 | 591 | ||
567 | void Launcher::select( const AppLnk *appLnk ) | 592 | void Launcher::select( const AppLnk *appLnk ) |
568 | { | 593 | { |
569 | if ( appLnk->type() == "Folder" ) { | 594 | if ( appLnk->type() == "Folder" ) { |
570 | // Not supported: flat is simpler for the user | 595 | // Not supported: flat is simpler for the user |
571 | } else { | 596 | } else { |
572 | if ( appLnk->exec().isNull() ) { | 597 | if ( appLnk->exec().isNull() ) { |
573 | QMessageBox::information(this,tr("No application"), | 598 | QMessageBox::information(this,tr("No application"), |
574 | tr("<p>No application is defined for this document." | 599 | tr("<p>No application is defined for this document." |
575 | "<p>Type is %1.").arg(appLnk->type())); | 600 | "<p>Type is %1.").arg(appLnk->type())); |
576 | return; | 601 | return; |
577 | } | 602 | } |
578 | tabs->setBusy(TRUE); | 603 | tabs->setBusy(TRUE); |
579 | emit executing( appLnk ); | 604 | emit executing( appLnk ); |
580 | appLnk->execute(); | 605 | appLnk->execute(); |
581 | } | 606 | } |
582 | } | 607 | } |
583 | 608 | ||
584 | void Launcher::externalSelected(const AppLnk *appLnk) | 609 | void Launcher::externalSelected(const AppLnk *appLnk) |
585 | { | 610 | { |
586 | tabs->setBusy(TRUE); | 611 | tabs->setBusy(TRUE); |
587 | emit executing( appLnk ); | 612 | emit executing( appLnk ); |
588 | } | 613 | } |
589 | 614 | ||
590 | void Launcher::properties( AppLnk *appLnk ) | 615 | void Launcher::properties( AppLnk *appLnk ) |
591 | { | 616 | { |
592 | if ( appLnk->type() == "Folder" ) { | 617 | if ( appLnk->type() == "Folder" ) { |
593 | // Not supported: flat is simpler for the user | 618 | // Not supported: flat is simpler for the user |
594 | } else { | 619 | } else { |
595 | in_lnk_props = TRUE; | 620 | in_lnk_props = TRUE; |
596 | got_lnk_change = FALSE; | 621 | got_lnk_change = FALSE; |
597 | LnkProperties prop(appLnk); | 622 | LnkProperties prop(appLnk); |
598 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 623 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
599 | prop.showMaximized(); | 624 | prop.showMaximized(); |
600 | prop.exec(); | 625 | prop.exec(); |
601 | in_lnk_props = FALSE; | 626 | in_lnk_props = FALSE; |
602 | if ( got_lnk_change ) { | 627 | if ( got_lnk_change ) { |
603 | updateLink(lnk_change); | 628 | updateLink(lnk_change); |
604 | } | 629 | } |
605 | } | 630 | } |
606 | } | 631 | } |
607 | 632 | ||
608 | void Launcher::updateLink(const QString& link) | 633 | void Launcher::updateLink(const QString& link) |
609 | { | 634 | { |
610 | if (link.isNull()) | 635 | if (link.isNull()) |
611 | updateTabs(); | 636 | updateTabs(); |
612 | else if (link.isEmpty()) | 637 | else if (link.isEmpty()) |
613 | updateDocs(); | 638 | updateDocs(); |
614 | else | 639 | else |
615 | tabs->updateLink(link); | 640 | tabs->updateLink(link); |
616 | } | 641 | } |
617 | 642 | ||
618 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 643 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
619 | { | 644 | { |
620 | QDataStream stream( data, IO_ReadOnly ); | 645 | QDataStream stream( data, IO_ReadOnly ); |
621 | if ( msg == "linkChanged(QString)" ) { | 646 | if ( msg == "linkChanged(QString)" ) { |
622 | QString link; | 647 | QString link; |
623 | stream >> link; | 648 | stream >> link; |
624 | if ( in_lnk_props ) { | 649 | if ( in_lnk_props ) { |
625 | got_lnk_change = TRUE; | 650 | got_lnk_change = TRUE; |
626 | lnk_change = link; | 651 | lnk_change = link; |
627 | } else { | 652 | } else { |
628 | updateLink(link); | 653 | updateLink(link); |
629 | } | 654 | } |
630 | } else if ( msg == "busy()" ) { | 655 | } else if ( msg == "busy()" ) { |
631 | emit busy(); | 656 | emit busy(); |
632 | } else if ( msg == "notBusy(QString)" ) { | 657 | } else if ( msg == "notBusy(QString)" ) { |
633 | QString app; | 658 | QString app; |
634 | stream >> app; | 659 | stream >> app; |
635 | tabs->setBusy(FALSE); | 660 | tabs->setBusy(FALSE); |
636 | emit notBusy(app); | 661 | emit notBusy(app); |
637 | } else if ( msg == "mkdir(QString)" ) { | 662 | } else if ( msg == "mkdir(QString)" ) { |
638 | QString dir; | 663 | QString dir; |
639 | stream >> dir; | 664 | stream >> dir; |
640 | if ( !dir.isEmpty() ) | 665 | if ( !dir.isEmpty() ) |
641 | mkdir( dir ); | 666 | mkdir( dir ); |
642 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 667 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
643 | QString baseFile, sigFile; | 668 | QString baseFile, sigFile; |
644 | stream >> baseFile >> sigFile; | 669 | stream >> baseFile >> sigFile; |
645 | QRsync::generateSignature( baseFile, sigFile ); | 670 | QRsync::generateSignature( baseFile, sigFile ); |
646 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 671 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
647 | QString baseFile, sigFile, deltaFile; | 672 | QString baseFile, sigFile, deltaFile; |
648 | stream >> baseFile >> sigFile >> deltaFile; | 673 | stream >> baseFile >> sigFile >> deltaFile; |
649 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 674 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
650 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 675 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
651 | QString baseFile, deltaFile; | 676 | QString baseFile, deltaFile; |
652 | stream >> baseFile >> deltaFile; | 677 | stream >> baseFile >> deltaFile; |
653 | if ( !QFile::exists( baseFile ) ) { | 678 | if ( !QFile::exists( baseFile ) ) { |
654 | QFile f( baseFile ); | 679 | QFile f( baseFile ); |
655 | f.open( IO_WriteOnly ); | 680 | f.open( IO_WriteOnly ); |
656 | f.close(); | 681 | f.close(); |
657 | } | 682 | } |
658 | QRsync::applyDiff( baseFile, deltaFile ); | 683 | QRsync::applyDiff( baseFile, deltaFile ); |
659 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 684 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
660 | e << baseFile; | 685 | e << baseFile; |
661 | } else if ( msg == "rdiffCleanup()" ) { | 686 | } else if ( msg == "rdiffCleanup()" ) { |
662 | mkdir( "/tmp/rdiff" ); | 687 | mkdir( "/tmp/rdiff" ); |
663 | QDir dir; | 688 | QDir dir; |
664 | dir.setPath( "/tmp/rdiff" ); | 689 | dir.setPath( "/tmp/rdiff" ); |
665 | QStringList entries = dir.entryList(); | 690 | QStringList entries = dir.entryList(); |
666 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 691 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
667 | dir.remove( *it ); | 692 | dir.remove( *it ); |
668 | } else if ( msg == "sendHandshakeInfo()" ) { | 693 | } else if ( msg == "sendHandshakeInfo()" ) { |
669 | QString home = getenv( "HOME" ); | 694 | QString home = getenv( "HOME" ); |
670 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 695 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
671 | e << home; | 696 | e << home; |
672 | int locked = (int) Desktop::screenLocked(); | 697 | int locked = (int) Desktop::screenLocked(); |
673 | e << locked; | 698 | e << locked; |
674 | // register an app for autostart | 699 | // register an app for autostart |
675 | // if clear is send the list is cleared. | 700 | // if clear is send the list is cleared. |
676 | } else if ( msg == "autoStart(QString)" ) { | 701 | } else if ( msg == "autoStart(QString)" ) { |
677 | QString appName; | 702 | QString appName; |
678 | stream >> appName; | 703 | stream >> appName; |
679 | Config cfg( "autostart" ); | 704 | Config cfg( "autostart" ); |
680 | cfg.setGroup( "AutoStart" ); | 705 | cfg.setGroup( "AutoStart" ); |
681 | if ( appName.compare("clear") == 0){ | 706 | if ( appName.compare("clear") == 0){ |
682 | cfg.writeEntry("Apps", ""); | 707 | cfg.writeEntry("Apps", ""); |
683 | } | 708 | } |
684 | } else if ( msg == "autoStart(QString,QString)" ) { | 709 | } else if ( msg == "autoStart(QString,QString)" ) { |
685 | QString modifier, appName; | 710 | QString modifier, appName; |
686 | stream >> modifier >> appName; | 711 | stream >> modifier >> appName; |
687 | Config cfg( "autostart" ); | 712 | Config cfg( "autostart" ); |
688 | cfg.setGroup( "AutoStart" ); | 713 | cfg.setGroup( "AutoStart" ); |
689 | if ( modifier.compare("add") == 0 ){ | 714 | if ( modifier.compare("add") == 0 ){ |
690 | // only add it appname is entered | 715 | // only add it appname is entered |
691 | if (!appName.isEmpty()) { | 716 | if (!appName.isEmpty()) { |
692 | cfg.writeEntry("Apps", appName); | 717 | cfg.writeEntry("Apps", appName); |
693 | } | 718 | } |
694 | } else if (modifier.compare("remove") == 0 ) { | 719 | } else if (modifier.compare("remove") == 0 ) { |
695 | // need to change for multiple entries | 720 | // need to change for multiple entries |
696 | // actually remove is right now simular to clear, but in future there | 721 | // actually remove is right now simular to clear, but in future there |
697 | // should be multiple apps in autostart possible. | 722 | // should be multiple apps in autostart possible. |
698 | QString checkName; | 723 | QString checkName; |
699 | checkName = cfg.readEntry("Apps", ""); | 724 | checkName = cfg.readEntry("Apps", ""); |
700 | if (checkName == appName) { | 725 | if (checkName == appName) { |
701 | cfg.writeEntry("Apps", ""); | 726 | cfg.writeEntry("Apps", ""); |
702 | } | 727 | } |
703 | } | 728 | } |
704 | } else if ( msg == "sendCardInfo()" ) { | 729 | } else if ( msg == "sendCardInfo()" ) { |
705 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 730 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
706 | const QList<FileSystem> &fs = storage->fileSystems(); | 731 | const QList<FileSystem> &fs = storage->fileSystems(); |
707 | QListIterator<FileSystem> it ( fs ); | 732 | QListIterator<FileSystem> it ( fs ); |
708 | QString s; | 733 | QString s; |
709 | QString homeDir = getenv("HOME"); | 734 | QString homeDir = getenv("HOME"); |
710 | QString hardDiskHome; | 735 | QString hardDiskHome; |
711 | for ( ; it.current(); ++it ) { | 736 | for ( ; it.current(); ++it ) { |
712 | if ( (*it)->isRemovable() ) | 737 | if ( (*it)->isRemovable() ) |
713 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " | 738 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " |
714 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 739 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
715 | + " " + (*it)->options() + ";"; | 740 | + " " + (*it)->options() + ";"; |
716 | else if ( (*it)->disk() == "/dev/mtdblock1" || | 741 | else if ( (*it)->disk() == "/dev/mtdblock1" || |
717 | (*it)->disk() == "/dev/mtdblock/1" ) | 742 | (*it)->disk() == "/dev/mtdblock/1" ) |
718 | s += (*it)->name() + "=" + homeDir + "/Documents " | 743 | s += (*it)->name() + "=" + homeDir + "/Documents " |
719 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 744 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
720 | + " " + (*it)->options() + ";"; | 745 | + " " + (*it)->options() + ";"; |
721 | else if ( (*it)->name().contains( "Hard Disk") && | 746 | else if ( (*it)->name().contains( "Hard Disk") && |
722 | homeDir.contains( (*it)->path() ) && | 747 | homeDir.contains( (*it)->path() ) && |
723 | (*it)->path().length() > hardDiskHome.length() ) | 748 | (*it)->path().length() > hardDiskHome.length() ) |
724 | hardDiskHome = | 749 | hardDiskHome = |
725 | (*it)->name() + "=" + homeDir + "/Documents " | 750 | (*it)->name() + "=" + homeDir + "/Documents " |
726 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 751 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h index 197bd19..d2efa58 100644 --- a/core/launcher/launcher.h +++ b/core/launcher/launcher.h | |||
@@ -1,138 +1,140 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LAUNCHER_H | 20 | #ifndef LAUNCHER_H |
21 | #define LAUNCHER_H | 21 | #define LAUNCHER_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qtabbar.h> | 24 | #include <qtabbar.h> |
25 | #include <qstringlist.h> | 25 | #include <qstringlist.h> |
26 | #include <qvbox.h> | 26 | #include <qvbox.h> |
27 | #include <qlist.h> | 27 | #include <qlist.h> |
28 | #include <qpe/palmtopuidgen.h> | ||
28 | #include "launcherview.h" | 29 | #include "launcherview.h" |
29 | 30 | ||
30 | class AppLnk; | 31 | class AppLnk; |
31 | class AppLnkSet; | 32 | class AppLnkSet; |
32 | class DocLnkSet; | 33 | class DocLnkSet; |
33 | class QWidgetStack; | 34 | class QWidgetStack; |
34 | class StorageInfo; | 35 | class StorageInfo; |
35 | class SyncDialog; | 36 | class SyncDialog; |
36 | 37 | ||
37 | class CategoryTabBar : public QTabBar | 38 | class CategoryTabBar : public QTabBar |
38 | { | 39 | { |
39 | Q_OBJECT | 40 | Q_OBJECT |
40 | public: | 41 | public: |
41 | CategoryTabBar( QWidget *parent=0, const char *name=0 ); | 42 | CategoryTabBar( QWidget *parent=0, const char *name=0 ); |
42 | ~CategoryTabBar(); | 43 | ~CategoryTabBar(); |
43 | 44 | ||
44 | protected slots: | 45 | protected slots: |
45 | virtual void layoutTabs(); | 46 | virtual void layoutTabs(); |
46 | 47 | ||
47 | protected: | 48 | protected: |
48 | void paint ( QPainter *p, QTab *t, bool f ) const; | 49 | void paint ( QPainter *p, QTab *t, bool f ) const; |
49 | void paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const; | 50 | void paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const; |
50 | }; | 51 | }; |
51 | 52 | ||
52 | class CategoryTabWidget : public QVBox { | 53 | class CategoryTabWidget : public QVBox { |
53 | // can't use a QTabWidget, since it won't let us set the frame style. | 54 | // can't use a QTabWidget, since it won't let us set the frame style. |
54 | Q_OBJECT | 55 | Q_OBJECT |
55 | public: | 56 | public: |
56 | CategoryTabWidget( QWidget* parent ); | 57 | CategoryTabWidget( QWidget* parent ); |
57 | void initializeCategories(AppLnkSet* rootFolder, AppLnkSet* docFolder, | 58 | void initializeCategories(AppLnkSet* rootFolder, AppLnkSet* docFolder, |
58 | const QList<FileSystem> &); | 59 | const QList<FileSystem> &); |
59 | void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); | 60 | void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); |
60 | void updateLink(const QString& linkfile); | 61 | void updateLink(const QString& linkfile); |
61 | void setBusy(bool on); | 62 | void setBusy(bool on); |
62 | 63 | ||
63 | signals: | 64 | signals: |
64 | void selected(const QString&); | 65 | void selected(const QString&); |
65 | void clicked(const AppLnk*); | 66 | void clicked(const AppLnk*); |
66 | void rightPressed(AppLnk*); | 67 | void rightPressed(AppLnk*); |
67 | 68 | ||
68 | public slots: | 69 | public slots: |
69 | void nextTab(); | 70 | void nextTab(); |
70 | void prevTab(); | 71 | void prevTab(); |
71 | 72 | ||
72 | protected: | 73 | protected: |
73 | void paletteChange( const QPalette &p ); | 74 | void paletteChange( const QPalette &p ); |
74 | 75 | ||
75 | private: | 76 | private: |
76 | CategoryTabBar* categoryBar; | 77 | CategoryTabBar* categoryBar; |
77 | QWidgetStack* stack; | 78 | QWidgetStack* stack; |
78 | LauncherView* docview; | 79 | LauncherView* docview; |
79 | QStringList ids; | 80 | QStringList ids; |
80 | int tabs; | 81 | int tabs; |
81 | LauncherView* newView( const QString&, const QPixmap& pm, const QString& label ); | 82 | LauncherView* newView( const QString&, const QPixmap& pm, const QString& label ); |
82 | void addItem( const QString& ); | 83 | void addItem( const QString& ); |
83 | }; | 84 | }; |
84 | 85 | ||
85 | class Launcher : public QMainWindow | 86 | class Launcher : public QMainWindow |
86 | { | 87 | { |
87 | Q_OBJECT | 88 | Q_OBJECT |
88 | friend class LauncherPrivate; | 89 | friend class LauncherPrivate; |
89 | public: | 90 | public: |
90 | Launcher( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 91 | Launcher( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
91 | ~Launcher(); | 92 | ~Launcher(); |
92 | 93 | ||
93 | static QString appsFolderName(); | 94 | static QString appsFolderName(); |
94 | 95 | ||
95 | virtual void showMaximized(); | 96 | virtual void showMaximized(); |
96 | static bool mkdir(const QString &path); | 97 | static bool mkdir(const QString &path); |
97 | 98 | ||
98 | public slots: | 99 | public slots: |
99 | void viewSelected(const QString&); | 100 | void viewSelected(const QString&); |
100 | void select( const AppLnk * ); | 101 | void select( const AppLnk * ); |
101 | void externalSelected( const AppLnk *); | 102 | void externalSelected( const AppLnk *); |
102 | void properties( AppLnk * ); | 103 | void properties( AppLnk * ); |
103 | void nextView(); | 104 | void nextView(); |
104 | 105 | ||
105 | signals: | 106 | signals: |
106 | void executing( const AppLnk * ); | 107 | void executing( const AppLnk * ); |
107 | void busy(); | 108 | void busy(); |
108 | void notBusy(const QString&); | 109 | void notBusy(const QString&); |
109 | 110 | ||
110 | private slots: | 111 | private slots: |
111 | void doMaximize(); | 112 | void doMaximize(); |
112 | void systemMessage( const QCString &, const QByteArray &); | 113 | void systemMessage( const QCString &, const QByteArray &); |
113 | void storageChanged(); | 114 | void storageChanged(); |
114 | void cancelSync(); | 115 | void cancelSync(); |
115 | 116 | ||
116 | private: | 117 | private: |
117 | void updateApps(); | 118 | void updateApps(); |
118 | void loadDocs(); | 119 | void loadDocs(); |
119 | void updateDocs(); | 120 | void updateDocs(); |
120 | void updateTabs(); | 121 | void updateTabs(); |
121 | void updateMimeTypes(); | 122 | void updateMimeTypes(); |
122 | void updateMimeTypes(AppLnkSet*); | 123 | void updateMimeTypes(AppLnkSet*); |
123 | void preloadApps(); | 124 | void preloadApps(); |
124 | AppLnkSet *rootFolder; | 125 | AppLnkSet *rootFolder; |
125 | DocLnkSet *docsFolder; | 126 | DocLnkSet *docsFolder; |
126 | CategoryTabWidget *tabs; | 127 | CategoryTabWidget *tabs; |
127 | StorageInfo *storage; | 128 | StorageInfo *storage; |
128 | SyncDialog *syncDialog; | 129 | SyncDialog *syncDialog; |
129 | 130 | ||
130 | void updateLink(const QString& link); | 131 | void updateLink(const QString& link); |
131 | bool in_lnk_props; | 132 | bool in_lnk_props; |
132 | bool got_lnk_change; | 133 | bool got_lnk_change; |
133 | QString lnk_change; | 134 | QString lnk_change; |
134 | QString m_timeStamp; | 135 | QString m_timeStamp; |
136 | Qtopia::UidGen uidgen; | ||
135 | }; | 137 | }; |
136 | 138 | ||
137 | #endif // LAUNCHERVIEW_H | 139 | #endif // LAUNCHERVIEW_H |
138 | 140 | ||
diff --git a/core/launcher/mediummountgui.cpp b/core/launcher/mediummountgui.cpp index f193024..6ad97e1 100644 --- a/core/launcher/mediummountgui.cpp +++ b/core/launcher/mediummountgui.cpp | |||
@@ -1,232 +1,232 @@ | |||
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 | ||
23 | MediumMountGui::MediumMountGui( const QString &path ,QWidget* parent, const char* name, bool modal, WFlags fl ) | 23 | MediumMountGui::MediumMountGui( const QString &path ,QWidget* parent, const char* name, bool modal, WFlags fl ) |
24 | : QDialog( parent, name, modal, fl ) { | 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 | ||
38 | void MediumMountGui::readConfig(){ | 38 | void 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", true); |
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 | ||
55 | bool MediumMountGui::check() { | 55 | bool MediumMountGui::check() { |
56 | return checkagain; | 56 | return checkagain; |
57 | } | 57 | } |
58 | 58 | ||
59 | QStringList MediumMountGui::dirs() { | 59 | QStringList MediumMountGui::dirs() { |
60 | QStringList list = QStringList::split(",", limittodirs ); | 60 | QStringList list = QStringList::split(",", limittodirs ); |
61 | return list; | 61 | return list; |
62 | } | 62 | } |
63 | 63 | ||
64 | void MediumMountGui::writeConfig(bool autocheck) { | 64 | void 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 "null" to the list. |
84 | if (checkmimeall) { | 84 | if (checkmimeall) { |
85 | mimeTypeList += ("null"); | 85 | mimeTypeList += ("null"); |
86 | } else { | 86 | } else { |
87 | if (checkmimeaudio) { | 87 | if (checkmimeaudio) { |
88 | mimeTypeList += ("audio//*"); | 88 | mimeTypeList += ("audio//*"); |
89 | } | 89 | } |
90 | if (checkmimetext) { | 90 | if (checkmimetext) { |
91 | mimeTypeList += ("text//*"); | 91 | mimeTypeList += ("text//*"); |
92 | } | 92 | } |
93 | if (checkmimevideo) { | 93 | if (checkmimevideo) { |
94 | mimeTypeList += ("video//*"); | 94 | mimeTypeList += ("video//*"); |
95 | } | 95 | } |
96 | if (checkmimeimage) { | 96 | if (checkmimeimage) { |
97 | mimeTypeList += ("image//*"); | 97 | mimeTypeList += ("image//*"); |
98 | } | 98 | } |
99 | if (checkmimeall) { | 99 | if (checkmimeall) { |
100 | mimeTypeList << ("null"); | 100 | mimeTypeList << ("null"); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | void MediumMountGui::startGui() { | 105 | void MediumMountGui::startGui() { |
106 | 106 | ||
107 | QPixmap image = Resource::loadPixmap( "HelpBrowser"); | 107 | QPixmap image = Resource::loadPixmap( "HelpBrowser"); |
108 | 108 | ||
109 | Text_2 = new QLabel( this ); | 109 | Text_2 = new QLabel( this ); |
110 | Text_2->setGeometry( QRect( 10, 15, 40, 40 ) ); | 110 | Text_2->setGeometry( QRect( 10, 15, 40, 40 ) ); |
111 | Text_2->setPixmap( image ); | 111 | Text_2->setPixmap( image ); |
112 | 112 | ||
113 | Text = new QLabel( this, "Text" ); | 113 | Text = new QLabel( this, "Text" ); |
114 | Text->setGeometry( QRect( 55, 11, this->width()-50, 50 ) ); | 114 | Text->setGeometry( QRect( 55, 11, this->width()-50, 50 ) ); |
115 | Text->setText( tr( "A <b>storage medium</b> was inserted. Should it be scanned for media files?" ) ); | 115 | Text->setText( tr( "A <b>storage medium</b> was inserted. Should it be scanned for media files?" ) ); |
116 | 116 | ||
117 | // media box | 117 | // media box |
118 | GroupBox1 = new QGroupBox( this, "GroupBox1" ); | 118 | GroupBox1 = new QGroupBox( this, "GroupBox1" ); |
119 | GroupBox1->setGeometry( QRect( 10, 80, (this->width())-25, 80 ) ); | 119 | GroupBox1->setGeometry( QRect( 10, 80, (this->width())-25, 80 ) ); |
120 | GroupBox1->setTitle( tr( "Which media files" ) ); | 120 | GroupBox1->setTitle( tr( "Which media files" ) ); |
121 | 121 | ||
122 | CheckBoxAudio = new QCheckBox( GroupBox1, "CheckBoxAudio" ); | 122 | CheckBoxAudio = new QCheckBox( GroupBox1, "CheckBoxAudio" ); |
123 | CheckBoxAudio->setGeometry( QRect( 10, 15, (GroupBox1->width()/2)-15 , 15 ) ); | 123 | CheckBoxAudio->setGeometry( QRect( 10, 15, (GroupBox1->width()/2)-15 , 15 ) ); |
124 | CheckBoxAudio->setText( tr( "Audio" ) ); | 124 | CheckBoxAudio->setText( tr( "Audio" ) ); |
125 | 125 | ||
126 | CheckBoxImage = new QCheckBox( GroupBox1, "CheckBoxImage" ); | 126 | CheckBoxImage = new QCheckBox( GroupBox1, "CheckBoxImage" ); |
127 | CheckBoxImage->setGeometry( QRect( 10, 35,(GroupBox1->width()/2)-15, 15 ) ); | 127 | CheckBoxImage->setGeometry( QRect( 10, 35,(GroupBox1->width()/2)-15, 15 ) ); |
128 | CheckBoxImage->setText( tr( "Image" ) ); | 128 | CheckBoxImage->setText( tr( "Image" ) ); |
129 | 129 | ||
130 | CheckBoxText = new QCheckBox( GroupBox1, "CheckBoxText" ); | 130 | CheckBoxText = new QCheckBox( GroupBox1, "CheckBoxText" ); |
131 | CheckBoxText->setGeometry( QRect((GroupBox1->width()/2) , 15, (GroupBox1->width()/2)-15, 15 ) ); | 131 | CheckBoxText->setGeometry( QRect((GroupBox1->width()/2) , 15, (GroupBox1->width()/2)-15, 15 ) ); |
132 | CheckBoxText->setText( tr( "Text" ) ); | 132 | CheckBoxText->setText( tr( "Text" ) ); |
133 | 133 | ||
134 | CheckBoxVideo = new QCheckBox( GroupBox1, "CheckBoxVideo" ); | 134 | CheckBoxVideo = new QCheckBox( GroupBox1, "CheckBoxVideo" ); |
135 | CheckBoxVideo->setGeometry( QRect( (GroupBox1->width()/2), 35, (GroupBox1->width()/2)-15, 15 ) ); | 135 | CheckBoxVideo->setGeometry( QRect( (GroupBox1->width()/2), 35, (GroupBox1->width()/2)-15, 15 ) ); |
136 | CheckBoxVideo->setText( tr( "Video" ) ); | 136 | CheckBoxVideo->setText( tr( "Video" ) ); |
137 | 137 | ||
138 | CheckBoxAll = new QCheckBox ( GroupBox1); | 138 | CheckBoxAll = new QCheckBox ( GroupBox1); |
139 | CheckBoxAll->setGeometry( QRect( 10, 55, (GroupBox1->width()/2)-15, 15 ) ); | 139 | CheckBoxAll->setGeometry( QRect( 10, 55, (GroupBox1->width()/2)-15, 15 ) ); |
140 | CheckBoxAll->setText( tr( "All" ) ); | 140 | CheckBoxAll->setText( tr( "All" ) ); |
141 | QObject::connect( (QObject*)CheckBoxAll, SIGNAL( clicked() ), this, SLOT( deactivateOthers()) ); | 141 | QObject::connect( (QObject*)CheckBoxAll, SIGNAL( clicked() ), this, SLOT( deactivateOthers()) ); |
142 | 142 | ||
143 | 143 | ||
144 | 144 | ||
145 | CheckBoxLink = new QCheckBox ( GroupBox1); | 145 | CheckBoxLink = new QCheckBox ( GroupBox1); |
146 | CheckBoxLink->setGeometry( QRect( (GroupBox1->width()/2), 55, (GroupBox1->width()/2)-15, 15 ) ); | 146 | CheckBoxLink->setGeometry( QRect( (GroupBox1->width()/2), 55, (GroupBox1->width()/2)-15, 15 ) ); |
147 | CheckBoxLink->setText( tr( "Link apps" ) ); | 147 | CheckBoxLink->setText( tr( "Link apps" ) ); |
148 | // as long as the feature is not supported | 148 | // as long as the feature is not supported |
149 | CheckBoxLink->setEnabled(false); | 149 | CheckBoxLink->setEnabled(false); |
150 | 150 | ||
151 | 151 | ||
152 | // select dirs | 152 | // select dirs |
153 | 153 | ||
154 | DirSelectText = new QLabel( this, "DirSelectText" ); | 154 | DirSelectText = new QLabel( this, "DirSelectText" ); |
155 | DirSelectText->setGeometry( QRect( 10, 160,this->width() , 20 ) ); | 155 | DirSelectText->setGeometry( QRect( 10, 160,this->width() , 20 ) ); |
156 | DirSelectText->setText( tr( "Limit search to dir: (not used yet)" ) ); | 156 | DirSelectText->setText( tr( "Limit search to dir: (not used yet)" ) ); |
157 | 157 | ||
158 | LineEdit1 = new QLineEdit( this ); | 158 | LineEdit1 = new QLineEdit( this ); |
159 | LineEdit1->setGeometry( QRect( 10, 180, (this->width())-60, 20 ) ); | 159 | LineEdit1->setGeometry( QRect( 10, 180, (this->width())-60, 20 ) ); |
160 | 160 | ||
161 | PushButton3 = new QPushButton( this ); | 161 | PushButton3 = new QPushButton( this ); |
162 | PushButton3->setGeometry( QRect( (this->width())-40, 180, 30, 20 ) ); | 162 | PushButton3->setGeometry( QRect( (this->width())-40, 180, 30, 20 ) ); |
163 | PushButton3->setText( tr( "Add" ) ); | 163 | PushButton3->setText( tr( "Add" ) ); |
164 | 164 | ||
165 | 165 | ||
166 | // decision | 166 | // decision |
167 | DirSelectText_2 = new QLabel( this ); | 167 | DirSelectText_2 = new QLabel( this ); |
168 | DirSelectText_2->setGeometry( QRect( 10,240,this->width(), 15 ) ); | 168 | DirSelectText_2->setGeometry( QRect( 10,240,this->width(), 15 ) ); |
169 | DirSelectText_2->setText( tr( "Your decision will be stored on the medium." ) ); | 169 | DirSelectText_2->setText( tr( "Your decision will be stored on the medium." ) ); |
170 | 170 | ||
171 | // ask again | 171 | // ask again |
172 | AskBox = new QCheckBox( this ); | 172 | AskBox = new QCheckBox( this ); |
173 | AskBox->setGeometry( QRect( 10, 215, (this->width())-15 , 15 ) ); | 173 | AskBox->setGeometry( QRect( 10, 215, (this->width())-15 , 15 ) ); |
174 | AskBox->setText( tr( "Do not ask again for this medium" ) ); | 174 | AskBox->setText( tr( "Do not ask again for this medium" ) ); |
175 | 175 | ||
176 | 176 | ||
177 | AskBox->setChecked(checkagain); | 177 | AskBox->setChecked(checkagain); |
178 | CheckBoxAudio->setChecked(checkmimeaudio); | 178 | CheckBoxAudio->setChecked(checkmimeaudio); |
179 | CheckBoxImage->setChecked(checkmimeimage); | 179 | CheckBoxImage->setChecked(checkmimeimage); |
180 | CheckBoxText->setChecked(checkmimetext); | 180 | CheckBoxText->setChecked(checkmimetext); |
181 | CheckBoxVideo->setChecked(checkmimevideo); | 181 | CheckBoxVideo->setChecked(checkmimevideo); |
182 | 182 | ||
183 | // buttons | 183 | // buttons |
184 | quit = new QPushButton( this ); | 184 | quit = new QPushButton( this ); |
185 | quit->setGeometry( QRect( (this->width()/2)- 90 , 260, 80, 22 ) ); | 185 | quit->setGeometry( QRect( (this->width()/2)- 90 , 260, 80, 22 ) ); |
186 | quit->setFocus(); | 186 | quit->setFocus(); |
187 | quit->setText( tr( "Yes" ) ); | 187 | quit->setText( tr( "Yes" ) ); |
188 | 188 | ||
189 | quit_2 = new QPushButton( this ); | 189 | quit_2 = new QPushButton( this ); |
190 | quit_2->setGeometry( QRect((this->width()/2) , 260, 80, 22 ) ); | 190 | quit_2->setGeometry( QRect((this->width()/2) , 260, 80, 22 ) ); |
191 | quit_2->setText( tr( "No" ) ); | 191 | quit_2->setText( tr( "No" ) ); |
192 | 192 | ||
193 | QObject::connect( (QObject*)quit, SIGNAL( clicked() ), this, SLOT(yesPressed() ) ); | 193 | QObject::connect( (QObject*)quit, SIGNAL( clicked() ), this, SLOT(yesPressed() ) ); |
194 | QObject::connect( (QObject*)quit_2, SIGNAL( clicked() ), this, SLOT(noPressed() ) ); | 194 | QObject::connect( (QObject*)quit_2, SIGNAL( clicked() ), this, SLOT(noPressed() ) ); |
195 | 195 | ||
196 | 196 | ||
197 | } | 197 | } |
198 | 198 | ||
199 | 199 | ||
200 | void MediumMountGui::deactivateOthers() { | 200 | void MediumMountGui::deactivateOthers() { |
201 | bool mod = !(CheckBoxAll->isChecked()); | 201 | bool mod = !(CheckBoxAll->isChecked()); |
202 | 202 | ||
203 | //if (!CheckBoxVideo->isChecked()){ | 203 | //if (!CheckBoxVideo->isChecked()){ |
204 | // mod = false; | 204 | // mod = false; |
205 | //} else { | 205 | //} else { |
206 | // mod = true; | 206 | // mod = true; |
207 | //} | 207 | //} |
208 | CheckBoxVideo->setEnabled(mod); | 208 | CheckBoxVideo->setEnabled(mod); |
209 | CheckBoxAudio->setEnabled(mod); | 209 | CheckBoxAudio->setEnabled(mod); |
210 | CheckBoxText->setEnabled(mod); | 210 | CheckBoxText->setEnabled(mod); |
211 | CheckBoxImage->setEnabled(mod); | 211 | CheckBoxImage->setEnabled(mod); |
212 | } | 212 | } |
213 | 213 | ||
214 | void MediumMountGui::yesPressed() { | 214 | void MediumMountGui::yesPressed() { |
215 | writeConfig(true); | 215 | writeConfig(true); |
216 | // and do something | 216 | // and do something |
217 | accept(); | 217 | accept(); |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | QStringList MediumMountGui::mimeTypes(){ | 221 | QStringList MediumMountGui::mimeTypes(){ |
222 | return mimeTypeList; | 222 | return mimeTypeList; |
223 | } | 223 | } |
224 | 224 | ||
225 | void MediumMountGui::noPressed() { | 225 | void MediumMountGui::noPressed() { |
226 | writeConfig(false); | 226 | writeConfig(false); |
227 | reject(); | 227 | reject(); |
228 | } | 228 | } |
229 | 229 | ||
230 | MediumMountGui::~MediumMountGui(){ | 230 | MediumMountGui::~MediumMountGui(){ |
231 | } | 231 | } |
232 | 232 | ||