author | mickeyl <mickeyl> | 2005-07-03 22:13:00 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-07-03 22:13:00 (UTC) |
commit | 2cabd9ad4b49eefccdf99ad59550c76546b473c9 (patch) (unidiff) | |
tree | 00bab275ac356aecc5a39b86ca22ce172d01f622 /core/launcher/launcher.cpp | |
parent | 47011752d4457a1055894479e5bf855e100fddac (diff) | |
download | opie-2cabd9ad4b49eefccdf99ad59550c76546b473c9.zip opie-2cabd9ad4b49eefccdf99ad59550c76546b473c9.tar.gz opie-2cabd9ad4b49eefccdf99ad59550c76546b473c9.tar.bz2 |
Resource -> OResource
This is a large diff and I'd appreciate some additional pairs of eyes checking it
-rw-r--r-- | core/launcher/launcher.cpp | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 4ec5f4c..361a159 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -1,222 +1,229 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | =. (C) 2000-2002 Trolltech AS |
4 | ** This file is part of the Qtopia Environment. | 4 | .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | .>+-= |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | _;:, .> :=|. This program is free software; you can |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | ** packaging of this file. | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | ** | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ._= =} : |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | .%`+i> _;_. |
13 | ** | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | ** | 15 | : .. .:, . . . without even the implied warranty of |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | ** not clear to you. | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ** | 18 | ..}^=.= = ; Library General Public License for more |
19 | **********************************************************************/ | 19 | ++= -. .` .: details. |
20 | 20 | : = ...= . :.=- | |
21 | -. .:....=;==+<; You should have received a copy of the GNU | ||
22 | -_. . . )=. = Library General Public License along with | ||
23 | -- :-=` this library; see the file COPYING.LIB. | ||
24 | If not, write to the Free Software Foundation, | ||
25 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | */ | ||
21 | #include "startmenu.h" | 28 | #include "startmenu.h" |
22 | #include "taskbar.h" | 29 | #include "taskbar.h" |
23 | #include "serverinterface.h" | 30 | #include "serverinterface.h" |
24 | #include "launcherview.h" | 31 | #include "launcherview.h" |
25 | #include "launcher.h" | 32 | #include "launcher.h" |
26 | #include "server.h" | 33 | #include "server.h" |
27 | |||
28 | /* OPIE */ | 34 | /* OPIE */ |
29 | #include <opie2/odebug.h> | 35 | #include <opie2/odebug.h> |
36 | #include <opie2/oresource.h> | ||
37 | using namespace Opie::Core; | ||
38 | |||
30 | #include <qtopia/global.h> | 39 | #include <qtopia/global.h> |
31 | #ifdef Q_WS_QWS | 40 | #ifdef Q_WS_QWS |
32 | #include <qtopia/qcopenvelope_qws.h> | 41 | #include <qtopia/qcopenvelope_qws.h> |
33 | #endif | 42 | #endif |
34 | #include <qtopia/resource.h> | ||
35 | #include <qtopia/applnk.h> | 43 | #include <qtopia/applnk.h> |
36 | #include <qtopia/config.h> | 44 | #include <qtopia/config.h> |
37 | #include <qtopia/qpeapplication.h> | 45 | #include <qtopia/qpeapplication.h> |
38 | #include <qtopia/mimetype.h> | 46 | #include <qtopia/mimetype.h> |
39 | #include <qtopia/private/categories.h> | 47 | #include <qtopia/private/categories.h> |
40 | #define QTOPIA_INTERNAL_FSLP | 48 | #define QTOPIA_INTERNAL_FSLP |
41 | #include <qtopia/lnkproperties.h> | 49 | #include <qtopia/lnkproperties.h> |
42 | 50 | ||
43 | /* QT */ | 51 | /* QT */ |
44 | #include <qdir.h> | 52 | #include <qdir.h> |
45 | #ifdef Q_WS_QWS | 53 | #ifdef Q_WS_QWS |
46 | #include <qkeyboard_qws.h> | 54 | #include <qkeyboard_qws.h> |
47 | #include <qwindowsystem_qws.h> | 55 | #include <qwindowsystem_qws.h> |
48 | #endif | 56 | #endif |
49 | #include <qtimer.h> | 57 | #include <qtimer.h> |
50 | #include <qcombobox.h> | 58 | #include <qcombobox.h> |
51 | #include <qvbox.h> | 59 | #include <qvbox.h> |
52 | #include <qlayout.h> | 60 | #include <qlayout.h> |
53 | #include <qstyle.h> | 61 | #include <qstyle.h> |
54 | #include <qpushbutton.h> | 62 | #include <qpushbutton.h> |
55 | #include <qtabbar.h> | 63 | #include <qtabbar.h> |
56 | #include <qwidgetstack.h> | 64 | #include <qwidgetstack.h> |
57 | #include <qregexp.h> | 65 | #include <qregexp.h> |
58 | #include <qmessagebox.h> | 66 | #include <qmessagebox.h> |
59 | #include <qframe.h> | 67 | #include <qframe.h> |
60 | #include <qpainter.h> | 68 | #include <qpainter.h> |
61 | #include <qlabel.h> | 69 | #include <qlabel.h> |
62 | #include <qtextstream.h> | 70 | #include <qtextstream.h> |
63 | #include <qpopupmenu.h> | 71 | #include <qpopupmenu.h> |
64 | 72 | ||
65 | /* STD */ | 73 | /* STD */ |
66 | #include <stdlib.h> | 74 | #include <stdlib.h> |
67 | #include <assert.h> | 75 | #include <assert.h> |
68 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 76 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
69 | #include <unistd.h> | 77 | #include <unistd.h> |
70 | #include <stdio.h> | 78 | #include <stdio.h> |
71 | #include <sys/vfs.h> | 79 | #include <sys/vfs.h> |
72 | #include <mntent.h> | 80 | #include <mntent.h> |
73 | #endif | 81 | #endif |
74 | 82 | ||
75 | 83 | ||
76 | static bool isVisibleWindow( int ); | 84 | static bool isVisibleWindow( int ); |
77 | //=========================================================================== | 85 | //=========================================================================== |
78 | 86 | ||
79 | LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : | 87 | LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : |
80 | QVBox( parent ), docview( 0 ),docTabEnabled(true),m_DocumentTabId(0) | 88 | QVBox( parent ), docview( 0 ),docTabEnabled(true),m_DocumentTabId(0) |
81 | { | 89 | { |
82 | docLoadingWidgetEnabled = false; | 90 | docLoadingWidgetEnabled = false; |
83 | docLoadingWidget = 0; | 91 | docLoadingWidget = 0; |
84 | docLoadingWidgetProgress = 0; | 92 | docLoadingWidgetProgress = 0; |
85 | launcher = parent; | 93 | launcher = parent; |
86 | categoryBar = new LauncherTabBar( this ); | 94 | categoryBar = new LauncherTabBar( this ); |
87 | QPalette pal = categoryBar->palette(); | 95 | QPalette pal = categoryBar->palette(); |
88 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 96 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
89 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 97 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
90 | categoryBar->setPalette( pal ); | 98 | categoryBar->setPalette( pal ); |
91 | stack = new QWidgetStack(this); | 99 | stack = new QWidgetStack(this); |
92 | connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); | 100 | connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); |
93 | categoryBar->show(); | 101 | categoryBar->show(); |
94 | stack->show(); | 102 | stack->show(); |
95 | 103 | ||
96 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 104 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
97 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); | 105 | QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); |
98 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 106 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
99 | this, SLOT(launcherMessage(const QCString&,const QByteArray&)) ); | 107 | this, SLOT(launcherMessage(const QCString&,const QByteArray&)) ); |
100 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), | 108 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
101 | this, SLOT(appMessage(const QCString&,const QByteArray&))); | 109 | this, SLOT(appMessage(const QCString&,const QByteArray&))); |
102 | #endif | 110 | #endif |
103 | 111 | ||
104 | createDocLoadingWidget(); | 112 | createDocLoadingWidget(); |
105 | } | 113 | } |
106 | 114 | ||
107 | void LauncherTabWidget::createDocLoadingWidget() | 115 | void LauncherTabWidget::createDocLoadingWidget() |
108 | { | 116 | { |
109 | // Construct the 'doc loading widget' shown when finding documents | 117 | // Construct the 'doc loading widget' shown when finding documents |
110 | 118 | ||
111 | // ### LauncherView class needs changing to be more generic so | 119 | // ### LauncherView class needs changing to be more generic so |
112 | // this widget can change its background similar to the iconviews | 120 | // this widget can change its background similar to the iconviews |
113 | // so the background for this matches | 121 | // so the background for this matches |
114 | docLoadingWidget = new LauncherView( stack ); | 122 | docLoadingWidget = new LauncherView( stack ); |
115 | docLoadingWidget->hideIcons(); | 123 | docLoadingWidget->hideIcons(); |
116 | QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); | 124 | QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); |
117 | 125 | ||
118 | docLoadingVBox->setSpacing( 20 ); | 126 | docLoadingVBox->setSpacing( 20 ); |
119 | docLoadingVBox->setMargin( 10 ); | 127 | docLoadingVBox->setMargin( 10 ); |
120 | 128 | ||
121 | QWidget *space1 = new QWidget( docLoadingVBox ); | 129 | QWidget *space1 = new QWidget( docLoadingVBox ); |
122 | docLoadingVBox->setStretchFactor( space1, 1 ); | 130 | docLoadingVBox->setStretchFactor( space1, 1 ); |
123 | 131 | ||
124 | QLabel *waitPixmap = new QLabel( docLoadingVBox ); | 132 | QLabel *waitPixmap = new QLabel( "Please Wait...", docLoadingVBox ); |
125 | waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); | 133 | waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); |
126 | waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); | ||
127 | waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); | 134 | waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); |
128 | 135 | ||
129 | Config cfg( "Launcher" ); | 136 | Config cfg( "Launcher" ); |
130 | cfg.setGroup( "DocTab" ); | 137 | cfg.setGroup( "DocTab" ); |
131 | docTabEnabled = cfg.readBoolEntry( "Enable", true ); | 138 | docTabEnabled = cfg.readBoolEntry( "Enable", true ); |
132 | 139 | ||
133 | QLabel *textLabel = new QLabel( docLoadingVBox ); | 140 | QLabel *textLabel = new QLabel( docLoadingVBox ); |
134 | textLabel->setAlignment( int( QLabel::AlignCenter ) ); | 141 | textLabel->setAlignment( int( QLabel::AlignCenter ) ); |
135 | docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); | 142 | docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); |
136 | docLoadingWidgetProgress->setProgress( 0 ); | 143 | docLoadingWidgetProgress->setProgress( 0 ); |
137 | docLoadingWidgetProgress->setCenterIndicator( TRUE ); | 144 | docLoadingWidgetProgress->setCenterIndicator( TRUE ); |
138 | docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker | 145 | docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker |
139 | setProgressStyle(); | 146 | setProgressStyle(); |
140 | 147 | ||
141 | if ( docTabEnabled ) | 148 | if ( docTabEnabled ) |
142 | { | 149 | { |
143 | textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); | 150 | textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); |
144 | } | 151 | } |
145 | else | 152 | else |
146 | { | 153 | { |
147 | textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" | 154 | textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" |
148 | "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); | 155 | "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); |
149 | docLoadingWidgetProgress->hide(); | 156 | docLoadingWidgetProgress->hide(); |
150 | docLoadingWidgetEnabled = true; | 157 | docLoadingWidgetEnabled = true; |
151 | } | 158 | } |
152 | 159 | ||
153 | QWidget *space2 = new QWidget( docLoadingVBox ); | 160 | QWidget *space2 = new QWidget( docLoadingVBox ); |
154 | docLoadingVBox->setStretchFactor( space2, 1 ); | 161 | docLoadingVBox->setStretchFactor( space2, 1 ); |
155 | 162 | ||
156 | cfg.setGroup( "Tab Documents" ); // No tr | 163 | cfg.setGroup( "Tab Documents" ); // No tr |
157 | setTabViewAppearance( docLoadingWidget, cfg ); | 164 | setTabViewAppearance( docLoadingWidget, cfg ); |
158 | 165 | ||
159 | stack->addWidget( docLoadingWidget, 0 ); | 166 | stack->addWidget( docLoadingWidget, 0 ); |
160 | } | 167 | } |
161 | 168 | ||
162 | void LauncherTabWidget::initLayout() | 169 | void LauncherTabWidget::initLayout() |
163 | { | 170 | { |
164 | layout()->activate(); | 171 | layout()->activate(); |
165 | docView()->setFocus(); | 172 | docView()->setFocus(); |
166 | categoryBar->showTab("Documents"); | 173 | categoryBar->showTab("Documents"); |
167 | } | 174 | } |
168 | 175 | ||
169 | void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) | 176 | void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) |
170 | { | 177 | { |
171 | if ( message == "nextView()" ) | 178 | if ( message == "nextView()" ) |
172 | categoryBar->nextTab(); | 179 | categoryBar->nextTab(); |
173 | } | 180 | } |
174 | 181 | ||
175 | void LauncherTabWidget::raiseTabWidget() | 182 | void LauncherTabWidget::raiseTabWidget() |
176 | { | 183 | { |
177 | if ( categoryBar->currentView() == docView() | 184 | if ( categoryBar->currentView() == docView() |
178 | && docLoadingWidgetEnabled ) { | 185 | && docLoadingWidgetEnabled ) { |
179 | stack->raiseWidget( docLoadingWidget ); | 186 | stack->raiseWidget( docLoadingWidget ); |
180 | docLoadingWidget->updateGeometry(); | 187 | docLoadingWidget->updateGeometry(); |
181 | } else { | 188 | } else { |
182 | stack->raiseWidget( categoryBar->currentView() ); | 189 | stack->raiseWidget( categoryBar->currentView() ); |
183 | } | 190 | } |
184 | } | 191 | } |
185 | 192 | ||
186 | void LauncherTabWidget::tabProperties() | 193 | void LauncherTabWidget::tabProperties() |
187 | { | 194 | { |
188 | LauncherView *view = categoryBar->currentView(); | 195 | LauncherView *view = categoryBar->currentView(); |
189 | QPopupMenu *m = new QPopupMenu( this ); | 196 | QPopupMenu *m = new QPopupMenu( this ); |
190 | m->insertItem( tr("Icon View"), LauncherView::Icon ); | 197 | m->insertItem( tr("Icon View"), LauncherView::Icon ); |
191 | m->insertItem( tr("List View"), LauncherView::List ); | 198 | m->insertItem( tr("List View"), LauncherView::List ); |
192 | m->setItemChecked( (int)view->viewMode(), TRUE ); | 199 | m->setItemChecked( (int)view->viewMode(), TRUE ); |
193 | int rv = m->exec( QCursor::pos() ); | 200 | int rv = m->exec( QCursor::pos() ); |
194 | if ( rv >= 0 && rv != view->viewMode() ) { | 201 | if ( rv >= 0 && rv != view->viewMode() ) { |
195 | view->setViewMode( (LauncherView::ViewMode)rv ); | 202 | view->setViewMode( (LauncherView::ViewMode)rv ); |
196 | } | 203 | } |
197 | 204 | ||
198 | delete m; | 205 | delete m; |
199 | } | 206 | } |
200 | 207 | ||
201 | void LauncherTabWidget::deleteView( const QString& id ) | 208 | void LauncherTabWidget::deleteView( const QString& id ) |
202 | { | 209 | { |
203 | LauncherTab *t = categoryBar->launcherTab(id); | 210 | LauncherTab *t = categoryBar->launcherTab(id); |
204 | if ( t ) { | 211 | if ( t ) { |
205 | stack->removeWidget( t->view ); | 212 | stack->removeWidget( t->view ); |
206 | delete t->view; | 213 | delete t->view; |
207 | categoryBar->removeTab( t ); | 214 | categoryBar->removeTab( t ); |
208 | } | 215 | } |
209 | } | 216 | } |
210 | 217 | ||
211 | LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 218 | LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
212 | { | 219 | { |
213 | LauncherView* view = new LauncherView( stack ); | 220 | LauncherView* view = new LauncherView( stack ); |
214 | connect( view, SIGNAL(clicked(const AppLnk*)), | 221 | connect( view, SIGNAL(clicked(const AppLnk*)), |
215 | this, SIGNAL(clicked(const AppLnk*))); | 222 | this, SIGNAL(clicked(const AppLnk*))); |
216 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 223 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
217 | this, SIGNAL(rightPressed(AppLnk*))); | 224 | this, SIGNAL(rightPressed(AppLnk*))); |
218 | 225 | ||
219 | 226 | ||
220 | int n = categoryBar->count(); | 227 | int n = categoryBar->count(); |
221 | 228 | ||
222 | stack->addWidget( view, n ); | 229 | stack->addWidget( view, n ); |
@@ -436,197 +443,194 @@ void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray & | |||
436 | if ( view(id) ) { | 443 | if ( view(id) ) { |
437 | if ( !fam.isEmpty() ) { | 444 | if ( !fam.isEmpty() ) { |
438 | view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); | 445 | view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); |
439 | odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; | 446 | odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; |
440 | } else { | 447 | } else { |
441 | view(id)->clearViewFont(); | 448 | view(id)->clearViewFont(); |
442 | } | 449 | } |
443 | } | 450 | } |
444 | }else if ( msg == "setBusyIndicatorType(QString)" ) { | 451 | }else if ( msg == "setBusyIndicatorType(QString)" ) { |
445 | QString type; | 452 | QString type; |
446 | stream >> type; | 453 | stream >> type; |
447 | setBusyIndicatorType( type ); | 454 | setBusyIndicatorType( type ); |
448 | }else if ( msg == "home()" ) { | 455 | }else if ( msg == "home()" ) { |
449 | if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { | 456 | if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { |
450 | if (categoryBar) | 457 | if (categoryBar) |
451 | categoryBar->nextTab(); | 458 | categoryBar->nextTab(); |
452 | }else { | 459 | }else { |
453 | static_cast<QWidget*>(parent())->raise(); | 460 | static_cast<QWidget*>(parent())->raise(); |
454 | } | 461 | } |
455 | } else if (msg=="doctabEnabled(int)") { | 462 | } else if (msg=="doctabEnabled(int)") { |
456 | int id; stream >> id; | 463 | int id; stream >> id; |
457 | odebug << "Doctab enabled " << id << oendl; | 464 | odebug << "Doctab enabled " << id << oendl; |
458 | reCheckDoctab(id); | 465 | reCheckDoctab(id); |
459 | } else if ( msg == "setStaticBackground(bool)" ) { | 466 | } else if ( msg == "setStaticBackground(bool)" ) { |
460 | int set; stream >> set; | 467 | int set; stream >> set; |
461 | odebug << "setStaticBackground " << set << oendl; | 468 | odebug << "setStaticBackground " << set << oendl; |
462 | for (int i = 0; i < categoryBar->count(); i++ ) | 469 | for (int i = 0; i < categoryBar->count(); i++ ) |
463 | { | 470 | { |
464 | LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; | 471 | LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; |
465 | view->iconView()->setStaticBackgroundPicture( set ); | 472 | view->iconView()->setStaticBackgroundPicture( set ); |
466 | } | 473 | } |
467 | } | 474 | } |
468 | } | 475 | } |
469 | 476 | ||
470 | void LauncherTabWidget::reCheckDoctab(int how) | 477 | void LauncherTabWidget::reCheckDoctab(int how) |
471 | { | 478 | { |
472 | if ((bool)how == docTabEnabled) { | 479 | if ((bool)how == docTabEnabled) { |
473 | /* nothing to do */ | 480 | /* nothing to do */ |
474 | return; | 481 | return; |
475 | } | 482 | } |
476 | if (docLoadingWidget) { | 483 | if (docLoadingWidget) { |
477 | stack->removeWidget(docLoadingWidget); | 484 | stack->removeWidget(docLoadingWidget); |
478 | delete docLoadingWidget; | 485 | delete docLoadingWidget; |
479 | docLoadingWidget = 0; | 486 | docLoadingWidget = 0; |
480 | } | 487 | } |
481 | createDocLoadingWidget(); | 488 | createDocLoadingWidget(); |
482 | { | 489 | { |
483 | QCopEnvelope( "QPE/System", "reforceDocuments()" ); | 490 | QCopEnvelope( "QPE/System", "reforceDocuments()" ); |
484 | odebug << "Sending doc rescan" << oendl; | 491 | odebug << "Sending doc rescan" << oendl; |
485 | } | 492 | } |
486 | } | 493 | } |
487 | 494 | ||
488 | //--------------------------------------------------------------------------- | 495 | //--------------------------------------------------------------------------- |
489 | 496 | ||
490 | Launcher::Launcher() | 497 | Launcher::Launcher() |
491 | : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) | 498 | : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) |
492 | { | 499 | { |
493 | tabs = 0; | 500 | tabs = 0; |
494 | tb = 0; | 501 | tb = 0; |
495 | Config cfg( "Launcher" ); | 502 | Config cfg( "Launcher" ); |
496 | cfg.setGroup( "DocTab" ); | 503 | cfg.setGroup( "DocTab" ); |
497 | docTabEnabled = cfg.readBoolEntry( "Enable", true ); | 504 | docTabEnabled = cfg.readBoolEntry( "Enable", true ); |
498 | } | 505 | } |
499 | 506 | ||
500 | void Launcher::createGUI() | 507 | void Launcher::createGUI() |
501 | { | 508 | { |
502 | setCaption( tr("Launcher") ); | 509 | setCaption( tr("Launcher") ); |
503 | 510 | ||
504 | // we have a pretty good idea how big we'll be | 511 | // we have a pretty good idea how big we'll be |
505 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 512 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
506 | 513 | ||
507 | tb = new TaskBar; | 514 | tb = new TaskBar; |
508 | tabs = new LauncherTabWidget( this ); | 515 | tabs = new LauncherTabWidget( this ); |
509 | setCentralWidget( tabs ); | 516 | setCentralWidget( tabs ); |
510 | 517 | ||
511 | ServerInterface::dockWidget( tb, ServerInterface::Bottom ); | 518 | ServerInterface::dockWidget( tb, ServerInterface::Bottom ); |
512 | tb->show(); | 519 | tb->show(); |
513 | 520 | ||
514 | qApp->installEventFilter( this ); | 521 | qApp->installEventFilter( this ); |
515 | 522 | ||
516 | connect( tb, SIGNAL(tabSelected(const QString&)), | 523 | connect( tb, SIGNAL(tabSelected(const QString&)), |
517 | this, SLOT(showTab(const QString&)) ); | 524 | this, SLOT(showTab(const QString&)) ); |
518 | connect( tabs, SIGNAL(selected(const QString&)), | 525 | connect( tabs, SIGNAL(selected(const QString&)), |
519 | this, SLOT(viewSelected(const QString&)) ); | 526 | this, SLOT(viewSelected(const QString&)) ); |
520 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 527 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
521 | this, SLOT(select(const AppLnk*))); | 528 | this, SLOT(select(const AppLnk*))); |
522 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 529 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
523 | this, SLOT(properties(AppLnk*))); | 530 | this, SLOT(properties(AppLnk*))); |
524 | 531 | ||
525 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 532 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
526 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 533 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
527 | connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 534 | connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
528 | this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); | 535 | this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); |
529 | #endif | 536 | #endif |
530 | 537 | ||
531 | // all documents | 538 | // all documents |
532 | QImage img( Resource::loadImage( "DocsIcon" ) ); | 539 | QPixmap pm = OResource::loadPixmap( "DocsIcon", OResource::SmallIcon ); |
533 | QPixmap pm; | ||
534 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | ||
535 | // It could add this itself if it handles docs | 540 | // It could add this itself if it handles docs |
536 | |||
537 | tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); | 541 | tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); |
538 | 542 | ||
539 | QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); | 543 | QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); |
540 | qApp->setMainWidget( this ); | 544 | qApp->setMainWidget( this ); |
541 | QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); | 545 | QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); |
542 | } | 546 | } |
543 | 547 | ||
544 | Launcher::~Launcher() | 548 | Launcher::~Launcher() |
545 | { | 549 | { |
546 | if ( tb ) | 550 | if ( tb ) |
547 | destroyGUI(); | 551 | destroyGUI(); |
548 | } | 552 | } |
549 | 553 | ||
550 | bool Launcher::requiresDocuments() const | 554 | bool Launcher::requiresDocuments() const |
551 | { | 555 | { |
552 | Config cfg( "Launcher" ); | 556 | Config cfg( "Launcher" ); |
553 | cfg.setGroup( "DocTab" ); | 557 | cfg.setGroup( "DocTab" ); |
554 | return cfg.readBoolEntry( "Enable", true ); | 558 | return cfg.readBoolEntry( "Enable", true ); |
555 | } | 559 | } |
556 | 560 | ||
557 | void Launcher::makeVisible() | 561 | void Launcher::makeVisible() |
558 | { | 562 | { |
559 | showMaximized(); | 563 | showMaximized(); |
560 | } | 564 | } |
561 | 565 | ||
562 | void Launcher::destroyGUI() | 566 | void Launcher::destroyGUI() |
563 | { | 567 | { |
564 | delete tb; | 568 | delete tb; |
565 | tb = 0; | 569 | tb = 0; |
566 | delete tabs; | 570 | delete tabs; |
567 | tabs =0; | 571 | tabs =0; |
568 | } | 572 | } |
569 | 573 | ||
570 | bool Launcher::eventFilter( QObject*, QEvent *ev ) | 574 | bool Launcher::eventFilter( QObject*, QEvent *ev ) |
571 | { | 575 | { |
572 | #ifdef QT_QWS_CUSTOM | 576 | #ifdef QT_QWS_CUSTOM |
573 | if ( ev->type() == QEvent::KeyPress ) { | 577 | if ( ev->type() == QEvent::KeyPress ) { |
574 | QKeyEvent *ke = (QKeyEvent *)ev; | 578 | QKeyEvent *ke = (QKeyEvent *)ev; |
575 | if ( ke->key() == Qt::Key_F11 ) { // menu key | 579 | if ( ke->key() == Qt::Key_F11 ) { // menu key |
576 | QWidget *active = qApp->activeWindow(); | 580 | QWidget *active = qApp->activeWindow(); |
577 | if ( active && active->isPopup() ) | 581 | if ( active && active->isPopup() ) |
578 | active->close(); | 582 | active->close(); |
579 | else { | 583 | else { |
580 | Global::terminateBuiltin("calibrate"); // No tr | 584 | Global::terminateBuiltin("calibrate"); // No tr |
581 | tb->launchStartMenu(); | 585 | tb->launchStartMenu(); |
582 | } | 586 | } |
583 | return TRUE; | 587 | return TRUE; |
584 | } | 588 | } |
585 | } | 589 | } |
586 | #else | 590 | #else |
587 | Q_UNUSED(ev); | 591 | Q_UNUSED(ev); |
588 | #endif | 592 | #endif |
589 | return FALSE; | 593 | return FALSE; |
590 | } | 594 | } |
591 | 595 | ||
592 | static bool isVisibleWindow(int wid) | 596 | static bool isVisibleWindow(int wid) |
593 | { | 597 | { |
594 | #ifdef Q_WS_QWS | 598 | #ifdef Q_WS_QWS |
595 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 599 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
596 | QWSWindow* w; | 600 | QWSWindow* w; |
597 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 601 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
598 | if ( w->winId() == wid ) | 602 | if ( w->winId() == wid ) |
599 | return !w->isFullyObscured(); | 603 | return !w->isFullyObscured(); |
600 | } | 604 | } |
601 | #endif | 605 | #endif |
602 | return FALSE; | 606 | return FALSE; |
603 | } | 607 | } |
604 | 608 | ||
605 | void Launcher::viewSelected(const QString& s) | 609 | void Launcher::viewSelected(const QString& s) |
606 | { | 610 | { |
607 | setCaption( s + tr(" - Launcher") ); | 611 | setCaption( s + tr(" - Launcher") ); |
608 | } | 612 | } |
609 | 613 | ||
610 | void Launcher::showTab(const QString& id) | 614 | void Launcher::showTab(const QString& id) |
611 | { | 615 | { |
612 | tabs->categoryBar->showTab(id); | 616 | tabs->categoryBar->showTab(id); |
613 | raise(); | 617 | raise(); |
614 | } | 618 | } |
615 | 619 | ||
616 | void Launcher::select( const AppLnk *appLnk ) | 620 | void Launcher::select( const AppLnk *appLnk ) |
617 | { | 621 | { |
618 | if ( appLnk->type() == "Folder" ) { // No tr | 622 | if ( appLnk->type() == "Folder" ) { // No tr |
619 | // Not supported: flat is simpler for the user | 623 | // Not supported: flat is simpler for the user |
620 | } else { | 624 | } else { |
621 | if ( appLnk->exec().isNull() ) { | 625 | if ( appLnk->exec().isNull() ) { |
622 | int i = QMessageBox::information(this,tr("No application"), | 626 | int i = QMessageBox::information(this,tr("No application"), |
623 | tr("<p>No application is defined for this document." | 627 | tr("<p>No application is defined for this document." |
624 | "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); | 628 | "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); |
625 | 629 | ||
626 | /* ### Fixme */ | 630 | /* ### Fixme */ |
627 | if ( i == 1 ) | 631 | if ( i == 1 ) |
628 | Global::execute("textedit",appLnk->file()); | 632 | Global::execute("textedit",appLnk->file()); |
629 | 633 | ||
630 | return; | 634 | return; |
631 | } | 635 | } |
632 | tabs->setBusy(TRUE); | 636 | tabs->setBusy(TRUE); |