本文整理汇总了C++中CommandManager::getActionFromShortcut方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandManager::getActionFromShortcut方法的具体用法?C++ CommandManager::getActionFromShortcut怎么用?C++ CommandManager::getActionFromShortcut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandManager
的用法示例。
在下文中一共展示了CommandManager::getActionFromShortcut方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressEvent
void ShortcutViewer::keyPressEvent(QKeyEvent *event)
{
int key = event->key();
if (key == Qt::Key_Control || key == Qt::Key_Shift || key == Qt::Key_Alt) {
event->ignore();
return;
}
Qt::KeyboardModifiers modifiers = event->modifiers();
// Tasti che non possono essere utilizzati come shortcut
if ((modifiers | (Qt::CTRL | Qt::SHIFT | Qt::ALT)) != (Qt::CTRL | Qt::SHIFT | Qt::ALT) || key == Qt::Key_Home || key == Qt::Key_End || key == Qt::Key_PageDown || key == Qt::Key_PageUp || key == Qt::Key_Escape || key == Qt::Key_Print || key == Qt::Key_Pause || key == Qt::Key_ScrollLock) {
if (key != Qt::Key_Plus && key != Qt::Key_Minus && key != Qt::Key_Asterisk && key != Qt::Key_Slash) {
event->ignore();
return;
} else
modifiers = 0;
}
if (m_action) {
CommandManager *cm = CommandManager::instance();
QKeySequence keySequence(key + modifiers);
std::string shortcutString = keySequence.toString().toStdString();
QAction *oldAction = cm->getActionFromShortcut(keySequence.toString().toStdString());
if (oldAction == m_action)
return;
if (oldAction) {
QString msg = tr("%1 is already assigned to '%2'\nAssign to '%3'?").arg(keySequence.toString()).arg(oldAction->iconText()).arg(m_action->iconText());
int ret = DVGui::MsgBox(msg, tr("Yes"), tr("No"), 1);
activateWindow();
if (ret == 2 || ret == 0)
return;
}
CommandManager::instance()->setShortcut(m_action, shortcutString);
emit shortcutChanged();
}
event->accept();
update();
}