summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp2
-rw-r--r--core/launcher/main.cpp2
-rw-r--r--core/launcher/taskbar.cpp7
-rw-r--r--core/launcher/taskbar.h2
4 files changed, 5 insertions, 8 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 974de0c..aa51898 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,234 +1,234 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of 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.
**
**********************************************************************/
#include "desktop.h"
#include "info.h"
#include "launcher.h"
#include "mrulist.h"
#include "qcopbridge.h"
#include "shutdownimpl.h"
#include "startmenu.h"
#include "taskbar.h"
#include "transferserver.h"
#include "irserver.h"
#include "packageslave.h"
#include <qpe/applnk.h>
#include <qpe/mimetype.h>
#include <qpe/password.h>
#include <qpe/config.h>
#include <qpe/power.h>
#include <qpe/timeconversion.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/global.h>
-#ifdef QT_QWS_CUSTOM
+#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
#include <qpe/custom.h>
#endif
#include <qgfx_qws.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qtimer.h>
#include <qwindowsystem_qws.h>
#include <qvaluelist.h>
#include <stdlib.h>
#include <unistd.h>
class QCopKeyRegister
{
public:
QCopKeyRegister() : keyCode(0) { }
QCopKeyRegister(int k, const QString &c, const QString &m)
: keyCode(k), channel(c), message(m) { }
int getKeyCode() const { return keyCode; }
QString getChannel() const { return channel; }
QString getMessage() const { return message; }
private:
int keyCode;
QString channel, message;
};
typedef QValueList<QCopKeyRegister> KeyRegisterList;
KeyRegisterList keyRegisterList;
static Desktop* qpedesktop = 0;
static int loggedin=0;
static void login(bool at_poweron)
{
if ( !loggedin ) {
Global::terminateBuiltin("calibrate");
Password::authenticate(at_poweron);
loggedin=1;
QCopEnvelope e( "QPE/Desktop", "unlocked()" );
}
}
bool Desktop::screenLocked()
{
return loggedin == 0;
}
/*
Priority is number of alerts that are needed to pop up
alert.
*/
class DesktopPowerAlerter : public QMessageBox
{
public:
DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
: QMessageBox( tr("Battery Status"), "Low Battery",
QMessageBox::Critical,
QMessageBox::Ok | QMessageBox::Default,
QMessageBox::NoButton, QMessageBox::NoButton,
parent, name, FALSE )
{
currentPriority = INT_MAX;
alertCount = 0;
}
void alert( const QString &text, int priority );
void hideEvent( QHideEvent * );
private:
int currentPriority;
int alertCount;
};
void DesktopPowerAlerter::alert( const QString &text, int priority )
{
alertCount++;
if ( alertCount < priority )
return;
if ( priority > currentPriority )
return;
currentPriority = priority;
setText( text );
show();
}
void DesktopPowerAlerter::hideEvent( QHideEvent *e )
{
QMessageBox::hideEvent( e );
alertCount = 0;
currentPriority = INT_MAX;
}
DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
: QPEApplication( argc, argv, appType )
{
QTimer *t = new QTimer( this );
connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
t->start( 10000 );
ps = new PowerStatus;
pa = new DesktopPowerAlerter( 0 );
channel = new QCopChannel( "QPE/Desktop", this );
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT(receive(const QCString&, const QByteArray&)) );
}
DesktopApplication::~DesktopApplication()
{
delete ps;
delete pa;
}
void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
{
QDataStream stream( data, IO_ReadOnly );
if (msg == "keyRegister(int key, QString channel, QString message)")
{
int k;
QString c, m;
stream >> k;
stream >> c;
stream >> m;
qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m );
keyRegisterList.append(QCopKeyRegister(k,c,m));
}
else if (msg == "suspend()"){
emit power();
}
}
enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
#ifdef Q_WS_QWS
bool DesktopApplication::qwsEventFilter( QWSEvent *e )
{
qpedesktop->checkMemory();
if ( e->type == QWSEvent::Key ) {
QWSKeyEvent *ke = (QWSKeyEvent *)e;
if ( !loggedin && ke->simpleData.keycode != Key_F34 )
return TRUE;
bool press = ke->simpleData.is_press;
bool autoRepeat= ke->simpleData.is_auto_repeat;
if (!keyRegisterList.isEmpty())
{
KeyRegisterList::Iterator it;
for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it )
{
if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat) {
if(press) qDebug("press"); else qDebug("release");
QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
}
}
}
if ( !keyboardGrabbed() ) {
if ( ke->simpleData.keycode == Key_F9 ) {
if ( press ) emit datebook();
return TRUE;
}
if ( ke->simpleData.keycode == Key_F10 ) {
if ( !press && cardSendTimer ) {
emit contacts();
delete cardSendTimer;
} else if ( press ) {
cardSendTimer = new QTimer();
cardSendTimer->start( 2000, TRUE );
connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
}
return TRUE;
}
/* menu key now opens application menu/toolbar
if ( ke->simpleData.keycode == Key_F11 ) {
if ( press ) emit menu();
return TRUE;
}
*/
if ( ke->simpleData.keycode == Key_F12 ) {
while( activePopupWidget() )
activePopupWidget()->close();
if ( press ) emit launch();
return TRUE;
}
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index 12c2a7c..fc6d829 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -1,220 +1,220 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of 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.
**
**********************************************************************/
#include "desktop.h"
#include "taskbar.h"
#include "stabmon.h"
#include <qpe/qpeapplication.h>
#include <qpe/network.h>
#include <qpe/config.h>
-#ifdef QT_QWS_CUSTOM
+#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
#include <qpe/custom.h>
#endif
#include <qfile.h>
#include <qwindowsystem_qws.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/alarmserver.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
#include "../calibrate/calibrate.h"
#endif
#ifdef QT_QWS_LOGIN
#include "../login/qdmdialogimpl.h"
#endif
#ifdef QT_QWS_CASSIOPEIA
static void ignoreMessage( QtMsgType, const char * )
{
}
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <qdatetime.h>
void initCassiopeia()
{
// MIPSEL-specific init - make sure /proc exists for shm
/*
if ( mount("/dev/ram0", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, 0 ) ) {
perror("Remounting - / read/write");
}
*/
if ( mount("none", "/tmp", "ramfs", 0, 0 ) ) {
perror("mounting ramfs /tmp");
} else {
fprintf( stderr, "mounted /tmp\n" );
}
if ( mount("none", "/home", "ramfs", 0, 0 ) ) {
perror("mounting ramfs /home");
} else {
fprintf( stderr, "mounted /home\n" );
}
if ( mount("none","/proc","proc",0,0) ) {
perror("Mounting - /proc");
} else {
fprintf( stderr, "mounted /proc\n" );
}
if ( mount("none","/mnt","shm",0,0) ) {
perror("Mounting - shm");
}
setenv( "QTDIR", "/", 1 );
setenv( "OPIEDIR", "/", 1 );
setenv( "HOME", "/home", 1 );
mkdir( "/home/Documents", 0755 );
// set a reasonable starting date
QDateTime dt( QDate( 2001, 3, 15 ) );
QDateTime now = QDateTime::currentDateTime();
int change = now.secsTo( dt );
time_t t = ::time(0);
t += change;
stime(&t);
qInstallMsgHandler(ignoreMessage);
}
#endif
#ifdef QPE_OWNAPM
#include <sys/ioctl.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <linux/ioctl.h>
#include <qpe/global.h>
static void disableAPM()
{
int fd, cur_val, ret;
char *device = "/dev/apm_bios";
fd = open (device, O_WRONLY);
if (fd == -1) {
perror(device);
return;
}
cur_val = ioctl(fd, APM_IOCGEVTSRC, 0);
if (cur_val == -1) {
perror("ioctl");
exit(errno);
}
ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON);
if (ret == -1) {
perror("ioctl");
return;
}
close(fd);
}
static void initAPM()
{
// So that we have to do it ourself, but better.
disableAPM();
}
#endif
#ifdef QT_DEMO_SINGLE_FLOPPY
#include <sys/mount.h>
void initFloppy()
{
mount("none","/proc","proc",0,0);
setenv( "QTDIR", "/", 0 );
setenv( "HOME", "/root", 0 );
setenv( "QWS_SIZE", "240x320", 0 );
}
#endif
void initEnvironment()
{
Config config("locale");
config.setGroup( "Location" );
QString tz = config.readEntry( "Timezone", getenv("TZ") );
// if not timezone set, pick New York
if (tz.isNull())
tz = "America/New_York";
setenv( "TZ", tz, 1 );
config.writeEntry( "Timezone", tz);
config.setGroup( "Language" );
QString lang = config.readEntry( "Language", getenv("LANG") );
if ( !lang.isNull() )
setenv( "LANG", lang, 1 );
}
static void initBacklight()
{
QCopEnvelope e("QPE/System", "setBacklight(int)" );
e << -3; // Forced on
}
int initApplication( int argc, char ** argv )
{
#ifdef QT_QWS_CASSIOPEIA
initCassiopeia();
#endif
#ifdef QPE_OWNAPM
initAPM();
#endif
#ifdef QT_DEMO_SINGLE_FLOPPY
initFloppy();
#endif
initEnvironment();
#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX)
setenv( "QWS_SIZE", "240x320", 0 );
#endif
//Don't flicker at startup:
QWSServer::setDesktopBackground( QImage() );
DesktopApplication a( argc, argv, QApplication::GuiServer );
initBacklight();
AlarmServer::initialize();
#if defined(QT_QWS_LOGIN)
for( int i=0; i<a.argc(); i++ )
if( strcmp( a.argv()[i], "-login" ) == 0 ) {
QDMDialogImpl::login( );
return 0;
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index bff2a1c..5e95c99 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -1,233 +1,230 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of 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.
**
*********************************************************************/
#include "startmenu.h"
#include "inputmethods.h"
#include "mrulist.h"
#include "systray.h"
#include "calibrate.h"
#include "wait.h"
#include "appicons.h"
#include "taskbar.h"
#include "desktop.h"
#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/global.h>
-#ifdef QT_QWS_CUSTOM
+
+#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
#include <qpe/custom.h>
#endif
-#if defined(QT_QWS_IPAQ)
-#include "qpe/custom-ipaq.h"
-#endif
-
#include <qlabel.h>
#include <qlayout.h>
#include <qtimer.h>
#include <qwindowsystem_qws.h>
#include <qwidgetstack.h>
#if defined( Q_WS_QWS )
#include <qwsdisplay_qws.h>
#include <qgfx_qws.h>
#endif
#define FACTORY(T) \
static QWidget *new##T( bool maximized ) { \
QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \
if ( maximized ) { \
if ( qApp->desktop()->width() <= 350 ) { \
w->showMaximized(); \
} else { \
w->resize( QSize( 300, 300 ) ); \
} \
} \
w->show(); \
return w; \
}
#ifdef SINGLE_APP
#define APP(a,b,c,d) FACTORY(b)
#include "../launcher/apps.h"
#undef APP
#endif // SINGLE_APP
static Global::Command builtins[] = {
#ifdef SINGLE_APP
#define APP(a,b,c,d) { a, new##b, c },
#include "../launcher/apps.h"
#undef APP
#endif
#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_EBX)
{ "calibrate", TaskBar::calibrate, 1, 0 },
#endif
#if !defined(QT_QWS_CASSIOPEIA)
{ "shutdown", Global::shutdown, 1, 0 },
// { "run", run, 1, 0 },
#endif
{ 0, TaskBar::calibrate, 0, 0 },
};
static bool initNumLock()
{
#ifdef QPE_INITIAL_NUMLOCK_STATE
QPE_INITIAL_NUMLOCK_STATE
#endif
return FALSE;
}
class LockKeyState : public QWidget
{
public:
LockKeyState( QWidget *parent ) :
QWidget(parent),
nl(initNumLock()), cl(FALSE)
{
nl_pm = Resource::loadPixmap("numlock");
cl_pm = Resource::loadPixmap("capslock");
}
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)
{
Global::setBuiltinCommands(builtins);
sm = new StartMenu( this );
inputMethods = new InputMethods( this );
connect( inputMethods, SIGNAL(inputToggled(bool)),
this, SLOT(calcMaxWindowRect()) );
//new QuickLauncher( this );
stack = new QWidgetStack( this );
stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
label = new QLabel(stack);
mru = new MRUList( stack );
stack->raiseWidget( mru );
waitIcon = new Wait( this );
(void) new AppIcons( this );
sysTray = new SysTray( this );
// ## make customizable in some way?
#ifdef QT_QWS_CUSTOM
lockState = new LockKeyState( this );
#else
lockState = 0;
#endif
#if defined(Q_WS_QWS)
#if !defined(QT_NO_COP)
QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this );
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT(receive(const QCString&, const QByteArray&)) );
#endif
#endif
waitTimer = new QTimer( this );
connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) );
clearer = new QTimer( this );
QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar()));
QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show()));
}
void TaskBar::setStatusMessage( const QString &text )
{
label->setText( text );
stack->raiseWidget( label );
if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) )
sysTray->hide();
clearer->start( 3000 );
}
void TaskBar::clearStatusBar()
{
label->clear();
stack->raiseWidget( mru );
}
void TaskBar::startWait()
{
waitIcon->setWaiting( true );
// a catchall stop after 10 seconds...
waitTimer->start( 10 * 1000, true );
}
void TaskBar::stopWait(const QString& app)
{
waitTimer->stop();
mru->addTask(sm->execToLink(app));
waitIcon->setWaiting( false );
}
void TaskBar::stopWait()
{
waitTimer->stop();
waitIcon->setWaiting( false );
}
void TaskBar::resizeEvent( QResizeEvent *e )
{
QHBox::resizeEvent( e );
calcMaxWindowRect();
}
void TaskBar::styleChange( QStyle &s )
{
QHBox::styleChange( s );
calcMaxWindowRect();
}
diff --git a/core/launcher/taskbar.h b/core/launcher/taskbar.h
index cdeb3c7..78c4722 100644
--- a/core/launcher/taskbar.h
+++ b/core/launcher/taskbar.h
@@ -1,86 +1,86 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of 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.
**
**********************************************************************/
#ifndef __TASKBAR_H__
#define __TASKBAR_H__
-#ifdef QT_QWS_CUSTOM
+#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
#include <qpe/custom.h>
#endif
#include <qhbox.h>
class QLabel;
class QTimer;
class InputMethods;
class Wait;
class SysTray;
class MRUList;
class QWidgetStack;
class QTimer;
class QLabel;
class StartMenu;
class LockKeyState;
class TaskBar : public QHBox {
Q_OBJECT
public:
TaskBar();
~TaskBar();
static QWidget *calibrate( bool );
bool recoverMemory();
StartMenu *startMenu() const { return sm; }
public slots:
void startWait();
void stopWait(const QString&);
void stopWait();
void clearStatusBar();
void toggleNumLockState();
void toggleCapsLockState();
void toggleSymbolInput();
protected:
void resizeEvent( QResizeEvent * );
void styleChange( QStyle & );
void setStatusMessage( const QString &text );
private slots:
void calcMaxWindowRect();
void receive( const QCString &msg, const QByteArray &data );
private:
QTimer *waitTimer;
Wait *waitIcon;
InputMethods *inputMethods;
SysTray *sysTray;
MRUList *mru;
QWidgetStack *stack;
QTimer *clearer;
QLabel *label;
LockKeyState* lockState;
StartMenu *sm;
};
#endif // __TASKBAR_H__