summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/rohfeedback.cpp28
-rw-r--r--library/backend/rohfeedback.h3
-rw-r--r--library/config.in4
-rw-r--r--library/library.pro6
-rw-r--r--library/qpeapplication.cpp58
-rw-r--r--library/qpeapplication.h2
6 files changed, 57 insertions, 44 deletions
diff --git a/library/backend/rohfeedback.cpp b/library/backend/rohfeedback.cpp
index ff76a36..21aad34 100644
--- a/library/backend/rohfeedback.cpp
+++ b/library/backend/rohfeedback.cpp
@@ -1,125 +1,125 @@
-#include <rohfeedback.h>
-
+#ifdef OPIE_WITHROHFEEDBACK
+#include <rohfeedback.h>
#include <stdio.h>
#include <qpeapplication.h>
#include <qevent.h>
#include <resource.h>
#include <qpixmap.h>
#include <qbitmap.h>
#define SPEED 600
#define DELAY 500
namespace Opie {
namespace Internal {
/*
RightOnHold feedback
*/
QPixmap * RoHFeedback::Imgs[NOOFICONS] = { 0, 0, 0, 0, 0 };
QBitmap * RoHFeedback::Masks[NOOFICONS];
int RoHFeedback::IconWidth;
int RoHFeedback::IconHeight;
RoHFeedback::RoHFeedback() :
QLabel( 0, 0, Qt::WType_Popup ), Timer() {
Receiver = 0l;
connect( &Timer, SIGNAL( timeout() ), this, SLOT( iconShow() ) );
if( Imgs[0] == 0 ) {
QString S;
for( int i = 0; i < NOOFICONS ; i ++ ) {
- Imgs[i] = new QPixmap( Resource::loadPixmap("RoH/star/"+
- QString::number(i+1) +
- ".png" ));
+ Imgs[i] = new QPixmap( Resource::loadPixmap(
+ "RoH/star/"+ QString::number(i+1) + ".png" ));
Masks[i] = new QBitmap();
- (*Masks[i]) = Resource::loadPixmap("RoH/star/"+QString::number(i+1) +
- ".png" );
+ (*Masks[i]) = Resource::loadPixmap(
+ "RoH/star/"+QString::number(i+1) + "-mask.png" );
}
}
IconWidth = Imgs[0]->size().width();
IconHeight = Imgs[0]->size().height();
resize( IconWidth, IconHeight );
}
int RoHFeedback::delay( void ) {
return DELAY+SPEED+50;
}
RoHFeedback::~RoHFeedback() {
for ( int i = 0; i < NOOFICONS; ++i ) {
delete Imgs [i];
delete Masks[i];
}
}
void RoHFeedback::init( const QPoint & P, QWidget* wid ) {
if( ! IconWidth )
return;
Receiver = wid;
- IconNr = -1;
+ IconNr = FeedbackTimerStart;
move( P.x()-IconWidth/2, P.y() - IconHeight/2 );
// to initialize
- Timer.start( DELAY - SPEED/NOOFICONS );
+ Timer.start( DELAY );
}
void RoHFeedback::stop( void ) {
- IconNr = -2; // stop
- hide();
- Timer.stop();
+ IconNr = FeedbackStopped; // stop
}
bool RoHFeedback::event( QEvent * E ) {
if( E->type() >= QEvent::MouseButtonPress &&
E->type() <= QEvent::MouseMove ) {
// pass the event to the receiver with translated coord
QMouseEvent QME( ((QMouseEvent *)E)->type(),
Receiver->mapFromGlobal(
((QMouseEvent *)E)->globalPos() ),
((QMouseEvent *)E)->globalPos(),
((QMouseEvent *)E)->button(),
((QMouseEvent *)E)->state()
);
return QPEApplication::sendEvent( Receiver, &QME );
}
// first let the label treat the event
return QLabel::event( E );
}
void RoHFeedback::iconShow( void ) {
switch( IconNr ) {
case FeedbackTimerStart:
- IconNr = 0;
+ IconNr = FeedbackShow;
Timer.start( SPEED/NOOFICONS );
break;
case FeedbackStopped:
// stopped
IconNr = FeedbackTimerStart;
hide();
+ Timer.stop();
break;
case FeedbackShow: // first
show();
// FT
default :
// show
setPixmap( *(Imgs[IconNr]) );
setMask( *(Masks[IconNr]) );
IconNr = (IconNr+1)%NOOFICONS; // rotate
break;
}
}
}
-} \ No newline at end of file
+}
+
+#endif
diff --git a/library/backend/rohfeedback.h b/library/backend/rohfeedback.h
index f38a095..9ffd35a 100644
--- a/library/backend/rohfeedback.h
+++ b/library/backend/rohfeedback.h
@@ -1,62 +1,65 @@
#ifndef ROHFEEDBACK_H
#define ROHFEEDBACK_H
+#ifdef OPIE_WITHROHFEEDBACK
+
/*
RightOnHold feedback show
*/
#define NOOFICONS 5
#include <qlabel.h>
#include <qtimer.h>
class QEvent;
class QPixmap;
class QBitmap;
class QMouseEvent;
namespace Opie {
namespace Internal {
class RoHFeedback : public QLabel {
Q_OBJECT
enum Actions {
FeedbackStopped = -2,
FeedbackTimerStart = -1,
FeedbackShow = 0
};
public :
RoHFeedback();
~RoHFeedback();
void init( const QPoint & P, QWidget* wid );
void stop( void );
int delay( void );
public slots :
void iconShow( void );
protected :
bool event( QEvent * E );
QTimer Timer;
int IconNr;
QWidget * Receiver;
static int IconWidth;
static int IconHeight;
static QPixmap * Imgs[NOOFICONS];
static QBitmap * Masks[NOOFICONS];
};
}
}
#endif
+#endif
diff --git a/library/config.in b/library/config.in
index ea69ccb..5273976 100644
--- a/library/config.in
+++ b/library/config.in
@@ -1,2 +1,6 @@
config LIBQPE
boolean "Qpe Library (Qt/Embedded version)"
+
+config LIBQPE_WITHROHFEEDBACK
+ boolean "Give visual feedback for RightOnHold"
+ depends LIBQPE
diff --git a/library/library.pro b/library/library.pro
index eb4bde3..af07fa3 100644
--- a/library/library.pro
+++ b/library/library.pro
@@ -1,137 +1,143 @@
TEMPLATE = lib
#CONFIG += qt warn_on release
CONFIG += qt warn_on debug
HEADERS = calendar.h \
global.h \
resource.h \
xmlreader.h \
mimetype.h \
menubutton.h \
network.h \
networkinterface.h \
filemanager.h \
fontmanager.h \
qdawg.h \
datebookmonth.h \
fileselector.h \
fileselector_p.h \
imageedit.h \
qcopenvelope_qws.h \
qpedecoration_qws.h \
qpeapplication.h \
qpestyle.h \
qpedialog.h \
lightstyle.h \
config.h \
applnk.h \
sound.h \
tzselect.h \
qmath.h \
datebookdb.h \
alarmserver.h \
process.h \
password.h \
timestring.h \
fontfactoryinterface.h \
fontdatabase.h \
power.h \
storage.h \
qpemessagebox.h \
timeconversion.h \
qpedebug.h \
qpemenubar.h \
qpetoolbar.h \
backend/categories.h \
stringutil.h \
backend/palmtoprecord.h \
backend/task.h \
backend/event.h \
backend/contact.h\
+ backend/rohfeedback.h \
categorymenu.h \
categoryedit_p.h \
categoryselect.h \
categorywidget.h \
ir.h \
backend/vobject_p.h \
findwidget_p.h \
finddialog.h \
lnkproperties.h \
windowdecorationinterface.h \
textcodecinterface.h \
imagecodecinterface.h \
qt_override_p.h
SOURCES = calendar.cpp \
global.cpp \
xmlreader.cpp \
mimetype.cpp \
menubutton.cpp \
network.cpp \
networkinterface.cpp \
filemanager.cpp \
fontmanager.cpp \
qdawg.cpp \
datebookmonth.cpp \
fileselector.cpp \
imageedit.cpp \
resource.cpp \
qpedecoration_qws.cpp \
qcopenvelope_qws.cpp \
qpeapplication.cpp \
qpestyle.cpp \
qpedialog.cpp \
lightstyle.cpp \
config.cpp \
applnk.cpp \
sound.cpp \
tzselect.cpp \
qmath.c \
datebookdb.cpp \
alarmserver.cpp \
password.cpp \
process.cpp \
process_unix.cpp \
timestring.cpp \
fontdatabase.cpp \
power.cpp \
storage.cpp \
qpemessagebox.cpp \
backend/timeconversion.cpp \
qpedebug.cpp \
qpemenubar.cpp \
qpetoolbar.cpp \
backend/categories.cpp \
backend/stringutil.cpp \
backend/palmtoprecord.cpp \
backend/task.cpp \
backend/event.cpp \
backend/contact.cpp \
+ backend/rohfeedback.cpp \
categorymenu.cpp \
categoryedit_p.cpp \
categoryselect.cpp \
categorywidget.cpp \
ir.cpp \
backend/vcc_yacc.cpp \
backend/vobject.cpp \
findwidget_p.cpp \
finddialog.cpp \
lnkproperties.cpp \
qt_override.cpp
# Qt 3 compatibility
HEADERS += quuid.h qcom.h qlibrary.h qlibrary_p.h
SOURCES += quuid.cpp qlibrary.cpp qlibrary_unix.cpp
INCLUDEPATH += $(OPIEDIR)/include backend
LIBS += -ldl -lcrypt -lm
INTERFACES = passwordbase_p.ui categoryeditbase_p.ui findwidgetbase_p.ui lnkpropertiesbase_p.ui
TARGET = qpe
DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
VERSION = 1.5.0.1
include ( $(OPIEDIR)/include.pro )
contains( CONFIG, no-override ){
DEFINES += OPIE_NO_OVERRIDE_QT
}
+
+contains( CONFIG, LIBQPE_WITHROHFEEDBACK ){
+ DEFINES += WITHROHFEEDBACK
+}
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 35f433c..c6d9cfd 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -4,234 +4,233 @@
** 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.
**
*/
#define QTOPIA_INTERNAL_LANGLIST
#include <stdlib.h>
#include <unistd.h>
#ifndef Q_OS_MACX
#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
#endif
#include <qfile.h>
#include <qqueue.h>
#ifdef Q_WS_QWS
#ifndef QT_NO_COP
#if QT_VERSION <= 231
#define private public
#define sendLocally processEvent
#include "qcopenvelope_qws.h"
#undef private
#else
#include "qcopenvelope_qws.h"
#endif
#endif
#include <qwindowsystem_qws.h>
#endif
#include <qtextstream.h>
#include <qpalette.h>
#include <qbuffer.h>
#include <qptrdict.h>
#include <qregexp.h>
#include <qdir.h>
#include <qlabel.h>
#include <qdialog.h>
#include <qdragobject.h>
#include <qtextcodec.h>
#include <qevent.h>
#include <qtooltip.h>
#include <qsignal.h>
#include <qmainwindow.h>
#include <qwidgetlist.h>
#include <qpixmapcache.h>
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
#define QTOPIA_INTERNAL_INITAPP
#include "qpeapplication.h"
#include "qpestyle.h"
#include "styleinterface.h"
#if QT_VERSION >= 300
#include <qstylefactory.h>
#else
#include <qplatinumstyle.h>
#include <qwindowsstyle.h>
#include <qmotifstyle.h>
#include <qmotifplusstyle.h>
#include "lightstyle.h"
#include <qpe/qlibrary.h>
#endif
#include "global.h"
#include "resource.h"
#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
#include "qutfcodec.h"
#endif
#include "config.h"
#include "network.h"
#ifdef QWS
#include "fontmanager.h"
#include "fontdatabase.h"
#endif
#include "alarmserver.h"
#include "applnk.h"
#include "qpemenubar.h"
#include "textcodecinterface.h"
#include "imagecodecinterface.h"
#include <unistd.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#ifndef QT_NO_SOUND
#include <sys/soundcard.h>
#endif
#include "qt_override_p.h"
-#include <qpe/rohfeedback.h>
+#include <backend/rohfeedback.h>
static bool useBigPixmaps = 0;
-
class HackWidget : public QWidget
{
public:
bool needsOk()
{ return (getWState() & WState_Reserved1 ); }
QRect normalGeometry()
{ return topData()->normalGeometry; };
};
class QPEApplicationData
{
public:
- QPEApplicationData ( )
- : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
+ QPEApplicationData ( ) :
+ presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
keep_running( true ), qcopQok( false ),
fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ),
bigIconSize( 32 ), qpe_main_widget( 0 )
{
Config cfg( "qpe" );
cfg.setGroup( "Appearance" );
useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false );
fontFamily = cfg.readEntry( "FontFamily", "Vera" );
fontSize = cfg.readNumEntry( "FontSize", 10 );
smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 );
bigIconSize = cfg.readNumEntry( "BigIconSize", 32 );
-#ifdef OPIE_ROHFEEDBACK
+#ifdef OPIE_WITHROHFEEDBACK
RoH = 0;
#endif
}
int presstimer;
QWidget* presswidget;
QPoint presspos;
-#ifdef OPIE_ROHFEEDBACK
+#ifdef OPIE_WITHROHFEEDBACK
Opie::Internal::RoHFeedback *RoH;
#endif
bool rightpressed : 1;
bool kbgrabbed : 1;
bool notbusysent : 1;
bool preloaded : 1;
bool forceshow : 1;
bool nomaximize : 1;
bool keep_running : 1;
bool qcopQok : 1;
QCString fontFamily;
int fontSize;
int smallIconSize;
int bigIconSize;
QStringList langs;
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;
};
QWidget* qpe_main_widget;
QGuardedPtr<QWidget> lastraised;
QQueue<QCopRec> qcopq;
QString styleName;
QString decorationName;
void enqueueQCop( const QCString &ch, const QCString &msg,
const QByteArray &data )
{
qcopq.enqueue( new QCopRec( ch, msg, data ) );
}
void sendQCopQ()
{
if (!qcopQok )
return;
QCopRec * r;
while((r=qcopq.dequeue())) {
// remove from queue before sending...
// event loop can come around again before getting
// back from sendLocally
#ifndef QT_NO_COP
QCopChannel::sendLocally( r->channel, r->message, r->data );
#endif
delete r;
}
}
static void show_mx(QWidget* mw, bool nomaximize, QString &strName)
{
if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") )
{
( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps );
}
QPoint p;
QSize s;
bool max;
if ( mw->isVisible() ) {
if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
mw->resize(s);
mw->move(p);
}
mw->raise();
} else {
if ( mw->layout() && mw->inherits("QDialog") ) {
if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
mw->resize(s);
mw->move(p);
if ( max && !nomaximize ) {
mw->showMaximized();
} else {
mw->show();
}
} else {
qpe_show_dialog((QDialog*)mw,nomaximize);
}
} else {
if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
mw->resize(s);
mw->move(p);
} else { //no stored rectangle, make an estimation
int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
@@ -409,192 +408,193 @@ static void qpe_show_dialog( QDialog* d, bool nomax )
// 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 );
QList<AppLnk> appsList = apps.children();
for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
if ( (*it)->exec() == appName ) {
mw->setCaption( (*it)->name() );
return TRUE;
}
}
*/
return FALSE;
}
void show(QWidget* mw, bool nomax)
{
setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
nomaximize = nomax;
qpe_main_widget = mw;
qcopQok = TRUE;
#ifndef QT_NO_COP
sendQCopQ();
#endif
if ( preloaded ) {
if (forceshow)
show_mx(mw, nomax, appName);
}
else if ( keep_running ) {
show_mx(mw, nomax, appName);
}
}
void loadTextCodecs()
{
QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
#ifdef Q_OS_MACX
QDir dir( path, "lib*.dylib" );
#else
QDir dir( path, "lib*.so" );
#endif
QStringList list;
if ( dir. exists ( ))
list = dir.entryList();
QStringList::Iterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
TextCodecInterface *iface = 0;
QLibrary *lib = new QLibrary( path + "/" + *it );
if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
QValueList<int> mibs = iface->mibEnums();
for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
(void)iface->createForMib(*i);
// ### it exists now; need to remember if we can delete it
}
}
else {
lib->unload();
delete lib;
}
}
}
void loadImageCodecs()
{
QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
#ifdef Q_OS_MACX
QDir dir( path, "lib*.dylib" );
#else
QDir dir( path, "lib*.so" );
#endif
QStringList list;
if ( dir. exists ( ))
list = dir.entryList();
QStringList::Iterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
ImageCodecInterface *iface = 0;
QLibrary *lib = new QLibrary( path + "/" + *it );
if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
QStringList formats = iface->keys();
for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
(void)iface->installIOHandler(*i);
// ### it exists now; need to remember if we can delete it
}
}
else {
lib->unload();
delete lib;
}
}
}
+
};
class ResourceMimeFactory : public QMimeSourceFactory
{
public:
ResourceMimeFactory() : resImage( 0 )
{
setFilePath( Global::helpPath() );
setExtensionType( "html", "text/html;charset=UTF-8" );
}
~ResourceMimeFactory() {
delete resImage;
}
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() ) {
delete resImage;
resImage = new QImageDrag( img );
r = resImage;
}
}
while ( !r && sl > 0 );
}
return r;
}
private:
mutable QImageDrag *resImage;
};
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 int muted = 0;
static int micMuted = 0;
static void setVolume( int t = 0, int percent = -1 )
{
switch ( t ) {
case 0: {
Config cfg( "qpe" );
cfg.setGroup( "Volume" );
if ( percent < 0 )
percent = cfg.readNumEntry( "VolumePercent", 50 );
#ifndef QT_NO_SOUND
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( SOUND_MIXER_VOLUME ), &vol );
::close( fd );
}
#endif
}
break;
}
}
static void setMic( int t = 0, int percent = -1 )
{
switch ( t ) {
case 0: {
Config cfg( "qpe" );
cfg.setGroup( "Volume" );
if ( percent < 0 )
percent = cfg.readNumEntry( "Mic", 50 );
#ifndef QT_NO_SOUND
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 );
}
#endif
}
break;
}
@@ -1122,194 +1122,196 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
// Use special "select" key to do whatever default action a widget has
mapToDefaultAction( ke, Qt::Key_Space );
}
else if ( ke->simpleData.keycode == Qt::Key_Escape &&
ke->simpleData.is_press ) {
// Escape key closes app if focus on toplevel
QWidget * active = activeWindow();
if ( active && active->testWFlags( WType_TopLevel ) &&
( int ) active->winId() == ke->simpleData.window &&
!active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
if ( active->inherits( "QDialog" ) ) {
HackDialog * d = ( HackDialog * ) active;
d->rejectIt();
return TRUE;
} else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ {
active->close();
}
}
}
else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
// this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
// but we cannot access libopie function within libqpe :(
QWidget * active = activeWindow ( );
if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
if ( d-> kbgrabbed ) { // we grabbed the keyboard
QChar ch ( ke-> simpleData.unicode );
QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
ke-> simpleData.keycode,
ch. latin1 ( ),
ke-> simpleData.modifiers,
QString ( ch ),
ke-> simpleData.is_auto_repeat, 1 );
QObject *which = QWidget::keyboardGrabber ( );
if ( !which )
which = QApplication::focusWidget ( );
if ( !which )
which = QApplication::activeWindow ( );
if ( !which )
which = qApp;
QApplication::sendEvent ( which, &qke );
}
else { // we didn't grab the keyboard, so send the event to the launcher
QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
}
}
return true;
}
}
if ( e->type == QWSEvent::Focus ) {
QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
if ( !fe->simpleData.get_focus ) {
QWidget * active = activeWindow();
while ( active && active->isPopup() ) {
active->close();
active = activeWindow();
}
}
else {
// make sure our modal widget is ALWAYS on top
QWidget *topm = activeModalWidget();
if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
topm->raise();
}
}
if ( fe->simpleData.get_focus && inputMethodDict ) {
InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
if ( m == AlwaysOff )
Global::hideInputMethod();
if ( m == AlwaysOn )
Global::showInputMethod();
}
}
return QApplication::qwsEventFilter( e );
}
#endif
/*!
Destroys the QPEApplication.
*/
QPEApplication::~QPEApplication()
{
ungrabKeyboard();
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
// Need to delete QCopChannels early, since the display will
// be gone by the time we get to ~QObject().
delete sysChannel;
delete pidChannel;
#endif
-#ifdef OPIE_ROHFEEDBACK
- delete d->RoH;
+
+#ifdef OPIE_WITHROHFEEDBACK
+ if( d->RoH )
+ delete d->RoH;
#endif
delete d;
}
/*!
Returns <tt>$OPIEDIR/</tt>.
*/
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 "/".
.. well, it does now,, and there's no 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 );
Config config("qpe");
config.setGroup( "Rotation" );
config.writeEntry( "Rot", r );
}
else {
#ifndef QT_NO_COP
{ QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
e << r;
}
#endif
}
}
#include <qgfx_qws.h>
#include <qwindowsystem_qws.h>
#if QT_VERSION > 236
extern void qws_clearLoadedFonts();
#endif
void QPEApplication::setCurrentMode( int x, int y, int depth )
{
// Reset the caches
#if QT_VERSION > 236
qws_clearLoadedFonts();
#endif
QPixmapCache::clear();
// Change the screen mode
qt_screen->setMode(x, y, depth);
if ( qApp->type() == GuiServer ) {
#if QT_VERSION > 236
@@ -1942,282 +1944,282 @@ void QPEApplication::prepareForTermination( bool willrestart )
lblWait->setAlignment( QWidget::AlignCenter );
lblWait->show();
lblWait->showMaximized();
}
#ifndef SINGLE_APP
{ QCopEnvelope envelope( "QPE/System", "forceQuit()" );
}
processEvents(); // ensure the message goes out.
sleep( 1 ); // You have 1 second to comply.
#endif
}
/*!
\internal
*/
void QPEApplication::shutdown()
{
// Implement in server's QPEApplication subclass
}
/*!
\internal
*/
void QPEApplication::restart()
{
// Implement in server's QPEApplication subclass
}
static QPtrDict<void>* stylusDict = 0;
static void createDict()
{
if ( !stylusDict )
stylusDict = new QPtrDict<void>;
}
/*!
Returns the current StylusMode for widget \a w.
\sa setStylusOperation() StylusMode
*/
QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
{
if ( stylusDict )
return ( StylusMode ) ( int ) stylusDict->find( w );
return LeftOnly;
}
/*!
\enum QPEApplication::StylusMode
\value LeftOnly the stylus only generates LeftButton
events (the default).
\value RightOnHold the stylus generates RightButton events
if the user uses the press-and-hold gesture.
\sa setStylusOperation() stylusOperation()
*/
/*!
Causes widget \a w to receive mouse events according to the stylus
\a mode.
\sa stylusOperation() StylusMode
*/
void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
{
createDict();
if ( mode == LeftOnly ) {
stylusDict->remove
( w );
w->removeEventFilter( qApp );
}
else {
stylusDict->insert( w, ( void* ) mode );
connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
w->installEventFilter( qApp );
}
}
/*!
\reimp
*/
bool QPEApplication::eventFilter( QObject *o, QEvent *e )
{
if ( !o->isWidgetType() )
return FALSE;
if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
QMouseEvent * me = ( QMouseEvent* ) e;
StylusMode mode = (StylusMode)(int)stylusDict->find(o);
switch (mode) {
case RightOnHold:
switch ( me->type() ) {
case QEvent::MouseButtonPress:
if ( me->button() == LeftButton ) {
+ static long Pref = 500; // #### pref.
d->presswidget = (QWidget*)o;
d->presspos = me->pos();
d->rightpressed = FALSE;
- // just for the time being
- static int pref = 500;
-#ifdef OPIE_ROHFEEDBACK
+#ifdef OPIE_WITHROHFEEDBACK
if( ! d->RoH )
d->RoH = new Opie::Internal::RoHFeedback;
d->RoH->init( me->globalPos(), d->presswidget );
- pref = d->RoH->delay();
+ Pref = d->RoH->delay();
+
#endif
if (!d->presstimer )
- d->presstimer = startTimer( pref ); // #### pref.
+ d->presstimer = startTimer( Pref ); // #### pref.
}
break;
case QEvent::MouseMove:
if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
killTimer(d->presstimer);
-#ifdef OPIE_ROHFEEDBACK
- if( d->RoH )
- d->RoH->stop( );
+#ifdef OPIE_WITHROHFEEDBACK
+ d->RoH->stop();
#endif
d->presstimer = 0;
}
break;
case QEvent::MouseButtonRelease:
if ( me->button() == LeftButton ) {
if ( d->presstimer ) {
killTimer(d->presstimer);
-#ifdef OPIE_ROHFEEDBACK
- if( d->RoH )
- d->RoH->stop( );
+#ifdef OPIE_WITHROHFEEDBACK
+ d->RoH->stop( );
#endif
d->presstimer = 0;
}
if ( d->rightpressed && d->presswidget ) {
+ printf( "Send ButtonRelease\n" );
// Right released
postEvent( d->presswidget,
new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
RightButton, LeftButton + RightButton ) );
// Left released, off-widget
postEvent( d->presswidget,
new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
LeftButton, LeftButton ) );
postEvent( d->presswidget,
new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
LeftButton, LeftButton ) );
d->rightpressed = FALSE;
return TRUE; // don't send the real Left release
}
}
break;
default:
break;
}
break;
default:
;
}
}
else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
QKeyEvent *ke = (QKeyEvent *)e;
if ( ke->key() == Key_Enter ) {
if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
return TRUE;
}
}
}
return FALSE;
}
/*!
\reimp
*/
void QPEApplication::timerEvent( QTimerEvent *e )
{
if ( e->timerId() == d->presstimer && d->presswidget ) {
- // Right pressed
- postEvent( d->presswidget,
- new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
- RightButton, LeftButton ) );
- killTimer( d->presstimer );
- d->presstimer = 0;
- d->rightpressed = TRUE;
-#ifdef OPIE_ROHFEEDBACK
- d->RoH->stop();
+
+ // Right pressed
+ postEvent( d->presswidget,
+ new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
+ RightButton, LeftButton ) );
+ killTimer( d->presstimer );
+ d->presstimer = 0;
+ d->rightpressed = TRUE;
+#ifdef OPIE_WITHROHFEEDBACK
+ d->RoH->stop();
#endif
}
}
void QPEApplication::removeSenderFromStylusDict()
{
stylusDict->remove
( ( void* ) sender() );
if ( d->presswidget == sender() )
d->presswidget = 0;
}
/*!
\internal
*/
bool QPEApplication::keyboardGrabbed() const
{
return d->kbgrabbed;
}
/*!
Reverses the effect of grabKeyboard(). This is called automatically
on program exit.
*/
void QPEApplication::ungrabKeyboard()
{
((QPEApplication *) qApp )-> d-> kbgrabbed = false;
}
/*!
Grabs the physical keyboard keys, e.g. the application's launching
keys. Instead of launching applications when these keys are pressed
the signals emitted are sent to this application instead. Some games
programs take over the launch keys in this way to make interaction
easier.
\sa ungrabKeyboard()
*/
void QPEApplication::grabKeyboard()
{
((QPEApplication *) qApp )-> d-> kbgrabbed = true;
}
/*!
\reimp
*/
int QPEApplication::exec()
{
d->qcopQok = true;
#ifndef QT_NO_COP
d->sendQCopQ();
if ( !d->keep_running )
processEvents(); // we may have received QCop messages in the meantime.
#endif
if ( d->keep_running )
//|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
return QApplication::exec();
#ifndef QT_NO_COP
{
QCopEnvelope e( "QPE/System", "closing(QString)" );
e << d->appName;
}
#endif
processEvents();
return 0;
}
/*!
\internal
External request for application to quit. Quits if possible without
loosing state.
*/
void QPEApplication::tryQuit()
{
if ( activeModalWidget() )
return ; // Inside modal loop or konsole. Too hard to save state.
#ifndef QT_NO_COP
{
QCopEnvelope e( "QPE/System", "closing(QString)" );
e << d->appName;
}
#endif
if ( d->keep_running )
d->store_widget_rect(d->qpe_main_widget, d->appName);
processEvents();
quit();
}
/*!
\internal
diff --git a/library/qpeapplication.h b/library/qpeapplication.h
index d2782e4..b07802f 100644
--- a/library/qpeapplication.h
+++ b/library/qpeapplication.h
@@ -91,180 +91,178 @@ public:
static void setDefaultRotation(int r);
static void setCurrentRotation(int r);
static void setCurrentMode(int x, int y, int depth );
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 showDialog( QDialog*, bool nomax=FALSE );
static int execDialog( QDialog*, bool nomax=FALSE );
static void showWidget( QWidget*, bool nomax=FALSE );
/* Merge setTempScreenSaverMode */
#ifdef QTOPIA_INTERNAL_INITAPP
void initApp( int argv, char **argv );
#endif
static void setKeepRunning();
bool keepRunning() const;
bool keyboardGrabbed() const;
int exec();
signals:
void clientMoused();
void timeChanged();
void clockChanged( bool pm );
void micChanged( bool muted );
void volumeChanged( bool muted );
void appMessage( const QCString& msg, const QByteArray& data);
void weekChanged( bool startOnMonday );
void dateFormatChanged( DateFormat );
void flush();
void reload();
/* linkChanged signal */
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 raiseAppropriateWindow();
virtual void tryQuit();
#ifndef OPIE_NO_ERASE_RECT_HACKFIX
#if QT_VERSION > 233
virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!)
#endif
#endif
private:
#ifndef QT_NO_TRANSLATION
void installTranslation( const QString& baseName );
#endif
void mapToDefaultAction( QWSKeyEvent *ke, int defKey );
void processQCopFile();
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
QCopChannel *sysChannel;
QCopChannel *pidChannel;
#endif
QPEApplicationData *d;
bool reserved_sh;
-
-
};
inline void QPEApplication::showDialog( QDialog* d, bool nomax )
{
showWidget( d, nomax );
}
inline int QPEApplication::execDialog( QDialog* d, bool nomax )
{
showDialog( d, nomax );
return d->exec();
}
#ifdef Q_WS_QWS
extern Q_EXPORT QRect qt_maxWindowRect;
#endif
inline void QPEApplication::showWidget( QWidget* wg, bool nomax )
{
if ( wg->isVisible() )
wg->show();
else
{
if ( !nomax
&& ( qApp->desktop()->width() <= 320 ) )
{
wg->showMaximized();
} else {
#ifdef Q_WS_QWS
QSize desk = QSize( qApp->desktop()->width(), qApp->desktop()->height() );
#else
QSize desk = QSize( qt_maxWindowRect.width(), qt_maxWindowRect.height() );
#endif
QSize sh = wg->sizeHint();
int w = QMAX( sh.width(), wg->width() );
int h = QMAX( sh.height(), wg->height() );
// desktop widget-frame taskbar
w = QMIN( w, ( desk.width() - ( wg->frameGeometry().width() - wg->geometry().width() ) - 25 ) );
h = QMIN( h, ( desk.height() - ( wg->frameGeometry().height() - wg->geometry().height() ) - 25 ) );
wg->resize( w, h );
wg->show();
}
}
}
enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */
inline int TransToDeg ( Transformation t )
{
int d = static_cast<int>( t );
return d * 90;
}
inline Transformation DegToTrans ( int d )
{
Transformation t = static_cast<Transformation>( d / 90 );
return t;
}
/*
* Set current rotation of Opie, and rotation for newly started apps.
* Differs from setDefaultRotation in that 1) it rotates currently running apps,
* and 2) does not set deforient or save orientation to qpe.conf.
*/
inline void QPEApplication::setCurrentRotation( int r )
{
// setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots
// for compatibility with the SharpROM use fallback to setDefaultTransformation()
#if QT_VERSION > 233
Transformation e = DegToTrans( r );
::setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
qApp->desktop()->qwsDisplay()->setTransformation( e );
#else
setDefaultRotation( r );
#endif
}
#endif