summaryrefslogtreecommitdiff
path: root/library
Side-by-side diff
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/opie-base.control2
-rw-r--r--library/qpeapplication.cpp181
-rw-r--r--library/qpeapplication.h6
3 files changed, 112 insertions, 77 deletions
diff --git a/library/opie-base.control b/library/opie-base.control
index f883268..e610b8b 100644
--- a/library/opie-base.control
+++ b/library/opie-base.control
@@ -1,10 +1,10 @@
Files: etc/qimpen etc/colors etc/init.d/qpe etc/rc2.d/S98qpe bin/qpe-reorgfiles $QTDIR/lib/libqpe.so.$VERSION_MAJ.$VERSION_MIN.$VERSION_PAT $QTDIR/lib/libqpe.so.$VERSION_MAJ.$VERSION_MIN $QTDIR/lib/libqpe.so.$VERSION_MAJ apps/__7separator.desktop apps/__9quit.desktop apps/*/.directory etc/mime.types apps/Settings/quit.desktop pics/UnknownDocument-14.png pics/UnknownDocument.png
Priority: required
Section: opie/system
Maintainer: Warwick Allison <warwick@trolltech.com>
Architecture: arm
-Version: $QPE_VERSION-$SUB_VERSION
+Version: $QPE_VERSION-$SUB_VERSION.1
Depends: qt-embedded (>=$QTE_VERSION), opie-qcop, opie-taskbar, opie-pics, opie-sounds, apmd
Description: Base Qtopia environment
A complete GUI environment for handhelds.
You will probably want to install one of the opie-i18n-* packages.
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 4dbfbd8..a55f5f9 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -70,211 +70,231 @@
#include "power.h"
#include "alarmserver.h"
#include "applnk.h"
#include "qpemenubar.h"
#include <unistd.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
// for setBacklight()
#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
#include <linux/fb.h>
#include <sys/types.h>
#include <sys/stat.h>
#endif
#include <stdlib.h>
class QPEApplicationData {
public:
QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE),
kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE),
forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0),
keep_running(TRUE)
{
qcopq.setAutoDelete(TRUE);
}
int presstimer;
QWidget* presswidget;
QPoint presspos;
bool rightpressed;
int kbgrabber;
bool kbregrab;
bool notbusysent;
QString appName;
struct QCopRec {
QCopRec(const QCString &ch, const QCString &msg,
const QByteArray &d) :
channel(ch), message(msg), data(d) { }
QCString channel;
QCString message;
QByteArray data;
};
bool preloaded;
bool forceshow;
bool nomaximize;
QWidget* qpe_main_widget;
bool keep_running;
QList<QCopRec> qcopq;
void enqueueQCop(const QCString &ch, const QCString &msg,
const QByteArray &data)
{
qcopq.append(new QCopRec(ch,msg,data));
}
void sendQCopQ()
{
QCopRec* r;
for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it)
QCopChannel::sendLocally(r->channel,r->message,r->data);
qcopq.clear();
}
};
class ResourceMimeFactory : public QMimeSourceFactory {
public:
ResourceMimeFactory()
{
setFilePath( Global::helpPath() );
setExtensionType("html","text/html;charset=UTF-8");
}
const QMimeSource* data(const QString& abs_name) const
{
const QMimeSource* r = QMimeSourceFactory::data(abs_name);
if ( !r ) {
int sl = abs_name.length();
do {
sl = abs_name.findRev('/',sl-1);
QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name;
int dot = name.findRev('.');
if ( dot >= 0 )
name = name.left(dot);
QImage img = Resource::loadImage(name);
if ( !img.isNull() )
r = new QImageDrag(img);
} while (!r && sl>0);
}
return r;
}
};
static int muted=0;
+static int micMuted=0;
static void setVolume(int t=0, int percent=-1)
{
- switch (t) {
- case 0: {
- Config cfg("Sound");
- cfg.setGroup("System");
- if ( percent < 0 )
- percent = cfg.readNumEntry("Volume",50);
- int fd = 0;
- if ((fd = open("/dev/mixer", O_RDWR))>=0) {
- int vol = muted ? 0 : percent;
- // set both channels to same volume
- vol |= vol << 8;
- ioctl(fd, MIXER_WRITE(0), &vol);
- ::close(fd);
- }
- } break;
- }
+ switch (t) {
+ case 0: {
+ Config cfg("Sound");
+ cfg.setGroup("System");
+ if ( percent < 0 )
+ percent = cfg.readNumEntry("Volume",50);
+ int fd = 0;
+ if ((fd = open("/dev/mixer", O_RDWR))>=0) {
+ int vol = muted ? 0 : percent;
+ // set both channels to same volume
+ vol |= vol << 8;
+ ioctl(fd, MIXER_WRITE(0), &vol);
+ ::close(fd);
+ }
+ } break;
+ }
+}
+
+static void setMic(int t=0, int percent=-1)
+{
+ switch (t) {
+ case 0: {
+ Config cfg("Sound");
+ cfg.setGroup("System");
+ if ( percent < 0 )
+ percent = cfg.readNumEntry("Mic",50);
+
+ int fd = 0;
+ int mic = micMuted ? 0 : percent;
+ if ((fd = open("/dev/mixer", O_RDWR))>=0) {
+ ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic);
+ ::close(fd);
+ }
+ } break;
+ }
}
int qpe_sysBrightnessSteps()
{
#if defined(QT_QWS_IPAQ)
return 255;
#elif defined(QT_QWS_EBX)
return 4;
#else
return 255; // ?
#endif
}
static int& hack(int& i)
{
#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
// These should be created, but aren't in Qt 2.3.0
(void)new QUtf8Codec;
(void)new QUtf16Codec;
#endif
return i;
}
static bool forced_off = FALSE;
static int curbl=-1;
static int backlight()
{
if ( curbl == -1 ) {
// Read from config
Config config( "qpe" );
config.setGroup( "Screensaver" );
curbl = config.readNumEntry("Brightness",255);
}
return curbl;
}
static void setBacklight(int bright)
{
if ( bright == -3 ) {
// Forced on
forced_off = FALSE;
bright = -1;
}
if ( forced_off && bright != -2 )
return;
if ( bright == -2 ) {
// Toggle between off and on
bright = curbl ? 0 : -1;
forced_off = !bright;
}
if ( bright == -1 ) {
// Read from config
Config config( "qpe" );
config.setGroup( "Screensaver" );
bright = config.readNumEntry("Brightness",255);
}
#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
if ( QFile::exists("/usr/bin/bl") ) {
QString cmd = "/usr/bin/bl 1 ";
cmd += bright<=0 ? "0 " : "1 ";
cmd += QString::number(bright);
system(cmd.latin1());
#if defined(QT_QWS_EBX)
} else if ( QFile::exists("/dev/fl") ) {
#define FL_IOCTL_STEP_CONTRAST 100
int fd = open("/dev/fl", O_WRONLY);
if (fd >= 0 ) {
int steps = qpe_sysBrightnessSteps();
int bl = ( bright * steps + 127 ) / 255;
if ( bright && !bl ) bl = 1;
bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl);
close(fd);
}
}
#elif defined(QT_QWS_IPAQ)
} else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) {
typedef struct {
unsigned char mode;
unsigned char pwr;
unsigned char brightness;
} FLITE_IN;
# ifndef FLITE_ON
# ifndef _LINUX_IOCTL_H
# include <linux/ioctl.h>
# endif
# define FLITE_ON _IOW('f', 7, FLITE_IN)
# endif
int fd;
if ( QFile::exists("/dev/ts") )
fd = open("/dev/ts", O_WRONLY);
else
fd = open("/dev/h3600_ts", O_WRONLY);
if (fd >= 0 ) {
FLITE_IN bl;
@@ -776,318 +796,327 @@ QPEApplication::~QPEApplication()
*/
QString QPEApplication::qpeDir()
{
const char *base = getenv( "OPIEDIR" );
if ( base )
return QString( base ) + "/";
return QString( "../" );
}
/*!
Returns the user's current Document directory. There is a trailing "/".
*/
QString QPEApplication::documentDir()
{
const char *base = getenv( "HOME" );
if ( base )
return QString( base ) + "/Documents/";
return QString( "../Documents/" );
}
static int deforient=-1;
/*!
\internal
*/
int QPEApplication::defaultRotation()
{
if ( deforient < 0 ) {
QString d = getenv("QWS_DISPLAY");
if ( d.contains("Rot90") ) {
deforient = 90;
} else if ( d.contains("Rot180") ) {
deforient = 180;
} else if ( d.contains("Rot270") ) {
deforient = 270;
} else {
deforient=0;
}
}
return deforient;
}
/*!
\internal
*/
void QPEApplication::setDefaultRotation(int r)
{
if ( qApp->type() == GuiServer ) {
deforient = r;
setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(r).latin1(), 1);
} else {
QCopEnvelope("QPE/System", "setDefaultRotation(int)") << r;
}
}
/*!
\internal
*/
void QPEApplication::applyStyle()
{
Config config( "qpe" );
config.setGroup( "Appearance" );
// Widget style
QString style = config.readEntry( "Style", "Light" );
internalSetStyle( style );
// Colors
QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );
QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );
QPalette pal( btncolor, bgcolor );
QString color = config.readEntry( "Highlight", "#800000" );
pal.setColor( QColorGroup::Highlight, QColor(color) );
color = config.readEntry( "HighlightedText", "#FFFFFF" );
pal.setColor( QColorGroup::HighlightedText, QColor(color) );
color = config.readEntry( "Text", "#000000" );
pal.setColor( QColorGroup::Text, QColor(color) );
color = config.readEntry( "ButtonText", "#000000" );
pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor(color) );
color = config.readEntry( "Base", "#FFFFFF" );
pal.setColor( QColorGroup::Base, QColor(color) );
pal.setColor( QPalette::Disabled, QColorGroup::Text,
pal.color(QPalette::Active, QColorGroup::Background).dark() );
setPalette( pal, TRUE );
}
void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data)
{
#ifdef Q_WS_QWS
QDataStream stream( data, IO_ReadOnly );
if ( msg == "applyStyle()" ) {
- applyStyle();
+ applyStyle();
} else if ( msg == "setScreenSaverInterval(int)" ) {
- if ( type() == GuiServer ) {
+ if ( type() == GuiServer ) {
int time;
stream >> time;
setScreenSaverInterval(time);
- }
+ }
} else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
- if ( type() == GuiServer ) {
+ if ( type() == GuiServer ) {
int t1,t2,t3;
stream >> t1 >> t2 >> t3;
setScreenSaverIntervals(t1,t2,t3);
- }
+ }
} else if ( msg == "setBacklight(int)" ) {
- if ( type() == GuiServer ) {
+ if ( type() == GuiServer ) {
int bright;
stream >> bright;
setBacklight(bright);
- }
+ }
} else if ( msg == "setDefaultRotation(int)" ) {
- if ( type() == GuiServer ) {
+ if ( type() == GuiServer ) {
int r;
stream >> r;
setDefaultRotation(r);
- }
+ }
} else if ( msg == "shutdown()" ) {
- if ( type() == GuiServer )
+ if ( type() == GuiServer )
shutdown();
} else if ( msg == "quit()" ) {
- if ( type() != GuiServer )
+ if ( type() != GuiServer )
tryQuit();
} else if ( msg == "forceQuit()" ) {
- if ( type() != GuiServer )
+ if ( type() != GuiServer )
quit();
} else if ( msg == "restart()" ) {
- if ( type() == GuiServer )
+ if ( type() == GuiServer )
restart();
} else if ( msg == "grabKeyboard(QString)" ) {
- QString who;
- stream >> who;
- if ( who.isEmpty() )
+ QString who;
+ stream >> who;
+ if ( who.isEmpty() )
d->kbgrabber = 0;
- else if ( who != d->appName )
+ else if ( who != d->appName )
d->kbgrabber = 1;
- else
+ else
d->kbgrabber = 2;
} else if ( msg == "language(QString)" ) {
- if ( type() == GuiServer ) {
+ if ( type() == GuiServer ) {
QString l;
stream >> l;
QString cl = getenv("LANG");
if ( cl != l ) {
- if ( l.isNull() )
+ if ( l.isNull() )
unsetenv( "LANG" );
- else
+ else
setenv( "LANG", l.latin1(), 1 );
- restart();
+ restart();
}
- }
+ }
} else if ( msg == "timeChange(QString)" ) {
- QString t;
- stream >> t;
- if ( t.isNull() )
+ QString t;
+ stream >> t;
+ if ( t.isNull() )
unsetenv( "TZ" );
- else
+ else
setenv( "TZ", t.latin1(), 1 );
- // emit the signal so everyone else knows...
- emit timeChanged();
+ // emit the signal so everyone else knows...
+ emit timeChanged();
} else if ( msg == "execute(QString)" ) {
- if ( type() == GuiServer ) {
+ if ( type() == GuiServer ) {
QString t;
stream >> t;
Global::execute( t );
- }
+ }
} else if ( msg == "execute(QString,QString)" ) {
- if ( type() == GuiServer ) {
+ if ( type() == GuiServer ) {
QString t,d;
stream >> t >> d;
Global::execute( t, d );
- }
+ }
} else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
- if ( type() == GuiServer ) {
+ if ( type() == GuiServer ) {
QDateTime when;
QCString channel, message;
int data;
stream >> when >> channel >> message >> data;
AlarmServer::addAlarm( when, channel, message, data );
- }
+ }
} else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
- if ( type() == GuiServer ) {
+ if ( type() == GuiServer ) {
QDateTime when;
QCString channel, message;
int data;
stream >> when >> channel >> message >> data;
AlarmServer::deleteAlarm( when, channel, message, data );
- }
+ }
} else if ( msg == "clockChange(bool)" ) {
- int tmp;
- stream >> tmp;
- emit clockChanged( tmp );
+ int tmp;
+ stream >> tmp;
+ emit clockChanged( tmp );
} else if ( msg == "weekChange(bool)" ) {
- int tmp;
- stream >> tmp;
- emit weekChanged( tmp );
+ int tmp;
+ stream >> tmp;
+ emit weekChanged( tmp );
} else if ( msg == "setDateFormat(DateFormat)" ) {
- DateFormat tmp;
- stream >> tmp;
- emit dateFormatChanged( tmp );
+ DateFormat tmp;
+ stream >> tmp;
+ emit dateFormatChanged( tmp );
} else if ( msg == "setVolume(int,int)" ) {
- int t,v;
- stream >> t >> v;
- setVolume(t,v);
- emit volumeChanged( muted );
+ int t,v;
+ stream >> t >> v;
+ setVolume(t,v);
+ emit volumeChanged( muted );
} else if ( msg == "volumeChange(bool)" ) {
- stream >> muted;
- setVolume();
- emit volumeChanged( muted );
+ stream >> muted;
+ setVolume();
+ emit volumeChanged( muted );
+ } else if ( msg == "setMic(int,int)") { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
+ int t,v;
+ stream >> t >> v;
+ setMic(t,v);
+ emit micChanged( micMuted );
+ } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
+ stream >> micMuted;
+ setMic();
+ emit micChanged( micMuted );
} else if ( msg == "setScreenSaverMode(int)" ) {
- if ( type() == GuiServer ) {
- int old = disable_suspend;
- stream >> disable_suspend;
- //qDebug("setScreenSaverMode(%d)", disable_suspend );
- if ( disable_suspend > old )
- setScreenSaverInterval( -1 );
+ if ( type() == GuiServer ) {
+ int old = disable_suspend;
+ stream >> disable_suspend;
+ //qDebug("setScreenSaverMode(%d)", disable_suspend );
+ if ( disable_suspend > old )
+ setScreenSaverInterval( -1 );
+ }
}
- }
#endif
}
/*!
\internal
*/
bool QPEApplication::raiseAppropriateWindow()
{
bool r=FALSE;
// ########## raise()ing main window should raise and set active
// ########## it and then all childen. This belongs in Qt/Embedded
QWidget *top = d->qpe_main_widget;
if ( !top ) top =mainWidget();
if ( top && d->keep_running ) {
if ( top->isVisible() )
r = TRUE;
#ifdef Q_WS_QWS
if ( !d->nomaximize )
top->showMaximized();
else
#endif
top->show();
top->raise();
top->setActiveWindow();
}
QWidget *topm = activeModalWidget();
if ( topm && topm != top ) {
topm->show();
topm->raise();
topm->setActiveWindow();
r = FALSE;
}
return r;
}
void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data)
{
#ifdef Q_WS_QWS
if ( msg == "quit()" ) {
tryQuit();
} else if ( msg == "quitIfInvisible()" ) {
if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
quit();
} else if ( msg == "close()" ) {
hideOrQuit();
} else if ( msg == "disablePreload()" ) {
d->preloaded = FALSE;
d->keep_running = TRUE;
/* so that quit will quit */
} else if ( msg == "enablePreload()" ) {
d->preloaded = TRUE;
d->keep_running = TRUE;
/* so next quit won't quit */
} else if ( msg == "raise()" ) {
d->keep_running = TRUE;
d->notbusysent = FALSE;
raiseAppropriateWindow();
} else if ( msg == "flush()" ) {
emit flush();
// we need to tell the desktop
QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
e << d->appName;
} else if ( msg == "reload()" ) {
emit reload();
} else if ( msg == "setDocument(QString)" ) {
d->keep_running = TRUE;
QDataStream stream( data, IO_ReadOnly );
QString doc;
stream >> doc;
QWidget *mw = mainWidget();
if ( !mw )
mw = d->qpe_main_widget;
if ( mw )
Global::setDocument( mw, doc );
} else if ( msg == "nextView()" ) {
if ( raiseAppropriateWindow() )
emit appMessage( msg, data);
} else {
emit appMessage( msg, data);
}
#endif
}
static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
{
/*
// This works but disable it for now until it is safe to apply
// What is does is scan the .desktop files of all the apps for
// the applnk that has the corresponding argv[0] as this program
// then it uses the name stored in the .desktop file as the caption
// for the main widget. This saves duplicating translations for
// the app name in the program and in the .desktop files.
AppLnkSet apps( appsPath );
diff --git a/library/qpeapplication.h b/library/qpeapplication.h
index fd5e57d..23606db 100644
--- a/library/qpeapplication.h
+++ b/library/qpeapplication.h
@@ -1,124 +1,130 @@
/**********************************************************************
** 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 __QPE_APPLICATION_H__
#define __QPE_APPLICATION_H__
#include <qapplication.h>
#if defined(_WS_QWS_) && !defined(Q_WS_QWS)
#define Q_WS_QWS
#endif
#include "qpedecoration_qws.h"
#include "timestring.h"
class QCopChannel;
class QPEApplicationData;
class QWSEvent;
class QWSKeyEvent;
class QPEApplication : public QApplication
{
Q_OBJECT
public:
QPEApplication( int& argc, char **argv, Type=GuiClient );
~QPEApplication();
static QString qpeDir();
static QString documentDir();
void applyStyle();
static int defaultRotation();
static void setDefaultRotation(int r);
static void grabKeyboard();
static void ungrabKeyboard();
enum StylusMode {
LeftOnly,
RightOnHold
// RightOnHoldLeftDelayed, etc.
};
static void setStylusOperation( QWidget*, StylusMode );
static StylusMode stylusOperation( QWidget* );
enum InputMethodHint {
Normal,
AlwaysOff,
AlwaysOn
};
enum screenSaverHint {
Disable = 0,
DisableLightOff = 1,
DisableSuspend = 2,
Enable = 100
};
static void setInputMethodHint( QWidget *, InputMethodHint );
static InputMethodHint inputMethodHint( QWidget * );
void showMainWidget( QWidget*, bool nomax=FALSE );
void showMainDocumentWidget( QWidget*, bool nomax=FALSE );
static void setKeepRunning();
bool keepRunning() const;
int exec();
signals:
void clientMoused();
void timeChanged();
void clockChanged( bool pm );
void volumeChanged( bool muted );
+ void micChanged( bool muted );
void appMessage( const QCString& msg, const QByteArray& data);
void weekChanged( bool startOnMonday );
void dateFormatChanged( DateFormat );
void flush();
void reload();
private slots:
void systemMessage( const QCString &msg, const QByteArray &data );
void pidMessage( const QCString &msg, const QByteArray &data );
void removeSenderFromStylusDict();
void hideOrQuit();
protected:
bool qwsEventFilter( QWSEvent * );
void internalSetStyle( const QString &style );
void prepareForTermination(bool willrestart);
virtual void restart();
virtual void shutdown();
bool eventFilter( QObject *, QEvent * );
void timerEvent( QTimerEvent * );
bool keyboardGrabbed() const;
bool raiseAppropriateWindow();
virtual void tryQuit();
private:
void mapToDefaultAction( QWSKeyEvent *ke, int defKey );
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
QCopChannel *sysChannel;
QCopChannel *pidChannel;
#endif
QPEApplicationData *d;
+
+ bool reserved_sh;
+
+
+
};
#endif