00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <qapplication.h>
00021 #include <qpixmap.h>
00022 #include "keyboard.h"
00023 #include "keyboardimpl.h"
00024
00025
00026 static const char * const kb_xpm[] = {
00027 "28 13 4 1",
00028 " c None",
00029 ". c #4C4C4C",
00030 "+ c #FFF7DD",
00031 "@ c #D6CFBA",
00032 " .......................... ",
00033 " .+++.+++.+++.+++.+++.++++. ",
00034 " .+@@.+@@.+@@.+@@.+@@.+@@@. ",
00035 " .......................... ",
00036 " .+++++.+++.+++.+++.++++++. ",
00037 " .+@@@@.+@@.+@@.+@@.+@@@@@. ",
00038 " .......................... ",
00039 " .++++++.+++.+++.+++.+++++. ",
00040 " .+@@@@@.+@@.+@@.+@@.+@@@@. ",
00041 " .......................... ",
00042 " .++++.++++++++++++++.++++. ",
00043 " .+@@@.+@@@@@@@@@@@@@.+@@@. ",
00044 " .......................... "};
00045
00046
00047 KeyboardImpl::KeyboardImpl()
00048 : input(0), icn(0)
00049 {
00050 }
00051
00052 KeyboardImpl::~KeyboardImpl()
00053 {
00054 delete input;
00055 delete icn;
00056 }
00057
00058 QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f )
00059 {
00060 if ( !input )
00061 input = new MultiKey::Keyboard( parent, "Keyboard", f );
00062 return input;
00063 }
00064
00065 void KeyboardImpl::resetState()
00066 {
00067 if ( input )
00068 input->resetState();
00069 }
00070
00071 QPixmap *KeyboardImpl::icon()
00072 {
00073 if ( !icn )
00074 icn = new QPixmap( (const char **)kb_xpm );
00075 return icn;
00076 }
00077
00078 QString KeyboardImpl::name()
00079 {
00080 return qApp->translate( "InputMethods", "Multikey" );
00081 }
00082
00083 void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot )
00084 {
00085 if ( input )
00086 QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
00087 }
00088
00089 #ifndef QT_NO_COMPONENT
00090 QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
00091 {
00092 *iface = 0;
00093 if ( uuid == IID_QUnknown )
00094 *iface = this;
00095 else if ( uuid == IID_InputMethod )
00096 *iface = this;
00097 else
00098 return QS_FALSE;
00099
00100 if ( *iface )
00101 (*iface)->addRef();
00102 return QS_OK;
00103 }
00104
00105 Q_EXPORT_INTERFACE()
00106 {
00107 Q_CREATE_INSTANCE( KeyboardImpl )
00108 }
00109 #endif