summaryrefslogtreecommitdiff
path: root/core
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
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') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/documentlist.cpp72
-rw-r--r--core/launcher/firstuse.cpp62
-rw-r--r--core/launcher/launcher.cpp60
-rw-r--r--core/launcher/launcherview.cpp53
-rw-r--r--core/launcher/startmenu.cpp79
-rw-r--r--core/launcher/syncdialog.cpp59
-rw-r--r--core/launcher/taskbar.cpp52
-rw-r--r--core/launcher/wait.cpp54
8 files changed, 260 insertions, 231 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp
index b8bf4e0..fd385d6 100644
--- a/core/launcher/documentlist.cpp
+++ b/core/launcher/documentlist.cpp
@@ -1,77 +1,85 @@
-/**********************************************************************
-** 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 "documentlist.h"
#include "serverinterface.h"
#include "mediadlg.h"
/* OPIE */
#include <opie2/oglobal.h>
#include <opie2/odebug.h>
+#include <opie2/oresource.h>
#include <qtopia/config.h>
#include <qtopia/mimetype.h>
-#include <qtopia/resource.h>
#include <qtopia/private/categories.h>
#include <qtopia/qpeapplication.h>
#include <qtopia/applnk.h>
#include <qtopia/storage.h>
#ifdef Q_WS_QWS
#include <qtopia/qcopenvelope_qws.h>
#endif
using namespace Opie::Core;
/* QT */
#include <qtimer.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#include <qfile.h>
#include <qdir.h>
#include <qpainter.h>
#include <qimage.h>
#include <qcopchannel_qws.h>
#include <qlistview.h>
#include <qlist.h>
#include <qpixmap.h>
AppLnkSet *DocumentList::appLnkSet = 0;
static const int MAX_SEARCH_DEPTH = 10;
class DocumentListPrivate : public QObject {
Q_OBJECT
public:
DocumentListPrivate( ServerInterface *gui );
~DocumentListPrivate();
void initialize();
const QString nextFile();
const DocLnk *iterate();
bool store( DocLnk* dl );
void estimatedPercentScanned();
void appendDocpath(FileSystem*);
DocLnkSet dls;
QDict<void> reference;
QDictIterator<void> *dit;
enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state;
@@ -187,112 +195,109 @@ void DocumentList::rescan()
void DocumentList::timerEvent( QTimerEvent *te )
{
if ( te->timerId() == d->tid ) {
// Do 3 at a time
if ( d->serverGui )
d->serverGui->aboutToAddBegin();
for (int i = 0; i < 3; i++ ) {
const DocLnk *lnk = d->iterate();
if ( lnk ) {
add( *lnk );
} else {
// stop when done
pause();
if ( d->serverGui )
d->serverGui->documentScanningProgress( 100 );
if ( d->needToSendAllDocLinks )
sendAllDocLinks();
break;
}
}
if ( d->serverGui )
d->serverGui->aboutToAddEnd();
}
}
void DocumentList::reloadAppLnks()
{
if ( d->sendAppLnks && d->serverGui ) {
d->serverGui->applicationScanningProgress( 0 );
d->serverGui->allApplicationsRemoved();
}
delete appLnkSet;
appLnkSet = new AppLnkSet( MimeType::appsFolderName() );
if ( d->sendAppLnks && d->serverGui ) {
static QStringList prevTypeList;
QStringList types = appLnkSet->types();
for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
if ( !(*ittypes).isEmpty() ) {
if ( !prevTypeList.contains(*ittypes) ) {
QString name = appLnkSet->typeName(*ittypes);
QPixmap pm = appLnkSet->typePixmap(*ittypes);
QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes);
- if (pm.isNull()) {
- QImage img( Resource::loadImage( "UnknownDocument" ) );
- pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
- bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
+ if (pm.isNull())
+ {
+ pm = OResource::loadImage( "UnknownDocument", OResource::SmallIcon );
+ bgPm = OResource::loadImage( "UnknownDocument", OResource::BigIcon );
}
- //odebug << "adding type " << (*ittypes) << "" << oendl;
-
- // ### our current launcher expects docs tab to be last
+ //FIXME our current launcher expects docs tab to be last
d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
}
prevTypeList.remove(*ittypes);
}
}
for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
- //odebug << "removing type " << (*ittypes) << "" << oendl;
d->serverGui->typeRemoved(*ittypes);
}
prevTypeList = types;
}
QListIterator<AppLnk> itapp( appLnkSet->children() );
AppLnk* l;
while ( (l=itapp.current()) ) {
++itapp;
if ( d->sendAppLnks && d->serverGui )
d->serverGui->applicationAdded( l->type(), *l );
}
if ( d->sendAppLnks && d->serverGui )
d->serverGui->applicationScanningProgress( 100 );
}
void DocumentList::reloadDocLnks()
{
if ( !d->scanDocs )
return;
if ( d->sendDocLnks && d->serverGui ) {
d->serverGui->documentScanningProgress( 0 );
d->serverGui->allDocumentsRemoved();
}
rescan();
}
void DocumentList::reforceDocuments()
{
Config cfg( "Launcher" );
cfg.setGroup( "DocTab" );
d->scanDocs = cfg.readBoolEntry( "Enable", true );
reloadDocLnks();
}
void DocumentList::linkChanged( QString arg )
{
odebug << "linkchanged( " << arg << " )" << oendl;
if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) {
reloadAppLnks();
} else {
const QList<DocLnk> &list = d->dls.children();
QListIterator<DocLnk> it( list );
@@ -312,112 +317,109 @@ void DocumentList::linkChanged( QString arg )
d->serverGui->documentChanged( *doc, *dl );
} else {
// Link has been removed or doesn't match the mimetypes any more
// so we aren't interested in it, so take it away from the list
//odebug << "removal case" << oendl;
if ( d->serverGui )
d->serverGui->documentRemoved( *doc );
}
d->dls.remove( doc ); // remove old link from docLnkSet
delete doc;
return;
}
}
// Didn't find existing link, must be new
DocLnk* dl = new DocLnk( arg );
if ( d->store( dl ) ) {
// Add if it's a link we are interested in
//odebug << "add case" << oendl;
add( *dl );
}
}
}
void DocumentList::restoreDone()
{
reloadAppLnks();
reloadDocLnks();
}
void DocumentList::DiffAppLnks()
{
static AppLnkSet *appLnkSet2;
appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() );
if ( d->sendAppLnks && d->serverGui ) {
static QStringList prevTypeList = appLnkSet->types();
QStringList types = appLnkSet2->types();
for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
if ( !(*ittypes).isEmpty() ) {
if ( !prevTypeList.contains(*ittypes) ) {
QString name = appLnkSet2->typeName(*ittypes);
QPixmap pm = appLnkSet2->typePixmap(*ittypes);
QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes);
- if (pm.isNull()) {
- QImage img( Resource::loadImage( "UnknownDocument" ) );
- pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
- bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
+ if (pm.isNull())
+ {
+ pm = OResource::loadImage( "UnknownDocument", OResource::SmallIcon );
+ bgPm = OResource::loadImage( "UnknownDocument", OResource::BigIcon );
}
- odebug << "adding type " << (*ittypes) << "" << oendl;
-
// ### our current launcher expects docs tab to be last
d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
}
prevTypeList.remove(*ittypes);
}
}
for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
- odebug << "removing type " << (*ittypes) << "" << oendl;
d->serverGui->typeRemoved(*ittypes);
}
prevTypeList = types;
}
QListIterator<AppLnk> it1( appLnkSet->children() );
QListIterator<AppLnk> it2( appLnkSet2->children() );
AppLnk *i;
AppLnk *j;
bool found;
while ( (j=it2.current()) ) {
it1 = appLnkSet->children();
found = false;
while ( (i=it1.current()) ){
if (j->name().ascii() && i->name().ascii() && strcmp(i->name().ascii(),j->name().ascii()) == 0)
found = true;
++it1;
}
if (!found) {
odebug << "Item " << j->name().ascii() << " needs to be added" << oendl;
d->serverGui->applicationAdded( j->type(), *j );
}
++it2;
}
it1 = appLnkSet->children();
while ( (i=it1.current()) ) {
it2 = appLnkSet2->children();
found = false;
while ( (j=it2.current()) ){
if (j->name().ascii() && i->name().ascii() && strcmp(i->name().ascii(),j->name().ascii()) == 0)
found = true;
++it2;
}
if (!found) {
odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl;
d->serverGui->applicationRemoved( i->type(), *i );
}
++it1;
}
delete appLnkSet;
appLnkSet = appLnkSet2;
diff --git a/core/launcher/firstuse.cpp b/core/launcher/firstuse.cpp
index 8344787..8c02ab0 100644
--- a/core/launcher/firstuse.cpp
+++ b/core/launcher/firstuse.cpp
@@ -1,85 +1,92 @@
-/**********************************************************************
-** 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.
+*/
// I need access to some things you don't normally get access to.
-
#ifndef _MSC_VER
//### revise to allow removal of translators under MSVC
#define private public
#define protected public
#endif
#include "firstuse.h"
#include "inputmethods.h"
#include "applauncher.h"
#include "serverapp.h"
#include "calibrate.h"
#include "documentlist.h"
/* OPIE */
#include <opie2/odebug.h>
-#include <qtopia/resource.h>
+#include <opie2/oresource.h>
#include <qtopia/qcopenvelope_qws.h>
#include <qtopia/config.h>
#include <qtopia/fontmanager.h>
using namespace Opie::Core;
/* QT */
#include <qfile.h>
#include <qpainter.h>
#include <qsimplerichtext.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qtimer.h>
#if defined( Q_WS_QWS )
#include <qwsdisplay_qws.h>
#include <qgfx_qws.h>
#endif
/* STD */
#include <stdlib.h>
#include <sys/types.h>
#if defined(Q_OS_LINUX) || defined(_OS_LINUX_)
#include <unistd.h>
#endif
struct settingsTable_t {
bool enabled : 1;
const char *app;
const char *start;
const char *stop;
const char *desc;
};
static settingsTable_t settingsTable [] =
{
{ FALSE, "language", "raise()", "accept()", // No tr
QT_TR_NOOP("Language") },
{ FALSE, "doctab", "raise()", "accept()", // No tr
QT_TR_NOOP("DocTab") },
#ifndef Q_OS_WIN32
{ FALSE, "systemtime", "raise()", "accept()", // No tr
QT_TR_NOOP("Time and Date") },
#endif
{ FALSE, "addressbook", "editPersonalAndClose()", "accept()", // No tr
QT_TR_NOOP("Personal Information") },
{ FALSE, 0, 0, 0, 0 }
};
@@ -196,102 +203,100 @@ FirstUse::~FirstUse()
delete taskBar;
ServerApplication::allowRestart = TRUE;
}
void FirstUse::calcMaxWindowRect()
{
#ifdef Q_WS_QWS
QRect wr;
int displayWidth = qApp->desktop()->width();
QRect ir = inputMethods->inputRect();
if ( ir.isValid() ) {
wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
} else {
wr.setCoords( 0, 0, displayWidth-1,
qApp->desktop()->height() - controlHeight-1);
}
#if QT_VERSION < 0x030000
QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,
QSize(qt_screen->width(),qt_screen->height()))
);
#else
QWSServer::setMaxWindowRect( wr );
#endif
#endif
}
/* cancel current dialog, and bring up next */
void FirstUse::nextDialog()
{
int prevApp = currApp;
do {
currApp++;
odebug << "currApp = " << currApp << "" << oendl;
if ( settingsTable[currApp].app == 0 ) {
if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) {
// The last application is still running.
// Tell it to stop, and when its done we'll come back
// to nextDialog and exit.
odebug << "Waiting for " << settingsTable[prevApp].app << " to exit" << oendl;
QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
settingsTable[prevApp].stop );
currApp = prevApp;
} else {
odebug << "Done!" << oendl;
Config config( "qpe" );
config.setGroup( "Startup" );
config.writeEntry( "FirstUse", FALSE );
- QPixmap pix = Resource::loadPixmap("bigwait");
- QLabel *lblWait = new QLabel(0, "wait hack!", // No tr
+ QLabel *lblWait = new QLabel("Please Wait...", 0, "wait hack!", // No tr
QWidget::WStyle_Customize | QWidget::WDestructiveClose |
QWidget::WStyle_NoBorder | QWidget::WStyle_Tool |
QWidget::WStyle_StaysOnTop);
- lblWait->setPixmap( pix );
lblWait->setAlignment( QWidget::AlignCenter );
lblWait->setGeometry( qApp->desktop()->geometry() );
lblWait->show();
qApp->processEvents();
QTimer::singleShot( 1000, lblWait, SLOT(close()) );
repaint();
close();
ServerApplication::allowRestart = TRUE;
}
return;
}
} while ( !settingsTable[currApp].enabled );
if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) {
odebug << "Shutdown: " << settingsTable[prevApp].app << "" << oendl;
QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
settingsTable[prevApp].stop );
waitForExit = prevApp;
} else {
odebug << "Startup: " << settingsTable[currApp].app << "" << oendl;
QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app,
settingsTable[currApp].start );
waitingForLaunch = TRUE;
}
updateButtons();
}
/* accept current dialog and bring up previous */
void FirstUse::previousDialog()
{
int prevApp = currApp;
do {
currApp--;
if ( currApp < 0 ) {
currApp = prevApp;
return;
}
} while ( !settingsTable[currApp].enabled );
if ( prevApp >= 0 ) {
odebug << "Shutdown: " << settingsTable[prevApp].app << "" << oendl;
QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
settingsTable[prevApp].stop );
/*
if (settingsTable[prevApp].app == QString("systemtime"))
QCopEnvelope e("QPE/Application/citytime", "close()");
*/
@@ -385,118 +390,111 @@ void FirstUse::reloadLanguages()
// clear old translators
#ifndef _MSC_VER
//### revise to allow removal of translators under MSVC
if(qApp->translators) {
qApp->translators->setAutoDelete(TRUE);
delete (qApp->translators);
qApp->translators = 0;
}
#endif
// load translation tables
transApp = new QTranslator(qApp);
QString tfn = QPEApplication::qpeDir() + "i18n/"+l+"/qpe.qm";
owarn << "loading " + tfn << oendl;
if ( transApp->load(tfn) ) {
owarn << "installing translator" << oendl;
qApp->installTranslator( transApp );
} else {
delete transApp;
transApp = 0;
}
transLib = new QTranslator(qApp);
tfn = QPEApplication::qpeDir() + "i18n/"+l+"/libqpe.qm";
owarn << "loading " + tfn << oendl;
if ( transLib->load(tfn) ) {
owarn << "installing translator library" << oendl;
qApp->installTranslator( transLib );
} else {
delete transLib;
transLib = 0;
}
loadPixmaps();
//###language/font hack; should look it up somewhere
#ifdef Q_WS_QWS
if ( l == "ja" || l == "zh_CN" || l == "zh_TW" || l == "ko" ) {
QFont fn = FontManager::unicodeFont( FontManager::Proportional );
qApp->setFont( fn, TRUE );
} else {
qApp->setFont( defaultFont, TRUE );
}
#endif
#endif
}
void FirstUse::paintEvent( QPaintEvent * )
{
QPainter p( this );
-
p.drawPixmap(0,0, splash);
- QFont f = p.font();
- f.setPointSize(15);
- f.setItalic(FALSE);
- f.setBold(FALSE);
- p.setFont(f);
-
if ( currApp < 0 ) {
drawText(p, tr( "Tap anywhere on the screen to continue." ));
} else if ( settingsTable[currApp].app ) {
if ( waitingForLaunch )
drawText(p, tr("Please wait, loading %1 settings.").arg(tr(settingsTable[currApp].desc)) );
} else {
drawText(p, tr("Please wait..."));
}
}
void FirstUse::loadPixmaps()
{
- splash.convertFromImage( Resource::loadImage("launcher/firstuse")
+ splash.convertFromImage( OResource::loadImage("launcher/firstuse", OResource::NoScale )
.smoothScale( width(), height() ) );
setBackgroundPixmap(splash);
}
void FirstUse::drawText(QPainter &p, const QString &text)
{
QString altered = "<CENTER>" + text + "</CENTER>";
QSimpleRichText rt(altered, p.font());
rt.setWidth(width() - 20);
int h = (height() * 3) / 10; // start at 30%
if (rt.height() < height() / 2)
h += ((height() / 2) - rt.height()) / 2;
rt.draw(&p, 10, h, QRegion(0,0, width()-20, height()), palette());
}
void FirstUse::updateButtons()
{
if ( currApp >= 0 ) {
taskBar->show();
}
int i = currApp-1;
while ( i >= 0 && !settingsTable[i].enabled )
i--;
back->setText(tr("<< Back"));
back->setEnabled( i >= 0 && !waitingForLaunch );
i = currApp+1;
while ( settingsTable[i].app && !settingsTable[i].enabled )
i++;
if ( !settingsTable[i].app )
next->setText(tr("Finish"));
else
next->setText(tr("Next >>"));
next->setEnabled( !waitingForLaunch );
}
void FirstUse::keyPressEvent( QKeyEvent *e )
{
// Allow cancelling at first dialog, in case display is broken.
if ( e->key() == Key_Escape && currApp < 0 )
QDialog::keyPressEvent(e);
}
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,174 +1,181 @@
-/**********************************************************************
-** 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();
}
@@ -484,101 +491,98 @@ void LauncherTabWidget::reCheckDoctab(int how)
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;
}
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index d960908..6275fcb 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -1,78 +1,85 @@
-/**********************************************************************
-** 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 "launcherview.h"
/* OPIE */
#include <opie2/odebug.h>
+#include <opie2/oresource.h>
#include <qpe/config.h>
#include <qtopia/qpeapplication.h>
#include <qtopia/private/categories.h>
#include <qtopia/categoryselect.h>
#include <qtopia/mimetype.h>
-#include <qtopia/resource.h>
using namespace Opie::Core;
#include <qpe/qcopenvelope_qws.h>
/* QT */
#include <qtimer.h>
#include <qfileinfo.h>
#include <qiconview.h>
#include <qobjectlist.h>
// These define how the busy icon is animated and highlighted
#define BRIGHTEN_BUSY_ICON
//#define ALPHA_FADE_BUSY_ICON
//#define USE_ANIMATED_BUSY_ICON_OVERLAY
#define BOUNCE_BUSY_ICON
typedef QMap<QString,QPixmap>::Iterator pixiter;
class BgPixmap
{
public:
BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
QPixmap pm;
int ref;
};
static QMap<QString,BgPixmap*> *bgCache = 0;
static void cleanup_cache()
{
QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
while ( it != bgCache->end() ) {
QMap<QString,BgPixmap*>::Iterator curr = it;
++it;
delete (*curr);
bgCache->remove( curr );
}
delete bgCache;
bgCache = 0;
}
class LauncherItem : public QIconViewItem
{
public:
enum iconstate_t {
@@ -381,97 +388,97 @@ void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort)
}
void LauncherIconView::setItemTextPos( ItemTextPos pos )
{
calculateGrid( pos );
QIconView::setItemTextPos( pos );
}
void LauncherIconView::drawBackground( QPainter *p, const QRect &r )
{
if ( bgPixmap.isNull() )
{
p->fillRect( r, bgColor );
}
else
{
if ( staticBackground )
{
p->drawTiledPixmap( r, bgPixmap, QPoint( r.x() % bgPixmap.width(), r.y() % bgPixmap.height() ) );
}
else
{
p->drawTiledPixmap( r, bgPixmap, QPoint( (r.x() + contentsX()) % bgPixmap.width(),
(r.y() + contentsY()) % bgPixmap.height() ) );
}
}
}
void LauncherIconView::addCatsAndMimes(AppLnk* app)
{
// QStringList c = app->categories();
// for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
// cats.replace(*cit,(void*)1);
// }
QString maj=app->type();
int sl=maj.find('/');
if (sl>=0) {
QString k;
k = maj.left(12) == "application/" ? maj : maj.left(sl);
mimes.replace(k,(void*)1);
}
}
void LauncherIconView::setBusy(bool on)
{
#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
if ( busyPix.isNull() ) {
int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
- busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) );
+ busyPix.convertFromImage( OResource::loadImage( "busy", OResource::NoScale ).smoothScale( size * 16, size ) );
}
#endif
if ( on ) {
busyTimer = startTimer( 100 );
} else {
if ( busyTimer ) {
killTimer( busyTimer );
busyTimer = 0;
}
}
LauncherItem *c = on ? (LauncherItem*)currentItem() : 0;
if ( bsy != c ) {
LauncherItem *oldBusy = bsy;
bsy = c;
if ( oldBusy ) {
oldBusy->resetIcon();
}
if ( bsy ) {
bsy->setBusyIndicatorType( busyType ) ;
bsy->animateIcon();
}
}
}
void LauncherIconView::clear()
{
mimes.clear();
cats.clear();
QIconView::clear();
hidden.clear();
}
QStringList LauncherIconView::mimeTypes() const
{
QStringList r;
QDictIterator<void> it(mimes);
while (it.current()) {
r.append(it.currentKey());
++it;
}
r.sort();
return r;
}
LauncherItem*LauncherIconView::findDocItem(const QString&fname)
@@ -956,97 +963,97 @@ QImage LauncherView::loadBackgroundImage(QString &bgName)
return imgio.image();
}
void LauncherView::setBackgroundType( BackgroundType t, const QString &val )
{
if ( !bgCache ) {
bgCache = new QMap<QString,BgPixmap*>;
qAddPostRoutine( cleanup_cache );
}
if ( bgCache->contains( bgName ) )
(*bgCache)[bgName]->ref--;
bgName = "";
QPixmap bg;
switch ( t ) {
case Ruled: {
bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr
if ( bgCache->contains( bgName ) ) {
(*bgCache)[bgName]->ref++;
bg = (*bgCache)[bgName]->pm;
} else {
bg.resize( width(), 9 );
QPainter painter( &bg );
for ( int i = 0; i < 3; i++ ) {
painter.setPen( white );
painter.drawLine( 0, i*3, width()-1, i*3 );
painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
painter.setPen( colorGroup().background().light(105) );
painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
}
painter.end();
bgCache->insert( bgName, new BgPixmap(bg) );
}
break;
}
case Image:
if (!val.isEmpty()) {
bgName = val;
if ( bgCache->contains( bgName ) ) {
(*bgCache)[bgName]->ref++;
bg = (*bgCache)[bgName]->pm;
} else {
QString imgFile = bgName;
bool tile = FALSE;
if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) {
- imgFile = Resource::findPixmap( imgFile );
+ imgFile = OResource::findPixmap( imgFile );
tile = TRUE;
}
QImage img = loadBackgroundImage(imgFile);
if ( img.depth() == 1 )
img = img.convertDepth(8);
img.setAlphaBuffer(FALSE);
bg.convertFromImage(img);
bgCache->insert( bgName, new BgPixmap(bg) );
}
}
break;
case SolidColor:
default:
break;
}
const QObjectList *list = queryList( "QWidget", 0, FALSE );
QObject *obj;
for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) {
if ( obj->isWidgetType() ) {
QWidget *w = (QWidget*)obj;
w->setBackgroundPixmap( bg );
if ( bgName.isEmpty() ) {
// Solid Color
if ( val.isEmpty() )
w->setBackgroundColor( colorGroup().base() );
else
w->setBackgroundColor( val );
} else {
// Ruled or Image pixmap
w->setBackgroundOrigin( ParentOrigin );
}
}
}
delete list;
bgType = t;
icons->viewport()->update();
QTimer::singleShot( 1000, this, SLOT(flushBgCache()) );
}
void LauncherView::setColNumber( int num )
{
icons->setColNumber( num );
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp
index ce7840e..24a9d7e 100644
--- a/core/launcher/startmenu.cpp
+++ b/core/launcher/startmenu.cpp
@@ -1,259 +1,254 @@
-/**********************************************************************
-** 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.
+*/
// TODO. During startup
// Launcher::typeAdded
// is called for each new tab and calls then each time the refresh of startmenu
// suboptimal
#define INCLUDE_MENUITEM_DEF
#include "startmenu.h"
+/* OPIE */
+#include <opie2/oresource.h>
+using namespace Opie::Core;
#include <qtopia/qpeapplication.h>
#include <qtopia/config.h>
-#include <qtopia/resource.h>
#include <qtopia/mimetype.h>
#include <qtopia/qlibrary.h>
-//#include <qpainter.h>
-
-//#include <stdlib.h>
-
-
#define APPLNK_ID_OFFSET 250
#define NO_ID -1
void StartPopupMenu::keyPressEvent( QKeyEvent *e )
{
if ( e->key() == Key_F33 || e->key() == Key_Space ) {
// "OK" button, little hacky
QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0);
QPopupMenu::keyPressEvent( &ke );
} else {
QPopupMenu::keyPressEvent( e );
}
}
//---------------------------------------------------------------------------
StartMenu::StartMenu(QWidget *parent) : QLabel( parent )
{
startButtonPixmap = "go"; // No tr
int sz = AppLnk::smallIconSize()+3;
QPixmap pm;
- pm.convertFromImage(Resource::loadImage( startButtonPixmap).smoothScale( sz,sz) );
+ pm.convertFromImage(OResource::loadImage( startButtonPixmap, OResource::NoScale ).smoothScale( sz,sz) );
setPixmap(pm);
setFocusPolicy( NoFocus );
useWidePopupMenu = true;
launchMenu = 0;
currentItem = 0;
refreshMenu();
}
void StartMenu::mousePressEvent( QMouseEvent * )
{
launch();
}
StartMenu::~StartMenu()
{
clearApplets();
}
void StartMenu::createMenu()
{
clearApplets();
delete launchMenu;
launchMenu = new StartPopupMenu( this );
loadMenu( launchMenu );
loadApplets();
bool result = currentItem || menuApplets.count();
if ( result )
connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) );
}
void StartMenu::refreshMenu()
{
Config cfg( "StartMenu" );
cfg.setGroup( "Menu" );
bool ltabs = cfg.readBoolEntry( "LauncherTabs", TRUE );
bool lot = cfg.readBoolEntry( "LauncherOther", TRUE );
useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE );
if ( launchMenu && !(ltabs || lot) ) return; // nothing to do
createMenu();
}
void StartMenu::itemSelected( int id )
{
if ( id == NO_ID ) return;
if ( id < 0 ) {
MenuApplet *applet = menuApplets.find( id );
if ( applet ) {
applet->iface->activated();
}
} else if ( id >= APPLNK_ID_OFFSET ) {
AppLnk * appLnk = appLnks.find( id );
if ( appLnk ) {
appLnk->execute();
}
} else {
QString *tabName = tabNames.find( id );
if ( tabName ) {
emit tabSelected( *tabName );
}
}
}
void StartMenu::createAppEntry( QPopupMenu *menu, QDir dir, QString file )
{
if ( file.right(8) == ".desktop" ) {
AppLnk* applnk = new AppLnk( dir.path() + "/" + file );
if ( !applnk->isValid() ) {
delete applnk;
return;
}
if ( applnk->type() == "Separator" ) { // No tr
menu->insertSeparator();
delete applnk;
} else {
- QPixmap test;
- QImage img = Resource::loadImage( applnk->icon() );
- if(!img.isNull() )
- test.convertFromImage(
- img.smoothScale(
- AppLnk::smallIconSize(), AppLnk::smallIconSize() ), 0 );
-
+ QPixmap pixmap = OResource::loadPixmap( applnk->icon(), OResource::SmallIcon );
// Insert items ordered lexically
int current, left = 0, right = currentItem;
while( left != right ) {
current = ( left + right ) / 2;
if ( menu->text(menu->idAt( ( current ) ) ) < applnk->name() )
left = ++current;
else
right = current;
}
-
- menu->insertItem( test, applnk->name(),
+
+ menu->insertItem( pixmap, applnk->name(),
currentItem + APPLNK_ID_OFFSET, current );
appLnks.insert( currentItem + APPLNK_ID_OFFSET, applnk );
currentItem++;
}
}
}
void StartMenu::createDirEntry( QPopupMenu *menu, QDir dir, QString file, bool lot )
{
// do some sanity checks and collect information
if ( file == "." || file == ".." ) return;
Config cfg( dir.path() + "/" + file + "/.directory", Config::File );
if ( !cfg.isValid() ) return;
QString name = cfg.readEntry( "Name" );
QString icon = cfg.readEntry( "Icon" );
if ( !name || !icon ) return;
QDir subdir = QDir( dir );
subdir.cd( file );
subdir.setFilter( QDir::Files );
subdir.setNameFilter( "*.desktop" );
// we don' t show the menu if there are no entries
// perhaps one should check if there exist subsubdirs with entries...
if ( subdir.entryList().isEmpty() ) return;
// checks were ok
- QPixmap test;
- test.convertFromImage( Resource::loadImage( icon ).smoothScale(
- AppLnk::smallIconSize(), AppLnk::smallIconSize() ), 0 );
-
+ QPixmap pixmap = OResource::loadPixmap( icon, OResource::SmallIcon );
if ( useWidePopupMenu ) {
// generate submenu
QPopupMenu *submenu = new QPopupMenu( menu );
connect( submenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) );
- menu->insertItem( test, name, submenu, NO_ID );
+ menu->insertItem( pixmap, name, submenu, NO_ID );
// ltabs is true cause else we wouldn't stuck around..
createMenuEntries( submenu, subdir, true, lot );
} else {
// no submenus - just bring corresponding tab to front
- menu->insertItem( test, name, currentItem );
+ menu->insertItem( pixmap, name, currentItem );
tabNames.insert( currentItem, new QString( file ) );
currentItem++;
}
}
void StartMenu::createMenuEntries( QPopupMenu *menu, QDir dir, bool ltabs, bool lot )
{
if ( lot ) {
dir.setFilter( QDir::Files );
dir.setNameFilter( "*.desktop" );
QStringList files = dir.entryList();
files.sort();
for ( QStringList::Iterator it = files.begin(); it != files.end(); it++ ) {
createAppEntry( menu, dir, *it );
}
}
if ( ltabs ) {
dir.setNameFilter( "*" );
dir.setFilter( QDir::Dirs );
QStringList dirs = dir.entryList();
dirs.sort();
for ( QStringList::Iterator it = dirs.begin(); it != dirs.end(); it++ ) {
createDirEntry( menu, dir, *it, lot );
}
}
}
bool StartMenu::loadMenu( QPopupMenu *menu )
{
Config cfg("StartMenu");
cfg.setGroup("Menu");
bool ltabs = cfg.readBoolEntry("LauncherTabs", TRUE);
bool lot = cfg.readBoolEntry("LauncherOther", TRUE);
useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE );
bool sepfirst = !ltabs && !lot;
currentItem = 0;
launchMenu->clear();
appLnks.setAutoDelete( true );
tabNames.setAutoDelete( true );
appLnks.clear();
tabNames.clear();
appLnks.setAutoDelete( false );
tabNames.setAutoDelete( false );
diff --git a/core/launcher/syncdialog.cpp b/core/launcher/syncdialog.cpp
index 4a2b8ff..d90b2ea 100644
--- a/core/launcher/syncdialog.cpp
+++ b/core/launcher/syncdialog.cpp
@@ -1,169 +1,178 @@
-/**********************************************************************
-** 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 "syncdialog.h"
-#include <qtopia/resource.h>
+/* OPIE */
+#include <opie2/oresource.h>
+using namespace Opie::Core;
+/* QT */
#include <qpainter.h>
#include <qapplication.h>
#include <qpushbutton.h>
#include <qfile.h>
-
SyncDialog::SyncDialog( QWidget *parent, const QString &w )
: QDialog( parent, "SyncDialog", FALSE, WStyle_Tool | WStyle_Customize |
WStyle_StaysOnTop ), what(w), nextPt(0), rev(FALSE), hideDot(TRUE)
{
QFont f( font() );
f.setPointSize( 16 );
setFont(f);
loadPath();
QSize ds = qApp->desktop()->size();
setGeometry( 0, 0, ds.width(), ds.height() );
- img = Resource::loadImage( "SyncScreen" );
+ img = OResource::loadImage( "SyncScreen", OResource::NoScale );
if ( img.width() > ds.width() || img.height() > ds.height() ) {
path = scalePath( path, ds.width(), img.width(), ds.height(), img.height() );
img = img.smoothScale( ds.width(), ds.height() );
}
- dot = Resource::loadImage( "syncdot" );
+ dot = OResource::loadImage( "syncdot", OResource::NoScale );
setBackgroundColor( white );
QPushButton *pb = new QPushButton( tr("Abort"), this, "CancelSync" );
QSize bs = pb->sizeHint();
bs.rwidth() += 10;
bs.rheight() += 5;
pb->setGeometry( (ds.width()-bs.width())/2, 4*ds.height()/5,
bs.width(), bs.height() );
connect( pb, SIGNAL(clicked()), this, SIGNAL(cancel()) );
if ( path.count() >= 2 ) {
path = generatePath( path, 8 );
startTimer( 200 );
}
}
void SyncDialog::paintEvent( QPaintEvent *pe )
{
QPainter p(this );
p.setClipRect( pe->rect() );
int ox = (width() - img.width())/2;
int oy = (height() - img.height())/2;
QRect ir = QRect(ox, oy, img.width(), img.height()) & pe->rect();
if ( ir.isValid() )
p.drawImage( ir.x(), ir.y(), img, ir.x()-ox, ir.y()-oy, ir.width(), ir.height() );
QString syncMsg = tr("Syncing:");
p.setPen( black );
QRect r( 0, 0, width()/2-5, QMAX(oy,80) );
p.drawText( r, AlignRight | AlignVCenter, syncMsg );
r.moveBy( width()/2, 0 );
QFont f( font() );
f.setWeight( QFont::Bold );
p.setFont( f );
p.drawText( r, AlignLeft | AlignVCenter, what );
if ( !hideDot )
p.drawImage( ox+path[nextPt].x()-dot.width()/2, oy+path[nextPt].y()-dot.height()/2, dot );
}
void SyncDialog::timerEvent( QTimerEvent * )
{
int ox = (width() - img.width())/2;
int oy = (height() - img.height())/2;
int oldPt = nextPt;
if ( !rev ) {
nextPt++;
if ( nextPt == (int)path.count() ) {
nextPt -= 2;
rev = TRUE;
}
} else {
nextPt--;
if ( nextPt < 0 ) {
nextPt = 1;
rev = FALSE;
}
}
hideDot = FALSE;
repaint( ox+path[nextPt].x()-dot.width()/2, oy+path[nextPt].y()-dot.height()/2,
dot.width(), dot.height() );
hideDot = TRUE;
repaint( ox+path[oldPt].x()-dot.width()/2, oy+path[oldPt].y()-dot.height()/2,
dot.width(), dot.height() );
}
void SyncDialog::loadPath()
{
- QString pfile = Resource::findPixmap( "syncdot" );
+ QString pfile = OResource::findPixmap( "syncdot" );
if ( pfile.isEmpty() )
return;
int dp = pfile.findRev('.');
pfile.replace( dp, pfile.length()-dp, ".path" );
int count = 0;
QFile file( pfile );
if ( file.open( IO_ReadOnly ) ) {
QString line;
while ( file.readLine( line, 256 ) > 0 ) {
int x, y;
if ( sscanf( line.latin1(), "%d %d", &x, &y ) == 2 ) {
path.resize( count+1 );
path[count++] = QPoint(x, y);
}
}
}
}
QPointArray SyncDialog::scalePath( const QPointArray &pa, int xn, int xd, int yn, int yd )
{
QPointArray sa( pa.size() );
for ( unsigned i = 0; i < pa.count(); i++ ) {
int x = xn * pa[int(i)].x() / xd;
int y = yn * pa[int(i)].y() / yd;
sa[int(i)] = QPoint( x, y );
}
return sa;
}
QPointArray SyncDialog::generatePath( const QPointArray &pa, int dist )
{
if ( pa.count() < 2 )
return pa;
QPointArray fa;
int count = 0;
fa.resize( count+1 );
fa[count++] = pa[0];
for ( unsigned i = 0; i < pa.count()-1; i++ ) {
int x1 = pa[int(i)].x();
int y1 = pa[int(i)].y();
int x2 = pa[int(i+1)].x();
int y2 = pa[int(i+1)].y();
int dx = x2 - x1;
int dy = y2 - y1;
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index 7cbfe13..1356c77 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -1,80 +1,88 @@
-/**********************************************************************
-** 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 "inputmethods.h"
#include "runningappbar.h"
#include "systray.h"
#include "wait.h"
#include "appicons.h"
#include "taskbar.h"
#include "server.h"
/* OPIE */
#include <opie2/odebug.h>
+#include <opie2/oresource.h>
#include <qtopia/config.h>
#include <qtopia/qpeapplication.h>
#ifdef QWS
#include <qtopia/qcopenvelope_qws.h>
#endif
#include <qtopia/global.h>
using namespace Opie::Core;
/* QT */
#include <qlabel.h>
#include <qlayout.h>
#include <qtimer.h>
#ifdef QWS
#include <qwindowsystem_qws.h>
#endif
#include <qwidgetstack.h>
#if defined( Q_WS_QWS )
#include <qwsdisplay_qws.h>
#include <qgfx_qws.h>
#endif
static bool initNumLock()
{
#ifdef QPE_INITIAL_NUMLOCK_STATE
QPE_INITIAL_NUMLOCK_STATE
#endif
return FALSE;
}
//---------------------------------------------------------------------------
class SafeMode : public QWidget
{
Q_OBJECT
public:
SafeMode( QWidget *parent ) : QWidget( parent ), menu(0)
{
message = tr("Safe Mode");
QFont f( font() );
f.setWeight( QFont::Bold );
setFont( f );
}
void mousePressEvent( QMouseEvent *);
QSize sizeHint() const;
void paintEvent( QPaintEvent* );
@@ -93,98 +101,98 @@ void SafeMode::mousePressEvent( QMouseEvent *)
menu = new QPopupMenu(this);
menu->insertItem( tr("Plugin Manager..."), 0 );
menu->insertItem( tr("Restart Qtopia"), 1 );
menu->insertItem( tr("Help..."), 2 );
connect(menu, SIGNAL(activated(int)), this, SLOT(action(int)));
}
QPoint curPos = mapToGlobal( QPoint(0,0) );
QSize sh = menu->sizeHint();
menu->popup( curPos-QPoint((sh.width()-width())/2,sh.height()) );
}
void SafeMode::action(int i)
{
switch (i) {
case 0:
Global::execute( "pluginmanager" );
break;
case 1:
Global::restart();
break;
case 2:
Global::execute( "helpbrowser", "safemode.html" );
break;
}
}
QSize SafeMode::sizeHint() const
{
QFontMetrics fm = fontMetrics();
return QSize( fm.width(message), fm.height() );
}
void SafeMode::paintEvent( QPaintEvent* )
{
QPainter p(this);
p.drawText( rect(), AlignCenter, message );
}
//---------------------------------------------------------------------------
class LockKeyState : public QWidget
{
public:
LockKeyState( QWidget *parent ) :
QWidget(parent),
nl(initNumLock()), cl(FALSE)
{
- nl_pm = Resource::loadPixmap("numlock");
- cl_pm = Resource::loadPixmap("capslock");
+ nl_pm = OResource::loadPixmap("numlock", OResource::NoScale);
+ cl_pm = OResource::loadPixmap("capslock", OResource::NoScale);
}
QSize sizeHint() const
{
return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1);
}
void toggleNumLockState()
{
nl = !nl; repaint();
}
void toggleCapsLockState()
{
cl = !cl; repaint();
}
void paintEvent( QPaintEvent * )
{
int y = (height()-sizeHint().height())/2;
QPainter p(this);
if ( nl )
p.drawPixmap(1,y,nl_pm);
if ( cl )
p.drawPixmap(1,y+nl_pm.height()+1,cl_pm);
}
private:
QPixmap nl_pm, cl_pm;
bool nl, cl;
};
//---------------------------------------------------------------------------
TaskBar::~TaskBar()
{
}
TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader)
{
/* Read InputMethod Config */
readConfig();
sm = new StartMenu( this );
connect( sm, SIGNAL(tabSelected(const QString&)), this,
SIGNAL(tabSelected(const QString&)) );
inputMethods = new InputMethods( this );
connect( inputMethods, SIGNAL(inputToggled(bool)),
this, SLOT(calcMaxWindowRect()) );
stack = new QWidgetStack( this );
diff --git a/core/launcher/wait.cpp b/core/launcher/wait.cpp
index 523819d..f872218 100644
--- a/core/launcher/wait.cpp
+++ b/core/launcher/wait.cpp
@@ -1,81 +1,87 @@
-/**********************************************************************
-** 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 "wait.h"
#include <opie2/owait.h>
+#include <opie2/oresource.h>
+using namespace Opie::Core;
#include <qtopia/config.h>
#include <qtopia/applnk.h>
Wait *lastWaitObject = NULL;
using namespace Opie::Ui;
Wait::Wait( QWidget *parent ) : QWidget( parent ),
waiting( FALSE )
{
QSize size( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
setFixedSize( size );
-
- QImage img = Resource::loadImage( "wait" );
- img = img.smoothScale( size.width(), size.height() );
- pm.convertFromImage( img );
+ pm = OResource::loadPixmap( "wait", OResource::SmallIcon );
lastWaitObject = this;
m_centralWait = new OWait( 0l );
m_centralWait->hide();
hide();
}
Wait *Wait::getWaitObject()
{
return lastWaitObject;
}
void Wait::setWaiting( bool w )
{
Config cfg ( "Launcher" );
cfg.setGroup("GUI");
waiting = w;
if ( w ) {
if ( cfg. readBoolEntry( "BigBusy" ) )
m_centralWait->show();
else
show();
}else{
m_centralWait->hide();
hide();
}
}
void Wait::paintEvent( QPaintEvent * )
{
QPainter p( this );
p.drawPixmap( 0, 0, pm );
}