diff options
author | Jinhyung Choi <jinh0.choi@samsung.com> | 2015-11-04 11:33:51 +0900 |
---|---|---|
committer | SeokYeon Hwang <syeon.hwang@samsung.com> | 2015-11-26 13:46:08 +0900 |
commit | cf9b7905746a104b83261bc3a4c6955ab0e62bbf (patch) | |
tree | ec5d26b40b80ce7c41750704eced5677fb12be90 /tizen/src/ui/menu | |
parent | 22cd3f8fe579dbacfe0df79fbba3966d4c7e8894 (diff) | |
download | qemu-cf9b7905746a104b83261bc3a4c6955ab0e62bbf.tar.gz qemu-cf9b7905746a104b83261bc3a4c6955ab0e62bbf.tar.bz2 qemu-cf9b7905746a104b83261bc3a4c6955ab0e62bbf.zip |
UI: supports reboot from context menu
When a malfunction of emulator occurs, such as no response from the guest OS,
what a developer can do is selecting "force close"
and restarting from emulator manager.
In order to avoid the inconvenience of doing it, reboot menu is added.
It is working directly to hardware after requesting sync() to guest OS
----------------
| Context menu |
----------------
| reboot |
---------------- ----------
| | emuld |
------------------------ ----------
| 1. send sync message | -------------> | sync() |
| 2. start a timer | ----------
------------------------
| The timer expires after 1s
-------------------------------
| qemu_system_reset_request() |
-------------------------------
Conflicts:
tizen/src/extension/ui/resource/skins/tv-1080x1920/layout.xml
tizen/src/extension/ui/resource/skins/tv-1920x1080/layout.xml
tizen/src/extension/ui/resource/skins/tv-2560x1080/layout.xml
Change-Id: I3c3c31c2cc19065f53b620d83c79e68e0183db53
Signed-off-by: Jinhyung Choi <jinh0.choi@samsung.com>
(cherry picked from commit 14fc61baff1e8b48cbcb810a8392a1ac601f2511)
Diffstat (limited to 'tizen/src/ui/menu')
-rw-r--r-- | tizen/src/ui/menu/contextmenu.cpp | 50 | ||||
-rw-r--r-- | tizen/src/ui/menu/contextmenu.h | 7 | ||||
-rw-r--r-- | tizen/src/ui/menu/menuitem.h | 1 |
3 files changed, 58 insertions, 0 deletions
diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index 90f77dea6c..72ea6d55b4 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -40,6 +40,9 @@ extern "C" { // FIXME: To avoid very complex header inclusion chains void qemu_system_graceful_shutdown_request(unsigned int sec); +void qemu_system_reset_request(void); +#define MENU_ACTION_REBOOT 1 +void send_shutdown_request(int action); #include "util/osutil.h" #include "util/device_hotplug.h" @@ -80,6 +83,9 @@ ContextMenu::ContextMenu(QWidget *parent) : QMenu(parent) /* for close */ longPressTimer = new QTimer(this); + /* for system reset */ + rebootTimer = new QTimer(this); + createItems(this, this->parent->getUiInfo()->getMenuList()); installEventFilter(this); @@ -143,6 +149,10 @@ void ContextMenu::createItems(QMenu *menu, QList<MenuItem *> &list) /* About menu */ createAboutItem(menu, item); break; + case MenuItemType::systemResetItem: + /* System Reset menu */ + createSystemResetItem(menu, item); + break; case MenuItemType::forceCloseItem: /* Force Close menu */ createForceCloseItem(menu, item); @@ -525,6 +535,23 @@ void ContextMenu::createAboutItem(QMenu *menu, MenuItem *item) item->setAction(actionAbout); } +void ContextMenu::createSystemResetItem(QMenu *menu, MenuItem *item) +{ + if (menu == NULL || item == NULL) { + return; + } + + QString menuName = item->getName(); + actionSystemReset = addGeneralAction( + menu, QIcon(QPixmap(":/icons/system_reset.png")), + menuName.isEmpty() ? MENU_FORCECLOSE_ITEM_TEXT : menuName, + item->getShortcuts().isEmpty()? NULL : + new QShortcut(item->getShortcuts().begin().value(), parent), + SLOT(slotSystemReset())); + + item->setAction(actionSystemReset); +} + void ContextMenu::createForceCloseItem(QMenu *menu, MenuItem *item) { if (menu == NULL || item == NULL) { @@ -1017,6 +1044,27 @@ void ContextMenu::slotAbout() #endif } +void ContextMenu::slotDeviceReset() +{ + qDebug("System reset request."); + qemu_system_reset_request(); + qDebug("Done for system reset request."); +} + +void ContextMenu::slotSystemReset() +{ + qDebug("Reboot."); + + send_shutdown_request(MENU_ACTION_REBOOT); + + qDebug("Sent sync message to emuld."); + + rebootTimer->setInterval(HARDWARE_REBOOT_INTERVAL); + rebootTimer->setSingleShot(true); + connect(rebootTimer, SIGNAL(timeout()), this, SLOT(slotDeviceReset())); + rebootTimer->start(); +} + void ContextMenu::slotForceClose() { qDebug("force close"); @@ -1090,4 +1138,6 @@ ContextMenu::~ContextMenu() delete shellOpener; longPressTimer->stop(); + + rebootTimer->stop(); } diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h index 63dc565140..942a077b67 100644 --- a/tizen/src/ui/menu/contextmenu.h +++ b/tizen/src/ui/menu/contextmenu.h @@ -49,6 +49,7 @@ extern "C" { } #define CLOSE_POWER_KEY_INTERVAL 1200 /* milli-seconds */ +#define HARDWARE_REBOOT_INTERVAL 1000 /* milli-seconds */ class ContextMenu : public QMenu { @@ -96,6 +97,9 @@ public slots: void slotHostKeyboard(bool on); void slotAbout(); + void slotSystemReset(); + void slotDeviceReset(); + void slotForceClose(); void slotClose(); void slotPwkeyRelease(); @@ -116,6 +120,7 @@ protected: void createControlPanelItem(QMenu *menu, MenuItem *item); void createScreenShotItem(QMenu *menu, MenuItem *item); void createAboutItem(QMenu *menu, MenuItem *item); + void createSystemResetItem(QMenu *menu, MenuItem *item); void createForceCloseItem(QMenu *menu, MenuItem *item); void createCloseItem(QMenu *menu, MenuItem *item); bool eventFilter(QObject *obj, QEvent *event); @@ -146,6 +151,7 @@ private: QAction *actionControlPanel; QAction *actionScreenShot; QAction *actionAbout; + QAction *actionSystemReset; QAction *actionForceClose; QAction *actionClose; @@ -155,5 +161,6 @@ private: ShellOpener *shellOpener; QTimer *longPressTimer; + QTimer *rebootTimer; }; #endif // CONTEXTMENU_H diff --git a/tizen/src/ui/menu/menuitem.h b/tizen/src/ui/menu/menuitem.h index d271700c3b..0658bea279 100644 --- a/tizen/src/ui/menu/menuitem.h +++ b/tizen/src/ui/menu/menuitem.h @@ -50,6 +50,7 @@ namespace MenuItemType controlPanelItem, screenShotItem, aboutItem, + systemResetItem, forceCloseItem, closeItem, }; |