summaryrefslogtreecommitdiff
path: root/tizen
diff options
context:
space:
mode:
authorjihye <jihye424.kim@samsung.com>2017-03-11 19:34:16 +0900
committerjihye <jihye424.kim@samsung.com>2017-03-16 16:53:17 +0900
commit668f3195125d6efa1ea44ff8383c4de08aceed2f (patch)
tree98bf86f24db7eb5559417524fc38dc55a79d056f /tizen
parent17a357d0327ebf0e8db43005ddc1fd0d4a1cf9b8 (diff)
downloadqemu-668f3195125d6efa1ea44ff8383c4de08aceed2f.tar.gz
qemu-668f3195125d6efa1ea44ff8383c4de08aceed2f.tar.bz2
qemu-668f3195125d6efa1ea44ff8383c4de08aceed2f.zip
skin: find event of menu button from list of context menu
- before: only four menus could be set - after: any menu is available Change-Id: Ia4e14009ab260909eaacf9325c8baad53aa084bf Signed-off-by: jihye <jihye424.kim@samsung.com>
Diffstat (limited to 'tizen')
-rw-r--r--tizen/src/ui/controller/dockingconview.cpp13
-rw-r--r--tizen/src/ui/controller/floatingconview.cpp13
-rw-r--r--tizen/src/ui/controller/generalpurposecon.cpp39
-rw-r--r--tizen/src/ui/controller/generalpurposecon.h8
-rw-r--r--tizen/src/ui/controller/hwkeybutton.cpp23
-rw-r--r--tizen/src/ui/controller/hwkeybutton.h2
-rw-r--r--tizen/src/ui/menu/contextmenu.cpp23
-rw-r--r--tizen/src/ui/menu/contextmenu.h2
-rw-r--r--tizen/src/ui/menu/menuitem.cpp11
-rw-r--r--tizen/src/ui/menu/menuitem.h4
-rw-r--r--tizen/src/ui/resource/ui_strings.h3
11 files changed, 86 insertions, 55 deletions
diff --git a/tizen/src/ui/controller/dockingconview.cpp b/tizen/src/ui/controller/dockingconview.cpp
index a37507c3dd..cc4d5e3d1b 100644
--- a/tizen/src/ui/controller/dockingconview.cpp
+++ b/tizen/src/ui/controller/dockingconview.cpp
@@ -66,20 +66,11 @@ void DockingConView::createItems(ControllerForm *conForm)
}
}
} else {
- GeneralPurposeCon *generalCon = new GeneralPurposeCon();
+ GeneralPurposeCon *generalCon = new GeneralPurposeCon(parent->getMainWindow());
- generalCon->createHeaderBarAndBorder(scene(), parent->getMainWindow()->getUiInfo(), false);
+ generalCon->createHeaderBarAndBorder(scene(), false);
QList<HWKeyButton *> buttons
= generalCon->createButtons(scene(), 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/floatingconview.cpp b/tizen/src/ui/controller/floatingconview.cpp
index 1e1429379a..c2190b6d4d 100644
--- a/tizen/src/ui/controller/floatingconview.cpp
+++ b/tizen/src/ui/controller/floatingconview.cpp
@@ -66,20 +66,11 @@ void FloatingConView::createItems(ControllerForm *conForm)
}
}
} else {
- GeneralPurposeCon *generalCon = new GeneralPurposeCon();
+ GeneralPurposeCon *generalCon = new GeneralPurposeCon(parent->getMainWindow());
- generalCon->createHeaderBarAndBorder(scene(), parent->getMainWindow()->getUiInfo(), true);
+ generalCon->createHeaderBarAndBorder(scene(), true);
QList<HWKeyButton *> buttons
= generalCon->createButtons(scene(), 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 5c7efbc149..b7f8f237b0 100644
--- a/tizen/src/ui/controller/generalpurposecon.cpp
+++ b/tizen/src/ui/controller/generalpurposecon.cpp
@@ -32,14 +32,17 @@
#include "generalpurposecon.h"
#include "resource/ui_strings.h"
+#include "menu/advancedmenuitem.h"
-GeneralPurposeCon::GeneralPurposeCon()
+GeneralPurposeCon::GeneralPurposeCon(MainWindow *window)
{
qDebug("create general purpose controller");
+ mainWindow = window;
}
-void GeneralPurposeCon::createHeaderBarAndBorder(QGraphicsScene *scene, UiInformation *uiInfo, bool isFloating)
+void GeneralPurposeCon::createHeaderBarAndBorder(QGraphicsScene *scene, bool isFloating)
{
+ UiInformation *uiInfo = mainWindow->getUiInfo();
QSize size = uiInfo->getConSize();
// draw color bar
@@ -124,11 +127,43 @@ void GeneralPurposeCon::createKeyList(QWidget *parent, QList<HardwareKey *> keyL
keyButton->setToolTip(hwKey->getName() + " " + tooltip);
keyButton->move(topLeft.x() + (GPC_KEYBUTTON_WIDTH + GPC_KEYBUTTON_HSPACING) * c,
topLeft.y() + (GPC_KEYBUTTON_HEIGHT + GPC_KEYBUTTON_VSPACING) * i);
+ if (hwKey->getKeycode() == 0) {
+ // set menu slot
+ bool find = setMenuSlot(keyButton, hwKey->getName(), mainWindow->getUiInfo()->getMenuList());
+ if (!find) {
+ QObject::connect(keyButton, SIGNAL(clicked()), mainWindow->getPopupMenu(),
+ SLOT(slotUndefinedMenu()));
+ }
+ }
buttonList.append(keyButton);
}
}
}
+bool GeneralPurposeCon::setMenuSlot(HWKeyButton *button, QString name, QList<MenuItem *> &list)
+{
+ MenuItem *item = NULL;
+ bool find = false;
+ for (int i = 0; i < list.count(); i++) {
+ item = list.at(i);
+ if (item->getType() == MenuItemType::advancedItem) {
+ find = setMenuSlot(button, name, ((AdvancedMenuItem *)item)->getMenuList());
+ if (find == true) {
+ break;
+ }
+ } else {
+ if (QString::compare(name, item->getName()) == 0) {
+ QObject::connect(button,
+ SIGNAL(clicked()), mainWindow->getPopupMenu(), item->getSlot());
+ find = true;
+ break;
+ }
+ }
+ }
+
+ return find;
+}
+
GeneralPurposeCon::~GeneralPurposeCon()
{
qDebug("destroy general purpose controller");
diff --git a/tizen/src/ui/controller/generalpurposecon.h b/tizen/src/ui/controller/generalpurposecon.h
index fe319e5d6f..0e5a50d6cb 100644
--- a/tizen/src/ui/controller/generalpurposecon.h
+++ b/tizen/src/ui/controller/generalpurposecon.h
@@ -33,7 +33,7 @@
#include "layout/hardwarekey.h"
#include "controller/hwkeybutton.h"
#include "layout/controllerform.h"
-#include "uiinformation.h"
+#include "mainwindow.h"
#define GPC_HEAD_BAR_HEIGHT (5)
#define GPC_BORDER_SIZE (1.0)
@@ -50,13 +50,15 @@ class GeneralPurposeCon
{
public:
- GeneralPurposeCon();
+ GeneralPurposeCon(MainWindow *window);
~GeneralPurposeCon();
- void createHeaderBarAndBorder(QGraphicsScene *scene, UiInformation *uiInfo, bool isFloating);
+ void createHeaderBarAndBorder(QGraphicsScene *scene, bool isFloating);
QList<HWKeyButton *> createButtons(QGraphicsScene *scene, QWidget *parent, ControllerForm *form);
private:
void createKeyList(QWidget *parent, QList<HardwareKey *> keyList, QPoint topLeft, int count, QList<HWKeyButton *> &buttonList);
+ bool setMenuSlot(HWKeyButton *dbutton, QString name, QList<MenuItem *> &list);
+ MainWindow *mainWindow;
};
#endif // GENERALPURPOSECON_H
diff --git a/tizen/src/ui/controller/hwkeybutton.cpp b/tizen/src/ui/controller/hwkeybutton.cpp
index 0c8afa28c1..07d52ed6db 100644
--- a/tizen/src/ui/controller/hwkeybutton.cpp
+++ b/tizen/src/ui/controller/hwkeybutton.cpp
@@ -58,24 +58,6 @@ HWKeyButton::HWKeyButton(QWidget *parent, HardwareKey *hwKey, QSize size) :
initialize(DEFAULT_NAME, size);
}
}
-
- //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;
- }
}
void HWKeyButton::initialize(QSize size)
@@ -157,11 +139,6 @@ void HWKeyButton::mouseReleaseEvent(QMouseEvent *event)
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 cba5ff0989..59d40a5768 100644
--- a/tizen/src/ui/controller/hwkeybutton.h
+++ b/tizen/src/ui/controller/hwkeybutton.h
@@ -40,7 +40,6 @@ class HWKeyButton : public QPushButton
public:
HWKeyButton(QWidget *parent, HardwareKey *hwKey, QSize size);
~HWKeyButton();
- virtual const char *getSlot();
protected:
virtual void initialize(QSize size);
@@ -51,7 +50,6 @@ protected:
private:
HardwareKey *hwKey;
- const char *slot;
};
#endif // HWKEYBUTTON_H
diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp
index 2fcd905ca0..96b292418d 100644
--- a/tizen/src/ui/menu/contextmenu.cpp
+++ b/tizen/src/ui/menu/contextmenu.cpp
@@ -218,6 +218,7 @@ void ContextMenu::createInfoItem(QMenu *menu, MenuItem *item)
actionDetailedInfo->setIconText(menuName.isEmpty() ? QString(DETAILED_INFO_TITLE) : menuName);
+ item->setSlot(SLOT(slotDetailedInfo()));
item->setAction(actionDetailedInfo);
}
@@ -247,6 +248,7 @@ void ContextMenu::createOnTopItem(QMenu *menu, MenuItem *item)
attachShortcut(actionOnTop, shortcut, SLOT(slotOnTopShortcut()));
}
+ item->setSlot(SLOT(slotOnTopShortcut()));
item->setAction(actionOnTop);
}
@@ -263,6 +265,7 @@ void ContextMenu::createMoveItem(QMenu *menu, MenuItem *item)
: new QShortcut(item->getShortcuts().begin().value(), parent),
SLOT(slotMove()));
+ item->setSlot(SLOT(slotMove()));
item->setAction(actionMove);
}
@@ -321,6 +324,7 @@ void ContextMenu::createSwitchItem(QMenu *menu, MenuItem *item)
qWarning("cannot create a switchItem");
}
+ item->setSlot(SLOT(slotSwitchShortcutNext()));
item->setAction(switchMenu->menuAction());
}
@@ -388,6 +392,7 @@ void ContextMenu::createScaleItem(QMenu *menu, MenuItem *item)
qWarning("cannot create a scaleItem");
}
+ item->setSlot(SLOT(slotScaleShortcutNext()));
item->setAction(scaleMenu->menuAction());
}
@@ -456,6 +461,7 @@ void ContextMenu::createControllerItem(QMenu *menu, MenuItem *item)
qWarning("cannot create a controllerItem");
}
+ item->setSlot(SLOT(slotConShortcutNext()));
item->setAction(controllerMenu->menuAction());
}
@@ -483,6 +489,7 @@ void ContextMenu::createHostKeyboardItem(QMenu *menu, MenuItem *item)
hostKbdAction->setCheckable(true);
hostKbdAction->setChecked(true);
+ // item->setSlot(slotHostKeyboardShortcut());
item->setAction(hostKbdAction);
}
@@ -500,6 +507,7 @@ void ContextMenu::createShellItem(QMenu *menu, MenuItem *item)
new QShortcut(item->getShortcuts().begin().value(), parent),
SLOT(slotShell()));
+ item->setSlot(SLOT(slotShell()));
item->setAction(actionShell);
}
@@ -517,6 +525,7 @@ void ContextMenu::createControlPanelItem(QMenu *menu, MenuItem *item)
new QShortcut(item->getShortcuts().begin().value(), parent),
SLOT(slotControlPanel()));
+ item->setSlot(SLOT(slotControlPanel()));
item->setAction(actionControlPanel);
}
@@ -534,6 +543,7 @@ void ContextMenu::createScreenShotItem(QMenu *menu, MenuItem *item)
new QShortcut(item->getShortcuts().begin().value(), parent),
SLOT(slotRequestScreenshot()));
+ item->setSlot(SLOT(slotRequestScreenshot()));
item->setAction(actionScreenShot);
}
@@ -551,6 +561,7 @@ void ContextMenu::createAboutItem(QMenu *menu, MenuItem *item)
new QShortcut(item->getShortcuts().begin().value(), parent),
SLOT(slotAbout()));
+ item->setSlot(SLOT(slotAbout()));
item->setAction(actionAbout);
}
@@ -568,6 +579,7 @@ void ContextMenu::createSystemResetItem(QMenu *menu, MenuItem *item)
new QShortcut(item->getShortcuts().begin().value(), parent),
SLOT(slotSystemReset()));
+ item->setSlot(SLOT(slotSystemReset()));
item->setAction(actionSystemReset);
}
@@ -585,6 +597,7 @@ void ContextMenu::createForceCloseItem(QMenu *menu, MenuItem *item)
new QShortcut(item->getShortcuts().begin().value(), parent),
SLOT(slotForceClose()));
+ item->setSlot(SLOT(slotForceClose()));
item->setAction(actionForceClose);
}
@@ -602,6 +615,7 @@ void ContextMenu::createCloseItem(QMenu *menu, MenuItem *item)
new QShortcut(item->getShortcuts().begin().value(), parent),
SLOT(slotClose()));
+ item->setSlot(SLOT(slotClose()));
item->setAction(actionClose);
}
@@ -671,6 +685,11 @@ bool ContextMenu::eventFilter(QObject *obj, QEvent *event)
return QObject::eventFilter(obj, event);
}
+void ContextMenu::slotUndefinedMenu()
+{
+ QMessageBox::warning(parent, EMULATOR_TITLE, MENU_UNDEFINED_ERROR);
+}
+
void ContextMenu::slotAmbiguousShortcut()
{
/* When a shortcut's key sequence is completed, activatedAmbiguously()
@@ -678,9 +697,7 @@ void ContextMenu::slotAmbiguousShortcut()
* start of one or more other shortcuts). */
qWarning("one shortcut key was overlapped with another");
- QMessageBox::warning(parent, EMULATOR_TITLE,
- "When a key sequence is being typed at the keyboard, "\
- "it is said to be ambiguous as long as it matches the start of more than one shortcut.");
+ QMessageBox::warning(parent, EMULATOR_TITLE, MENE_AMBIGUOUS_SHORTCUT);
}
void ContextMenu::slotDetailedInfo()
diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h
index f8518de322..5c29513c90 100644
--- a/tizen/src/ui/menu/contextmenu.h
+++ b/tizen/src/ui/menu/contextmenu.h
@@ -101,6 +101,8 @@ public slots:
void slotClose();
void slotPwkeyRelease();
+ void slotUndefinedMenu();
+
protected:
void createItems(QMenu *menu, QList<MenuItem *> &list);
void createSeparator(QMenu *menu);
diff --git a/tizen/src/ui/menu/menuitem.cpp b/tizen/src/ui/menu/menuitem.cpp
index d8b2326e60..5b13dd7122 100644
--- a/tizen/src/ui/menu/menuitem.cpp
+++ b/tizen/src/ui/menu/menuitem.cpp
@@ -61,6 +61,17 @@ QAction *MenuItem::getAction()
return action;
}
+const char *MenuItem::getSlot()
+{
+ return slot;
+}
+
+void MenuItem::setSlot(const char *slot)
+{
+ this->slot = slot;
+}
+
+
MenuItem::~MenuItem()
{
/* do nothing */
diff --git a/tizen/src/ui/menu/menuitem.h b/tizen/src/ui/menu/menuitem.h
index 0658bea279..dcde3874ec 100644
--- a/tizen/src/ui/menu/menuitem.h
+++ b/tizen/src/ui/menu/menuitem.h
@@ -67,12 +67,16 @@ public:
QMap<QString, QKeySequence> &getShortcuts();
void setAction(QAction *action);
QAction *getAction();
+ const char *getSlot();
+ void setSlot(const char *slot);
private:
int type;
QString name;
QMap<QString, QKeySequence> shortcuts;
QAction *action;
+
+ const char *slot;
};
#endif // MENUITEM_H
diff --git a/tizen/src/ui/resource/ui_strings.h b/tizen/src/ui/resource/ui_strings.h
index 81c7dce683..a17e9aaeed 100644
--- a/tizen/src/ui/resource/ui_strings.h
+++ b/tizen/src/ui/resource/ui_strings.h
@@ -89,6 +89,9 @@
#define MENU_ON_ITEM_TEXT "On"
#define MENU_OFF_ITEM_TEXT "OFF"
+#define MENU_UNDEFINED_ERROR "The corresponding context menu does not exist"
+#define MENE_AMBIGUOUS_SHORTCUT "When a key sequence is being typed at the keyboard,\n"\
+ "it is said to be ambiguous as long as it matches the start of more than one shortcut."
/* detailed info dialog */
#define DETAILED_INFO_TITLE "Detailed Info"
#define DETAILED_INFO_VMTAB_TITLE "VM Info"