qDebug() << "Removed hwKey shortcuts";
}
-void KeyboardShortcut::removePopupMenuShortcut()
-{
- for (int index = 0; index < popupMenuShortcutList.count(); index++) {
- delete popupMenuShortcutList.at(index);
- }
-
- popupMenuShortcutList.clear();
- popupMenuShortcutMap.clear();
-
- qDebug() << "Removed popupMenu shortcuts";
-}
-
void KeyboardShortcut::registShortcutKey(QShortcut *shortcut, QString item)
{
QSignalMapper *mapper = new QSignalMapper(this);
}
}
-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);
- }
-
- popupMenuShortcutList.append(shortcut);
- 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<QAction *> switchList = parent->getPopupMenu()->switchGroup->actions();
-
- if (!action) {
- qWarning() << "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<QAction *> switchList = parent->getPopupMenu()->switchGroup->actions();
-
- if (!action) {
- qWarning() << "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<QAction *> scaleList = parent->getPopupMenu()->scaleGroup->actions();
-
- if (!action) {
- qWarning() << "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<QAction *> scaleList = parent->getPopupMenu()->scaleGroup->actions();
-
- if (!action) {
- qWarning() << "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<QAction *> controllerList = parent->getPopupMenu()->controllerGroup->actions();
-
- if (!action) {
- qWarning() << "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) {
- qWarning() << "controllerList.at(" << index << ") is NULL";
- return;
- }
-
- nextControllerAction->setChecked(true);
- nextControllerAction->trigger();
-}
-
void KeyboardShortcut::slotShortcutHostKeyboard()
{
QAction *action = parent->getPopupMenu()->keyboardGroup->checkedAction();
return controllerShortcutList;
}
-QList<QShortcut *> KeyboardShortcut::getPopupMenuShortcutList()
-{
- return popupMenuShortcutList;
-}
-
QList<QShortcut *> KeyboardShortcut::getHwKeyShortcutList()
{
return hwKeyShortcutList;
}
-QMap<QString, QString> KeyboardShortcut::getPopupMenuShortcutMap()
-{
- return popupMenuShortcutMap;
-}
-
QMap<QString, QString> KeyboardShortcut::getHwKeyShortcutMap()
{
return hwKeyShortcutMap;
{
removeHwKeyShortcut();
removeControllerShortcut();
- removePopupMenuShortcut();
qDebug("destroy keyboard shortcut");
}
void ContextMenu::createItems(QMenu *menu, QList<MenuItem *> &list)
{
MenuItem *item = NULL;
- KeyboardShortcut *keyboardShortcut = parent->getKeyboardShortcut();
-
for (int i = 0; i < list.count(); i++) {
item = list.at(i);
- QMap<QString, QString> shortcutMap = item->getShortcutMap();
- if (!shortcutMap.isEmpty()) {
- QMap<QString, QString>::iterator iter;
- for (iter = shortcutMap.begin(); iter != shortcutMap.end(); iter++) {
- keyboardShortcut->setKeyboardShortcutContextMenu(item,
- iter.key(), iter.value());
- }
- }
-
switch (item->getType()) {
case MenuItemType::separator:
createSeparator(menu);
createItems(advancedMenu, ((AdvancedMenuItem *)item)->getMenuList());
}
-QString ContextMenu::getShortcutKeySeq(QString key)
-{
- KeyboardShortcut *keyboardShortcut = parent->getKeyboardShortcut();
- QMap<QString, QString> shortcutMap = keyboardShortcut->getPopupMenuShortcutMap();
- QMap<QString, QString>::iterator iter;
- QString keySequence;
-
- if (!shortcutMap.isEmpty()) {
- for (iter = shortcutMap.begin(); iter != shortcutMap.end(); iter++) {
- if (iter.key().startsWith(key)) {
- keySequence.append(iter.value());
- break;
- }
- }
- }
-
- return keySequence;
-}
-
void ContextMenu::createInfoItem(QMenu *menu, MenuItem *item)
{
if (menu == NULL || item == NULL) {
}
QString menuName = item->getName();
- actionDetailedInfo = addGeneralAction(menu, QIcon(QPixmap(":/icons/detailed_info.png")),
- menuName.isEmpty() ? vmName : menuName, SLOT(slotDetailedInfo()),
- getShortcutKeySeq(DETAILED_INFO_TITLE));
+ actionDetailedInfo = addGeneralAction(
+ menu, QIcon(QPixmap(":/icons/detailed_info.png")),
+ menuName.isEmpty() ? vmName : menuName,
+ item->getShortcutMap().isEmpty()? NULL :
+ new QShortcut(item->getShortcutMap().begin().value(), parent),
+ SLOT(slotDetailedInfo()));
+
+ actionDetailedInfo->setIconText(menuName.isEmpty() ? QString(DETAILED_INFO_TITLE) : menuName);
+
+ item->setAction(actionDetailedInfo);
}
void ContextMenu::createOnTopItem(QMenu *menu, MenuItem *item)
QString menuName = item->getName();
actionTopMost = menu->addAction(
menuName.isEmpty() ? MENU_ONTOP_ITEM_TEXT : menuName);
- actionTopMost->setShortcut(getShortcutKeySeq(menuName));
actionTopMost->setCheckable(true);
connect(actionTopMost, SIGNAL(triggered(bool)), this, SLOT(slotTopMost(bool)));
+
+ /* shortcut */
+ if (item->getShortcutMap().isEmpty() == false) {
+ QShortcut *shortcut = new QShortcut(
+ item->getShortcutMap().begin().value(), parent);
+ connect(shortcut, SIGNAL(activated()), this, SLOT(slotTopMostShortcut()));
+
+ actionTopMost->setShortcut(shortcut->key());
+ }
+
+ item->setAction(actionTopMost);
}
void ContextMenu::createSwitchItem(QMenu *menu, MenuItem *item)
switchMenu = menu->addMenu(QIcon(QPixmap(":/icons/rotate.png")),
menuName.isEmpty() ? MENU_SWITCH_ITEM_TEXT : menuName);
- QAction *menuAction = switchMenu->menuAction();
- menuAction->setShortcut(getShortcutKeySeq(menuName));
switchGroup = new QActionGroup(this);
switchMapper = new QSignalMapper(this);
connect(switchMapper, SIGNAL(mapped(int)), this, SLOT(slotSwitch(int)));
+ /* shortcuts */
+ QAction *switchAction = switchMenu->menuAction();
+ QMap<QString, QKeySequence> shortcutMap = item->getShortcutMap();
+
+ if (shortcutMap.isEmpty() == false) {
+ QMap<QString, QKeySequence>::const_iterator iter;
+ if ((iter = shortcutMap.find("prev")) != shortcutMap.end()) {
+ QShortcut *shortcut = new QShortcut(iter.value(), parent);
+ connect(shortcut, SIGNAL(activated()), this, SLOT(slotSwitchShortcutPrev()));
+
+ switchAction->setShortcut(shortcut->key());
+ }
+ if ((iter = shortcutMap.find("next")) != shortcutMap.end()) {
+ QShortcut *shortcut = new QShortcut(iter.value(), parent);
+ connect(shortcut, SIGNAL(activated()), this, SLOT(slotSwitchShortcutNext()));
+
+ switchAction->setShortcut(shortcut->key());
+ }
+
+ if (switchAction->shortcut().isEmpty() == true) {
+ QShortcut *shortcut = new QShortcut(
+ item->getShortcutMap().begin().value(), parent);
+ connect(shortcut, SIGNAL(activated()), this, SLOT(slotSwitchShortcutNext()));
+
+ switchAction->setShortcut(shortcut->key());
+ }
+ }
+
QAction *action = NULL;
for (int i = 0; i < mainFormList.count(); i++) {
action = switchMenu->addAction(mainFormList.at(i)->getName());
} else {
qWarning("cannot create a switchItem");
}
+
+ item->setAction(switchMenu->menuAction());
}
void ContextMenu::createScaleItem(QMenu *menu, MenuItem *item)
scaleMenu = menu->addMenu(QIcon(QPixmap(":/icons/scale.png")),
menuName.isEmpty() ? MENU_SCALE_ITEM_TEXT : menuName);
- QAction *menuAction = scaleMenu->menuAction();
- menuAction->setShortcut(getShortcutKeySeq(menuName));
scaleGroup = new QActionGroup(this);
scaleMapper = new QSignalMapper(this);
connect(scaleMapper, SIGNAL(mapped(int)), this, SLOT(slotScale(int)));
+ /* shortcuts */
+ QAction *scaleAction = scaleMenu->menuAction();
+ QMap<QString, QKeySequence> shortcutMap = item->getShortcutMap();
+
+ if (shortcutMap.isEmpty() == false) {
+ QMap<QString, QKeySequence>::const_iterator shortcutIter;
+ if ((shortcutIter = shortcutMap.find("prev")) != shortcutMap.end()) {
+ QShortcut *shortcut = new QShortcut(shortcutIter.value(), parent);
+ connect(shortcut, SIGNAL(activated()), this, SLOT(slotScaleShortcutPrev()));
+
+ scaleAction->setShortcut(shortcut->key());
+ }
+ if ((shortcutIter = shortcutMap.find("next")) != shortcutMap.end()) {
+ QShortcut *shortcut = new QShortcut(shortcutIter.value(), parent);
+ connect(shortcut, SIGNAL(activated()), this, SLOT(slotScaleShortcutNext()));
+
+ scaleAction->setShortcut(shortcut->key());
+ }
+
+ if (scaleAction->shortcut().isEmpty() == true) {
+ QShortcut *shortcut = new QShortcut(
+ item->getShortcutMap().begin().value(), parent);
+ connect(shortcut, SIGNAL(activated()), this, SLOT(slotScaleShortcutNext()));
+
+ scaleAction->setShortcut(shortcut->key());
+ }
+ }
+
QAction *action = NULL;
- QMapIterator<int, QString> iter(factorMap);
- iter.toBack();
- while(iter.hasPrevious() == true) {
- iter.previous();
+ QMapIterator<int, QString> factorIter(factorMap);
+ factorIter.toBack();
+ while(factorIter.hasPrevious() == true) {
+ factorIter.previous();
- QString factorName = iter.value();
+ QString factorName = factorIter.value();
action = scaleMenu->addAction(
- factorName.isEmpty() ? (QString::number(iter.key()) + '%') : factorName);
+ factorName.isEmpty() ? (QString::number(factorIter.key()) + '%') : factorName);
action->setActionGroup(scaleGroup);
action->setCheckable(true);
- scaleMapper->setMapping(action, iter.key());
+ scaleMapper->setMapping(action, factorIter.key());
connect(action, SIGNAL(triggered()), scaleMapper, SLOT(map()));
}
} else {
qWarning("cannot create a scaleItem");
}
+
+ item->setAction(scaleMenu->menuAction());
}
void ContextMenu::createControllerItem(QMenu *menu, MenuItem *item)
controllerMenu = menu->addMenu(
menuName.isEmpty() ? MENU_CONTROLLER_ITEM_TEXT : menuName);
- QAction *menuAction = controllerMenu->menuAction();
- menuAction->setShortcut(getShortcutKeySeq(menuName));
controllerGroup = new QActionGroup(this);
controllerMapper = new QSignalMapper(this);
- connect(controllerMapper, SIGNAL(mapped(int)), this,
- SLOT(slotController(int)));
+ connect(controllerMapper, SIGNAL(mapped(int)), this, SLOT(slotController(int)));
+
+ /* shortcuts */
+ QAction *conAction = controllerMenu->menuAction();
+ QMap<QString, QKeySequence> shortcutMap = item->getShortcutMap();
+
+ if (shortcutMap.isEmpty() == false) {
+ QMap<QString, QKeySequence>::const_iterator iter;
+ if ((iter = shortcutMap.find("prev")) != shortcutMap.end()) {
+ QShortcut *shortcut = new QShortcut(iter.value(), parent);
+ connect(shortcut, SIGNAL(activated()), this, SLOT(slotConShortcutPrev()));
+
+ conAction->setShortcut(shortcut->key());
+ }
+ if ((iter = shortcutMap.find("next")) != shortcutMap.end()) {
+ QShortcut *shortcut = new QShortcut(iter.value(), parent);
+ connect(shortcut, SIGNAL(activated()), this, SLOT(slotConShortcutNext()));
+
+ conAction->setShortcut(shortcut->key());
+ }
+
+ if (conAction->shortcut().isEmpty() == true) {
+ QShortcut *shortcut = new QShortcut(
+ item->getShortcutMap().begin().value(), parent);
+ connect(shortcut, SIGNAL(activated()), this, SLOT(slotConShortcutNext()));
+
+ conAction->setShortcut(shortcut->key());
+ }
+ }
QAction *action = NULL;
action = controllerMenu->addAction("None");
} else {
qWarning("cannot create a controllerItem");
}
+
+ item->setAction(controllerMenu->menuAction());
}
void ContextMenu::createHostKeyboardItem(QMenu *menu, MenuItem *item)
QString menuName = item->getName();
QMenu *keyboardMenu = menu->addMenu(QIcon(QPixmap(":/icons/host_keyboard.png")),
menuName.isEmpty() ? MENU_HOSTKBD_ITEM_TEXT : menuName);
- QAction *menuAction = keyboardMenu->menuAction();
- menuAction->setShortcut(getShortcutKeySeq(menuName));
keyboardGroup = new QActionGroup(this);
- QAction *action = keyboardMenu->addAction(MENU_ON_ITEM_TEXT);
- action->setActionGroup(keyboardGroup);
- action->setCheckable(true);
- connect(action, SIGNAL(toggled(bool)), this, SLOT(slotHostKeyboard(bool)));
+ QAction *hostKbdAction = keyboardMenu->addAction(MENU_ON_ITEM_TEXT);
+ hostKbdAction->setActionGroup(keyboardGroup);
+ hostKbdAction->setCheckable(true);
+ connect(hostKbdAction, SIGNAL(toggled(bool)), this, SLOT(slotHostKeyboard(bool)));
- action = keyboardMenu->addAction(MENU_OFF_ITEM_TEXT);
- action->setActionGroup(keyboardGroup);
- action->setCheckable(true);
- action->setChecked(true);
+ /* shortcuts */
+ // TODO:
+
+ hostKbdAction = keyboardMenu->addAction(MENU_OFF_ITEM_TEXT);
+ hostKbdAction->setActionGroup(keyboardGroup);
+ hostKbdAction->setCheckable(true);
+ hostKbdAction->setChecked(true);
+
+ item->setAction(hostKbdAction);
}
void ContextMenu::createShellItem(QMenu *menu, MenuItem *item)
}
QString menuName = item->getName();
- actionShell = addGeneralAction(menu, QIcon(QPixmap(":/icons/shell.png")),
- menuName.isEmpty() ? MENU_SHELL_ITEM_TEXT : menuName, SLOT(slotShell()),
- getShortcutKeySeq(menuName));
+ actionShell = addGeneralAction(
+ menu, QIcon(QPixmap(":/icons/shell.png")),
+ menuName.isEmpty() ? MENU_SHELL_ITEM_TEXT : menuName,
+ item->getShortcutMap().isEmpty()? NULL :
+ new QShortcut(item->getShortcutMap().begin().value(), parent),
+ SLOT(slotShell()));
+
+ item->setAction(actionShell);
}
void ContextMenu::createControlPanelItem(QMenu *menu, MenuItem *item)
actionControlPanel = addGeneralAction(
menu, QIcon(QPixmap(":/icons/control_panel.png")),
menuName.isEmpty() ? MENU_ECP_ITEM_TEXT : menuName,
- SLOT(slotControlPanel()),
- getShortcutKeySeq(menuName));
+ item->getShortcutMap().isEmpty()? NULL :
+ new QShortcut(item->getShortcutMap().begin().value(), parent),
+ SLOT(slotControlPanel()));
+
+ item->setAction(actionControlPanel);
}
void ContextMenu::createScreenShotItem(QMenu *menu, MenuItem *item)
actionScreenShot = addGeneralAction(
menu, QIcon(QPixmap(":/icons/screen_shot.png")),
menuName.isEmpty() ? MENU_SCREENSHOT_ITEM_TEXT : menuName,
- SLOT(slotRequestScreenshot()),
- getShortcutKeySeq(menuName));
+ item->getShortcutMap().isEmpty()? NULL :
+ new QShortcut(item->getShortcutMap().begin().value(), parent),
+ SLOT(slotRequestScreenshot()));
+
+ item->setAction(actionScreenShot);
}
void ContextMenu::createAboutItem(QMenu *menu, MenuItem *item)
}
QString menuName = item->getName();
- actionAbout = addGeneralAction(menu, QIcon(QPixmap(":/icons/about.png")),
- menuName.isEmpty() ? MENU_ABOUT_ITEM_TEXT : menuName, SLOT(slotAbout()),
- getShortcutKeySeq(menuName));
+ actionAbout = addGeneralAction(
+ menu, QIcon(QPixmap(":/icons/about.png")),
+ menuName.isEmpty() ? MENU_ABOUT_ITEM_TEXT : menuName,
+ item->getShortcutMap().isEmpty()? NULL :
+ new QShortcut(item->getShortcutMap().begin().value(), parent),
+ SLOT(slotAbout()));
+
+ item->setAction(actionAbout);
}
void ContextMenu::createForceCloseItem(QMenu *menu, MenuItem *item)
actionForceClose = addGeneralAction(
menu, QIcon(QPixmap(":/icons/force_close.png")),
menuName.isEmpty() ? MENU_FORCECLOSE_ITEM_TEXT : menuName,
- SLOT(slotForceClose()),
- getShortcutKeySeq(menuName));
+ item->getShortcutMap().isEmpty()? NULL :
+ new QShortcut(item->getShortcutMap().begin().value(), parent),
+ SLOT(slotForceClose()));
+
+ item->setAction(actionForceClose);
}
void ContextMenu::createCloseItem(QMenu *menu, MenuItem *item)
}
QString menuName = item->getName();
- actionClose = addGeneralAction(menu, QIcon(QPixmap(":/icons/close.png")),
- menuName.isEmpty() ? MENU_CLOSE_ITEM_TEXT : menuName, SLOT(slotClose()),
- getShortcutKeySeq(menuName));
+ actionClose = addGeneralAction(
+ menu, QIcon(QPixmap(":/icons/close.png")),
+ menuName.isEmpty() ? MENU_CLOSE_ITEM_TEXT : menuName,
+ item->getShortcutMap().isEmpty()? NULL :
+ new QShortcut(item->getShortcutMap().begin().value(), parent),
+ SLOT(slotClose()));
+
+ item->setAction(actionClose);
}
QAction *ContextMenu::addGeneralAction(QMenu *menu,
- const QIcon &icon, const QString &text, const char *slot, const QString &shortcut)
+ const QIcon &icon, const QString &text, QShortcut *shortcut, const char *slot)
{
QAction *action = menu->addAction(text);
action->setIcon(icon);
- action->setShortcut(shortcut);
connect(action, SIGNAL(triggered()), this, slot);
+ if (shortcut != NULL) {
+ connect(shortcut, SIGNAL(activated()), this, slot);
+ action->setShortcut(shortcut->key());
+ }
+
return action;
}
parent->getUIState()->setOnTop(on);
}
+void ContextMenu::slotTopMostShortcut()
+{
+ /* toggle */
+ slotTopMost(!actionTopMost->isChecked());
+
+ qDebug() << "shortcut:" << actionTopMost->text() << actionTopMost->isChecked();
+}
+
void ContextMenu::slotSwitch(int index)
{
qDebug("switch : %d", index);
keyboardShortcut->setKeyboardShortcutHwKey();
}
+void ContextMenu::slotSwitchShortcutPrev()
+{
+ QList<QAction *> switchActions = switchGroup->actions();
+ if (switchActions.count() < 2) {
+ return;
+ }
+
+ int index = 0;
+
+ QAction *action = switchGroup->checkedAction();
+ if (action != NULL) {
+ index = switchActions.indexOf(action);
+ if (index == 0) {
+ index = switchActions.count() - 1;
+ } else {
+ index--;
+ }
+ }
+
+ QAction *prevAction = switchActions.at(index);
+ prevAction->setChecked(true);
+ prevAction->trigger();
+
+ qDebug() << "shortcut: prev" << switchMenu->title() << prevAction->text();
+}
+
+void ContextMenu::slotSwitchShortcutNext()
+{
+ QList<QAction *> switchActions = switchGroup->actions();
+ if (switchActions.count() < 2) {
+ return;
+ }
+
+ int index = 0;
+
+ QAction *action = switchGroup->checkedAction();
+ if (action != NULL) {
+ index = switchActions.indexOf(action);
+ if (index == switchActions.count() - 1) {
+ index = 0;
+ } else {
+ index++;
+ }
+ }
+
+ QAction *nextAction = switchActions.at(index);
+ nextAction->setChecked(true);
+ nextAction->trigger();
+
+ qDebug() << "shortcut: next" << switchMenu->title() << nextAction->text();
+}
+
void ContextMenu::slotScale(int scale)
{
qDebug("scale : %d", scale);
}
}
+void ContextMenu::slotScaleShortcutPrev()
+{
+ QList<QAction *> scaleActions = scaleGroup->actions();
+ if (scaleActions.count() < 2) {
+ return;
+ }
+
+ int index = 0;
+
+ QAction *action = scaleGroup->checkedAction();
+ if (action != NULL) {
+ index = scaleActions.indexOf(action);
+ if (index == 0) {
+ index = scaleActions.count() - 1;
+ } else {
+ index--;
+ }
+ }
+
+ QAction *prevAction = scaleActions.at(index);
+ prevAction->setChecked(true);
+ prevAction->trigger();
+
+ qDebug() << "shortcut: prev" << scaleMenu->title() << prevAction->text();
+}
+
+void ContextMenu::slotScaleShortcutNext()
+{
+ QList<QAction *> scaleActions = scaleGroup->actions();
+ if (scaleActions.count() < 2) {
+ return;
+ }
+
+ int index = 0;
+
+ QAction *action = scaleGroup->checkedAction();
+ if (action != NULL) {
+ index = scaleActions.indexOf(action);
+ if (index == scaleActions.count() - 1) {
+ index = 0;
+ } else {
+ index++;
+ }
+ }
+
+ QAction *nextAction = scaleActions.at(index);
+ nextAction->setChecked(true);
+ nextAction->trigger();
+
+ qDebug() << "shortcut: next" << scaleMenu->title() << nextAction->text();
+}
+
void ContextMenu::slotController(int index)
{
qDebug("controller : %d", index);
parent->getUIState()->conState.conFormIndex = -1;
}
+void ContextMenu::slotConShortcutPrev()
+{
+ QList<QAction *> conActions = controllerGroup->actions();
+ if (conActions.count() < 2) {
+ return;
+ }
+
+ int index = 0;
+
+ QAction *action = controllerGroup->checkedAction();
+ if (action != NULL) {
+ index = conActions.indexOf(action);
+ if (index == 0) {
+ index = conActions.count() - 1;
+ } else {
+ index--;
+ }
+ }
+
+ QAction *prevAction = conActions.at(index);
+ prevAction->setChecked(true);
+ prevAction->trigger();
+
+ qDebug() << "shortcut: prev" << controllerMenu->title() << prevAction->text();
+}
+
+void ContextMenu::slotConShortcutNext()
+{
+ QList<QAction *> conActions = controllerGroup->actions();
+ if (conActions.count() < 2) {
+ return;
+ }
+
+ int index = 0;
+
+ QAction *action = controllerGroup->checkedAction();
+ if (action != NULL) {
+ index = conActions.indexOf(action);
+ if (index == conActions.count() - 1) {
+ index = 0;
+ } else {
+ index++;
+ }
+ }
+
+ QAction *nextAction = conActions.at(index);
+ nextAction->setChecked(true);
+ nextAction->trigger();
+
+ qDebug() << "shortcut: next" << controllerMenu->title() << nextAction->text();
+}
+
void ContextMenu::slotShell()
{
qDebug("SDB shell");
return controllerMapper;
}
-QAction *ContextMenu::getActionTopMost()
-{
- return actionTopMost;
-}
-
QMessageBox *ContextMenu::showMsgBox(
QMessageBox::Icon iconType, const QString &text,
QMessageBox::StandardButtons buttons,