00001 #include <iostream>
00002 #include <qapplication.h>
00003 #include <qobject.h>
00004 #include <qpixmap.h>
00005 #include "DasherInterface.h"
00006 #include "QtDasherScreen.h"
00007 #include "QtDasherImpl.h"
00008
00009
00010 static const char * qtdasher_xpm[]={
00011 "28 7 2 1",
00012 "# c #303030",
00013 " c None",
00014 " ########################## ",
00015 " ",
00016 " # # ",
00017 " # # # # ",
00018 " # # # # ",
00019 " # # # ",
00020 " ########################## "};
00021
00022
00023 QtDasherImpl::QtDasherImpl()
00024 : qtdasherinterface(0), qtdasherwidget(0), icn(0)
00025 {
00026 }
00027
00028 QtDasherImpl::~QtDasherImpl()
00029 {
00030 delete qtdasherwidget;
00031 delete icn;
00032 }
00033
00034 QWidget *QtDasherImpl::inputMethod( QWidget *parent, Qt::WFlags f )
00035 {
00036 if ( !qtdasherwidget ) {
00037 qtdasherwidget = new QtDasherPlugin( parent, "Dasher", f );
00038 }
00039 return qtdasherwidget;
00040 }
00041
00042 void QtDasherImpl::resetState()
00043 {
00044 if ( qtdasherwidget )
00045 qtdasherwidget->resetState();
00046 }
00047
00048 QPixmap *QtDasherImpl::icon()
00049 {
00050 if ( !icn )
00051 icn = new QPixmap( (const char **)qtdasher_xpm );
00052 return icn;
00053 }
00054
00055 QString QtDasherImpl::name()
00056 {
00057 return qApp->translate( "InputMethods", "Dasher" );
00058 }
00059
00060 void QtDasherImpl::onKeyPress( QObject *receiver, const char *slot )
00061 {
00062 if ( qtdasherwidget )
00063 QObject::connect( qtdasherwidget, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
00064 }
00065
00066 #ifndef QT_NO_COMPONENT
00067 QRESULT QtDasherImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
00068 {
00069 *iface = 0;
00070 if ( uuid == IID_QUnknown )
00071 *iface = this;
00072 else if ( uuid == IID_InputMethod )
00073 *iface = this;
00074 else
00075 return QS_FALSE;
00076
00077 if ( *iface )
00078 (*iface)->addRef();
00079 return QS_OK;
00080 }
00081
00082 Q_EXPORT_INTERFACE()
00083 {
00084 Q_CREATE_INSTANCE( QtDasherImpl )
00085 }
00086 #endif
00087