本文整理汇总了C++中KShortcut::keyCodeQt方法的典型用法代码示例。如果您正苦于以下问题:C++ KShortcut::keyCodeQt方法的具体用法?C++ KShortcut::keyCodeQt怎么用?C++ KShortcut::keyCodeQt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KShortcut
的用法示例。
在下文中一共展示了KShortcut::keyCodeQt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addShortcut
void starter::addShortcut(const KShortcut &cut)
{
// in case of empty shortcut, remove the entry from the list and return
if (!short(cut.keyCodeQt()))
{
ShortcutList::Iterator it;
for ( it = shortcutList.begin(); it != shortcutList.end(); ++it )
if (it.data() == configDialog->categoryList->currentText())
{
shortcutList.remove(it);
break;
}
configDialog->buttonShortcut->setShortcut(KShortcut::null(), false);
return;
}
// generate MyKey
short state = 0;
if (cut.seq(0).key(0).modFlags() & KKey::CTRL)
state |= Qt::ControlButton;
if (cut.seq(0).key(0).modFlags() & KKey::ALT)
state |= Qt::AltButton;
if (cut.seq(0).key(0).modFlags() & KKey::SHIFT)
state |= Qt::ShiftButton;
MyKey key(cut.seq(0).keyCodeQt(), state);
// Test if this is a valid shotrcut, i.e. contains 'ctrl' or 'alt', returns iff not
if (!(state & Qt::ControlButton || state & Qt::AltButton))
{
KMessageBox::sorry(this, i18n("<qt>To ensure usefull behaviour of the searchline, the shortcut <b>must contain</b> a metabutton, i.e. <b>'ctrl' and/or 'alt'</b></qt>"), i18n("Sorry, invalid Shortcut"));
return;
}
// test if the cut was allready bound to another category and ask the user whta to do (return iff not rebind)
ShortcutList::Iterator it = shortcutList.find(key);
if ((it != shortcutList.end() && KMessageBox::questionYesNo(this, i18n("<qt>The selected shortcut is allready bound to the category \"%1\".<br>Do you want to <b>rebind</b> it?</qt>").arg(it.data()), i18n("Rebind Shortcut?")) == KMessageBox::No))
return;
// if rebind (it is not end and we did not return ;) remove the old shortcut
if (it != shortcutList.end())
{
shortcutList.remove(it);
}
// test if another shortcut is bound to this category and remove it in case
for ( it = shortcutList.begin(); it != shortcutList.end(); ++it )
if (it.data() == configDialog->categoryList->currentText())
{
shortcutList.remove(it);
break;
}
// add new shortcut/category map entry
shortcutList[key] = configDialog->categoryList->currentText();
// update UI
configDialog->buttonShortcut->setShortcut(cut, false);
}
示例2: contextMenuKey
int KGlobalSettings::contextMenuKey ()
{
KConfigGroup g(KGlobal::config(), "Shortcuts");
KShortcut cut (g.readEntry ("PopupMenuContext", "Menu"));
return cut.keyCodeQt();
}