00001 #include "QtDasherPlugin.h"
00002
00003 #include <qpe/global.h>
00004 #include <qpe/qpeapplication.h>
00005
00006 #include <qpainter.h>
00007 #include <qlist.h>
00008 #include <qbitmap.h>
00009 #include <qlayout.h>
00010 #include <qvbox.h>
00011 #include <qdialog.h>
00012 #include <qfile.h>
00013 #include <qscrollview.h>
00014 #include <qpopupmenu.h>
00015 #include <qhbuttongroup.h>
00016 #include <qpushbutton.h>
00017 #include <qmessagebox.h>
00018 #include <qwindowsystem_qws.h>
00019
00020 QtDasherPlugin::QtDasherPlugin(QWidget* parent, const char* name, WFlags f) : QFrame(parent,name,f)
00021 {
00022 (new QHBoxLayout(this))->setAutoAdd(TRUE);
00023 interface = new CDasherInterface;
00024 interface->SetSystemLocation( QFile::encodeName(QPEApplication::qpeDir()+"share/dasher/").data() );
00025 interface->Unpause(0);
00026 interface->Start();
00027 d = new QtDasherScreen(240,100,interface,this,this);
00028 interface->ChangeMaxBitRate(2.5);
00029 d->show();
00030 utf8_codec = new QUtf8Codec;
00031 }
00032
00033 QSize QtDasherPlugin::sizeHint() const
00034 {
00035 return QSize(240,100);
00036 }
00037
00038 QtDasherPlugin::~QtDasherPlugin()
00039 {
00040 delete interface;
00041 }
00042
00043 void QtDasherPlugin::resetState()
00044 {
00045 flushcount=0;
00046 interface->Start();
00047 interface->Redraw();
00048 }
00049
00050 void QtDasherPlugin::unflush()
00051 {
00052 if (flushcount==0)
00053 return;
00054 for (; flushcount>0; flushcount--) {
00055 deletetext();
00056 }
00057 }
00058
00059 void QtDasherPlugin::output(int Symbol)
00060 {
00061 std::string label = interface->GetEditText(Symbol);
00062 QString unicodestring = utf8_codec->toUnicode(label.c_str());
00063 for (int i=0; i<int(unicodestring.length()); i++) {
00064 emit key( unicodestring[i].unicode(), 0, 0, true, false );
00065 emit key( unicodestring[i].unicode(), 0, 0, false, false );
00066 }
00067 }
00068
00069 void QtDasherPlugin::deletetext()
00070 {
00071 emit key( 0, Qt::Key_Backspace, 0, true, false);
00072 emit key( 0, Qt::Key_Backspace, 0, false, false);
00073 }
00074
00075 void QtDasherPlugin::flush(int Symbol)
00076 {
00077 if (Symbol==0)
00078 return;
00079 output(Symbol);
00080 flushcount++;
00081 }