From a764eb8b193c5b6ac2261cb87dab4bd26d422c8b Mon Sep 17 00:00:00 2001 From: jihye Date: Mon, 28 Nov 2016 15:26:28 +0900 Subject: [PATCH] skin: make menu key button Change-Id: Ib98325f540a27db085169d855d61cbac2d2cec11 Signed-off-by: jihye --- tizen/src/ui/controller/dockingcontroller.cpp | 5 ++++ tizen/src/ui/controller/dockingcontroller.h | 1 + tizen/src/ui/controller/dockingconview.cpp | 9 ++++++ tizen/src/ui/controller/floatingcontroller.cpp | 6 ++++ tizen/src/ui/controller/floatingcontroller.h | 4 +++ tizen/src/ui/controller/floatingconview.cpp | 9 ++++++ tizen/src/ui/controller/generalpurposecon.cpp | 14 ++++++++- tizen/src/ui/controller/hwkeybutton.cpp | 35 +++++++++++++++++++--- tizen/src/ui/controller/hwkeybutton.h | 2 ++ tizen/src/ui/layout/controllerform.cpp | 5 ++++ tizen/src/ui/layout/controllerform.h | 2 ++ tizen/src/ui/layout/keycodetype.cpp | 4 +-- tizen/src/ui/resource/resource.qrc | 12 ++++++++ .../controller/key-window/layout.xml | 16 ++++++++++ .../controller/key-window/layout.xml | 16 ++++++++++ tizen/src/ui/skinpainter.cpp | 13 ++++++-- tizen/src/ui/skinpainter.h | 10 +++++-- tizen/src/ui/xmllayoutparser.cpp | 32 ++++++++++++++++++-- 18 files changed, 180 insertions(+), 15 deletions(-) diff --git a/tizen/src/ui/controller/dockingcontroller.cpp b/tizen/src/ui/controller/dockingcontroller.cpp index 51d4daf..ad06118 100644 --- a/tizen/src/ui/controller/dockingcontroller.cpp +++ b/tizen/src/ui/controller/dockingcontroller.cpp @@ -58,6 +58,11 @@ DockingConView *DockingController::getConView() return conView; } +MainWindow *DockingController::getMainWindow() +{ + return win; +} + int DockingController::getDockPos() { return dockPos; diff --git a/tizen/src/ui/controller/dockingcontroller.h b/tizen/src/ui/controller/dockingcontroller.h index cd16730..57bb4cb 100644 --- a/tizen/src/ui/controller/dockingcontroller.h +++ b/tizen/src/ui/controller/dockingcontroller.h @@ -48,6 +48,7 @@ public: ControllerForm *getConForm(); DockingConView *getConView(); + MainWindow *getMainWindow(); int getDockPos(); void updateGeometry(); diff --git a/tizen/src/ui/controller/dockingconview.cpp b/tizen/src/ui/controller/dockingconview.cpp index 98a0328..217108c 100644 --- a/tizen/src/ui/controller/dockingconview.cpp +++ b/tizen/src/ui/controller/dockingconview.cpp @@ -69,6 +69,15 @@ void DockingConView::createItems(ControllerForm *conForm) GeneralPurposeCon *generalCon = new GeneralPurposeCon(); QList buttons = generalCon->createButtons(parentWidget(), conForm); + + for (int i = 0; i < buttons.count(); i++) { + HWKeyButton *button = buttons.at(i); + if (button->getSlot() == NULL) { + continue; + } + connect(button, SIGNAL(clicked()), + parent->getMainWindow()->getPopupMenu(), button->getSlot()); + } } } diff --git a/tizen/src/ui/controller/floatingcontroller.cpp b/tizen/src/ui/controller/floatingcontroller.cpp index 1f807d8..238517f 100644 --- a/tizen/src/ui/controller/floatingcontroller.cpp +++ b/tizen/src/ui/controller/floatingcontroller.cpp @@ -33,6 +33,7 @@ FloatingController::FloatingController(ControllerForm *conForm, QAction *menu, QWidget *parent) : QDialog(parent) { + this->win = (MainWindow *)parent; this->conForm = conForm; this->menu = menu; @@ -57,6 +58,11 @@ FloatingConView *FloatingController::getConView() return conView; } +MainWindow *FloatingController::getMainWindow() +{ + return win; +} + /* override */ void FloatingController::showEvent(QShowEvent *event) { diff --git a/tizen/src/ui/controller/floatingcontroller.h b/tizen/src/ui/controller/floatingcontroller.h index 25c9121..9c91ffe 100644 --- a/tizen/src/ui/controller/floatingcontroller.h +++ b/tizen/src/ui/controller/floatingcontroller.h @@ -35,6 +35,8 @@ #include "layout/controllerform.h" #include "floatingconview.h" +class MainWindow; + class FloatingController : public QDialog { Q_OBJECT @@ -45,6 +47,7 @@ public: ControllerForm *getConForm(); FloatingConView *getConView(); + MainWindow *getMainWindow(); protected: void showEvent(QShowEvent *event); @@ -53,6 +56,7 @@ protected: void reject(); private: + MainWindow *win; FloatingConView *conView; ControllerForm *conForm; QAction *menu; diff --git a/tizen/src/ui/controller/floatingconview.cpp b/tizen/src/ui/controller/floatingconview.cpp index bf38d32..e4b9f80 100644 --- a/tizen/src/ui/controller/floatingconview.cpp +++ b/tizen/src/ui/controller/floatingconview.cpp @@ -69,6 +69,15 @@ void FloatingConView::createItems(ControllerForm *conForm) GeneralPurposeCon *generalCon = new GeneralPurposeCon(); QList buttons = generalCon->createButtons(parentWidget(), conForm); + + for (int i = 0; i < buttons.count(); i++) { + HWKeyButton *button = buttons.at(i); + if (button->getSlot() == NULL) { + continue; + } + connect(button, SIGNAL(clicked()), + parent->getMainWindow()->getPopupMenu(), button->getSlot()); + } } } diff --git a/tizen/src/ui/controller/generalpurposecon.cpp b/tizen/src/ui/controller/generalpurposecon.cpp index aacb467..e4925e2 100644 --- a/tizen/src/ui/controller/generalpurposecon.cpp +++ b/tizen/src/ui/controller/generalpurposecon.cpp @@ -44,13 +44,25 @@ QList GeneralPurposeCon::createButtons(QWidget *parent, Controlle topLeft.setY(topLeft.y() + GPC_HEAD_SPACING); QList buttonList; + // H/W key list createKeyList(parent, form->getKeyList(), topLeft, buttonList); + topLeft.setY(topLeft.y() + + (GPC_KEYBUTTON_VSPACING + GPC_KEYBUTTON_HEIGHT) * form->getKeyList().count()); + + // Menu key list + for (int i = 0; i < form->getSubFormList().count(); i++) { + ControllerForm *subForm = form->getSubFormList().at(i); + createKeyList(parent, subForm->getKeyList(), topLeft, buttonList); + topLeft.setY(topLeft.y() + + (GPC_KEYBUTTON_VSPACING + GPC_KEYBUTTON_HEIGHT) * subForm->getKeyList().count()); + } return buttonList; } -void GeneralPurposeCon::createKeyList(QWidget *parent, QList keyList, QPoint topLeft, QList &buttonList) +void GeneralPurposeCon::createKeyList(QWidget *parent, QList keyList, + QPoint topLeft, QList &buttonList) { HardwareKey *hwKey = NULL; HWKeyButton *keyButton = NULL; diff --git a/tizen/src/ui/controller/hwkeybutton.cpp b/tizen/src/ui/controller/hwkeybutton.cpp index 5b81849..16c109b 100644 --- a/tizen/src/ui/controller/hwkeybutton.cpp +++ b/tizen/src/ui/controller/hwkeybutton.cpp @@ -60,6 +60,24 @@ HWKeyButton::HWKeyButton(QWidget *parent, HardwareKey *hwKey, QSize size) : "color:#2E2E2E; background-color:#CCCCCC;" "}" ); + + //FIXME: set slot for menu button + if (hwKey->getKeycode() == 0) { + QString name = hwKey->getName(); + if (QString::compare(name, "Control Panel") == 0) { + slot = SLOT(slotControlPanel()); + } else if (QString::compare(name, "Screen Shot") == 0) { + slot = SLOT(slotRequestScreenshot()); + } else if (QString::compare(name, "Rotate") == 0) { + slot = SLOT(slotSwitchShortcutNext()); + } else if (QString::compare(name, "Shell") == 0) { + slot = SLOT(slotShell()); + } else { + slot = NULL; + } + } else { + slot = NULL; + } } /* override */ @@ -67,8 +85,10 @@ void HWKeyButton::mousePressEvent(QMouseEvent *event) { const int keycode = hwKey->getKeycode(); - qDebug() << hwKey->getName() << "key button pressed:" << keycode; - do_hw_key_event(KEY_PRESSED, keycode); + if (keycode > 0) { + qDebug() << hwKey->getName() << "key button pressed:" << keycode; + do_hw_key_event(KEY_PRESSED, keycode); + } QPushButton::mousePressEvent(event); } @@ -78,12 +98,19 @@ void HWKeyButton::mouseReleaseEvent(QMouseEvent *event) { const int keycode = hwKey->getKeycode(); - qDebug() << hwKey->getName() << "key button released:" << keycode; - do_hw_key_event(KEY_RELEASED, keycode); + if (keycode > 0) { + qDebug() << hwKey->getName() << "key button released:" << keycode; + do_hw_key_event(KEY_RELEASED, keycode); + } QPushButton::mouseReleaseEvent(event); } +const char *HWKeyButton::getSlot() +{ + return slot; +} + HWKeyButton::~HWKeyButton() { /* do nothing */ diff --git a/tizen/src/ui/controller/hwkeybutton.h b/tizen/src/ui/controller/hwkeybutton.h index b758c26..807ae0a 100644 --- a/tizen/src/ui/controller/hwkeybutton.h +++ b/tizen/src/ui/controller/hwkeybutton.h @@ -40,6 +40,7 @@ class HWKeyButton : public QPushButton public: HWKeyButton(QWidget *parent, HardwareKey *hwKey, QSize size); ~HWKeyButton(); + virtual const char *getSlot(); protected: void mousePressEvent(QMouseEvent *event); @@ -47,6 +48,7 @@ protected: private: HardwareKey *hwKey; + const char *slot; }; #endif // HWKEYBUTTON_H diff --git a/tizen/src/ui/layout/controllerform.cpp b/tizen/src/ui/layout/controllerform.cpp index 0cc8380..fffcf4d 100644 --- a/tizen/src/ui/layout/controllerform.cpp +++ b/tizen/src/ui/layout/controllerform.cpp @@ -44,6 +44,11 @@ QRect ControllerForm::getCenteralRect() return centeralRect; } +QList &ControllerForm::getSubFormList() +{ + return subFormList; +} + ControllerForm::~ControllerForm() { qDebug("destroy con layout"); diff --git a/tizen/src/ui/layout/controllerform.h b/tizen/src/ui/layout/controllerform.h index 45482b6..9cb3b4f 100644 --- a/tizen/src/ui/layout/controllerform.h +++ b/tizen/src/ui/layout/controllerform.h @@ -44,9 +44,11 @@ public: void setCenteralRect(const QRect &rect); QRect getCenteralRect(); + QList &getSubFormList(); private: QRect centeralRect; + QList subFormList; }; #endif // CONTROLLERFORM_H diff --git a/tizen/src/ui/layout/keycodetype.cpp b/tizen/src/ui/layout/keycodetype.cpp index fd8bf97..d59745e 100644 --- a/tizen/src/ui/layout/keycodetype.cpp +++ b/tizen/src/ui/layout/keycodetype.cpp @@ -51,8 +51,8 @@ KeycodeType::KeycodeType(int shortPress, int longPress) int KeycodeType::getShortPressKeycode() { - if (shortPress <= 0) { - qWarning() << "invalid short press keycode:" << shortPress; + if (shortPress < 0) { + qWarning() << "invalid short press key code:" << shortPress; } return shortPress; diff --git a/tizen/src/ui/resource/resource.qrc b/tizen/src/ui/resource/resource.qrc index b888348..637465b 100644 --- a/tizen/src/ui/resource/resource.qrc +++ b/tizen/src/ui/resource/resource.qrc @@ -36,6 +36,18 @@ images/controller-skin/VolumeUp_hover.png images/controller-skin/VolumeUp_normal.png images/controller-skin/VolumeUp_pushed.png + images/controller-skin/Shell_hover.png + images/controller-skin/Shell_normal.png + images/controller-skin/Shell_pushed.png + images/controller-skin/Rotate_hover.png + images/controller-skin/Rotate_normal.png + images/controller-skin/Rotate_pushed.png + images/controller-skin/Screen Shot_hover.png + images/controller-skin/Screen Shot_normal.png + images/controller-skin/Screen Shot_pushed.png + images/controller-skin/Control Panel_hover.png + images/controller-skin/Control Panel_normal.png + images/controller-skin/Control Panel_pushed.png icons/emulator_icon.ico icons/shell.png diff --git a/tizen/src/ui/resource/skins/mobile/mobile-general-3btn/controller/key-window/layout.xml b/tizen/src/ui/resource/skins/mobile/mobile-general-3btn/controller/key-window/layout.xml index e49c6ff..2145206 100644 --- a/tizen/src/ui/resource/skins/mobile/mobile-general-3btn/controller/key-window/layout.xml +++ b/tizen/src/ui/resource/skins/mobile/mobile-general-3btn/controller/key-window/layout.xml @@ -30,5 +30,21 @@ Ctrl+Shift+[ +
+ + + Ctrl+Shift+Left + + + Ctrl+Shift+S + + + Ctrl+Shift+P + + + Ctrl+Shift+F12 + + +
diff --git a/tizen/src/ui/resource/skins/wearable/wearable-general-2btn/controller/key-window/layout.xml b/tizen/src/ui/resource/skins/wearable/wearable-general-2btn/controller/key-window/layout.xml index f4db577..fbac90f 100644 --- a/tizen/src/ui/resource/skins/wearable/wearable-general-2btn/controller/key-window/layout.xml +++ b/tizen/src/ui/resource/skins/wearable/wearable-general-2btn/controller/key-window/layout.xml @@ -13,5 +13,21 @@ Ctrl+Shift+F8 +
+ + + Ctrl+Shift+Left + + + Ctrl+Shift+S + + + Ctrl+Shift+P + + + Ctrl+Shift+F12 + + +
diff --git a/tizen/src/ui/skinpainter.cpp b/tizen/src/ui/skinpainter.cpp index e55d3a2..c78d496 100644 --- a/tizen/src/ui/skinpainter.cpp +++ b/tizen/src/ui/skinpainter.cpp @@ -43,12 +43,12 @@ SkinPainter::SkinPainter(const QString &patchPath, drawSkin(path, centerPatch, degree, tagLeftTop, tagColor); } -SkinPainter::SkinPainter(QSize centerPatch, int degree) +SkinPainter::SkinPainter(QSize centerPatch, int degree, QList separators) { - drawSkin(centerPatch, degree); + drawSkin(centerPatch, degree, separators); } -void SkinPainter::drawSkin(QSize center, int degree) { +void SkinPainter::drawSkin(QSize center, int degree, QList separators) { qDebug() << "draw skin surface"; QRect centeralRect(0, 0, center.width(), center.height()); @@ -58,6 +58,13 @@ void SkinPainter::drawSkin(QSize center, int degree) { QPainter painter(&image); painter.fillRect(centeralRect, QBrush(QColor(244, 244, 244))); + // add separators + for (int i = 0; i < separators.count(); i++) { + Separator *s = separators.at(i); + painter.setPen(s->pen); + painter.drawLine(0, s->hOffset, center.width(), s->hOffset); + } + /* rotate */ QTransform transform; skin = new QPixmap(image.transformed(transform.rotate(degree))); diff --git a/tizen/src/ui/skinpainter.h b/tizen/src/ui/skinpainter.h index 8adde2d..03e91fc 100644 --- a/tizen/src/ui/skinpainter.h +++ b/tizen/src/ui/skinpainter.h @@ -34,12 +34,18 @@ #include "layout/displaytype.h" +struct Separator +{ + int hOffset; + QPen pen; +}; + class SkinPainter { public: SkinPainter(const QString &patchPath, QSize centerPatch, int degree, QPoint tagLeftTop, QColor tagColor); - SkinPainter(QSize centerPatch, int degree); + SkinPainter(QSize centerPatch, int degree, QList separators); ~SkinPainter(); QImage getSkinImage() const; @@ -48,7 +54,7 @@ public: private: void drawSkin(QString patchPath, QSize center, int degree, QPoint tagLeftTop, QColor tagColor); - void drawSkin(QSize center, int degree); + void drawSkin(QSize center, int degree, QList separators); QPixmap *skin; QRect centeralRect; diff --git a/tizen/src/ui/xmllayoutparser.cpp b/tizen/src/ui/xmllayoutparser.cpp index d7e82ce..59e81b1 100644 --- a/tizen/src/ui/xmllayoutparser.cpp +++ b/tizen/src/ui/xmllayoutparser.cpp @@ -720,6 +720,13 @@ ControllerForm *XmlLayoutParser::parseControllerForm( } else if (xml.name() == HOVER_KEYWORD) { /* hover */ form->setHoverType(parseHover(xml, depth + 1)); + } else if (xml.name() == FORM_KEYWORD) { + /* sub form */ + QWARN_INDENT(depth + 1) << "undefined element: " << xml.name(); + ControllerForm *subform = parseControllerForm(xml, depth + 1); + if (subform != NULL) { + form->getSubFormList().append(subform); + } } else { QWARN_INDENT(depth + 1) << "undefined element: " << xml.name(); } @@ -788,14 +795,33 @@ QString XmlLayoutParser::parseControllerUI(QXmlStreamReader &xml) void XmlLayoutParser::makeGeneralCon(ControllerForm *form) { - const int keyCount = form->getKeyList().count(); + int keyCount = form->getKeyList().count(); int width = GPC_KEYBUTTON_WIDTH + GPC_KEYBUTTON_HSPACING; int height = GPC_HEAD_SPACING; height += (GPC_KEYBUTTON_HEIGHT * keyCount) + - (GPC_KEYBUTTON_VSPACING * (keyCount - 1)) + GPC_TAIL_SPACING; + (GPC_KEYBUTTON_VSPACING * (keyCount - 1)); + + // add sub form + QList sList; + QPen pen(QColor(205, 205, 205), 1, Qt::SolidLine); + for (int i = 0; i < form->getSubFormList().count(); i++) { + // for separator + Separator *s = new Separator(); + s->pen = pen; + s->hOffset = height + GPC_KEYBUTTON_VSPACING / 2; + sList.append(s); + + ControllerForm *subForm = form->getSubFormList().at(i); + keyCount = subForm->getKeyList().count(); + + height += (GPC_KEYBUTTON_HEIGHT * keyCount) + + (GPC_KEYBUTTON_VSPACING * keyCount); + } + + height += GPC_TAIL_SPACING; - SkinPainter painter(QSize(width, qMax(height, QT_LAYOUT_MINIMUM - 20)), 0); + SkinPainter painter(QSize(width, qMax(height, QT_LAYOUT_MINIMUM - 20)), 0, sList); form->skinImg[LayoutForm::normal] = painter.getSkinImage(); form->setCenteralRect(painter.getCenteralRect()); -- 2.7.4