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 51d4daf..ad06118 100644 (file)
@@ -58,6 +58,11 @@ DockingConView *DockingController::getConView()
     return conView;
 }
 
+MainWindow *DockingController::getMainWindow()
+{
+    return win;
+}
+
 int DockingController::getDockPos()
 {
     return dockPos;
index cd16730..57bb4cb 100644 (file)
@@ -48,6 +48,7 @@ public:
 
     ControllerForm *getConForm();
     DockingConView *getConView();
+    MainWindow *getMainWindow();
     int getDockPos();
     void updateGeometry();
 
index 98a0328..217108c 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 1f807d8..238517f 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 25c9121..9c91ffe 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 bf38d32..e4b9f80 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 aacb467..e4925e2 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 5b81849..16c109b 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 b758c26..807ae0a 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 0cc8380..fffcf4d 100644 (file)
@@ -44,6 +44,11 @@ QRect ControllerForm::getCenteralRect()
     return centeralRect;
 }
 
+QList<ControllerForm *> &ControllerForm::getSubFormList()
+{
+    return subFormList;
+}
+
 ControllerForm::~ControllerForm()
 {
     qDebug("destroy con layout");
index 45482b6..9cb3b4f 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 fd8bf97..d59745e 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 b888348..637465b 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 e49c6ff..2145206 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 f4db577..fbac90f 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 e55d3a2..c78d496 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 8adde2d..03e91fc 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 d7e82ce..59e81b1 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());