From: GiWoong Kim Date: Fri, 31 Jul 2015 07:19:21 +0000 (+0900) Subject: hwkey: define additional attribute schema of XML for HW key long pressing X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~40^2~240 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d7f08b45708ea5523f678faf747675f61bda22a;p=sdk%2Femulator%2Fqemu.git hwkey: define additional attribute schema of XML for HW key long pressing ... 11 ... Change-Id: I21a3aa86fa30d96809e3b15f61801e09a54686b1 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/display/xmllayoutkeyword.h b/tizen/src/display/xmllayoutkeyword.h index 4392ad81cc..dd84f762c6 100644 --- a/tizen/src/display/xmllayoutkeyword.h +++ b/tizen/src/display/xmllayoutkeyword.h @@ -40,6 +40,7 @@ #define REGION_TOP_ATTR_KEYWORD "top" #define REGION_WIDTH_ATTR_KEYWORD "width" #define REGION_HEIGHT_ATTR_KEYWORD "height" +#define KEYCODE_LONGPRESS_ATTR_KEYWORD "longPress" #define EMULATOR_UI_KEYWORD "EmulatorUI" #define CONTROLLER_UI_KEYWORD "ControllerUI" diff --git a/tizen/src/display/xmllayoutparser.cpp b/tizen/src/display/xmllayoutparser.cpp index 0ce779efea..82ed1dfb9b 100644 --- a/tizen/src/display/xmllayoutparser.cpp +++ b/tizen/src/display/xmllayoutparser.cpp @@ -30,6 +30,7 @@ #include "xmllayoutparser.h" #include "xmllayoutkeyword.h" #include "skinpainter.h" +#include "layout/keycodetype.h" #include "controller/generalpurposecon.h" /* Qt Qlayout has a minimum size */ @@ -158,10 +159,22 @@ DisplayType *XmlLayoutParser::parseDisplay(QXmlStreamReader &xml) return new DisplayType(displayRect, angle, maskImage); } +KeycodeType *XmlLayoutParser::parseKeycode(QXmlStreamReader &xml) +{ + int longPress = -1, shortPress = 0; + + /* attribute */ + longPress = xml.attributes().value(KEYCODE_LONGPRESS_ATTR_KEYWORD).toString().toInt(); + + shortPress = xml.readElementText().toInt(); + + return new KeycodeType(shortPress, longPress); +} + HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml) { QRect keyRegion; - int keycode = 0; + KeycodeType *keycodeType = NULL; QString keyTooptip; QString keySequence; @@ -179,7 +192,7 @@ HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml) keyRegion = parseRegion(xml); } else if (xml.name() == KEYCODE_KEYWORD) { /* keycode */ - keycode = xml.readElementText().toInt(); + keycodeType = parseKeycode(xml); } else if (xml.name() == TOOLTIP_KEYWORD) { /* tooltip */ keyTooptip = xml.readElementText(); @@ -192,7 +205,7 @@ HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml) token = xml.readNext(); } - return new HardwareKey(keyName, keycode, keyRegion, keyTooptip, keySequence); + return new HardwareKey(keyName, keycodeType, keyRegion, keyTooptip, keySequence); } int XmlLayoutParser::parseKeyList( diff --git a/tizen/src/display/xmllayoutparser.h b/tizen/src/display/xmllayoutparser.h index 3155da9d30..6e01a0231f 100644 --- a/tizen/src/display/xmllayoutparser.h +++ b/tizen/src/display/xmllayoutparser.h @@ -33,11 +33,13 @@ #include #include "uiinformation.h" +#include "layout/keycodetype.h" #include "layout/mainform.h" +#include "layout/controllerform.h" #include "menu/menuitem.h" #include "menu/advancedmenuitem.h" #include "menu/scalemenuitem.h" -#include "layout/controllerform.h" + class XmlLayoutParser { @@ -52,6 +54,7 @@ private: HoverType *parseHover(QXmlStreamReader &xml); QRect parseRegion(QXmlStreamReader &xml); DisplayType *parseDisplay(QXmlStreamReader &xml); + KeycodeType *parseKeycode(QXmlStreamReader &xml); HardwareKey *parseKey(QXmlStreamReader &xml); int parseKeyList(QXmlStreamReader &xml, QList &list); MainForm *parseMainForm(QXmlStreamReader &xml); diff --git a/tizen/src/ui/controller/hwkeybutton.cpp b/tizen/src/ui/controller/hwkeybutton.cpp index ee5eecf627..d443b54d9a 100644 --- a/tizen/src/ui/controller/hwkeybutton.cpp +++ b/tizen/src/ui/controller/hwkeybutton.cpp @@ -27,6 +27,8 @@ * */ +#include + #include "hwkeybutton.h" extern "C" { @@ -58,18 +60,20 @@ HWKeyButton::HWKeyButton(QWidget *parent, HardwareKey *hwKey, QSize size) : void HWKeyButton::mousePressEvent(QMouseEvent *event) { - qDebug("HW key button pressed : %s", qPrintable(hwKey->name)); + const int keycode = hwKey->getKeycodeType()->getShortPressKeycode(); - do_hw_key_event(KEY_PRESSED, hwKey->keycode); + qDebug() << hwKey->name << "key button pressed:" << keycode; + do_hw_key_event(KEY_PRESSED, keycode); QPushButton::mousePressEvent(event); } void HWKeyButton::mouseReleaseEvent(QMouseEvent *event) { - qDebug("HW key button released : %s", qPrintable(hwKey->name)); + const int keycode = hwKey->getKeycodeType()->getShortPressKeycode(); - do_hw_key_event(KEY_RELEASED, hwKey->keycode); + qDebug() << hwKey->name << "key button released:" << keycode; + do_hw_key_event(KEY_RELEASED, keycode); QPushButton::mouseReleaseEvent(event); } diff --git a/tizen/src/ui/input/keyboardshortcut.cpp b/tizen/src/ui/input/keyboardshortcut.cpp index 872a84266a..9b71be3d72 100644 --- a/tizen/src/ui/input/keyboardshortcut.cpp +++ b/tizen/src/ui/input/keyboardshortcut.cpp @@ -411,7 +411,8 @@ int KeyboardShortcut::getHwKeyCode(QString item) for (index = 0; index < hwKeyList.count(); index++) { if (hwKeyList.at(index)->name.compare(item) == 0) { - keyCode = hwKeyList.at(index)->keycode; + keyCode = hwKeyList.at(index)-> + getKeycodeType()->getShortPressKeycode(); break; } } @@ -419,7 +420,8 @@ int KeyboardShortcut::getHwKeyCode(QString item) if (index == hwKeyList.count()) { for (index = 0; index < controllerKeyList.count(); index++) { if (controllerKeyList.at(index)->name.compare(item) == 0) { - keyCode = controllerKeyList.at(index)->keycode; + keyCode = controllerKeyList.at(index)-> + getKeycodeType()->getShortPressKeycode(); break; } } diff --git a/tizen/src/ui/layout/Makefile.objs b/tizen/src/ui/layout/Makefile.objs index b10587af56..dc0c9ddfc3 100644 --- a/tizen/src/ui/layout/Makefile.objs +++ b/tizen/src/ui/layout/Makefile.objs @@ -3,4 +3,5 @@ obj-$(CONFIG_QT) += mainform.o obj-$(CONFIG_QT) += controllerform.o obj-$(CONFIG_QT) += displaytype.o obj-$(CONFIG_QT) += hardwarekey.o -obj-$(CONFIG_QT) += hovertype.o \ No newline at end of file +obj-$(CONFIG_QT) += hovertype.o +obj-$(CONFIG_QT) += keycodetype.o \ No newline at end of file diff --git a/tizen/src/ui/layout/hardwarekey.cpp b/tizen/src/ui/layout/hardwarekey.cpp index ba09e5081b..4c087ec3e7 100644 --- a/tizen/src/ui/layout/hardwarekey.cpp +++ b/tizen/src/ui/layout/hardwarekey.cpp @@ -29,16 +29,33 @@ #include "hardwarekey.h" -HardwareKey::HardwareKey(QString name, int keycode, QRect region, QString tooltip, QString keySequence) +HardwareKey::HardwareKey(QString name, KeycodeType *keycodeType, + QRect region, QString tooltip, QString keySequence) { this->name = name; - this->keycode = keycode; + this->keycodeType = keycodeType; this->region = region; this->tooltip = tooltip; this->keySequence = keySequence; + + if (keycodeType == NULL) { + this->keycodeType = new KeycodeType(-1, -1); + } +} + +KeycodeType *HardwareKey::getKeycodeType() +{ + return keycodeType; +} + +bool HardwareKey::hasLongPressKeycode() +{ + return (keycodeType->getLongPressKeycode() > 0); } HardwareKey::~HardwareKey() { - /* do nothing */ + if (keycodeType != NULL) { + delete keycodeType; + } } diff --git a/tizen/src/ui/layout/hardwarekey.h b/tizen/src/ui/layout/hardwarekey.h index 4b85f75161..ac1a38a20c 100644 --- a/tizen/src/ui/layout/hardwarekey.h +++ b/tizen/src/ui/layout/hardwarekey.h @@ -32,17 +32,25 @@ #include +#include "layout/keycodetype.h" + class HardwareKey { public: - HardwareKey(QString name, int keycode, QRect region, QString tooltip, QString keySequence); + HardwareKey(QString name, KeycodeType *keycodeType, + QRect region, QString tooltip, QString keySequence); ~HardwareKey(); + KeycodeType *getKeycodeType(); + bool hasLongPressKeycode(); + QString name; - int keycode; QRect region; QString tooltip; QString keySequence; + +private: + KeycodeType *keycodeType; }; #endif // HARDWAREKEY_H diff --git a/tizen/src/ui/layout/keycodetype.cpp b/tizen/src/ui/layout/keycodetype.cpp new file mode 100644 index 0000000000..5974957b34 --- /dev/null +++ b/tizen/src/ui/layout/keycodetype.cpp @@ -0,0 +1,63 @@ +/* + * Qt UI + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include + +#include "keycodetype.h" + +KeycodeType::KeycodeType(int shortPress) +{ + this->shortPress = shortPress; + this->longPress = -1; +} + +KeycodeType::KeycodeType(int shortPress, int longPress) +{ + this->shortPress = shortPress; + this->longPress = longPress; +} + +int KeycodeType::getShortPressKeycode() +{ + if (shortPress <= 0) { + qWarning() << "invalid short press keycode:" << shortPress; + } + + return shortPress; +} + +int KeycodeType::getLongPressKeycode() +{ + return longPress; +} + +KeycodeType::~KeycodeType() +{ + /* do nothing */ +} diff --git a/tizen/src/ui/layout/keycodetype.h b/tizen/src/ui/layout/keycodetype.h new file mode 100644 index 0000000000..5de6677610 --- /dev/null +++ b/tizen/src/ui/layout/keycodetype.h @@ -0,0 +1,50 @@ +/* + * Qt UI + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef KEYCODETYPE_H +#define KEYCODETYPE_H + +#include + +class KeycodeType +{ +public: + KeycodeType(int shortPress); + KeycodeType(int shortPress, int longPress); + ~KeycodeType(); + + int getShortPressKeycode(); + int getLongPressKeycode(); + +private: + int shortPress; + int longPress; +}; + +#endif // KEYCODETYPE_H diff --git a/tizen/src/ui/skinkeyitem.cpp b/tizen/src/ui/skinkeyitem.cpp index 6cb5d36303..8431c0f90d 100644 --- a/tizen/src/ui/skinkeyitem.cpp +++ b/tizen/src/ui/skinkeyitem.cpp @@ -27,6 +27,8 @@ * */ +#include + #include "skinkeyitem.h" SkinKeyItem::SkinKeyItem(SkinBezelItem *parent, @@ -62,14 +64,16 @@ void SkinKeyItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { bezelParent->setHWKeyHandling(isPressed = true); - if (hwKey->keycode == LONGPRESS_KEYCODE) { + if (hwKey->hasLongPressKeycode() == true) { /* long press checking first */ longPressTimer->start(); return; } - qDebug("HW key pressed: %s", qPrintable(hwKey->name)); - do_hw_key_event(KEY_PRESSED, hwKey->keycode); + const int keycode = hwKey->getKeycodeType()->getShortPressKeycode(); + + qDebug() << hwKey->name << "key pressed:" << keycode; + do_hw_key_event(KEY_PRESSED, keycode); hoverPen.setColor(Qt::transparent); update(); @@ -80,22 +84,25 @@ void SkinKeyItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { bezelParent->setHWKeyHandling(isPressed = false); - const int keyCode = hwKey->keycode; - if (keyCode == LONGPRESS_KEYCODE) { + int keycode = hwKey->getKeycodeType()->getShortPressKeycode(); + + if (hwKey->hasLongPressKeycode() == true) { if (longPressTimer->remainingTime() <= 0) { /* long press */ - qDebug("HW key long pressed : %s", qPrintable(hwKey->name)); + keycode = hwKey->getKeycodeType()->getLongPressKeycode(); + qDebug() << hwKey->name << "key long pressed:" << keycode; } else { /* short press */ longPressTimer->stop(); - qDebug("HW key short pressed : %s", qPrintable(hwKey->name)); + + qDebug() << hwKey->name << "key short pressed:" << keycode; } - do_hw_key_event(KEY_PRESSED, keyCode); + do_hw_key_event(KEY_PRESSED, keycode); } - qDebug("HW key released: %s", qPrintable(hwKey->name)); - do_hw_key_event(KEY_RELEASED, keyCode); + qDebug() << hwKey->name << "key released:" << keycode; + do_hw_key_event(KEY_RELEASED, keycode); update(); } @@ -137,7 +144,7 @@ void SkinKeyItem::paint(QPainter *painter, void SkinKeyItem::longPressHook() { - qDebug("long press detected"); + qDebug("key long press detected"); /* do nothing */ } diff --git a/tizen/src/ui/skinkeyitem.h b/tizen/src/ui/skinkeyitem.h index 5dad7f74c1..85e1e0b71e 100644 --- a/tizen/src/ui/skinkeyitem.h +++ b/tizen/src/ui/skinkeyitem.h @@ -43,8 +43,6 @@ extern "C" { #include "emul_state.h" } -#define LONGPRESS_KEYCODE (-999) - class SkinKeyItem : public QObject, public QGraphicsRectItem { Q_OBJECT