this->rotateAngle = displayForm->getAngle();
this->scaleFactor = scaleFactor;
this->isDragging = false;
+
this->tsHelper = new TouchScreenHelper(this);
+ MainWindow *win = (MainWindow *)widget->parentWidget();
+ win->getSkinView()->getKbdHelper()->setMtTracker(tsHelper->getMtTracker());
updateGeometry();
}
KeyboardHelper::KeyboardHelper(QWidget *parent)
{
this->parent = parent;
+ this->mtTracker = NULL;
this->numLockState = false;
this->capsLockState = false;
keyMap.insert(Qt::Key_F12, 88); /* f12 */
}
-void KeyboardHelper::finishMtTracking()
+void KeyboardHelper::setMtTracker(MultiTouchTracker *mtTracker)
{
- DisplayBase *display = ((MainWindow *)parent->parentWidget())->getDisplay();
- if (display != NULL) {
- display->getTouchScreenHelper()->finishMtTracking();
- }
+ this->mtTracker = mtTracker;
}
void KeyboardHelper::autoKeyRelease(void)
{
while (!keyCodeList.isEmpty()) {
- qDebug() << "auto release scancode : " << keyCodeList.last();
+ qDebug() << "auto release scancode :" << keyCodeList.last();
do_qt_keyboard_key_event(KEY_RELEASED, keyCodeList.last());
keyCodeList.removeLast();
qDebug() << "disable multi-touch";
set_multi_touch_enable(MultiTouchTracker::MT_OFF);
- finishMtTracking();
+ mtTracker->finishTracking();
}
}
}
if (keyMapIter == keyMap.end()) {
- qWarning() << "unsupported keycode pressed : " << keyCode;
+ qWarning() << "unsupported keycode pressed :" << keyCode;
return -1;
}
qDebug() << "disable multi-touch";
set_multi_touch_enable(MultiTouchTracker::MT_OFF);
- finishMtTracking();
+ mtTracker->finishTracking();
}
break;
event->nativeScanCode() << event->modifiers() << event->nativeModifiers();
/* multi-touch checking */
- if (get_emul_max_touch_point() > 1) {
+ if (mtTracker != NULL && get_emul_max_touch_point() > 1) {
pressFilterMtChecking(event);
/* fall through */
}
qDebug() << "disable multi-touch";
set_multi_touch_enable(MultiTouchTracker::MT_OFF);
- finishMtTracking();
+ mtTracker->finishTracking();
}
break;
qDebug() << "disable multi-touch";
set_multi_touch_enable(MultiTouchTracker::MT_OFF);
- finishMtTracking();
+ mtTracker->finishTracking();
}
break;
qDebug() << "disable multi-touch";
set_multi_touch_enable(MultiTouchTracker::MT_OFF);
- finishMtTracking();
+ mtTracker->finishTracking();
}
break;
event->nativeScanCode() << event->modifiers() << event->nativeModifiers();
/* multi-touch checking */
- if (get_emul_max_touch_point() > 1) {
+ if (mtTracker != NULL && get_emul_max_touch_point() > 1) {
releaseFilterMtChecking(event);
/* fall through */
}
}
#endif
- int ret = keyCodeOperation(event, keyCode);
+ const int ret = keyCodeOperation(event, keyCode);
if (ret != -1) {
do_qt_keyboard_key_event(KEY_RELEASED, ret);
/* remove keycode from list */
#include <QMap>
+#include "multitouchtracker.h"
+
enum KbdLedState {
OFF,
ON
KeyboardHelper(QWidget *parent);
~KeyboardHelper();
+ void setMtTracker(MultiTouchTracker *mtTracker);
void keyPressed(QKeyEvent *event);
void keyReleased(QKeyEvent *event);
void autoKeyRelease(void);
protected:
QWidget *parent;
+ MultiTouchTracker *mtTracker;
+
QList<int> keyCodeList;
QMap<int, int> keyMap;
QMap<int, int> keypadMap;
void createKeyMap();
void createKeypadMap();
- void finishMtTracking();
void pressFilterMtChecking(QKeyEvent *event);
void releaseFilterMtChecking(QKeyEvent *event);
};
return parent;
}
+MultiTouchTracker *TouchScreenHelper::getMtTracker()
+{
+ return mtTracker;
+}
+
void TouchScreenHelper::mousePressed(QMouseEvent *event, QPoint guestPos)
{
/* multi-touch processing */
virtio_touchscreen_event(guestPos.x(), guestPos.y(), 0, 1);
}
-void TouchScreenHelper::finishMtTracking()
-{
- mtTracker->finishTracking();
-}
-
TouchScreenHelper::~TouchScreenHelper()
{
qDebug("destroy touch screen helper");
~TouchScreenHelper();
void *getParent();
+ MultiTouchTracker *getMtTracker();
+
void mousePressed(QMouseEvent *event, QPoint guestPos);
void mouseReleased(QMouseEvent *event, QPoint guestPos);
void mouseMoved(QMouseEvent *event, QPoint guestPos);
- void finishMtTracking();
-
private:
void *parent;
MultiTouchTracker *mtTracker;
return &(uiInfo->uiState);
}
+SkinView *MainWindow::getSkinView()
+{
+ return skinView;
+}
+
ContextMenu *MainWindow::getPopupMenu()
{
return popupMenu;
~MainWindow();
UIState *getUIState(void);
+ SkinView *getSkinView();
ContextMenu *getPopupMenu();
DisplayBase *getDisplay();
KeyboardShortcut *getKeyboardShortcut();
SkinView::SkinView(QGraphicsScene *scene, QWidget *parent) :
QGraphicsView(scene, parent)
{
- setStyleSheet("border-style: none");
+ this->win = ((MainWindow *)parent);
+ this->kbdHelper = new KeyboardHelper(this);
+ this->grabWinPos = QPoint(-1, -1);
+ this->grabPos = QPoint(-1, -1);
+ setStyleSheet("border-style: none");
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setAlignment(Qt::AlignLeft | Qt::AlignTop);
- this->win = ((MainWindow *)parent);
- this->grabWinPos = QPoint(-1, -1);
- this->grabPos = QPoint(-1, -1);
-
updateLayout();
-
- kbd = new KeyboardHelper(this);
}
void SkinView::createItems(MainForm *form)
}
}
+KeyboardHelper *SkinView::getKbdHelper()
+{
+ return kbdHelper;
+}
+
void SkinView::updateLayout()
{
scene()->clear();
createItems(win->uiInfo->getMainForm());
}
+/* override */
void SkinView::resizeEvent(QResizeEvent *event)
{
qDebug() << "resize skin view :" << size();
QGraphicsView::resizeEvent(event);
}
+/* override */
void SkinView::mousePressEvent(QMouseEvent *event)
{
//qDebug("pressed %dx%d", event->x(), event->y());
if (event->button() == Qt::LeftButton) {
- //qDebug("grab");
-
grabWinPos = parentWidget()->pos();
grabPos = event->globalPos();
}
QGraphicsView::mousePressEvent(event);
}
+/* override */
void SkinView::mouseReleaseEvent(QMouseEvent *event)
{
//qDebug("released %dx%d", event->x(), event->y());
if (event->button() == Qt::LeftButton) {
- //qDebug("unloose");
-
grabPos = QPoint(-1, -1);
}
QGraphicsView::mouseReleaseEvent(event);
}
+/* override */
void SkinView::mouseMoveEvent(QMouseEvent *event)
{
if (grabPos != QPoint(-1, -1)) {
QGraphicsView::mouseMoveEvent(event);
}
+/* override */
void SkinView::focusOutEvent(QFocusEvent *event)
{
qDebug() << "focus out!";
- kbd->autoKeyRelease();
+ kbdHelper->autoKeyRelease();
}
+/* override */
void SkinView::keyPressEvent(QKeyEvent *event)
{
- kbd->keyPressed(event);
+ kbdHelper->keyPressed(event);
}
+/* override */
void SkinView::keyReleaseEvent(QKeyEvent *event)
{
- kbd->keyReleased(event);
+ kbdHelper->keyReleased(event);
}
SkinView::~SkinView()
{
qDebug("destroy skin view");
- if (kbd != NULL) {
- delete kbd;
+ if (kbdHelper != NULL) {
+ delete kbdHelper;
}
}
SkinView(QGraphicsScene *scene, QWidget *parent = 0);
~SkinView();
+ KeyboardHelper *getKbdHelper();
void updateLayout();
protected:
void focusOutEvent(QFocusEvent *event);
MainWindow *win;
+ KeyboardHelper *kbdHelper;
+
QPoint grabWinPos;
QPoint grabPos;
- KeyboardHelper *kbd;
private:
void createItems(MainForm *form);