summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--examples/config.in4
-rw-r--r--examples/example.pro12
-rw-r--r--examples/exampleboardimpl.cpp157
-rw-r--r--examples/exampleboardimpl.h50
-rw-r--r--examples/inputmethod/config.in4
-rw-r--r--examples/inputmethod/example.pro12
-rw-r--r--examples/inputmethod/exampleboardimpl.cpp157
-rw-r--r--examples/inputmethod/exampleboardimpl.h50
8 files changed, 446 insertions, 0 deletions
diff --git a/examples/config.in b/examples/config.in
new file mode 100644
index 0000000..7afe926
--- a/dev/null
+++ b/examples/config.in
@@ -0,0 +1,4 @@
+ config EXAMPLE_BOARD
+ boolean "Input Method"
+ default "y"
+ depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE
diff --git a/examples/example.pro b/examples/example.pro
new file mode 100644
index 0000000..3c003af
--- a/dev/null
+++ b/examples/example.pro
@@ -0,0 +1,12 @@
+TEMPLATE = lib
+CONFIG += qt plugin warn_on release
+HEADERS = exampleboardimpl.h
+SOURCES = exampleboardimpl.cpp
+TARGET = example_board
+DESTDIR = $(OPIEDIR)/plugins/inputmethods
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += ../$(OPIEDIR)/include ../../launcher
+LIBS += -lqpe
+VERSION = 1.0.0
+
+include ( $(OPIEDIR)/include.pro )
diff --git a/examples/exampleboardimpl.cpp b/examples/exampleboardimpl.cpp
new file mode 100644
index 0000000..36989a2
--- a/dev/null
+++ b/examples/exampleboardimpl.cpp
@@ -0,0 +1,157 @@
+#include <qwidget.h>
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qsignalmapper.h>
+#include <qpushbutton.h>
+#include <qpe/resource.h>
+
+#include "exampleboardimpl.h"
+
+ExampleBoard::ExampleBoard(QWidget* par, WFlags fl )
+ : QHBox(par, "name", fl )
+{
+ QCheckBox *box1 = new QCheckBox(tr("Alt"),this);
+ connect(box1,SIGNAL(toggled(bool)),
+ this,SLOT(slotAlt(bool)));
+ m_alt = box1;
+ box1 = new QCheckBox(tr("Shift"),this );
+ connect(box1,SIGNAL(toggled(bool)),
+ this,SLOT(slotShift(bool)));
+ m_shi = box1;
+ box1 = new QCheckBox(tr("Ctrl","Control Shortcut on keyboard"),this );
+ connect(box1,SIGNAL(toggled(bool)),
+ this,SLOT(slotCtrl(bool)));
+ m_ctrl = box1;
+
+ QSignalMapper *map = new QSignalMapper(this);
+ QPushButton *btn = new QPushButton("a",this);
+ map->setMapping(btn,0);
+ connect(btn,SIGNAL(clicked()),map,SLOT(map()));
+
+ btn = new QPushButton("b",this);
+ map->setMapping(btn,1);
+ connect(btn,SIGNAL(clicked()),map,SLOT(map()));
+
+ btn = new QPushButton("c",this);
+ map->setMapping(btn,2);
+ connect(btn,SIGNAL(clicked()),map,SLOT(map()));
+
+ connect(map,SIGNAL(mapped(int)),
+ this,SLOT(slotKey(int)));
+ resetState();
+}
+
+ExampleBoard::~ExampleBoard(){
+}
+
+void ExampleBoard::resetState(){
+ m_state = 0;
+ m_shi->setChecked(false);
+ m_ctrl->setChecked(false);
+ m_alt->setChecked(false);
+}
+
+void ExampleBoard::slotKey(int _ke){
+ int ke = _ke + 0x61; // 0 + 65 = 0x41 == A
+ if(m_state & ShiftButton )
+ ke -= 0x20;
+
+ /*
+ * Send the key
+ * ke is the unicode
+ * _ke + 0x41 is the keycode
+ * m_state Normally the state
+ * down/up
+ * auto repeat
+ */
+ emit key(ke, _ke +0x41,m_state,true,false);
+ emit key(ke, _ke + 0x41,m_state,false,false);
+}
+
+void ExampleBoard::slotShift(bool b){
+ if(b)
+ m_state |= ShiftButton;
+ else
+ m_state &= ~ShiftButton;
+}
+
+void ExampleBoard::slotAlt(bool b){
+ if(b)
+ m_state |= AltButton;
+ else
+ m_state &= ~AltButton;
+}
+
+void ExampleBoard::slotCtrl(bool b){
+ if(b)
+ m_state |= ControlButton;
+ else
+ m_state &= ~ControlButton;
+}
+
+
+
+ExampleboardImpl::ExampleboardImpl()
+ : m_pickboard(0), m_icn(0)
+{
+}
+
+ExampleboardImpl::~ExampleboardImpl()
+{
+ delete m_pickboard;
+ delete m_icn;
+}
+
+QWidget *ExampleboardImpl::inputMethod( QWidget *parent, Qt::WFlags f )
+{
+ if ( !m_pickboard )
+ m_pickboard = new ExampleBoard( parent, f );
+ return m_pickboard;
+}
+
+void ExampleboardImpl::resetState()
+{
+ if ( m_pickboard )
+ m_pickboard->resetState();
+}
+
+QPixmap *ExampleboardImpl::icon()
+{
+ if ( !m_icn )
+ m_icn = new QPixmap(Resource::loadPixmap("Tux"));
+ return m_icn;
+}
+
+QString ExampleboardImpl::name()
+{
+ return QObject::tr("Example Input");
+}
+
+void ExampleboardImpl::onKeyPress( QObject *receiver, const char *slot )
+{
+ if ( m_pickboard )
+ QObject::connect( m_pickboard, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
+}
+
+#ifndef QT_NO_COMPONENT
+QRESULT ExampleboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = this;
+ else if ( uuid == IID_InputMethod )
+ *iface = this;
+ else
+ return QS_FALSE;
+
+ if ( *iface )
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( ExampleboardImpl )
+}
+#endif
+
diff --git a/examples/exampleboardimpl.h b/examples/exampleboardimpl.h
new file mode 100644
index 0000000..37e2a5f
--- a/dev/null
+++ b/examples/exampleboardimpl.h
@@ -0,0 +1,50 @@
+#ifndef EXAMPLEBOARDIMPL_H
+#define EXAMPLEBOARDIMPL_H
+
+#include <qhbox.h>
+
+#include <qpe/inputmethodinterface.h>
+
+class QPixmap;
+class QCheckBox;
+class ExampleBoard : public QHBox {
+ Q_OBJECT
+public:
+ ExampleBoard( QWidget *par, WFlags f );
+ ~ExampleBoard();
+ void resetState();
+private slots:
+ void slotKey(int);
+ void slotShift(bool);
+ void slotAlt(bool);
+ void slotCtrl(bool);
+signals:
+ void key(ushort,ushort,ushort,bool,bool);
+private:
+ int m_state;
+ QCheckBox *m_alt,*m_shi,*m_ctrl;
+};
+
+class ExampleboardImpl : public InputMethodInterface
+{
+public:
+ ExampleboardImpl();
+ virtual ~ExampleboardImpl();
+
+#ifndef QT_NO_COMPONENT
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT
+#endif
+
+ virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f );
+ virtual void resetState();
+ virtual QPixmap *icon();
+ virtual QString name();
+ virtual void onKeyPress( QObject *receiver, const char *slot );
+
+private:
+ ExampleBoard *m_pickboard;
+ QPixmap *m_icn;
+};
+
+#endif
diff --git a/examples/inputmethod/config.in b/examples/inputmethod/config.in
new file mode 100644
index 0000000..7afe926
--- a/dev/null
+++ b/examples/inputmethod/config.in
@@ -0,0 +1,4 @@
+ config EXAMPLE_BOARD
+ boolean "Input Method"
+ default "y"
+ depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE
diff --git a/examples/inputmethod/example.pro b/examples/inputmethod/example.pro
new file mode 100644
index 0000000..3c003af
--- a/dev/null
+++ b/examples/inputmethod/example.pro
@@ -0,0 +1,12 @@
+TEMPLATE = lib
+CONFIG += qt plugin warn_on release
+HEADERS = exampleboardimpl.h
+SOURCES = exampleboardimpl.cpp
+TARGET = example_board
+DESTDIR = $(OPIEDIR)/plugins/inputmethods
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += ../$(OPIEDIR)/include ../../launcher
+LIBS += -lqpe
+VERSION = 1.0.0
+
+include ( $(OPIEDIR)/include.pro )
diff --git a/examples/inputmethod/exampleboardimpl.cpp b/examples/inputmethod/exampleboardimpl.cpp
new file mode 100644
index 0000000..36989a2
--- a/dev/null
+++ b/examples/inputmethod/exampleboardimpl.cpp
@@ -0,0 +1,157 @@
+#include <qwidget.h>
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qsignalmapper.h>
+#include <qpushbutton.h>
+#include <qpe/resource.h>
+
+#include "exampleboardimpl.h"
+
+ExampleBoard::ExampleBoard(QWidget* par, WFlags fl )
+ : QHBox(par, "name", fl )
+{
+ QCheckBox *box1 = new QCheckBox(tr("Alt"),this);
+ connect(box1,SIGNAL(toggled(bool)),
+ this,SLOT(slotAlt(bool)));
+ m_alt = box1;
+ box1 = new QCheckBox(tr("Shift"),this );
+ connect(box1,SIGNAL(toggled(bool)),
+ this,SLOT(slotShift(bool)));
+ m_shi = box1;
+ box1 = new QCheckBox(tr("Ctrl","Control Shortcut on keyboard"),this );
+ connect(box1,SIGNAL(toggled(bool)),
+ this,SLOT(slotCtrl(bool)));
+ m_ctrl = box1;
+
+ QSignalMapper *map = new QSignalMapper(this);
+ QPushButton *btn = new QPushButton("a",this);
+ map->setMapping(btn,0);
+ connect(btn,SIGNAL(clicked()),map,SLOT(map()));
+
+ btn = new QPushButton("b",this);
+ map->setMapping(btn,1);
+ connect(btn,SIGNAL(clicked()),map,SLOT(map()));
+
+ btn = new QPushButton("c",this);
+ map->setMapping(btn,2);
+ connect(btn,SIGNAL(clicked()),map,SLOT(map()));
+
+ connect(map,SIGNAL(mapped(int)),
+ this,SLOT(slotKey(int)));
+ resetState();
+}
+
+ExampleBoard::~ExampleBoard(){
+}
+
+void ExampleBoard::resetState(){
+ m_state = 0;
+ m_shi->setChecked(false);
+ m_ctrl->setChecked(false);
+ m_alt->setChecked(false);
+}
+
+void ExampleBoard::slotKey(int _ke){
+ int ke = _ke + 0x61; // 0 + 65 = 0x41 == A
+ if(m_state & ShiftButton )
+ ke -= 0x20;
+
+ /*
+ * Send the key
+ * ke is the unicode
+ * _ke + 0x41 is the keycode
+ * m_state Normally the state
+ * down/up
+ * auto repeat
+ */
+ emit key(ke, _ke +0x41,m_state,true,false);
+ emit key(ke, _ke + 0x41,m_state,false,false);
+}
+
+void ExampleBoard::slotShift(bool b){
+ if(b)
+ m_state |= ShiftButton;
+ else
+ m_state &= ~ShiftButton;
+}
+
+void ExampleBoard::slotAlt(bool b){
+ if(b)
+ m_state |= AltButton;
+ else
+ m_state &= ~AltButton;
+}
+
+void ExampleBoard::slotCtrl(bool b){
+ if(b)
+ m_state |= ControlButton;
+ else
+ m_state &= ~ControlButton;
+}
+
+
+
+ExampleboardImpl::ExampleboardImpl()
+ : m_pickboard(0), m_icn(0)
+{
+}
+
+ExampleboardImpl::~ExampleboardImpl()
+{
+ delete m_pickboard;
+ delete m_icn;
+}
+
+QWidget *ExampleboardImpl::inputMethod( QWidget *parent, Qt::WFlags f )
+{
+ if ( !m_pickboard )
+ m_pickboard = new ExampleBoard( parent, f );
+ return m_pickboard;
+}
+
+void ExampleboardImpl::resetState()
+{
+ if ( m_pickboard )
+ m_pickboard->resetState();
+}
+
+QPixmap *ExampleboardImpl::icon()
+{
+ if ( !m_icn )
+ m_icn = new QPixmap(Resource::loadPixmap("Tux"));
+ return m_icn;
+}
+
+QString ExampleboardImpl::name()
+{
+ return QObject::tr("Example Input");
+}
+
+void ExampleboardImpl::onKeyPress( QObject *receiver, const char *slot )
+{
+ if ( m_pickboard )
+ QObject::connect( m_pickboard, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
+}
+
+#ifndef QT_NO_COMPONENT
+QRESULT ExampleboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = this;
+ else if ( uuid == IID_InputMethod )
+ *iface = this;
+ else
+ return QS_FALSE;
+
+ if ( *iface )
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( ExampleboardImpl )
+}
+#endif
+
diff --git a/examples/inputmethod/exampleboardimpl.h b/examples/inputmethod/exampleboardimpl.h
new file mode 100644
index 0000000..37e2a5f
--- a/dev/null
+++ b/examples/inputmethod/exampleboardimpl.h
@@ -0,0 +1,50 @@
+#ifndef EXAMPLEBOARDIMPL_H
+#define EXAMPLEBOARDIMPL_H
+
+#include <qhbox.h>
+
+#include <qpe/inputmethodinterface.h>
+
+class QPixmap;
+class QCheckBox;
+class ExampleBoard : public QHBox {
+ Q_OBJECT
+public:
+ ExampleBoard( QWidget *par, WFlags f );
+ ~ExampleBoard();
+ void resetState();
+private slots:
+ void slotKey(int);
+ void slotShift(bool);
+ void slotAlt(bool);
+ void slotCtrl(bool);
+signals:
+ void key(ushort,ushort,ushort,bool,bool);
+private:
+ int m_state;
+ QCheckBox *m_alt,*m_shi,*m_ctrl;
+};
+
+class ExampleboardImpl : public InputMethodInterface
+{
+public:
+ ExampleboardImpl();
+ virtual ~ExampleboardImpl();
+
+#ifndef QT_NO_COMPONENT
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT
+#endif
+
+ virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f );
+ virtual void resetState();
+ virtual QPixmap *icon();
+ virtual QString name();
+ virtual void onKeyPress( QObject *receiver, const char *slot );
+
+private:
+ ExampleBoard *m_pickboard;
+ QPixmap *m_icn;
+};
+
+#endif