author | wimpie <wimpie> | 2004-08-25 01:47:35 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-08-25 01:47:35 (UTC) |
commit | f6a6fe57c9e0047379f4b8b40da4776f1c4d7b25 (patch) (side-by-side diff) | |
tree | 2db64e885b1a67058fa45533819993c8dcb4fb96 /library | |
parent | 49c47e98bed6e35d0bdc8e1e4cc40bdbb07eab06 (diff) | |
download | opie-f6a6fe57c9e0047379f4b8b40da4776f1c4d7b25.zip opie-f6a6fe57c9e0047379f4b8b40da4776f1c4d7b25.tar.gz opie-f6a6fe57c9e0047379f4b8b40da4776f1c4d7b25.tar.bz2 |
Final changes for RoH Feedback
- changed *.pro file to compile in backend
- some more fixes to rohfeedback and qpeapplication
-rw-r--r-- | library/backend/rohfeedback.cpp | 28 | ||||
-rw-r--r-- | library/backend/rohfeedback.h | 3 | ||||
-rw-r--r-- | library/config.in | 4 | ||||
-rw-r--r-- | library/library.pro | 6 | ||||
-rw-r--r-- | library/qpeapplication.cpp | 58 | ||||
-rw-r--r-- | library/qpeapplication.h | 2 |
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,19 +1,19 @@ -#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 @@ -22,104 +22,104 @@ namespace Internal { 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,19 +1,21 @@ #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; @@ -47,16 +49,17 @@ 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 @@ -34,32 +34,33 @@ HEADERS = calendar.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 \ @@ -93,45 +94,50 @@ SOURCES = calendar.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 @@ -84,74 +84,73 @@ #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; @@ -489,32 +488,33 @@ static void qpe_show_dialog( QDialog* d, bool nomax ) 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 { @@ -1202,34 +1202,36 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) 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( "../" ); } @@ -2022,70 +2024,69 @@ void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) /*! \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; @@ -2103,41 +2104,42 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 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 diff --git a/library/qpeapplication.h b/library/qpeapplication.h index d2782e4..b07802f 100644 --- a/library/qpeapplication.h +++ b/library/qpeapplication.h @@ -171,34 +171,32 @@ protected: #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 |