From ff8c814b11864e6e7203ada085ef79133cb60259 Mon Sep 17 00:00:00 2001 From: sungmin ha Date: Wed, 4 Mar 2015 19:19:28 +0900 Subject: [PATCH] shortcut: added keyboard shortcut The key sequence of shortcut can be changed from layout.xml. The shortcut info table is added in the detailed info popup menu. The shortcuts are comprehensive of popup menu, hwkey and controller. Change-Id: I34e640d53ed9950611ba388b203d2e57dff613b8 Signed-off-by: sungmin ha --- tizen/src/display/xmllayoutparser.cpp | 6 +- tizen/src/ui/Makefile.objs | 4 + tizen/src/ui/dockingconview.cpp | 7 +- tizen/src/ui/dockingconview.h | 2 + tizen/src/ui/floatingconview.cpp | 7 +- tizen/src/ui/floatingconview.h | 2 + tizen/src/ui/hardwarekey.cpp | 3 +- tizen/src/ui/hardwarekey.h | 3 +- tizen/src/ui/keyboardshortcut.cpp | 446 +++++++++++++++++++++ tizen/src/ui/keyboardshortcut.h | 93 +++++ tizen/src/ui/mainwindow.cpp | 15 + tizen/src/ui/mainwindow.h | 3 + tizen/src/ui/menu/contextmenu.cpp | 32 +- tizen/src/ui/menu/contextmenu.h | 9 + tizen/src/ui/menu/detailedinfodialog.cpp | 189 +++++---- tizen/src/ui/menu/detailedinfodialog.h | 13 +- .../ui/resource/mobile-720x1280-3btn/layout.xml | 24 +- .../ui/resource/wearable-320x320-1btn/layout.xml | 8 +- 18 files changed, 770 insertions(+), 96 deletions(-) create mode 100644 tizen/src/ui/keyboardshortcut.cpp create mode 100644 tizen/src/ui/keyboardshortcut.h diff --git a/tizen/src/display/xmllayoutparser.cpp b/tizen/src/display/xmllayoutparser.cpp index c74ffee..f0b9fdd 100644 --- a/tizen/src/display/xmllayoutparser.cpp +++ b/tizen/src/display/xmllayoutparser.cpp @@ -104,6 +104,7 @@ HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml) QRect keyRegion; int keycode = 0; QString keyTooptip; + QString keySequence; /* attribute */ QString keyName = xml.attributes().value(NAME_ATTR_KEYWORD).toString(); @@ -123,13 +124,16 @@ HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml) } else if (xml.name() == "tooltip") { /* tooltip */ keyTooptip = xml.readElementText(); + } else if (xml.name() == "shortcut") { + /* shortcut */ + keySequence = xml.readElementText(); } } token = xml.readNext(); } - return new HardwareKey(keyName, keycode, keyRegion, keyTooptip); + return new HardwareKey(keyName, keycode, keyRegion, keyTooptip, keySequence); } int XmlLayoutParser::parseKeyList( diff --git a/tizen/src/ui/Makefile.objs b/tizen/src/ui/Makefile.objs index 66a1398..a798bd3 100644 --- a/tizen/src/ui/Makefile.objs +++ b/tizen/src/ui/Makefile.objs @@ -20,6 +20,7 @@ obj-$(CONFIG_QT) += skinkeyitem.o moc_skinkeyitem.o obj-$(CONFIG_QT) += displaytype.o obj-$(CONFIG_QT) += mainform.o obj-$(CONFIG_QT) += keyboardhelper.o +obj-$(CONFIG_QT) += keyboardshortcut.o moc_keyboardshortcut.o obj-$(CONFIG_QT) += skinview.o obj-$(CONFIG_QT) += uiinformation.o obj-$(CONFIG_QT) += uistate.o @@ -46,3 +47,6 @@ $(obj)/moc_mainwindow.cpp: $(obj)/mainwindow.h $(obj)/moc_skinkeyitem.o: $(obj)/moc_skinkeyitem.cpp $(obj)/moc_skinkeyitem.cpp: $(obj)/skinkeyitem.h moc $< -o $@ +$(obj)/moc_keyboardshortcut.o: $(obj)/moc_keyboardshortcut.cpp +$(obj)/moc_keyboardshortcut.cpp: $(obj)/keyboardshortcut.h + moc $< -o $@ diff --git a/tizen/src/ui/dockingconview.cpp b/tizen/src/ui/dockingconview.cpp index a6bfb63..469a11b 100644 --- a/tizen/src/ui/dockingconview.cpp +++ b/tizen/src/ui/dockingconview.cpp @@ -57,7 +57,7 @@ void DockingConView::createItems(ControllerForm *conForm) scene()->addItem(bezelItem); /* HW keys */ - QList keyList = conForm->keyList; + keyList = conForm->keyList; HardwareKey *hwKey = NULL; for (int i = 0; i < keyList.count(); i++) { @@ -140,6 +140,11 @@ void DockingConView::mouseMoveEvent(QMouseEvent *event) } } +QList DockingConView::getKeyList() +{ + return keyList; +} + DockingConView::~DockingConView() { qDebug("destroy docking controller view"); diff --git a/tizen/src/ui/dockingconview.h b/tizen/src/ui/dockingconview.h index 691400d..9579b46 100644 --- a/tizen/src/ui/dockingconview.h +++ b/tizen/src/ui/dockingconview.h @@ -43,6 +43,7 @@ class DockingConView : public QGraphicsView public: DockingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0); ~DockingConView(); + QList getKeyList(); protected: void resizeEvent(QResizeEvent *event); @@ -60,6 +61,7 @@ private: DockingController *parent; SkinBezelItem *bezelItem; QRubberBand *rubberBand; + QList keyList; }; #endif // DOCKINGCONVIEW_H diff --git a/tizen/src/ui/floatingconview.cpp b/tizen/src/ui/floatingconview.cpp index a6572dc..c65f690 100644 --- a/tizen/src/ui/floatingconview.cpp +++ b/tizen/src/ui/floatingconview.cpp @@ -59,7 +59,7 @@ void FloatingConView::createItems(ControllerForm *conForm) scene()->addItem(bezelItem); /* HW keys */ - QList keyList = conForm->keyList; + keyList = conForm->keyList; HardwareKey *hwKey = NULL; for (int i = 0; i < keyList.count(); i++) { @@ -217,6 +217,11 @@ void FloatingConView::mouseMoveEvent(QMouseEvent *event) } } +QList FloatingConView::getKeyList() +{ + return keyList; +} + FloatingConView::~FloatingConView() { qDebug("destroy floating controller view"); diff --git a/tizen/src/ui/floatingconview.h b/tizen/src/ui/floatingconview.h index f2e996f..164e964 100644 --- a/tizen/src/ui/floatingconview.h +++ b/tizen/src/ui/floatingconview.h @@ -43,6 +43,7 @@ class FloatingConView : public QGraphicsView public: FloatingConView(ControllerForm *conForm, QGraphicsScene *scene, QWidget *parent = 0); ~FloatingConView(); + QList getKeyList(); protected: void resizeEvent(QResizeEvent *event); @@ -61,6 +62,7 @@ private: FloatingController *parent; SkinBezelItem *bezelItem; QRubberBand *rubberBand; + QList keyList; }; #endif // FLOATINGCONVIEW_H diff --git a/tizen/src/ui/hardwarekey.cpp b/tizen/src/ui/hardwarekey.cpp index 336f277..e525d36 100644 --- a/tizen/src/ui/hardwarekey.cpp +++ b/tizen/src/ui/hardwarekey.cpp @@ -29,12 +29,13 @@ #include "hardwarekey.h" -HardwareKey::HardwareKey(QString name, int keycode, QRect region, QString tooltip) +HardwareKey::HardwareKey(QString name, int keycode, QRect region, QString tooltip, QString keySequence) { this->name = name; this->keycode = keycode; this->region = region; this->tooltip = tooltip; + this->keySequence = keySequence; } HardwareKey::~HardwareKey() diff --git a/tizen/src/ui/hardwarekey.h b/tizen/src/ui/hardwarekey.h index 6fabe42..4b85f75 100644 --- a/tizen/src/ui/hardwarekey.h +++ b/tizen/src/ui/hardwarekey.h @@ -35,13 +35,14 @@ class HardwareKey { public: - HardwareKey(QString name, int keycode, QRect region, QString tooltip); + HardwareKey(QString name, int keycode, QRect region, QString tooltip, QString keySequence); ~HardwareKey(); QString name; int keycode; QRect region; QString tooltip; + QString keySequence; }; #endif // HARDWAREKEY_H diff --git a/tizen/src/ui/keyboardshortcut.cpp b/tizen/src/ui/keyboardshortcut.cpp new file mode 100644 index 0000000..a730b50 --- /dev/null +++ b/tizen/src/ui/keyboardshortcut.cpp @@ -0,0 +1,446 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Sungmin Ha + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "keyboardshortcut.h" +#include "mainwindow.h" + +KeyboardShortcut::KeyboardShortcut(QWidget *parent) : QWidget(parent) +{ + this->parent = (MainWindow *)parent; +} + +void KeyboardShortcut::removeControllerShortcut() +{ + for (int index = 0; index < controllerShortcutList.count(); index++) { + delete controllerShortcutList.at(index); + } + + controllerShortcutList.clear(); + controllerShortcutMap.clear(); + + qDebug() << "Removed controller shortcuts"; +} + +void KeyboardShortcut::removeHwKeyShortcut() +{ + for (int index = 0; index < hwKeyShortcutList.count(); index++) { + delete hwKeyShortcutList.at(index); + } + + hwKeyShortcutList.clear(); + hwKeyShortcutMap.clear(); + + qDebug() << "Removed hwKey shortcuts"; +} + +void KeyboardShortcut::registShortcutKey(QShortcut *shortcut, QString item) +{ + QSignalMapper *mapper = new QSignalMapper(this); + if (!mapper || !shortcut) { + qDebug() << "regist HwKey shortcut failed."; + return; + } + + connect(shortcut, SIGNAL(activated()), mapper, SLOT(map())); + mapper->setMapping(shortcut, item); + connect(mapper, SIGNAL(mapped(const QString &)), this, SLOT(slotShortcutHwKey(const QString &))); +} + +void KeyboardShortcut::setKeyboardShortcutController() +{ + DockingController *dct = parent->getDockingCon(); + FloatingController *fct = parent->getFloatingCon(); + + if (dct) { + controllerKeyList = dct->getConView()->getKeyList(); + } else if (fct) { + controllerKeyList = fct->getConView()->getKeyList(); + } else { + qDebug() << "controllerKeyList is not exist!"; + return; + } + + qDebug() << "Set keyboard shortcut ControllerKeys."; + for (int index = 0; index < controllerKeyList.count(); index++) { + HardwareKey *controllerKey = controllerKeyList.at(index); + if (controllerKey) { + if (!controllerKey->keySequence.isEmpty()) { + QShortcut *shortcut = new QShortcut(QKeySequence::fromString(controllerKey->keySequence), parent); + registShortcutKey(shortcut, controllerKey->name); + + controllerShortcutList.append(shortcut); + controllerShortcutMap.insert(controllerKey->name, controllerKey->keySequence); + } + } else { + qDebug() << "controllerKeyList.at(" << index << ") is NULL"; + } + } +} + +void KeyboardShortcut::setKeyboardShortcutHwKey() +{ + UIInformation *uiInfo = parent->uiInfo; + + if (uiInfo) { + if (uiInfo->getMainForm() != NULL) { + if (uiInfo->getMainForm()->keyList.count() > 0) { + hwKeyList = uiInfo->getMainForm()->keyList; + } else if (uiInfo->getMainForm()->keyList.count() == 0) { + qDebug() << "hwKey is not exist"; + return; + } else { + qDebug() << "hwKeyList is not exist"; + return; + } + } else { + qDebug() << "uiInfo->getMainForm() is NULL"; + } + } else { + qDebug() << "uiInfo is NULL"; + return; + } + + qDebug() << "Set keyboard shortcut HwKeys."; + for (int index = 0; index < hwKeyList.count(); index++) { + HardwareKey *hwKey = hwKeyList.at(index); + if (hwKey) { + if (!hwKey->keySequence.isEmpty()) { + QShortcut *shortcut = new QShortcut(QKeySequence::fromString(hwKey->keySequence), parent); + registShortcutKey(shortcut, hwKey->name); + + hwKeyShortcutList.append(shortcut); + hwKeyShortcutMap.insert(hwKey->name, hwKey->keySequence); + } + } else { + qDebug() << "hwKeyList.at(" << index << ") is NULL"; + } + } +} + +void KeyboardShortcut::setKeyboardShortcutContextMenu(MenuItem *item, QString property, QString keySequence) +{ + QShortcut *shortcut = new QShortcut(QKeySequence::fromString(keySequence), parent); + int itemType = item->getType(); + QString itemName = item->getName(); + + switch (itemType) { + case MenuItemType::closeItem: + connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutClose())); + break; + case MenuItemType::infoItem: + connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutDetailedInfo())); + if (itemName.isEmpty()) { + itemName = DETAILED_INFO_TITLE; + } + break; + case MenuItemType::onTopItem: + connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutTopMost())); + break; + case MenuItemType::hostKeyboardItem: + connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutHostKeyboard())); + break; + case MenuItemType::forceCloseItem: + connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutForceClose())); + break; + case MenuItemType::shellItem: + connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutShell())); + break; + case MenuItemType::controlPanelItem: + connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutControlPanel())); + break; + case MenuItemType::screenShotItem: + connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutRequestScreenshot())); + break; + case MenuItemType::controllerItem: + connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutController())); + break; + case MenuItemType::scaleItem: + if (property == "prev") { + connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutScalePrev())); + } else if (property == "next") { + connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutScaleNext())); + } else { + qDebug() << "undefined property: " << property; + } + break; + case MenuItemType::switchItem: + if (property == "prev") { + connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutSwitchPrev())); + } else if (property == "next") { + connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutSwitchNext())); + } else { + qDebug() << "undefined property: " << property; + } + break; + default: + qDebug() << "undefined item type: " << itemType; + return; + } + + if (!property.isEmpty()) { + itemName.append(" " + property); + } + + popupMenuShortcutMap.insert(itemName, keySequence); +} + +void KeyboardShortcut::slotShortcutClose() +{ + parent->getPopupMenu()->slotClose(); +} + +void KeyboardShortcut::slotShortcutDetailedInfo() +{ + parent->getPopupMenu()->slotDetailedInfo(); +} + +void KeyboardShortcut::slotShortcutShell() +{ + parent->getPopupMenu()->slotShell(); +} + +void KeyboardShortcut::slotShortcutRequestScreenshot() +{ + parent->getPopupMenu()->slotRequestScreenshot(); +} + +void KeyboardShortcut::slotShortcutForceClose() +{ + parent->getPopupMenu()->slotForceClose(); +} + +void KeyboardShortcut::slotShortcutControlPanel() +{ + parent->getPopupMenu()->slotControlPanel(); +} + +void KeyboardShortcut::slotShortcutTopMost() +{ + QAction *action = parent->getPopupMenu()->getActionTopMost(); + parent->getPopupMenu()->slotTopMost(!action->isChecked()); +} + +void KeyboardShortcut::slotShortcutSwitchPrev() +{ + QAction *action = parent->getPopupMenu()->switchGroup->checkedAction(); + QList switchList = parent->getPopupMenu()->switchGroup->actions(); + + if (!action) { + qDebug() << "switch prev failed."; + return; + } + + int index = switchList.indexOf(action); + if (index == switchList.count() - 1) { + index = 0; + } else { + index++; + } + + QAction *nextSwitchAction = switchList.at(index); + nextSwitchAction->setChecked(true); + nextSwitchAction->trigger(); +} + +void KeyboardShortcut::slotShortcutSwitchNext() +{ + QAction *action = parent->getPopupMenu()->switchGroup->checkedAction(); + QList switchList = parent->getPopupMenu()->switchGroup->actions(); + + if (!action) { + qDebug() << "switch next failed."; + return; + } + + int index = switchList.indexOf(action); + if (index == 0) { + index = switchList.count() - 1; + } else { + index--; + } + + QAction *nextSwitchAction = switchList.at(index); + nextSwitchAction->setChecked(true); + nextSwitchAction->trigger(); +} + +void KeyboardShortcut::slotShortcutScaleNext() +{ + QAction *action = parent->getPopupMenu()->scaleGroup->checkedAction(); + QList scaleList = parent->getPopupMenu()->scaleGroup->actions(); + + if (!action) { + qDebug() << "scale next failed."; + return; + } + + int index = scaleList.indexOf(action); + if (index == 0) { + index = scaleList.count() - 1; + } else { + index--; + } + + QAction *nextScaleAction = scaleList.at(index); + nextScaleAction->setChecked(true); + nextScaleAction->trigger(); +} + +void KeyboardShortcut::slotShortcutScalePrev() +{ + QAction *action = parent->getPopupMenu()->scaleGroup->checkedAction(); + QList scaleList = parent->getPopupMenu()->scaleGroup->actions(); + + if (!action) { + qDebug() << "scale prev failed."; + return; + } + + int index = scaleList.indexOf(action); + if (index == scaleList.count() - 1) { + index = 0; + } else { + index++; + } + + QAction *nextScaleAction = scaleList.at(index); + nextScaleAction->setChecked(true); + nextScaleAction->trigger(); +} + +void KeyboardShortcut::slotShortcutController() +{ + QAction *action = parent->getPopupMenu()->controllerGroup->checkedAction(); + QList controllerList = parent->getPopupMenu()->controllerGroup->actions(); + + if (!action) { + qDebug() << "change controller failed."; + return; + } + + int last_index = controllerList.count() - 1; + int index = controllerList.indexOf(action) + 1; + + if (index > last_index) { + index = 0; + } + + QAction *nextControllerAction = controllerList.at(index); + if (!nextControllerAction) { + qDebug() << "controllerList.at(" << index << ") is NULL"; + return; + } + + nextControllerAction->setChecked(true); + nextControllerAction->trigger(); +} + +void KeyboardShortcut::slotShortcutHostKeyboard() +{ + QAction *action = parent->getPopupMenu()->keyboardGroup->checkedAction(); + QList keyboardStatusList = parent->getPopupMenu()->keyboardGroup->actions(); + + if (!action) { + qDebug() << "HostKeyboard enable/disable failed"; + return; + } + + int index = 0; + if (action->text().contains(KEYBOARD_ON)) { + for (index = 0; index < keyboardStatusList.count(); index++) { + if (keyboardStatusList.at(index)->text().contains(KEYBOARD_OFF)) { + break; + } + } + } else { + for (index = 0; index < keyboardStatusList.count(); index++) { + if (keyboardStatusList.at(index)->text().contains(KEYBOARD_ON)) { + break; + } + } + } + + keyboardStatusList.at(index)->setChecked(true); +} + +int KeyboardShortcut::getHwKeyCode(const char *item) +{ + int index = 0, keyCode = 0; + + for (index = 0; index < hwKeyList.count(); index++) { + if (strcmp(hwKeyList.at(index)->name.toLocal8Bit().data(), item) == 0) { + keyCode = hwKeyList.at(index)->keycode; + break; + } + } + + if (index == hwKeyList.count()) { + qDebug() << item << "is not exist in KeyList"; + } + + return keyCode; +} + +void KeyboardShortcut::doHwKeyEvent(int keyCode) +{ + do_hw_key_event(KEY_PRESSED, keyCode); + do_hw_key_event(KEY_RELEASED, keyCode); +} + +void KeyboardShortcut::slotShortcutHwKey(const QString &name) +{ + int keyCode = getHwKeyCode(name.toLocal8Bit().data()); + doHwKeyEvent(keyCode); +} + +QList KeyboardShortcut::getControllerShortcutList() +{ + return controllerShortcutList; +} + +QMap KeyboardShortcut::getPopupMenuShortcutMap() +{ + return popupMenuShortcutMap; +} + +QMap KeyboardShortcut::getHwKeyShortcutMap() +{ + return hwKeyShortcutMap; +} + +QMap KeyboardShortcut::getControllerShortcutMap() +{ + return controllerShortcutMap; +} + +KeyboardShortcut::~KeyboardShortcut() +{ + qDebug("destroy keyboard shortcut"); +} diff --git a/tizen/src/ui/keyboardshortcut.h b/tizen/src/ui/keyboardshortcut.h new file mode 100644 index 0000000..6ee5a45 --- /dev/null +++ b/tizen/src/ui/keyboardshortcut.h @@ -0,0 +1,93 @@ +/* + * Qt UI + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Sungmin Ha + * GiWoong Kim + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef KEYBOARDSHORTCUT_H +#define KEYBOARDSHORTCUT_H + +#include +#include +#include + +#include "hardwarekey.h" +#include "menu/menuitem.h" + +class MainWindow; + +class KeyboardShortcut : public QWidget +{ + Q_OBJECT + +public: + KeyboardShortcut(QWidget *parent = 0); + ~KeyboardShortcut(); + + void setKeyboardShortcutHwKey(); + void setKeyboardShortcutController(); + void setKeyboardShortcutContextMenu(MenuItem *item, QString property, QString keySequence); + void removeControllerShortcut(); + void removeHwKeyShortcut(); + + QList getControllerShortcutList(); + QMap getPopupMenuShortcutMap(); + QMap getHwKeyShortcutMap(); + QMap getControllerShortcutMap(); + +public slots: + void slotShortcutHwKey(const QString &name); + void slotShortcutClose(); + void slotShortcutDetailedInfo(); + void slotShortcutControlPanel(); + void slotShortcutShell(); + void slotShortcutRequestScreenshot(); + void slotShortcutForceClose(); + void slotShortcutHostKeyboard(); + void slotShortcutController(); + void slotShortcutScalePrev(); + void slotShortcutScaleNext(); + void slotShortcutSwitchPrev(); + void slotShortcutSwitchNext(); + void slotShortcutTopMost(); + +private: + void registShortcutKey(QShortcut *shortcut, QString item); + int getHwKeyCode(const char *item); + void doHwKeyEvent(int keyCode); + + MainWindow *parent; + QList hwKeyList; + QList controllerKeyList; + QList controllerShortcutList; + QList hwKeyShortcutList; + QMap popupMenuShortcutMap; + QMap hwKeyShortcutMap; + QMap controllerShortcutMap; +}; + +#endif // KEYBOARDSHORTCUT_H diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index c5191e2..ddc2988 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -134,6 +134,10 @@ MainWindow::MainWindow(UIInformation *uiInfo, QWidget *parent) screenWidget = w; } + /* set HwKey shortcut */ + keyboardShortcut = new KeyboardShortcut(this); + keyboardShortcut->setKeyboardShortcutHwKey(); + /* popup menu */ popupMenu = new ContextMenu(this); @@ -269,6 +273,9 @@ void MainWindow::openController(int index, int dockPos) * So, we need an additional updating for display. */ display->update(); + /* set controller shortcut */ + keyboardShortcut->setKeyboardShortcutController(); + #ifdef CONFIG_LINUX popupMenu->slotTopMost(getUIState()->isOnTop()); #endif @@ -300,6 +307,9 @@ void MainWindow::closeController() /* Some part of QGLWidget's surface might be lost on Windows when view changing. * So, we need an additional updating for display. */ display->update(); + + /* remove controller shortcut */ + keyboardShortcut->removeControllerShortcut(); } void MainWindow::resizeEvent(QResizeEvent *event) @@ -392,6 +402,11 @@ void MainWindow::setTopMost(bool on) popupMenu->slotTopMost(on); } +KeyboardShortcut *MainWindow::getKeyboardShortcut() +{ + return keyboardShortcut; +} + MainWindow::~MainWindow() { qDebug("destory main window"); diff --git a/tizen/src/ui/mainwindow.h b/tizen/src/ui/mainwindow.h index 98da3f6..94714c5 100644 --- a/tizen/src/ui/mainwindow.h +++ b/tizen/src/ui/mainwindow.h @@ -43,6 +43,7 @@ #include "uiinformation.h" #include "dockingcontroller.h" #include "floatingcontroller.h" +#include "keyboardshortcut.h" extern "C" { #include "skin/maruskin_operation.h" @@ -75,6 +76,7 @@ public: UIState *getUIState(void); ContextMenu *getPopupMenu(); + KeyboardShortcut *getKeyboardShortcut(); QLabel *getScreenWidget(); void switchForm(int angle); void scaleForm(int scale); @@ -112,6 +114,7 @@ private: ContextMenu *popupMenu; QThread *swapperThread; DisplaySwapper *swapper; + KeyboardShortcut *keyboardShortcut; void (*captureRequestHandler)(void *data); void *captureRequestData; diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index 0b32324..54df96f 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -70,6 +70,7 @@ ContextMenu::ContextMenu(QWidget *parent) : QMenu(parent) void ContextMenu::createItems(QMenu *menu, QList &list) { MenuItem *item = NULL; + KeyboardShortcut *keyboardShortcut = parent->getKeyboardShortcut(); for (int i = 0; i < list.count(); i++) { item = list.at(i); @@ -133,6 +134,15 @@ void ContextMenu::createItems(QMenu *menu, QList &list) default: qWarning("unknown menu item type : %d", item->getType()); } + + QMap shortcutMap = item->getShortcutMap(); + if (!shortcutMap.isEmpty()) { + QMap::iterator iter; + for (iter = shortcutMap.begin(); iter != shortcutMap.end(); iter++) { + keyboardShortcut->setKeyboardShortcutContextMenu(item, + iter.key(), iter.value()); + } + } } } @@ -193,7 +203,7 @@ void ContextMenu::createSwitchItem(QMenu *menu, MenuItem *item) QString menuName = item->getName(); switchMenu = menu->addMenu( QIcon(QPixmap(":/icons/rotate.png")), menuName.isEmpty() ? "Switch" : menuName); - QActionGroup *switchGroup = new QActionGroup(this); + switchGroup = new QActionGroup(this); switchMapper = new QSignalMapper(this); connect(switchMapper, SIGNAL(mapped(int)), this, SLOT(slotSwitch(int))); @@ -226,7 +236,7 @@ void ContextMenu::createScaleItem(QMenu *menu, MenuItem *item) QString menuName = item->getName(); scaleMenu = menu->addMenu( QIcon(QPixmap(":/icons/scale.png")), menuName.isEmpty() ? "Scale" : menuName); - QActionGroup *scaleGroup = new QActionGroup(this); + scaleGroup = new QActionGroup(this); scaleMapper = new QSignalMapper(this); connect(scaleMapper, SIGNAL(mapped(int)), this, SLOT(slotScale(int))); @@ -267,7 +277,7 @@ void ContextMenu::createControllerItem(QMenu *menu, MenuItem *item) if (conFormList.isEmpty() == false) { QString menuName = item->getName(); controllerMenu = menu->addMenu(menuName.isEmpty() ? "Controller" : menuName); - QActionGroup *controllerGroup = new QActionGroup(this); + controllerGroup = new QActionGroup(this); controllerMapper = new QSignalMapper(this); connect(controllerMapper, SIGNAL(mapped(int)), this, SLOT(slotController(int))); @@ -300,14 +310,14 @@ void ContextMenu::createHostKeyboardItem(QMenu *menu, MenuItem *item) QString menuName = item->getName(); QMenu *keyboardMenu = menu->addMenu(QIcon(QPixmap(":/icons/host_keyboard.png")), menuName.isEmpty() ? "Host keyboard" : menuName); - QActionGroup *keyboardGroup = new QActionGroup(this); + keyboardGroup = new QActionGroup(this); - QAction *action = keyboardMenu->addAction("On"); + QAction *action = keyboardMenu->addAction(KEYBOARD_ON); action->setActionGroup(keyboardGroup); action->setCheckable(true); connect(action, SIGNAL(toggled(bool)), this, SLOT(slotHostKeyboard(bool))); - action = keyboardMenu->addAction("Off"); + action = keyboardMenu->addAction(KEYBOARD_OFF); action->setActionGroup(keyboardGroup); action->setCheckable(true); action->setChecked(true); @@ -451,6 +461,11 @@ void ContextMenu::slotSwitch(int index) qDebug("switch : %d", index); parent->switchForm(index); + + /* reset HwKey shortcut */ + KeyboardShortcut *keyboardShortcut = parent->getKeyboardShortcut(); + keyboardShortcut->removeHwKeyShortcut(); + keyboardShortcut->setKeyboardShortcutHwKey(); } void ContextMenu::slotScale(int scale) @@ -802,6 +817,11 @@ QSignalMapper *ContextMenu::getControllerMapper() return controllerMapper; } +QAction *ContextMenu::getActionTopMost() +{ + return actionTopMost; +} + ContextMenu::~ContextMenu() { qDebug("destroy menu"); diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h index a776b3b..cacc56c 100644 --- a/tizen/src/ui/menu/contextmenu.h +++ b/tizen/src/ui/menu/contextmenu.h @@ -38,6 +38,7 @@ #include "aboutdialog.h" #include "screenshotdialog.h" #include "menu/menuitem.h" +#include "keyboardshortcut.h" class MainWindow; @@ -48,6 +49,8 @@ extern "C" { } #define CLOSE_POWER_KEY_INTERVAL 1200 /* milli-seconds */ +#define KEYBOARD_ON "On" +#define KEYBOARD_OFF "Off" class ContextMenu : public QMenu { @@ -61,6 +64,12 @@ public: QSignalMapper *getScaleMapper(); QSignalMapper *getControllerMapper(); + QActionGroup *scaleGroup; + QActionGroup *keyboardGroup; + QActionGroup *controllerGroup; + QActionGroup *switchGroup; + + QAction *getActionTopMost(); ScreenShotDialog *screenshotDialog; signals: diff --git a/tizen/src/ui/menu/detailedinfodialog.cpp b/tizen/src/ui/menu/detailedinfodialog.cpp index 7c86f0c..ecc7084 100644 --- a/tizen/src/ui/menu/detailedinfodialog.cpp +++ b/tizen/src/ui/menu/detailedinfodialog.cpp @@ -40,8 +40,9 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) : { QStringList imagePathList = getImagePathList(); MainWindow *win = ((MainWindow *)parent); + keyboardShortcut = win->getKeyboardShortcut(); - setWindowTitle("Detailed Info"); + setWindowTitle(DETAILED_INFO_TITLE); baseLayout = new QVBoxLayout(this); baseLayout->setMargin(10); @@ -52,102 +53,87 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) : upsideLayout->setMargin(0); upsideLayout->setSpacing(0); + /* tab */ + QTabWidget *tabWidget = new QTabWidget(this); + QWidget *vmInfo = new QWidget; + QWidget *shortcutInfo = new QWidget; + tabWidget->addTab(vmInfo, tr("VM Info")); + tabWidget->addTab(shortcutInfo, tr("Shortcut Info")); + /* VM information table */ - infoTable = new QTableWidget(this); - infoTable->setRowCount(11); - infoTable->setColumnCount(2); - infoTable->setEditTriggers(QAbstractItemView::NoEditTriggers); - infoTable->setAlternatingRowColors(true); + vmInfoTable = new QTableWidget(vmInfo); + vmInfoTable->setColumnCount(2); + vmInfoTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + vmInfoTable->setAlternatingRowColors(true); - infoTable->verticalHeader()->hide(); - infoTable->resizeRowsToContents(); - infoTable->horizontalHeader()->setStretchLastSection(true); - infoTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + vmInfoTable->verticalHeader()->hide(); + vmInfoTable->resizeRowsToContents(); + vmInfoTable->horizontalHeader()->setStretchLastSection(true); + vmInfoTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); QStringList header; header << "Feature" << "Value"; - infoTable->setHorizontalHeaderLabels(header); + vmInfoTable->setHorizontalHeaderLabels(header); /* table items */ int index = 0; - item = new QTableWidgetItem("VM Name"); - infoTable->setItem(index, 0, item); - item = new QTableWidgetItem(win->uiInfo->vmName); - infoTable->setItem(index++, 1, item); - - item = new QTableWidgetItem("Skin Name"); - infoTable->setItem(index, 0, item); - item = new QTableWidgetItem(win->uiInfo->skinName); - infoTable->setItem(index++, 1, item); - - item = new QTableWidgetItem("CPU"); - infoTable->setItem(index, 0, item); - item = new QTableWidgetItem("x86"); - infoTable->setItem(index++, 1, item); - - item = new QTableWidgetItem("Ram Size"); - infoTable->setItem(index, 0, item); - item = new QTableWidgetItem(QString(get_emul_ram_size()) + " MB"); - infoTable->setItem(index++, 1, item); - - item = new QTableWidgetItem("Display Resolution"); - infoTable->setItem(index, 0, item); - item = new QTableWidgetItem(QString::number(win->uiInfo->resolution.width()) - + "x" + QString::number(win->uiInfo->resolution.height())); - infoTable->setItem(index++, 1, item); - + setDataTable(vmInfoTable, "VM Name", win->uiInfo->vmName, index++); + setDataTable(vmInfoTable, "Skin Name", win->uiInfo->skinName, index++); + setDataTable(vmInfoTable, "CPU", "x86", index++); + setDataTable(vmInfoTable, "Ram Size", QString(get_emul_ram_size()) + " MB", index++); + setDataTable(vmInfoTable, "Display Resolution", + QString::number(win->uiInfo->resolution.width()) + "x" + + QString::number(win->uiInfo->resolution.height()), index++); #if 0 - item = new QTableWidgetItem("Display Density"); - infoTable->setItem(index, 0, item); - item = new QTableWidgetItem("0"); // TODO: - infoTable->setItem(index++, 1, item); + setDataTable(vmInfoTable, "Display Density", "0"/* TODO: */, index++); #endif - item = new QTableWidgetItem("File Sharing Path"); - infoTable->setItem(index, 0, item); QString sharingPath(get_emul_file_sharing_path()); - item = new QTableWidgetItem((sharingPath.isEmpty()) ? "None" : sharingPath); - infoTable->setItem(index++, 1, item); - - item = new QTableWidgetItem("CPU Virtualization"); - infoTable->setItem(index, 0, item); - item = new QTableWidgetItem((get_emul_cpu_accel()) ? "Enabled" : "Disabled"); - infoTable->setItem(index++, 1, item); - - item = new QTableWidgetItem("GPU Virtualization"); - infoTable->setItem(index, 0, item); - item = new QTableWidgetItem((get_emul_gpu_accel()) ? "Enabled" : "Disabled"); - infoTable->setItem(index++, 1, item); + setDataTable(vmInfoTable, "File Sharing Path", (sharingPath.isEmpty()) ? "None" : sharingPath, index++); + setDataTable(vmInfoTable, "CPU Virtualization", (get_emul_cpu_accel()) ? "Enabled" : "Disabled", index++); + setDataTable(vmInfoTable, "GPU Virtualization", (get_emul_gpu_accel()) ? "Enabled" : "Disabled", index++); for (int i = 0; i < imagePathList.size(); i++) { - item = new QTableWidgetItem("Image Path " + QString::number(i + 1)); - infoTable->setItem(index, 0, item); - item = new QTableWidgetItem(imagePathList[i]); + setDataTable(vmInfoTable, "Image Path " + QString::number(i + 1), + imagePathList[i], index++); + item->setToolTip(imagePathList[i]); - infoTable->setItem(index++, 1, item); } - item = new QTableWidgetItem("Log Path"); - infoTable->setItem(index, 0, item); - item = new QTableWidgetItem(get_log_path()); + setDataTable(vmInfoTable, "Log Path", get_log_path(), index++); item->setToolTip(get_log_path()); - infoTable->setItem(index++, 1, item); /* temp */ - item = new QTableWidgetItem("Logging Telnet Port"); - infoTable->setItem(index, 0, item); - item = new QTableWidgetItem(QString::number(get_emul_serial_port())); - infoTable->setItem(index++, 1, item); + setDataTable(vmInfoTable, "Logging Telnet Port", QString::number(get_emul_serial_port()), index++); /* add double click event listener */ - connect(infoTable, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(slotDoubleClicked(int, int))); + connect(vmInfoTable, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(slotDoubleClicked(int, int))); - int tableHeight = infoTable->horizontalHeader()->height(); - for (int i = 0; i < infoTable->rowCount(); i++) { - tableHeight += infoTable->rowHeight(i); + int tableHeight = vmInfoTable->horizontalHeader()->height(); + for (int i = 0; i < vmInfoTable->rowCount(); i++) { + tableHeight += vmInfoTable->rowHeight(i); } - infoTable->setMinimumWidth(200); - infoTable->setMinimumHeight(tableHeight + 2/*border*/); - upsideLayout->addWidget(infoTable); + vmInfoTable->setMinimumWidth(200); + vmInfoTable->setMinimumHeight(tableHeight + 2/*border*/); + + /* shortcut info table */ + shortcutInfoTable = new QTableWidget(shortcutInfo); + shortcutInfoTable->setColumnCount(2); + shortcutInfoTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + shortcutInfoTable->setAlternatingRowColors(true); + + shortcutInfoTable->verticalHeader()->hide(); + shortcutInfoTable->horizontalHeader()->setStretchLastSection(true); + shortcutInfoTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + shortcutInfoTable->setMinimumHeight(tableHeight + 2); + + header.clear(); + header << "Function" << "Key sequence"; + shortcutInfoTable->setHorizontalHeaderLabels(header); + + tabWidget->setMinimumWidth(vmInfoTable->width() + 60); + tabWidget->setMinimumHeight(vmInfoTable->height() + 30); + + upsideLayout->addWidget(tabWidget); baseLayout->addLayout(upsideLayout); @@ -163,6 +149,32 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) : baseLayout->addLayout(downsideLayout); } +void DetailedInfoDialog::setShortcutInfoTable(QMap map) +{ + int row = shortcutInfoTable->rowCount(); + QMap::const_iterator mapIter = map.constBegin(); + while (mapIter != map.constEnd()) { + setDataTable(shortcutInfoTable, mapIter.key(), mapIter.value(), row++); + ++mapIter; + } +} + +void DetailedInfoDialog::setDataTable(QTableWidget* table, QString key, QString value, int index) +{ + table->insertRow(index); + item = new QTableWidgetItem(key); + table->setItem(index, 0, item); + item = new QTableWidgetItem(value); + table->setItem(index, 1, item); +} + +void DetailedInfoDialog::removeDataTable(QTableWidget* table, int startIndex, int lastIndex) +{ + for (int cnt = startIndex; cnt < lastIndex; cnt++) { + table->removeRow(startIndex); + } +} + QStringList DetailedInfoDialog::getImagePathList() { QStringList imagePathList; @@ -188,12 +200,12 @@ void DetailedInfoDialog::slotDoubleClicked(int nRow, int nCol) if (nCol == 0) return; - item = infoTable->item(nRow, 0); + item = vmInfoTable->item(nRow, 0); if (item->text().compare("File Sharing Path", Qt::CaseInsensitive) == 0 || - item->text().compare("Image Path", Qt::CaseInsensitive) == 0 || + item->text().startsWith("Image Path") == true || item->text().compare("Log Path", Qt::CaseInsensitive) == 0) { /* get path name */ - item = infoTable->item(nRow, nCol); + item = vmInfoTable->item(nRow, nCol); if (item->text().compare("None", Qt::CaseInsensitive) == 0 || item->text().compare("", Qt::CaseInsensitive) == 0) { /* ignore this event */ @@ -224,15 +236,32 @@ void DetailedInfoDialog::showEvent(QShowEvent *event) QWidget *win = parentWidget(); move(win->geometry().center().x() - (geometry().size().width() / 2), win->geometry().center().y() - (geometry().size().height() / 2)); + + /* insert shortcut info */ + removeDataTable(shortcutInfoTable, 0, shortcutInfoTable->rowCount()); + setShortcutInfoTable(keyboardShortcut->getPopupMenuShortcutMap()); + setShortcutInfoTable(keyboardShortcut->getHwKeyShortcutMap()); + setShortcutInfoTable(keyboardShortcut->getControllerShortcutMap()); +} + +QTableWidget *DetailedInfoDialog::getShortcutInfoTable() +{ + return shortcutInfoTable; } DetailedInfoDialog::~DetailedInfoDialog() { qDebug("destroy detailed info dialog"); - for (int i = 0; i < infoTable->rowCount(); i++) { - for (int j = 0; j < infoTable->columnCount(); j++) { - delete infoTable->item(i, j); + for (int i = 0; i < vmInfoTable->rowCount(); i++) { + for (int j = 0; j < vmInfoTable->columnCount(); j++) { + delete vmInfoTable->item(i, j); + } + } + + for (int i = 0; i < shortcutInfoTable->rowCount(); i++) { + for (int j = 0; j < shortcutInfoTable->columnCount(); j++) { + delete shortcutInfoTable->item(i, j); } } } diff --git a/tizen/src/ui/menu/detailedinfodialog.h b/tizen/src/ui/menu/detailedinfodialog.h index d20d299..c63b114 100644 --- a/tizen/src/ui/menu/detailedinfodialog.h +++ b/tizen/src/ui/menu/detailedinfodialog.h @@ -33,6 +33,10 @@ #include #include +#include "keyboardshortcut.h" + +#define DETAILED_INFO_TITLE "Detailed Info" + class DetailedInfoDialog : public QDialog { Q_OBJECT @@ -41,6 +45,11 @@ public: explicit DetailedInfoDialog(QWidget *parent = 0); ~DetailedInfoDialog(); + QTableWidget *getShortcutInfoTable(); + void setShortcutInfoTable(QMap map); + void setDataTable(QTableWidget* table, QString key, QString value, int index); + void removeDataTable(QTableWidget* table, int startIndex, int lastIndex); + protected: void showEvent(QShowEvent *event); @@ -51,10 +60,12 @@ private: QStringList getImagePathList(); QVBoxLayout *baseLayout; QHBoxLayout *upsideLayout; - QTableWidget *infoTable; + QTableWidget *vmInfoTable; + QTableWidget *shortcutInfoTable; QTableWidgetItem *item; QHBoxLayout *downsideLayout; QPushButton *okBtn; + KeyboardShortcut* keyboardShortcut; }; #endif // DETAILEDINFODIALOG_H diff --git a/tizen/src/ui/resource/mobile-720x1280-3btn/layout.xml b/tizen/src/ui/resource/mobile-720x1280-3btn/layout.xml index c882b07..cc5bc01 100644 --- a/tizen/src/ui/resource/mobile-720x1280-3btn/layout.xml +++ b/tizen/src/ui/resource/mobile-720x1280-3btn/layout.xml @@ -14,11 +14,13 @@ 169 Menu + F2 139 Home + F1 @@ -29,16 +31,19 @@ 116 Power + F3 115 Volume + + Ctrl+Num++ 114 Volume - + Ctrl+Num+- @@ -54,11 +59,13 @@ 169 Menu + F2 139 Home + F1 @@ -69,16 +76,19 @@ 116 Power + F3 115 Volume + + Ctrl+Num++ 114 Volume - + Ctrl+Num+- @@ -94,11 +104,13 @@ 169 Menu + F2 139 Home + F1 @@ -109,16 +121,19 @@ 116 Power + F3 115 Volume + + Ctrl+Num++ 114 Volume - + Ctrl+Num+- @@ -134,11 +149,13 @@ 169 Menu + F2 139 Home + F1 @@ -149,16 +166,19 @@ 116 Power + F3 115 Volume + + Ctrl+Num++ 114 Volume - + Ctrl+Num+- @@ -173,8 +193,8 @@ Ctrl+F2 - Ctrl+Num7 - Ctrl+Num9 + Ctrl+Num+7 + Ctrl+Num+9 Ctrl+F9 diff --git a/tizen/src/ui/resource/wearable-320x320-1btn/layout.xml b/tizen/src/ui/resource/wearable-320x320-1btn/layout.xml index e813380..9d329dd 100644 --- a/tizen/src/ui/resource/wearable-320x320-1btn/layout.xml +++ b/tizen/src/ui/resource/wearable-320x320-1btn/layout.xml @@ -14,6 +14,7 @@ 116 Power + F3 @@ -29,6 +30,7 @@ 116 Power + F3 @@ -44,6 +46,7 @@ 116 Power + F3 @@ -59,6 +62,7 @@ 116 Power + F3 @@ -73,8 +77,8 @@ Ctrl+F2 - Ctrl+Num7 - Ctrl+Num9 + Ctrl+Num+7 + Ctrl+Num+9 -- 2.7.4