summaryrefslogtreecommitdiff
path: root/inputmethods/dasher/QtDasherPlugin.cc
blob: 91167c2b516f1b24b98b957415d7d3427309f26f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "QtDasherPlugin.h"

#include <qpe/global.h>
#include <qpe/qpeapplication.h>
 
#include <qpainter.h>
#include <qlist.h>
#include <qbitmap.h>
#include <qlayout.h>
#include <qvbox.h>
#include <qdialog.h>
#include <qfile.h>
#include <qscrollview.h>
#include <qpopupmenu.h>
#include <qhbuttongroup.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qwindowsystem_qws.h>

QtDasherPlugin::QtDasherPlugin(QWidget* parent, const char* name, WFlags f) : QFrame(parent,name,f)
{
  (new QHBoxLayout(this))->setAutoAdd(TRUE);
  interface = new CDasherInterface;
  interface->SetSystemLocation( QFile::encodeName(QPEApplication::qpeDir()+"share/dasher/").data() );
  interface->Unpause(0);
  interface->Start();  
  d = new QtDasherScreen(240,100,interface,this,this);
  interface->ChangeMaxBitRate(2.5);
  d->show();
  utf8_codec = new QUtf8Codec;
}

QSize QtDasherPlugin::sizeHint() const
{
  return QSize(240,100);
}

QtDasherPlugin::~QtDasherPlugin()
{
    delete interface;
}

void QtDasherPlugin::resetState()
{
  flushcount=0;
  interface->Start();
  interface->Redraw();
}

void QtDasherPlugin::unflush()
{
  if (flushcount==0)
    return;
  for (; flushcount>0; flushcount--) {
    deletetext();
  }
}

void QtDasherPlugin::output(int Symbol)
{
  std::string label = interface->GetEditText(Symbol);
  QString unicodestring = utf8_codec->toUnicode(label.c_str());
  for (int i=0; i<int(unicodestring.length()); i++) {
    emit key( unicodestring[i].unicode(), 0, 0, true, false );
    emit key( unicodestring[i].unicode(), 0, 0, false, false );
  }
}

void QtDasherPlugin::deletetext()
{
  emit key( 0, Qt::Key_Backspace, 0, true, false);
  emit key( 0, Qt::Key_Backspace, 0, false, false);
}

void QtDasherPlugin::flush(int Symbol)
{
  if (Symbol==0)
    return;
  output(Symbol);
  flushcount++;
}