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 "dvorak.h"
00023 #include "dvorakimpl.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
00048 static const char * const opti_xpm[] = {
00049 "28 13 4 1",
00050 " c None",
00051 ". c #4C4C4C",
00052 "+ c #FFF7DD",
00053 "@ c #D6CFBA",
00054 " ......................... ",
00055 " .+++.+++.+++.+++.+++.+++. ",
00056 " .+@@.+@@.+@@.+@@.+@@.+@@. ",
00057 " ......................... ",
00058 " .+++.+++.+++.+++.+++.+++. ",
00059 " .+@@.+@@.+@@.+@@.+@@.+@@. ",
00060 " ......................... ",
00061 " .+++.+++.+++.+++.+++.+++. ",
00062 " .+@@.+@@.+@@.+@@.+@@.+@@. ",
00063 " ......................... ",
00064 " .+++.+++.+++.+++.+++.+++. ",
00065 " .+@@.+@@.+@@.+@@.+@@.+@@. ",
00066 " ......................... "};
00067
00068
00069
00070 KeyboardImpl::KeyboardImpl()
00071 : input(0), icn(0)
00072 {
00073 }
00074
00075 KeyboardImpl::~KeyboardImpl()
00076 {
00077 delete input;
00078 delete icn;
00079 }
00080
00081 QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f )
00082 {
00083 if ( !input )
00084 input = new Dvorak::Keyboard( parent, "Keyboard", f );
00085 return input;
00086 }
00087
00088 void KeyboardImpl::resetState()
00089 {
00090 if ( input )
00091 input->resetState();
00092 }
00093
00094 QPixmap *KeyboardImpl::icon()
00095 {
00096 if ( !icn )
00097 icn = new QPixmap( (const char **)kb_xpm );
00098 return icn;
00099 }
00100
00101 QString KeyboardImpl::name()
00102 {
00103 return qApp->translate( "InputMethods", "Dvorak" );
00104 }
00105
00106 void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot )
00107 {
00108 if ( input )
00109 QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
00110 }
00111
00112 #ifndef QT_NO_COMPONENT
00113 QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
00114 {
00115 *iface = 0;
00116 if ( uuid == IID_QUnknown )
00117 *iface = this;
00118 else if ( uuid == IID_InputMethod )
00119 *iface = this;
00120 else
00121 return QS_FALSE;
00122
00123 if ( *iface )
00124 (*iface)->addRef();
00125 return QS_OK;
00126 }
00127
00128 Q_EXPORT_INTERFACE()
00129 {
00130 Q_CREATE_INSTANCE( KeyboardImpl )
00131 }
00132 #endif