-rw-r--r-- | core/launcher/launcher.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 779fe54..87a54bf 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -1,786 +1,801 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "startmenu.h" | 21 | #include "startmenu.h" |
22 | #include "taskbar.h" | 22 | #include "taskbar.h" |
23 | #include "serverinterface.h" | 23 | #include "serverinterface.h" |
24 | #include "launcherview.h" | 24 | #include "launcherview.h" |
25 | #include "launcher.h" | 25 | #include "launcher.h" |
26 | #include "server.h" | 26 | #include "server.h" |
27 | 27 | ||
28 | /* OPIE */ | 28 | /* OPIE */ |
29 | #include <opie2/odebug.h> | 29 | #include <opie2/odebug.h> |
30 | #include <qtopia/global.h> | 30 | #include <qtopia/global.h> |
31 | #ifdef Q_WS_QWS | 31 | #ifdef Q_WS_QWS |
32 | #include <qtopia/qcopenvelope_qws.h> | 32 | #include <qtopia/qcopenvelope_qws.h> |
33 | #endif | 33 | #endif |
34 | #include <qtopia/resource.h> | 34 | #include <qtopia/resource.h> |
35 | #include <qtopia/applnk.h> | 35 | #include <qtopia/applnk.h> |
36 | #include <qtopia/config.h> | 36 | #include <qtopia/config.h> |
37 | #include <qtopia/qpeapplication.h> | 37 | #include <qtopia/qpeapplication.h> |
38 | #include <qtopia/mimetype.h> | 38 | #include <qtopia/mimetype.h> |
39 | #include <qtopia/private/categories.h> | 39 | #include <qtopia/private/categories.h> |
40 | #define QTOPIA_INTERNAL_FSLP | 40 | #define QTOPIA_INTERNAL_FSLP |
41 | #include <qtopia/lnkproperties.h> | 41 | #include <qtopia/lnkproperties.h> |
42 | 42 | ||
43 | /* QT */ | 43 | /* QT */ |
44 | #include <qdir.h> | 44 | #include <qdir.h> |
45 | #ifdef Q_WS_QWS | 45 | #ifdef Q_WS_QWS |
46 | #include <qkeyboard_qws.h> | 46 | #include <qkeyboard_qws.h> |
47 | #include <qwindowsystem_qws.h> | 47 | #include <qwindowsystem_qws.h> |
48 | #endif | 48 | #endif |
49 | #include <qtimer.h> | 49 | #include <qtimer.h> |
50 | #include <qcombobox.h> | 50 | #include <qcombobox.h> |
51 | #include <qvbox.h> | 51 | #include <qvbox.h> |
52 | #include <qlayout.h> | 52 | #include <qlayout.h> |
53 | #include <qstyle.h> | 53 | #include <qstyle.h> |
54 | #include <qpushbutton.h> | 54 | #include <qpushbutton.h> |
55 | #include <qtabbar.h> | 55 | #include <qtabbar.h> |
56 | #include <qwidgetstack.h> | 56 | #include <qwidgetstack.h> |
57 | #include <qregexp.h> | 57 | #include <qregexp.h> |
58 | #include <qmessagebox.h> | 58 | #include <qmessagebox.h> |
59 | #include <qframe.h> | 59 | #include <qframe.h> |
60 | #include <qpainter.h> | 60 | #include <qpainter.h> |
61 | #include <qlabel.h> | 61 | #include <qlabel.h> |
62 | #include <qtextstream.h> | 62 | #include <qtextstream.h> |
63 | #include <qpopupmenu.h> | 63 | #include <qpopupmenu.h> |
64 | 64 | ||
65 | /* STD */ | 65 | /* STD */ |
66 | #include <stdlib.h> | 66 | #include <stdlib.h> |
67 | #include <assert.h> | 67 | #include <assert.h> |
68 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 68 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
69 | #include <unistd.h> | 69 | #include <unistd.h> |
70 | #include <stdio.h> | 70 | #include <stdio.h> |
71 | #include <sys/vfs.h> | 71 | #include <sys/vfs.h> |
72 | #include <mntent.h> | 72 | #include <mntent.h> |
73 | #endif | 73 | #endif |
74 | 74 | ||
75 | 75 | ||
76 | static bool isVisibleWindow( int ); | 76 | static bool isVisibleWindow( int ); |
77 | //=========================================================================== | 77 | //=========================================================================== |
78 | 78 | ||
79 | LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : | 79 | LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : |
80 | QVBox( parent ), docview( 0 ) | 80 | QVBox( parent ), docview( 0 ) |
81 | { | 81 | { |
82 | docLoadingWidgetEnabled = false; | 82 | docLoadingWidgetEnabled = false; |
83 | docLoadingWidget = 0; | 83 | docLoadingWidget = 0; |
84 | docLoadingWidgetProgress = 0; | 84 | docLoadingWidgetProgress = 0; |
85 | launcher = parent; | 85 | launcher = parent; |
86 | categoryBar = new LauncherTabBar( this ); | 86 | categoryBar = new LauncherTabBar( this ); |
87 | QPalette pal = categoryBar->palette(); | 87 | QPalette pal = categoryBar->palette(); |
88 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 88 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
89 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 89 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
90 | categoryBar->setPalette( pal ); | 90 | categoryBar->setPalette( pal ); |
91 | stack = new QWidgetStack(this); | 91 | stack = new QWidgetStack(this); |
92 | connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); | 92 | connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); |
93 | categoryBar->show(); | 93 | categoryBar->show(); |
94 | stack->show(); | 94 | stack->show(); |
95 | 95 | ||
96 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 96 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
97 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); | 97 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); |
98 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 98 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
99 | this, SLOT(launcherMessage(const QCString&,const QByteArray&)) ); | 99 | this, SLOT(launcherMessage(const QCString&,const QByteArray&)) ); |
100 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), | 100 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
101 | this, SLOT(appMessage(const QCString&,const QByteArray&))); | 101 | this, SLOT(appMessage(const QCString&,const QByteArray&))); |
102 | #endif | 102 | #endif |
103 | 103 | ||
104 | createDocLoadingWidget(); | 104 | createDocLoadingWidget(); |
105 | } | 105 | } |
106 | 106 | ||
107 | void LauncherTabWidget::createDocLoadingWidget() | 107 | void LauncherTabWidget::createDocLoadingWidget() |
108 | { | 108 | { |
109 | // Construct the 'doc loading widget' shown when finding documents | 109 | // Construct the 'doc loading widget' shown when finding documents |
110 | 110 | ||
111 | // ### LauncherView class needs changing to be more generic so | 111 | // ### LauncherView class needs changing to be more generic so |
112 | // this widget can change its background similar to the iconviews | 112 | // this widget can change its background similar to the iconviews |
113 | // so the background for this matches | 113 | // so the background for this matches |
114 | docLoadingWidget = new LauncherView( stack ); | 114 | docLoadingWidget = new LauncherView( stack ); |
115 | docLoadingWidget->hideIcons(); | 115 | docLoadingWidget->hideIcons(); |
116 | QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); | 116 | QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); |
117 | 117 | ||
118 | docLoadingVBox->setSpacing( 20 ); | 118 | docLoadingVBox->setSpacing( 20 ); |
119 | docLoadingVBox->setMargin( 10 ); | 119 | docLoadingVBox->setMargin( 10 ); |
120 | 120 | ||
121 | QWidget *space1 = new QWidget( docLoadingVBox ); | 121 | QWidget *space1 = new QWidget( docLoadingVBox ); |
122 | docLoadingVBox->setStretchFactor( space1, 1 ); | 122 | docLoadingVBox->setStretchFactor( space1, 1 ); |
123 | 123 | ||
124 | QLabel *waitPixmap = new QLabel( docLoadingVBox ); | 124 | QLabel *waitPixmap = new QLabel( docLoadingVBox ); |
125 | waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); | 125 | waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); |
126 | waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); | 126 | waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); |
127 | waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); | 127 | waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); |
128 | 128 | ||
129 | Config cfg( "Launcher" ); | 129 | Config cfg( "Launcher" ); |
130 | cfg.setGroup( "DocTab" ); | 130 | cfg.setGroup( "DocTab" ); |
131 | bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); | 131 | bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); |
132 | 132 | ||
133 | QLabel *textLabel = new QLabel( docLoadingVBox ); | 133 | QLabel *textLabel = new QLabel( docLoadingVBox ); |
134 | textLabel->setAlignment( int( QLabel::AlignCenter ) ); | 134 | textLabel->setAlignment( int( QLabel::AlignCenter ) ); |
135 | docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); | 135 | docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); |
136 | docLoadingWidgetProgress->setProgress( 0 ); | 136 | docLoadingWidgetProgress->setProgress( 0 ); |
137 | docLoadingWidgetProgress->setCenterIndicator( TRUE ); | 137 | docLoadingWidgetProgress->setCenterIndicator( TRUE ); |
138 | docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker | 138 | docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker |
139 | setProgressStyle(); | 139 | setProgressStyle(); |
140 | 140 | ||
141 | if ( docTabEnabled ) | 141 | if ( docTabEnabled ) |
142 | { | 142 | { |
143 | textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); | 143 | textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); |
144 | } | 144 | } |
145 | else | 145 | else |
146 | { | 146 | { |
147 | textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" | 147 | textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" |
148 | "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); | 148 | "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); |
149 | docLoadingWidgetProgress->hide(); | 149 | docLoadingWidgetProgress->hide(); |
150 | docLoadingWidgetEnabled = true; | 150 | docLoadingWidgetEnabled = true; |
151 | } | 151 | } |
152 | 152 | ||
153 | QWidget *space2 = new QWidget( docLoadingVBox ); | 153 | QWidget *space2 = new QWidget( docLoadingVBox ); |
154 | docLoadingVBox->setStretchFactor( space2, 1 ); | 154 | docLoadingVBox->setStretchFactor( space2, 1 ); |
155 | 155 | ||
156 | cfg.setGroup( "Tab Documents" ); // No tr | 156 | cfg.setGroup( "Tab Documents" ); // No tr |
157 | setTabViewAppearance( docLoadingWidget, cfg ); | 157 | setTabViewAppearance( docLoadingWidget, cfg ); |
158 | 158 | ||
159 | stack->addWidget( docLoadingWidget, 0 ); | 159 | stack->addWidget( docLoadingWidget, 0 ); |
160 | } | 160 | } |
161 | 161 | ||
162 | void LauncherTabWidget::initLayout() | 162 | void LauncherTabWidget::initLayout() |
163 | { | 163 | { |
164 | layout()->activate(); | 164 | layout()->activate(); |
165 | docView()->setFocus(); | 165 | docView()->setFocus(); |
166 | categoryBar->showTab("Documents"); | 166 | categoryBar->showTab("Documents"); |
167 | } | 167 | } |
168 | 168 | ||
169 | void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) | 169 | void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) |
170 | { | 170 | { |
171 | if ( message == "nextView()" ) | 171 | if ( message == "nextView()" ) |
172 | categoryBar->nextTab(); | 172 | categoryBar->nextTab(); |
173 | } | 173 | } |
174 | 174 | ||
175 | void LauncherTabWidget::raiseTabWidget() | 175 | void LauncherTabWidget::raiseTabWidget() |
176 | { | 176 | { |
177 | if ( categoryBar->currentView() == docView() | 177 | if ( categoryBar->currentView() == docView() |
178 | && docLoadingWidgetEnabled ) { | 178 | && docLoadingWidgetEnabled ) { |
179 | stack->raiseWidget( docLoadingWidget ); | 179 | stack->raiseWidget( docLoadingWidget ); |
180 | docLoadingWidget->updateGeometry(); | 180 | docLoadingWidget->updateGeometry(); |
181 | } else { | 181 | } else { |
182 | stack->raiseWidget( categoryBar->currentView() ); | 182 | stack->raiseWidget( categoryBar->currentView() ); |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | void LauncherTabWidget::tabProperties() | 186 | void LauncherTabWidget::tabProperties() |
187 | { | 187 | { |
188 | LauncherView *view = categoryBar->currentView(); | 188 | LauncherView *view = categoryBar->currentView(); |
189 | QPopupMenu *m = new QPopupMenu( this ); | 189 | QPopupMenu *m = new QPopupMenu( this ); |
190 | m->insertItem( tr("Icon View"), LauncherView::Icon ); | 190 | m->insertItem( tr("Icon View"), LauncherView::Icon ); |
191 | m->insertItem( tr("List View"), LauncherView::List ); | 191 | m->insertItem( tr("List View"), LauncherView::List ); |
192 | m->setItemChecked( (int)view->viewMode(), TRUE ); | 192 | m->setItemChecked( (int)view->viewMode(), TRUE ); |
193 | int rv = m->exec( QCursor::pos() ); | 193 | int rv = m->exec( QCursor::pos() ); |
194 | if ( rv >= 0 && rv != view->viewMode() ) { | 194 | if ( rv >= 0 && rv != view->viewMode() ) { |
195 | view->setViewMode( (LauncherView::ViewMode)rv ); | 195 | view->setViewMode( (LauncherView::ViewMode)rv ); |
196 | } | 196 | } |
197 | 197 | ||
198 | delete m; | 198 | delete m; |
199 | } | 199 | } |
200 | 200 | ||
201 | void LauncherTabWidget::deleteView( const QString& id ) | 201 | void LauncherTabWidget::deleteView( const QString& id ) |
202 | { | 202 | { |
203 | LauncherTab *t = categoryBar->launcherTab(id); | 203 | LauncherTab *t = categoryBar->launcherTab(id); |
204 | if ( t ) { | 204 | if ( t ) { |
205 | stack->removeWidget( t->view ); | 205 | stack->removeWidget( t->view ); |
206 | delete t->view; | 206 | delete t->view; |
207 | categoryBar->removeTab( t ); | 207 | categoryBar->removeTab( t ); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 211 | LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
212 | { | 212 | { |
213 | LauncherView* view = new LauncherView( stack ); | 213 | LauncherView* view = new LauncherView( stack ); |
214 | connect( view, SIGNAL(clicked(const AppLnk*)), | 214 | connect( view, SIGNAL(clicked(const AppLnk*)), |
215 | this, SIGNAL(clicked(const AppLnk*))); | 215 | this, SIGNAL(clicked(const AppLnk*))); |
216 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 216 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
217 | this, SIGNAL(rightPressed(AppLnk*))); | 217 | this, SIGNAL(rightPressed(AppLnk*))); |
218 | 218 | ||
219 | int n = categoryBar->count(); | 219 | int n = categoryBar->count(); |
220 | stack->addWidget( view, n ); | 220 | stack->addWidget( view, n ); |
221 | 221 | ||
222 | LauncherTab *tab = new LauncherTab( id, view, pm, label ); | 222 | LauncherTab *tab = new LauncherTab( id, view, pm, label ); |
223 | categoryBar->insertTab( tab, n-1 ); | 223 | categoryBar->insertTab( tab, n-1 ); |
224 | 224 | ||
225 | if ( id == "Documents" ) | 225 | if ( id == "Documents" ) |
226 | docview = view; | 226 | docview = view; |
227 | 227 | ||
228 | odebug << "inserting " << id << " at " << n-1 << "" << oendl; | 228 | odebug << "inserting " << id << " at " << n-1 << "" << oendl; |
229 | 229 | ||
230 | Config cfg("Launcher"); | 230 | Config cfg("Launcher"); |
231 | setTabAppearance( tab, cfg ); | 231 | setTabAppearance( tab, cfg ); |
232 | 232 | ||
233 | cfg.setGroup( "GUI" ); | 233 | cfg.setGroup( "GUI" ); |
234 | view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); | 234 | view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); |
235 | 235 | ||
236 | return view; | 236 | return view; |
237 | } | 237 | } |
238 | 238 | ||
239 | LauncherView *LauncherTabWidget::view( const QString &id ) | 239 | LauncherView *LauncherTabWidget::view( const QString &id ) |
240 | { | 240 | { |
241 | LauncherTab *t = categoryBar->launcherTab(id); | 241 | LauncherTab *t = categoryBar->launcherTab(id); |
242 | if ( !t ) | 242 | if ( !t ) |
243 | return 0; | 243 | return 0; |
244 | return t->view; | 244 | return t->view; |
245 | } | 245 | } |
246 | 246 | ||
247 | LauncherView *LauncherTabWidget::docView() | 247 | LauncherView *LauncherTabWidget::docView() |
248 | { | 248 | { |
249 | return docview; | 249 | return docview; |
250 | } | 250 | } |
251 | 251 | ||
252 | void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) | 252 | void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) |
253 | { | 253 | { |
254 | if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { | 254 | if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { |
255 | docLoadingWidgetEnabled = v; | 255 | docLoadingWidgetEnabled = v; |
256 | raiseTabWidget(); | 256 | raiseTabWidget(); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | void LauncherTabWidget::setLoadingProgress( int percent ) | 260 | void LauncherTabWidget::setLoadingProgress( int percent ) |
261 | { | 261 | { |
262 | docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); | 262 | docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); |
263 | } | 263 | } |
264 | 264 | ||
265 | // ### this function could more to LauncherView | 265 | // ### this function could more to LauncherView |
266 | void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) | 266 | void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) |
267 | { | 267 | { |
268 | // View | 268 | // View |
269 | QString view = cfg.readEntry( "View", "Icon" ); | 269 | QString view = cfg.readEntry( "View", "Icon" ); |
270 | if ( view == "List" ) // No tr | 270 | if ( view == "List" ) // No tr |
271 | v->setViewMode( LauncherView::List ); | 271 | v->setViewMode( LauncherView::List ); |
272 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); | 272 | QString bgType = cfg.readEntry( "BackgroundType", "Image" ); |
273 | if ( bgType == "Image" ) { // No tr | 273 | if ( bgType == "Image" ) { // No tr |
274 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); | 274 | QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); |
275 | v->setBackgroundType( LauncherView::Image, pm ); | 275 | v->setBackgroundType( LauncherView::Image, pm ); |
276 | } else if ( bgType == "SolidColor" ) { | 276 | } else if ( bgType == "SolidColor" ) { |
277 | QString c = cfg.readEntry( "BackgroundColor" ); | 277 | QString c = cfg.readEntry( "BackgroundColor" ); |
278 | v->setBackgroundType( LauncherView::SolidColor, c ); | 278 | v->setBackgroundType( LauncherView::SolidColor, c ); |
279 | } else { | 279 | } else { |
280 | v->setBackgroundType( LauncherView::Ruled, QString::null ); | 280 | v->setBackgroundType( LauncherView::Ruled, QString::null ); |
281 | } | 281 | } |
282 | QString textCol = cfg.readEntry( "TextColor" ); | 282 | QString textCol = cfg.readEntry( "TextColor" ); |
283 | if ( textCol.isEmpty() ) | 283 | if ( textCol.isEmpty() ) |
284 | v->setTextColor( QColor() ); | 284 | v->setTextColor( QColor() ); |
285 | else | 285 | else |
286 | v->setTextColor( QColor(textCol) ); | 286 | v->setTextColor( QColor(textCol) ); |
287 | // bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); | 287 | // bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); |
288 | 288 | ||
289 | 289 | ||
290 | QStringList font = cfg.readListEntry( "Font", ',' ); | 290 | QStringList font = cfg.readListEntry( "Font", ',' ); |
291 | if ( font.count() == 4 ) | 291 | if ( font.count() == 4 ) |
292 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); | 292 | v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); |
293 | 293 | ||
294 | // ### FIXME TabColor TabTextColor | 294 | // ### FIXME TabColor TabTextColor |
295 | 295 | ||
296 | } | 296 | } |
297 | 297 | ||
298 | // ### Could move to LauncherTab | 298 | // ### Could move to LauncherTab |
299 | void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) | 299 | void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) |
300 | { | 300 | { |
301 | cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr | 301 | cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr |
302 | 302 | ||
303 | setTabViewAppearance( tab->view, cfg ); | 303 | setTabViewAppearance( tab->view, cfg ); |
304 | 304 | ||
305 | // Tabs | 305 | // Tabs |
306 | QString tabCol = cfg.readEntry( "TabColor" ); | 306 | QString tabCol = cfg.readEntry( "TabColor" ); |
307 | if ( tabCol.isEmpty() ) | 307 | if ( tabCol.isEmpty() ) |
308 | tab->bgColor = QColor(); | 308 | tab->bgColor = QColor(); |
309 | else | 309 | else |
310 | tab->bgColor = QColor(tabCol); | 310 | tab->bgColor = QColor(tabCol); |
311 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); | 311 | QString tabTextCol = cfg.readEntry( "TabTextColor" ); |
312 | if ( tabTextCol.isEmpty() ) | 312 | if ( tabTextCol.isEmpty() ) |
313 | tab->fgColor = QColor(); | 313 | tab->fgColor = QColor(); |
314 | else | 314 | else |
315 | tab->fgColor = QColor(tabTextCol); | 315 | tab->fgColor = QColor(tabTextCol); |
316 | } | 316 | } |
317 | 317 | ||
318 | void LauncherTabWidget::paletteChange( const QPalette &p ) | 318 | void LauncherTabWidget::paletteChange( const QPalette &p ) |
319 | { | 319 | { |
320 | QVBox::paletteChange( p ); | 320 | QVBox::paletteChange( p ); |
321 | QPalette pal = palette(); | 321 | QPalette pal = palette(); |
322 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 322 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
323 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 323 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
324 | categoryBar->setPalette( pal ); | 324 | categoryBar->setPalette( pal ); |
325 | categoryBar->update(); | 325 | categoryBar->update(); |
326 | } | 326 | } |
327 | 327 | ||
328 | void LauncherTabWidget::styleChange( QStyle & ) | 328 | void LauncherTabWidget::styleChange( QStyle & ) |
329 | { | 329 | { |
330 | QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); | 330 | QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); |
331 | } | 331 | } |
332 | 332 | ||
333 | void LauncherTabWidget::setProgressStyle() | 333 | void LauncherTabWidget::setProgressStyle() |
334 | { | 334 | { |
335 | if (docLoadingWidgetProgress) { | 335 | if (docLoadingWidgetProgress) { |
336 | docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); | 336 | docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); |
337 | docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); | 337 | docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); |
338 | docLoadingWidgetProgress->setMargin( 1 ); | 338 | docLoadingWidgetProgress->setMargin( 1 ); |
339 | docLoadingWidgetProgress->setLineWidth( 1 ); | 339 | docLoadingWidgetProgress->setLineWidth( 1 ); |
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | /* | ||
344 | * FIXME | ||
345 | * The following NULL check is triggered by inserting, then removing a tab on the fly | ||
346 | * as you would if you had removable media (which I do). Without this check | ||
347 | * the first app launched after a tab removal causes qpe to Segfault. | ||
348 | * This obviously has a more sinister cause, but this works around it with no | ||
349 | * obvious adverse effects. Please FIXME | ||
350 | * bkc - 17/6/2004 | ||
351 | * | ||
352 | */ | ||
353 | |||
343 | void LauncherTabWidget::setBusy(bool on) | 354 | void LauncherTabWidget::setBusy(bool on) |
344 | { | 355 | { |
345 | if ( on ) | 356 | if ( on ) |
346 | currentView()->setBusy(TRUE); | 357 | currentView()->setBusy(TRUE); |
347 | else { | 358 | else { |
348 | for ( int i = 0; i < categoryBar->count(); i++ ) { | 359 | for ( int i = 0; i < categoryBar->count(); i++ ) { |
349 | LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; | 360 | if (categoryBar->tab(i)) { |
350 | view->setBusy( FALSE ); | 361 | LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; |
362 | view->setBusy( FALSE ); | ||
363 | } else { | ||
364 | odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl; | ||
365 | } | ||
351 | } | 366 | } |
352 | } | 367 | } |
353 | } | 368 | } |
354 | 369 | ||
355 | void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { | 370 | void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { |
356 | for (int i = 0; i < categoryBar->count(); i++ ) { | 371 | for (int i = 0; i < categoryBar->count(); i++ ) { |
357 | LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; | 372 | LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; |
358 | view->setBusyIndicatorType( str ); | 373 | view->setBusyIndicatorType( str ); |
359 | } | 374 | } |
360 | } | 375 | } |
361 | 376 | ||
362 | LauncherView *LauncherTabWidget::currentView(void) | 377 | LauncherView *LauncherTabWidget::currentView(void) |
363 | { | 378 | { |
364 | return (LauncherView*)stack->visibleWidget(); | 379 | return (LauncherView*)stack->visibleWidget(); |
365 | } | 380 | } |
366 | 381 | ||
367 | 382 | ||
368 | 383 | ||
369 | void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) | 384 | void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) |
370 | { | 385 | { |
371 | QDataStream stream( data, IO_ReadOnly ); | 386 | QDataStream stream( data, IO_ReadOnly ); |
372 | if ( msg == "setTabView(QString,int)" ) { | 387 | if ( msg == "setTabView(QString,int)" ) { |
373 | QString id; | 388 | QString id; |
374 | stream >> id; | 389 | stream >> id; |
375 | int mode; | 390 | int mode; |
376 | stream >> mode; | 391 | stream >> mode; |
377 | if ( view(id) ) | 392 | if ( view(id) ) |
378 | view(id)->setViewMode( (LauncherView::ViewMode)mode ); | 393 | view(id)->setViewMode( (LauncherView::ViewMode)mode ); |
379 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { | 394 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { |
380 | QString id; | 395 | QString id; |
381 | stream >> id; | 396 | stream >> id; |
382 | int mode; | 397 | int mode; |
383 | stream >> mode; | 398 | stream >> mode; |
384 | QString pixmapOrColor; | 399 | QString pixmapOrColor; |
385 | stream >> pixmapOrColor; | 400 | stream >> pixmapOrColor; |
386 | if ( view(id) ) | 401 | if ( view(id) ) |
387 | view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 402 | view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
388 | if ( id == "Documents" ) | 403 | if ( id == "Documents" ) |
389 | docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 404 | docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
390 | } else if ( msg == "setTextColor(QString,QString)" ) { | 405 | } else if ( msg == "setTextColor(QString,QString)" ) { |
391 | QString id; | 406 | QString id; |
392 | stream >> id; | 407 | stream >> id; |
393 | QString color; | 408 | QString color; |
394 | stream >> color; | 409 | stream >> color; |
395 | if ( view(id) ) | 410 | if ( view(id) ) |
396 | view(id)->setTextColor( QColor(color) ); | 411 | view(id)->setTextColor( QColor(color) ); |
397 | if ( id == "Documents" ) | 412 | if ( id == "Documents" ) |
398 | docLoadingWidget->setTextColor( QColor(color) ); | 413 | docLoadingWidget->setTextColor( QColor(color) ); |
399 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { | 414 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { |
400 | QString id; | 415 | QString id; |
401 | stream >> id; | 416 | stream >> id; |
402 | QString fam; | 417 | QString fam; |
403 | stream >> fam; | 418 | stream >> fam; |
404 | int size; | 419 | int size; |
405 | stream >> size; | 420 | stream >> size; |
406 | int weight; | 421 | int weight; |
407 | stream >> weight; | 422 | stream >> weight; |
408 | int italic; | 423 | int italic; |
409 | stream >> italic; | 424 | stream >> italic; |
410 | if ( view(id) ) { | 425 | if ( view(id) ) { |
411 | if ( !fam.isEmpty() ) { | 426 | if ( !fam.isEmpty() ) { |
412 | view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); | 427 | view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); |
413 | odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; | 428 | odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; |
414 | } else { | 429 | } else { |
415 | view(id)->clearViewFont(); | 430 | view(id)->clearViewFont(); |
416 | } | 431 | } |
417 | } | 432 | } |
418 | }else if ( msg == "setBusyIndicatorType(QString)" ) { | 433 | }else if ( msg == "setBusyIndicatorType(QString)" ) { |
419 | QString type; | 434 | QString type; |
420 | stream >> type; | 435 | stream >> type; |
421 | setBusyIndicatorType( type ); | 436 | setBusyIndicatorType( type ); |
422 | }else if ( msg == "home()" ) { | 437 | }else if ( msg == "home()" ) { |
423 | if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { | 438 | if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { |
424 | if (categoryBar) | 439 | if (categoryBar) |
425 | categoryBar->nextTab(); | 440 | categoryBar->nextTab(); |
426 | }else | 441 | }else |
427 | static_cast<QWidget*>(parent())->raise(); | 442 | static_cast<QWidget*>(parent())->raise(); |
428 | } | 443 | } |
429 | } | 444 | } |
430 | 445 | ||
431 | 446 | ||
432 | 447 | ||
433 | //--------------------------------------------------------------------------- | 448 | //--------------------------------------------------------------------------- |
434 | 449 | ||
435 | Launcher::Launcher() | 450 | Launcher::Launcher() |
436 | : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) | 451 | : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) |
437 | { | 452 | { |
438 | tabs = 0; | 453 | tabs = 0; |
439 | tb = 0; | 454 | tb = 0; |
440 | Config cfg( "Launcher" ); | 455 | Config cfg( "Launcher" ); |
441 | cfg.setGroup( "DocTab" ); | 456 | cfg.setGroup( "DocTab" ); |
442 | docTabEnabled = cfg.readBoolEntry( "Enable", true ); | 457 | docTabEnabled = cfg.readBoolEntry( "Enable", true ); |
443 | } | 458 | } |
444 | 459 | ||
445 | void Launcher::createGUI() | 460 | void Launcher::createGUI() |
446 | { | 461 | { |
447 | setCaption( tr("Launcher") ); | 462 | setCaption( tr("Launcher") ); |
448 | 463 | ||
449 | // we have a pretty good idea how big we'll be | 464 | // we have a pretty good idea how big we'll be |
450 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 465 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
451 | 466 | ||
452 | tb = new TaskBar; | 467 | tb = new TaskBar; |
453 | tabs = new LauncherTabWidget( this ); | 468 | tabs = new LauncherTabWidget( this ); |
454 | setCentralWidget( tabs ); | 469 | setCentralWidget( tabs ); |
455 | 470 | ||
456 | ServerInterface::dockWidget( tb, ServerInterface::Bottom ); | 471 | ServerInterface::dockWidget( tb, ServerInterface::Bottom ); |
457 | tb->show(); | 472 | tb->show(); |
458 | 473 | ||
459 | qApp->installEventFilter( this ); | 474 | qApp->installEventFilter( this ); |
460 | 475 | ||
461 | 476 | ||
462 | connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); | 477 | connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); |
463 | connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); | 478 | connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); |
464 | connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); | 479 | connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); |
465 | 480 | ||
466 | connect( tb, SIGNAL(tabSelected(const QString&)), | 481 | connect( tb, SIGNAL(tabSelected(const QString&)), |
467 | this, SLOT(showTab(const QString&)) ); | 482 | this, SLOT(showTab(const QString&)) ); |
468 | connect( tabs, SIGNAL(selected(const QString&)), | 483 | connect( tabs, SIGNAL(selected(const QString&)), |
469 | this, SLOT(viewSelected(const QString&)) ); | 484 | this, SLOT(viewSelected(const QString&)) ); |
470 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 485 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
471 | this, SLOT(select(const AppLnk*))); | 486 | this, SLOT(select(const AppLnk*))); |
472 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 487 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
473 | this, SLOT(properties(AppLnk*))); | 488 | this, SLOT(properties(AppLnk*))); |
474 | 489 | ||
475 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 490 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
476 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 491 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
477 | connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 492 | connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
478 | this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); | 493 | this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); |
479 | #endif | 494 | #endif |
480 | 495 | ||
481 | // all documents | 496 | // all documents |
482 | QImage img( Resource::loadImage( "DocsIcon" ) ); | 497 | QImage img( Resource::loadImage( "DocsIcon" ) ); |
483 | QPixmap pm; | 498 | QPixmap pm; |
484 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 499 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
485 | // It could add this itself if it handles docs | 500 | // It could add this itself if it handles docs |
486 | 501 | ||
487 | tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); | 502 | tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); |
488 | 503 | ||
489 | QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); | 504 | QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); |
490 | qApp->setMainWidget( this ); | 505 | qApp->setMainWidget( this ); |
491 | QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); | 506 | QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); |
492 | } | 507 | } |
493 | 508 | ||
494 | Launcher::~Launcher() | 509 | Launcher::~Launcher() |
495 | { | 510 | { |
496 | if ( tb ) | 511 | if ( tb ) |
497 | destroyGUI(); | 512 | destroyGUI(); |
498 | } | 513 | } |
499 | 514 | ||
500 | bool Launcher::requiresDocuments() const | 515 | bool Launcher::requiresDocuments() const |
501 | { | 516 | { |
502 | Config cfg( "Launcher" ); | 517 | Config cfg( "Launcher" ); |
503 | cfg.setGroup( "DocTab" ); | 518 | cfg.setGroup( "DocTab" ); |
504 | return cfg.readBoolEntry( "Enable", true ); | 519 | return cfg.readBoolEntry( "Enable", true ); |
505 | } | 520 | } |
506 | 521 | ||
507 | void Launcher::makeVisible() | 522 | void Launcher::makeVisible() |
508 | { | 523 | { |
509 | showMaximized(); | 524 | showMaximized(); |
510 | } | 525 | } |
511 | 526 | ||
512 | void Launcher::destroyGUI() | 527 | void Launcher::destroyGUI() |
513 | { | 528 | { |
514 | delete tb; | 529 | delete tb; |
515 | tb = 0; | 530 | tb = 0; |
516 | delete tabs; | 531 | delete tabs; |
517 | tabs =0; | 532 | tabs =0; |
518 | } | 533 | } |
519 | 534 | ||
520 | bool Launcher::eventFilter( QObject*, QEvent *ev ) | 535 | bool Launcher::eventFilter( QObject*, QEvent *ev ) |
521 | { | 536 | { |
522 | #ifdef QT_QWS_CUSTOM | 537 | #ifdef QT_QWS_CUSTOM |
523 | if ( ev->type() == QEvent::KeyPress ) { | 538 | if ( ev->type() == QEvent::KeyPress ) { |
524 | QKeyEvent *ke = (QKeyEvent *)ev; | 539 | QKeyEvent *ke = (QKeyEvent *)ev; |
525 | if ( ke->key() == Qt::Key_F11 ) { // menu key | 540 | if ( ke->key() == Qt::Key_F11 ) { // menu key |
526 | QWidget *active = qApp->activeWindow(); | 541 | QWidget *active = qApp->activeWindow(); |
527 | if ( active && active->isPopup() ) | 542 | if ( active && active->isPopup() ) |
528 | active->close(); | 543 | active->close(); |
529 | else { | 544 | else { |
530 | Global::terminateBuiltin("calibrate"); // No tr | 545 | Global::terminateBuiltin("calibrate"); // No tr |
531 | tb->launchStartMenu(); | 546 | tb->launchStartMenu(); |
532 | } | 547 | } |
533 | return TRUE; | 548 | return TRUE; |
534 | } | 549 | } |
535 | } | 550 | } |
536 | #else | 551 | #else |
537 | Q_UNUSED(ev); | 552 | Q_UNUSED(ev); |
538 | #endif | 553 | #endif |
539 | return FALSE; | 554 | return FALSE; |
540 | } | 555 | } |
541 | 556 | ||
542 | void Launcher::toggleSymbolInput() | 557 | void Launcher::toggleSymbolInput() |
543 | { | 558 | { |
544 | tb->toggleSymbolInput(); | 559 | tb->toggleSymbolInput(); |
545 | } | 560 | } |
546 | 561 | ||
547 | void Launcher::toggleNumLockState() | 562 | void Launcher::toggleNumLockState() |
548 | { | 563 | { |
549 | tb->toggleNumLockState(); | 564 | tb->toggleNumLockState(); |
550 | } | 565 | } |
551 | 566 | ||
552 | void Launcher::toggleCapsLockState() | 567 | void Launcher::toggleCapsLockState() |
553 | { | 568 | { |
554 | tb->toggleCapsLockState(); | 569 | tb->toggleCapsLockState(); |
555 | } | 570 | } |
556 | 571 | ||
557 | static bool isVisibleWindow(int wid) | 572 | static bool isVisibleWindow(int wid) |
558 | { | 573 | { |
559 | #ifdef Q_WS_QWS | 574 | #ifdef Q_WS_QWS |
560 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 575 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
561 | QWSWindow* w; | 576 | QWSWindow* w; |
562 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 577 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
563 | if ( w->winId() == wid ) | 578 | if ( w->winId() == wid ) |
564 | return !w->isFullyObscured(); | 579 | return !w->isFullyObscured(); |
565 | } | 580 | } |
566 | #endif | 581 | #endif |
567 | return FALSE; | 582 | return FALSE; |
568 | } | 583 | } |
569 | 584 | ||
570 | void Launcher::viewSelected(const QString& s) | 585 | void Launcher::viewSelected(const QString& s) |
571 | { | 586 | { |
572 | setCaption( s + tr(" - Launcher") ); | 587 | setCaption( s + tr(" - Launcher") ); |
573 | } | 588 | } |
574 | 589 | ||
575 | void Launcher::showTab(const QString& id) | 590 | void Launcher::showTab(const QString& id) |
576 | { | 591 | { |
577 | tabs->categoryBar->showTab(id); | 592 | tabs->categoryBar->showTab(id); |
578 | raise(); | 593 | raise(); |
579 | } | 594 | } |
580 | 595 | ||
581 | void Launcher::select( const AppLnk *appLnk ) | 596 | void Launcher::select( const AppLnk *appLnk ) |
582 | { | 597 | { |
583 | if ( appLnk->type() == "Folder" ) { // No tr | 598 | if ( appLnk->type() == "Folder" ) { // No tr |
584 | // Not supported: flat is simpler for the user | 599 | // Not supported: flat is simpler for the user |
585 | } else { | 600 | } else { |
586 | if ( appLnk->exec().isNull() ) { | 601 | if ( appLnk->exec().isNull() ) { |
587 | int i = QMessageBox::information(this,tr("No application"), | 602 | int i = QMessageBox::information(this,tr("No application"), |
588 | tr("<p>No application is defined for this document." | 603 | tr("<p>No application is defined for this document." |
589 | "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); | 604 | "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); |
590 | 605 | ||
591 | /* ### Fixme */ | 606 | /* ### Fixme */ |
592 | if ( i == 1 ) | 607 | if ( i == 1 ) |
593 | Global::execute("textedit",appLnk->file()); | 608 | Global::execute("textedit",appLnk->file()); |
594 | 609 | ||
595 | return; | 610 | return; |
596 | } | 611 | } |
597 | tabs->setBusy(TRUE); | 612 | tabs->setBusy(TRUE); |
598 | emit executing( appLnk ); | 613 | emit executing( appLnk ); |
599 | appLnk->execute(); | 614 | appLnk->execute(); |
600 | } | 615 | } |
601 | } | 616 | } |
602 | 617 | ||
603 | void Launcher::properties( AppLnk *appLnk ) | 618 | void Launcher::properties( AppLnk *appLnk ) |
604 | { | 619 | { |
605 | if ( appLnk->type() == "Folder" ) { // No tr | 620 | if ( appLnk->type() == "Folder" ) { // No tr |
606 | // Not supported: flat is simpler for the user | 621 | // Not supported: flat is simpler for the user |
607 | } else { | 622 | } else { |
608 | /* ### libqtopia FIXME also moving docLnks... */ | 623 | /* ### libqtopia FIXME also moving docLnks... */ |
609 | LnkProperties prop(appLnk,0 ); | 624 | LnkProperties prop(appLnk,0 ); |
610 | 625 | ||
611 | QPEApplication::execDialog( &prop ); | 626 | QPEApplication::execDialog( &prop ); |
612 | } | 627 | } |
613 | } | 628 | } |
614 | 629 | ||
615 | void Launcher::storageChanged( const QList<FileSystem> &fs ) | 630 | void Launcher::storageChanged( const QList<FileSystem> &fs ) |
616 | { | 631 | { |
617 | // ### update combo boxes if we had a combo box for the storage type | 632 | // ### update combo boxes if we had a combo box for the storage type |
618 | } | 633 | } |
619 | 634 | ||
620 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 635 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
621 | { | 636 | { |
622 | QDataStream stream( data, IO_ReadOnly ); | 637 | QDataStream stream( data, IO_ReadOnly ); |
623 | if ( msg == "busy()" ) { | 638 | if ( msg == "busy()" ) { |
624 | tb->startWait(); | 639 | tb->startWait(); |
625 | } else if ( msg == "notBusy(QString)" ) { | 640 | } else if ( msg == "notBusy(QString)" ) { |
626 | QString app; | 641 | QString app; |
627 | stream >> app; | 642 | stream >> app; |
628 | tabs->setBusy(FALSE); | 643 | tabs->setBusy(FALSE); |
629 | tb->stopWait(app); | 644 | tb->stopWait(app); |
630 | } else if (msg == "applyStyle()") { | 645 | } else if (msg == "applyStyle()") { |
631 | tabs->currentView()->relayout(); | 646 | tabs->currentView()->relayout(); |
632 | } | 647 | } |
633 | } | 648 | } |
634 | 649 | ||
635 | // These are the update functions from the server | 650 | // These are the update functions from the server |
636 | void Launcher::typeAdded( const QString& type, const QString& name, | 651 | void Launcher::typeAdded( const QString& type, const QString& name, |
637 | const QPixmap& pixmap, const QPixmap& ) | 652 | const QPixmap& pixmap, const QPixmap& ) |
638 | { | 653 | { |
639 | tabs->newView( type, pixmap, name ); | 654 | tabs->newView( type, pixmap, name ); |
640 | ids.append( type ); | 655 | ids.append( type ); |
641 | /* this will be called in applicationScanningProgress with value 100! */ | 656 | /* this will be called in applicationScanningProgress with value 100! */ |
642 | // tb->refreshStartMenu(); | 657 | // tb->refreshStartMenu(); |
643 | 658 | ||
644 | static bool first = TRUE; | 659 | static bool first = TRUE; |
645 | if ( first ) { | 660 | if ( first ) { |
646 | first = FALSE; | 661 | first = FALSE; |
647 | tabs->categoryBar->showTab(type); | 662 | tabs->categoryBar->showTab(type); |
648 | } | 663 | } |
649 | 664 | ||
650 | tabs->view( type )->setUpdatesEnabled( FALSE ); | 665 | tabs->view( type )->setUpdatesEnabled( FALSE ); |
651 | tabs->view( type )->setSortEnabled( FALSE ); | 666 | tabs->view( type )->setSortEnabled( FALSE ); |
652 | } | 667 | } |
653 | 668 | ||
654 | void Launcher::typeRemoved( const QString& type ) | 669 | void Launcher::typeRemoved( const QString& type ) |
655 | { | 670 | { |
656 | tabs->view( type )->removeAllItems(); | 671 | tabs->view( type )->removeAllItems(); |
657 | tabs->deleteView( type ); | 672 | tabs->deleteView( type ); |
658 | ids.remove( type ); | 673 | ids.remove( type ); |
659 | /* this will be called in applicationScanningProgress with value 100! */ | 674 | /* this will be called in applicationScanningProgress with value 100! */ |
660 | // tb->refreshStartMenu(); | 675 | // tb->refreshStartMenu(); |
661 | } | 676 | } |
662 | 677 | ||
663 | void Launcher::applicationAdded( const QString& type, const AppLnk& app ) | 678 | void Launcher::applicationAdded( const QString& type, const AppLnk& app ) |
664 | { | 679 | { |
665 | if ( app.type() == "Separator" ) // No tr | 680 | if ( app.type() == "Separator" ) // No tr |
666 | return; | 681 | return; |
667 | 682 | ||
668 | LauncherView *view = tabs->view( type ); | 683 | LauncherView *view = tabs->view( type ); |
669 | if ( view ) | 684 | if ( view ) |
670 | view->addItem( new AppLnk( app ), FALSE ); | 685 | view->addItem( new AppLnk( app ), FALSE ); |
671 | else | 686 | else |
672 | owarn << "addAppLnk: No view for type " << type.latin1() << ". Can't add app " | 687 | owarn << "addAppLnk: No view for type " << type.latin1() << ". Can't add app " |
673 | << app.name().latin1() << "!", | 688 | << app.name().latin1() << "!", |
674 | 689 | ||
675 | MimeType::registerApp( app ); | 690 | MimeType::registerApp( app ); |
676 | } | 691 | } |
677 | 692 | ||
678 | void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) | 693 | void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) |
679 | { | 694 | { |
680 | LauncherView *view = tabs->view( type ); | 695 | LauncherView *view = tabs->view( type ); |
681 | if ( view ) | 696 | if ( view ) |
682 | view->removeLink( app.linkFile() ); | 697 | view->removeLink( app.linkFile() ); |
683 | else | 698 | else |
684 | owarn << "removeAppLnk: No view for " << type << "!" << oendl; | 699 | owarn << "removeAppLnk: No view for " << type << "!" << oendl; |
685 | } | 700 | } |
686 | 701 | ||
687 | void Launcher::allApplicationsRemoved() | 702 | void Launcher::allApplicationsRemoved() |
688 | { | 703 | { |
689 | MimeType::clear(); | 704 | MimeType::clear(); |
690 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) | 705 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) |
691 | tabs->view( (*it) )->removeAllItems(); | 706 | tabs->view( (*it) )->removeAllItems(); |
692 | } | 707 | } |
693 | 708 | ||
694 | void Launcher::documentAdded( const DocLnk& doc ) | 709 | void Launcher::documentAdded( const DocLnk& doc ) |
695 | { | 710 | { |
696 | tabs->docView()->addItem( new DocLnk( doc ), FALSE ); | 711 | tabs->docView()->addItem( new DocLnk( doc ), FALSE ); |
697 | } | 712 | } |
698 | 713 | ||
699 | void Launcher::aboutToAddBegin() | 714 | void Launcher::aboutToAddBegin() |
700 | { | 715 | { |
701 | tabs->docView()->setUpdatesEnabled( false ); | 716 | tabs->docView()->setUpdatesEnabled( false ); |
702 | } | 717 | } |
703 | 718 | ||
704 | void Launcher::aboutToAddEnd() | 719 | void Launcher::aboutToAddEnd() |
705 | { | 720 | { |
706 | tabs->docView()->setUpdatesEnabled( true ); | 721 | tabs->docView()->setUpdatesEnabled( true ); |
707 | } | 722 | } |
708 | 723 | ||
709 | void Launcher::showLoadingDocs() | 724 | void Launcher::showLoadingDocs() |
710 | { | 725 | { |
711 | tabs->docView()->hide(); | 726 | tabs->docView()->hide(); |
712 | } | 727 | } |
713 | 728 | ||
714 | void Launcher::showDocTab() | 729 | void Launcher::showDocTab() |
715 | { | 730 | { |
716 | if ( tabs->categoryBar->currentView() == tabs->docView() ) | 731 | if ( tabs->categoryBar->currentView() == tabs->docView() ) |
717 | tabs->docView()->show(); | 732 | tabs->docView()->show(); |
718 | } | 733 | } |
719 | 734 | ||
720 | void Launcher::documentRemoved( const DocLnk& doc ) | 735 | void Launcher::documentRemoved( const DocLnk& doc ) |
721 | { | 736 | { |
722 | tabs->docView()->removeLink( doc.linkFile() ); | 737 | tabs->docView()->removeLink( doc.linkFile() ); |
723 | } | 738 | } |
724 | 739 | ||
725 | void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) | 740 | void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) |
726 | { | 741 | { |
727 | documentRemoved( oldDoc ); | 742 | documentRemoved( oldDoc ); |
728 | documentAdded( newDoc ); | 743 | documentAdded( newDoc ); |
729 | } | 744 | } |
730 | 745 | ||
731 | void Launcher::allDocumentsRemoved() | 746 | void Launcher::allDocumentsRemoved() |
732 | { | 747 | { |
733 | tabs->docView()->removeAllItems(); | 748 | tabs->docView()->removeAllItems(); |
734 | } | 749 | } |
735 | 750 | ||
736 | void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) | 751 | void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) |
737 | { | 752 | { |
738 | tb->setApplicationState( name, state ); | 753 | tb->setApplicationState( name, state ); |
739 | } | 754 | } |
740 | 755 | ||
741 | void Launcher::applicationScanningProgress( int percent ) | 756 | void Launcher::applicationScanningProgress( int percent ) |
742 | { | 757 | { |
743 | switch ( percent ) { | 758 | switch ( percent ) { |
744 | case 0: { | 759 | case 0: { |
745 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { | 760 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { |
746 | tabs->view( (*it) )->setUpdatesEnabled( FALSE ); | 761 | tabs->view( (*it) )->setUpdatesEnabled( FALSE ); |
747 | tabs->view( (*it) )->setSortEnabled( FALSE ); | 762 | tabs->view( (*it) )->setSortEnabled( FALSE ); |
748 | } | 763 | } |
749 | break; | 764 | break; |
750 | } | 765 | } |
751 | case 100: { | 766 | case 100: { |
752 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { | 767 | for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { |
753 | tabs->view( (*it) )->setUpdatesEnabled( TRUE ); | 768 | tabs->view( (*it) )->setUpdatesEnabled( TRUE ); |
754 | tabs->view( (*it) )->setSortEnabled( TRUE ); | 769 | tabs->view( (*it) )->setSortEnabled( TRUE ); |
755 | } | 770 | } |
756 | tb->refreshStartMenu(); | 771 | tb->refreshStartMenu(); |
757 | break; | 772 | break; |
758 | } | 773 | } |
759 | default: | 774 | default: |
760 | break; | 775 | break; |
761 | } | 776 | } |
762 | } | 777 | } |
763 | 778 | ||
764 | void Launcher::documentScanningProgress( int percent ) | 779 | void Launcher::documentScanningProgress( int percent ) |
765 | { | 780 | { |
766 | switch ( percent ) { | 781 | switch ( percent ) { |
767 | case 0: { | 782 | case 0: { |
768 | tabs->setLoadingProgress( 0 ); | 783 | tabs->setLoadingProgress( 0 ); |
769 | tabs->setLoadingWidgetEnabled( TRUE ); | 784 | tabs->setLoadingWidgetEnabled( TRUE ); |
770 | tabs->docView()->setUpdatesEnabled( FALSE ); | 785 | tabs->docView()->setUpdatesEnabled( FALSE ); |
771 | tabs->docView()->setSortEnabled( FALSE ); | 786 | tabs->docView()->setSortEnabled( FALSE ); |
772 | break; | 787 | break; |
773 | } | 788 | } |
774 | case 100: { | 789 | case 100: { |
775 | tabs->docView()->updateTools(); | 790 | tabs->docView()->updateTools(); |
776 | tabs->docView()->setSortEnabled( TRUE ); | 791 | tabs->docView()->setSortEnabled( TRUE ); |
777 | tabs->docView()->setUpdatesEnabled( TRUE ); | 792 | tabs->docView()->setUpdatesEnabled( TRUE ); |
778 | tabs->setLoadingWidgetEnabled( FALSE ); | 793 | tabs->setLoadingWidgetEnabled( FALSE ); |
779 | break; | 794 | break; |
780 | } | 795 | } |
781 | default: | 796 | default: |
782 | tabs->setLoadingProgress( percent ); | 797 | tabs->setLoadingProgress( percent ); |
783 | break; | 798 | break; |
784 | } | 799 | } |
785 | } | 800 | } |
786 | 801 | ||