summaryrefslogtreecommitdiff
path: root/core/launcher/launcher.cpp
authormickeyl <mickeyl>2005-07-03 22:13:00 (UTC)
committer mickeyl <mickeyl>2005-07-03 22:13:00 (UTC)
commit2cabd9ad4b49eefccdf99ad59550c76546b473c9 (patch) (side-by-side diff)
tree00bab275ac356aecc5a39b86ca22ce172d01f622 /core/launcher/launcher.cpp
parent47011752d4457a1055894479e5bf855e100fddac (diff)
downloadopie-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
Diffstat (limited to 'core/launcher/launcher.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp60
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 @@
-/**********************************************************************
-** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
-**
-** This file is part of the Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
-
+/*
+                 This file is part of the Opie Project
+ =. (C) 2000-2002 Trolltech AS
+ .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+ :`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; version 2 of the License.
+     ._= =}       :
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+ : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#include "startmenu.h"
#include "taskbar.h"
#include "serverinterface.h"
#include "launcherview.h"
#include "launcher.h"
#include "server.h"
-
/* OPIE */
#include <opie2/odebug.h>
+#include <opie2/oresource.h>
+using namespace Opie::Core;
+
#include <qtopia/global.h>
#ifdef Q_WS_QWS
#include <qtopia/qcopenvelope_qws.h>
#endif
-#include <qtopia/resource.h>
#include <qtopia/applnk.h>
#include <qtopia/config.h>
#include <qtopia/qpeapplication.h>
#include <qtopia/mimetype.h>
#include <qtopia/private/categories.h>
#define QTOPIA_INTERNAL_FSLP
#include <qtopia/lnkproperties.h>
/* QT */
#include <qdir.h>
#ifdef Q_WS_QWS
#include <qkeyboard_qws.h>
#include <qwindowsystem_qws.h>
#endif
#include <qtimer.h>
#include <qcombobox.h>
#include <qvbox.h>
#include <qlayout.h>
#include <qstyle.h>
#include <qpushbutton.h>
#include <qtabbar.h>
#include <qwidgetstack.h>
#include <qregexp.h>
#include <qmessagebox.h>
#include <qframe.h>
#include <qpainter.h>
#include <qlabel.h>
#include <qtextstream.h>
#include <qpopupmenu.h>
/* STD */
#include <stdlib.h>
#include <assert.h>
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
#include <unistd.h>
#include <stdio.h>
#include <sys/vfs.h>
#include <mntent.h>
#endif
static bool isVisibleWindow( int );
//===========================================================================
LauncherTabWidget::LauncherTabWidget( Launcher* parent ) :
QVBox( parent ), docview( 0 ),docTabEnabled(true),m_DocumentTabId(0)
{
docLoadingWidgetEnabled = false;
docLoadingWidget = 0;
docLoadingWidgetProgress = 0;
launcher = parent;
categoryBar = new LauncherTabBar( this );
QPalette pal = categoryBar->palette();
pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
categoryBar->setPalette( pal );
stack = new QWidgetStack(this);
connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) );
categoryBar->show();
stack->show();
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
this, SLOT(launcherMessage(const QCString&,const QByteArray&)) );
connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
this, SLOT(appMessage(const QCString&,const QByteArray&)));
#endif
createDocLoadingWidget();
}
void LauncherTabWidget::createDocLoadingWidget()
{
// Construct the 'doc loading widget' shown when finding documents
// ### LauncherView class needs changing to be more generic so
// this widget can change its background similar to the iconviews
// so the background for this matches
docLoadingWidget = new LauncherView( stack );
docLoadingWidget->hideIcons();
QVBox *docLoadingVBox = new QVBox( docLoadingWidget );
docLoadingVBox->setSpacing( 20 );
docLoadingVBox->setMargin( 10 );
QWidget *space1 = new QWidget( docLoadingVBox );
docLoadingVBox->setStretchFactor( space1, 1 );
- QLabel *waitPixmap = new QLabel( docLoadingVBox );
+ QLabel *waitPixmap = new QLabel( "Please Wait...", docLoadingVBox );
waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) );
- waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) );
waitPixmap->setAlignment( int( QLabel::AlignCenter ) );
Config cfg( "Launcher" );
cfg.setGroup( "DocTab" );
docTabEnabled = cfg.readBoolEntry( "Enable", true );
QLabel *textLabel = new QLabel( docLoadingVBox );
textLabel->setAlignment( int( QLabel::AlignCenter ) );
docLoadingWidgetProgress = new QProgressBar( docLoadingVBox );
docLoadingWidgetProgress->setProgress( 0 );
docLoadingWidgetProgress->setCenterIndicator( TRUE );
docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker
setProgressStyle();
if ( docTabEnabled )
{
textLabel->setText( tr( "<b>Finding Documents...</b>" ) );
}
else
{
textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>"
"Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) );
docLoadingWidgetProgress->hide();
docLoadingWidgetEnabled = true;
}
QWidget *space2 = new QWidget( docLoadingVBox );
docLoadingVBox->setStretchFactor( space2, 1 );
cfg.setGroup( "Tab Documents" ); // No tr
setTabViewAppearance( docLoadingWidget, cfg );
stack->addWidget( docLoadingWidget, 0 );
}
void LauncherTabWidget::initLayout()
{
layout()->activate();
docView()->setFocus();
categoryBar->showTab("Documents");
}
void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&)
{
if ( message == "nextView()" )
categoryBar->nextTab();
}
void LauncherTabWidget::raiseTabWidget()
{
if ( categoryBar->currentView() == docView()
&& docLoadingWidgetEnabled ) {
stack->raiseWidget( docLoadingWidget );
docLoadingWidget->updateGeometry();
} else {
stack->raiseWidget( categoryBar->currentView() );
}
}
void LauncherTabWidget::tabProperties()
{
LauncherView *view = categoryBar->currentView();
QPopupMenu *m = new QPopupMenu( this );
m->insertItem( tr("Icon View"), LauncherView::Icon );
m->insertItem( tr("List View"), LauncherView::List );
m->setItemChecked( (int)view->viewMode(), TRUE );
int rv = m->exec( QCursor::pos() );
if ( rv >= 0 && rv != view->viewMode() ) {
view->setViewMode( (LauncherView::ViewMode)rv );
}
delete m;
}
void LauncherTabWidget::deleteView( const QString& id )
{
LauncherTab *t = categoryBar->launcherTab(id);
if ( t ) {
stack->removeWidget( t->view );
delete t->view;
categoryBar->removeTab( t );
}
}
LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
{
LauncherView* view = new LauncherView( stack );
connect( view, SIGNAL(clicked(const AppLnk*)),
this, SIGNAL(clicked(const AppLnk*)));
connect( view, SIGNAL(rightPressed(AppLnk*)),
this, SIGNAL(rightPressed(AppLnk*)));
int n = categoryBar->count();
stack->addWidget( view, n );
@@ -436,197 +443,194 @@ void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &
if ( view(id) ) {
if ( !fam.isEmpty() ) {
view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl;
} else {
view(id)->clearViewFont();
}
}
}else if ( msg == "setBusyIndicatorType(QString)" ) {
QString type;
stream >> type;
setBusyIndicatorType( type );
}else if ( msg == "home()" ) {
if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) {
if (categoryBar)
categoryBar->nextTab();
}else {
static_cast<QWidget*>(parent())->raise();
}
} else if (msg=="doctabEnabled(int)") {
int id; stream >> id;
odebug << "Doctab enabled " << id << oendl;
reCheckDoctab(id);
} else if ( msg == "setStaticBackground(bool)" ) {
int set; stream >> set;
odebug << "setStaticBackground " << set << oendl;
for (int i = 0; i < categoryBar->count(); i++ )
{
LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view;
view->iconView()->setStaticBackgroundPicture( set );
}
}
}
void LauncherTabWidget::reCheckDoctab(int how)
{
if ((bool)how == docTabEnabled) {
/* nothing to do */
return;
}
if (docLoadingWidget) {
stack->removeWidget(docLoadingWidget);
delete docLoadingWidget;
docLoadingWidget = 0;
}
createDocLoadingWidget();
{
QCopEnvelope( "QPE/System", "reforceDocuments()" );
odebug << "Sending doc rescan" << oendl;
}
}
//---------------------------------------------------------------------------
Launcher::Launcher()
: QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader )
{
tabs = 0;
tb = 0;
Config cfg( "Launcher" );
cfg.setGroup( "DocTab" );
docTabEnabled = cfg.readBoolEntry( "Enable", true );
}
void Launcher::createGUI()
{
setCaption( tr("Launcher") );
// we have a pretty good idea how big we'll be
setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
tb = new TaskBar;
tabs = new LauncherTabWidget( this );
setCentralWidget( tabs );
ServerInterface::dockWidget( tb, ServerInterface::Bottom );
tb->show();
qApp->installEventFilter( this );
connect( tb, SIGNAL(tabSelected(const QString&)),
this, SLOT(showTab(const QString&)) );
connect( tabs, SIGNAL(selected(const QString&)),
this, SLOT(viewSelected(const QString&)) );
connect( tabs, SIGNAL(clicked(const AppLnk*)),
this, SLOT(select(const AppLnk*)));
connect( tabs, SIGNAL(rightPressed(AppLnk*)),
this, SLOT(properties(AppLnk*)));
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)),
this, SLOT(systemMessage(const QCString&,const QByteArray&)) );
#endif
// all documents
- QImage img( Resource::loadImage( "DocsIcon" ) );
- QPixmap pm;
- pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
+ QPixmap pm = OResource::loadPixmap( "DocsIcon", OResource::SmallIcon );
// It could add this itself if it handles docs
-
tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE );
QTimer::singleShot( 0, tabs, SLOT( initLayout() ) );
qApp->setMainWidget( this );
QTimer::singleShot( 500, this, SLOT( makeVisible() ) );
}
Launcher::~Launcher()
{
if ( tb )
destroyGUI();
}
bool Launcher::requiresDocuments() const
{
Config cfg( "Launcher" );
cfg.setGroup( "DocTab" );
return cfg.readBoolEntry( "Enable", true );
}
void Launcher::makeVisible()
{
showMaximized();
}
void Launcher::destroyGUI()
{
delete tb;
tb = 0;
delete tabs;
tabs =0;
}
bool Launcher::eventFilter( QObject*, QEvent *ev )
{
#ifdef QT_QWS_CUSTOM
if ( ev->type() == QEvent::KeyPress ) {
QKeyEvent *ke = (QKeyEvent *)ev;
if ( ke->key() == Qt::Key_F11 ) { // menu key
QWidget *active = qApp->activeWindow();
if ( active && active->isPopup() )
active->close();
else {
Global::terminateBuiltin("calibrate"); // No tr
tb->launchStartMenu();
}
return TRUE;
}
}
#else
Q_UNUSED(ev);
#endif
return FALSE;
}
static bool isVisibleWindow(int wid)
{
#ifdef Q_WS_QWS
const QList<QWSWindow> &list = qwsServer->clientWindows();
QWSWindow* w;
for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
if ( w->winId() == wid )
return !w->isFullyObscured();
}
#endif
return FALSE;
}
void Launcher::viewSelected(const QString& s)
{
setCaption( s + tr(" - Launcher") );
}
void Launcher::showTab(const QString& id)
{
tabs->categoryBar->showTab(id);
raise();
}
void Launcher::select( const AppLnk *appLnk )
{
if ( appLnk->type() == "Folder" ) { // No tr
// Not supported: flat is simpler for the user
} else {
if ( appLnk->exec().isNull() ) {
int i = QMessageBox::information(this,tr("No application"),
tr("<p>No application is defined for this document."
"<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1);
/* ### Fixme */
if ( i == 1 )
Global::execute("textedit",appLnk->file());
return;
}
tabs->setBusy(TRUE);