skin: make menu key button
authorjihye <jihye424.kim@samsung.com>
Mon, 28 Nov 2016 06:26:28 +0000 (15:26 +0900)
committerjihye <jihye424.kim@samsung.com>
Wed, 1 Feb 2017 10:53:34 +0000 (19:53 +0900)
Change-Id: Ib98325f540a27db085169d855d61cbac2d2cec11
Signed-off-by: jihye <jihye424.kim@samsung.com>
18 files changed:
tizen/src/ui/controller/dockingcontroller.cpp
tizen/src/ui/controller/dockingcontroller.h
tizen/src/ui/controller/dockingconview.cpp
tizen/src/ui/controller/floatingcontroller.cpp
tizen/src/ui/controller/floatingcontroller.h
tizen/src/ui/controller/floatingconview.cpp
tizen/src/ui/controller/generalpurposecon.cpp
tizen/src/ui/controller/hwkeybutton.cpp
tizen/src/ui/controller/hwkeybutton.h
tizen/src/ui/layout/controllerform.cpp
tizen/src/ui/layout/controllerform.h
tizen/src/ui/layout/keycodetype.cpp
tizen/src/ui/resource/resource.qrc
tizen/src/ui/resource/skins/mobile/mobile-general-3btn/controller/key-window/layout.xml
tizen/src/ui/resource/skins/wearable/wearable-general-2btn/controller/key-window/layout.xml
tizen/src/ui/skinpainter.cpp
tizen/src/ui/skinpainter.h
tizen/src/ui/xmllayoutparser.cpp

index 51d4daf0f500d8d704173bd6318585d363a06e81..ad06118f5c288c18d1ea77619a89f26376837b33 100644 (file)
@@ -58,6 +58,11 @@ DockingConView *DockingController::getConView()
     return conView;
 }
 
+MainWindow *DockingController::getMainWindow()
+{
+    return win;
+}
+
 int DockingController::getDockPos()
 {
     return dockPos;
index cd1673034ab970344b17315b7348afe67464d9fe..57bb4cb26638674094bf71aa2a9b1db1d2df5375 100644 (file)
@@ -48,6 +48,7 @@ public:
 
     ControllerForm *getConForm();
     DockingConView *getConView();
+    MainWindow *getMainWindow();
     int getDockPos();
     void updateGeometry();
 
index 98a032858ce2a03de3153a4656effa81850c3f94..217108c634f7b42546108425337f31ba5d4b4c7c 100644 (file)
@@ -69,6 +69,15 @@ void DockingConView::createItems(ControllerForm *conForm)
         GeneralPurposeCon *generalCon = new GeneralPurposeCon();
         QList<HWKeyButton *> 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());
+       }
     }
 }
 
index 1f807d85eb969431013b8afc5bcdb7f95358c7a7..238517faeaeacf4dbcc2b4702a5c4e5857de17dd 100644 (file)
@@ -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)
 {
index 25c91216401cde4f4468221f1ea8f631bd01157a..9c91ffe9c06943f840d7e6208632b785a2513357 100644 (file)
@@ -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;
index bf38d32102895f2c918e276d8ae5f2eb6e0f7d49..e4b9f80d665942c6b3f26e72efbbf42614bd86ab 100644 (file)
@@ -69,6 +69,15 @@ void FloatingConView::createItems(ControllerForm *conForm)
         GeneralPurposeCon *generalCon = new GeneralPurposeCon();
         QList<HWKeyButton *> 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());
+        }
     }
 }
 
index aacb467771a943ab5599750202bccf2a1b699a00..e4925e22ddc1b27279e425db5428d7304d513d7f 100644 (file)
@@ -44,13 +44,25 @@ QList<HWKeyButton *> GeneralPurposeCon::createButtons(QWidget *parent, Controlle
     topLeft.setY(topLeft.y() + GPC_HEAD_SPACING);
 
     QList<HWKeyButton *> 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<HardwareKey *> keyList, QPoint topLeft, QList<HWKeyButton *> &buttonList)
+void GeneralPurposeCon::createKeyList(QWidget *parent, QList<HardwareKey *> keyList,
+                                        QPoint topLeft, QList<HWKeyButton *> &buttonList)
 {
     HardwareKey *hwKey = NULL;
     HWKeyButton *keyButton = NULL;
index 5b81849b20af8de891185bad54551092a67e54ea..16c109bc0ce8f9619a5f23583989e5a58d8220d4 100644 (file)
@@ -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 */
index b758c2672f04325d9bdd392a3ea91dc06e7c345e..807ae0aeaacc16f046010068e5d085265de16900 100644 (file)
@@ -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
index 0cc8380a0241d7b85a51d1efc3f37597b4a7de0a..fffcf4d625a35ee813eec032d2b379e7ba8a0bc8 100644 (file)
@@ -44,6 +44,11 @@ QRect ControllerForm::getCenteralRect()
     return centeralRect;
 }
 
+QList<ControllerForm *> &ControllerForm::getSubFormList()
+{
+    return subFormList;
+}
+
 ControllerForm::~ControllerForm()
 {
     qDebug("destroy con layout");
index 45482b687af52c33784d5e5396d85a16b840c006..9cb3b4fc05cde09b490e7445ed4e799ea552bf75 100644 (file)
@@ -44,9 +44,11 @@ public:
 
     void setCenteralRect(const QRect &rect);
     QRect getCenteralRect();
+    QList<ControllerForm *> &getSubFormList();
 
 private:
     QRect centeralRect;
+    QList<ControllerForm *> subFormList;
 };
 
 #endif // CONTROLLERFORM_H
index fd8bf973207958d3364937efdbee196fa04fa979..d59745e6fb36f57420483e3835f0daf2b1e104ec 100644 (file)
@@ -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;
index b888348d4a05304c7ee7cb6d1d466426b8ffc1e4..637465b24ed767d79d095878887179e99dda453f 100644 (file)
         <file>images/controller-skin/VolumeUp_hover.png</file>
         <file>images/controller-skin/VolumeUp_normal.png</file>
         <file>images/controller-skin/VolumeUp_pushed.png</file>
+        <file>images/controller-skin/Shell_hover.png</file>
+        <file>images/controller-skin/Shell_normal.png</file>
+        <file>images/controller-skin/Shell_pushed.png</file>
+        <file>images/controller-skin/Rotate_hover.png</file>
+        <file>images/controller-skin/Rotate_normal.png</file>
+        <file>images/controller-skin/Rotate_pushed.png</file>
+        <file>images/controller-skin/Screen Shot_hover.png</file>
+        <file>images/controller-skin/Screen Shot_normal.png</file>
+        <file>images/controller-skin/Screen Shot_pushed.png</file>
+        <file>images/controller-skin/Control Panel_hover.png</file>
+        <file>images/controller-skin/Control Panel_normal.png</file>
+        <file>images/controller-skin/Control Panel_pushed.png</file>
 
         <file>icons/emulator_icon.ico</file>
         <file>icons/shell.png</file>
index e49c6ffca6ba413d187b2352709e1ab94a9e2383..2145206a41a9e5cf97b9f0d330f66508d506b39f 100644 (file)
                 <shortcut>Ctrl+Shift+[</shortcut>
             </key>
         </keyList>
+        <form name="Menu Window">
+            <keyList>
+                <key name="Rotate">
+                    <shortcut>Ctrl+Shift+Left</shortcut>
+                </key>
+                <key name="Shell">
+                    <shortcut>Ctrl+Shift+S</shortcut>
+                </key>
+                <key name="Control Panel">
+                    <shortcut>Ctrl+Shift+P</shortcut>
+                </key>
+                <key name="Screen Shot">
+                    <shortcut>Ctrl+Shift+F12</shortcut>
+                </key>
+            </keyList>
+        </form>
     </form>
 </ControllerUI>
index f4db577977fc17c8e941b48ffb624267f6391523..fbac90fdbb255e34b65ac657fe4e2f001a14e165 100644 (file)
                 <shortcut>Ctrl+Shift+F8</shortcut>
             </key>
         </keyList>
+        <form name="Menu Window">
+            <keyList>
+                <key name="Rotate">
+                    <shortcut>Ctrl+Shift+Left</shortcut>
+                </key>
+                <key name="Shell">
+                    <shortcut>Ctrl+Shift+S</shortcut>
+                </key>
+                <key name="Control Panel">
+                    <shortcut>Ctrl+Shift+P</shortcut>
+                </key>
+                <key name="Screen Shot">
+                    <shortcut>Ctrl+Shift+F12</shortcut>
+                </key>
+            </keyList>
+        </form>
     </form>
 </ControllerUI>
index e55d3a27af2e106ca30b7dc62c49a4f2975c93c5..c78d4962c13db77024b01719909f771afe448fdc 100644 (file)
@@ -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<Separator *> separators)
 {
-    drawSkin(centerPatch, degree);
+    drawSkin(centerPatch, degree, separators);
 }
 
-void SkinPainter::drawSkin(QSize center, int degree) {
+void SkinPainter::drawSkin(QSize center, int degree, QList<Separator *> 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)));
index 8adde2d954a83f1c0522bd28b6f22ba8a088d202..03e91fc7810eef03ea3cd22e01a47250bedc1b74 100644 (file)
 
 #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<Separator *> 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<Separator *> separators);
 
     QPixmap *skin;
     QRect centeralRect;
index d7e82ced2b87aed65cd79391261a3a8752756f72..59e81b1c9989b2e548e049827a6979cfcc4e12aa 100644 (file)
@@ -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<Separator *> 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());