本文整理汇总了C++中KShortcut::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ KShortcut::toString方法的具体用法?C++ KShortcut::toString怎么用?C++ KShortcut::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KShortcut
的用法示例。
在下文中一共展示了KShortcut::toString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotCapturedShortcut
void BasicTab::slotCapturedShortcut(const KShortcut &cut)
{
if(signalsBlocked())
return;
if(KKeyChooser::checkGlobalShortcutsConflict(cut, true, topLevelWidget())
|| KKeyChooser::checkStandardShortcutsConflict(cut, true, topLevelWidget()))
return;
if(KHotKeys::present())
{
if(!_menuEntryInfo->isShortcutAvailable(cut))
{
KService::Ptr service;
emit findServiceShortcut(cut, service);
if(!service)
service = KHotKeys::findMenuEntry(cut.toString());
if(service)
{
KMessageBox::sorry(this, i18n("<qt>The key <b>%1</b> can not be used here because it is already used to activate <b>%2</b>.")
.arg(cut.toString(), service->name()));
return;
}
else
{
KMessageBox::sorry(this, i18n("<qt>The key <b>%1</b> can not be used here because it is already in use.").arg(cut.toString()));
return;
}
}
_menuEntryInfo->setShortcut(cut);
}
_keyEdit->setShortcut(cut, false);
if(_menuEntryInfo)
emit changed(_menuEntryInfo);
}
示例2: isKeyPresentLocally
bool KKeyChooser::isKeyPresentLocally(const KShortcut &cut, KKeyChooserItem *ignoreItem, bool bWarnUser)
{
if(cut.toString().isEmpty())
return false;
// Search for shortcut conflicts with other actions in the
// lists we're configuring.
for(QListViewItemIterator it(d->pList); it.current(); ++it)
{
KKeyChooserItem *pItem2 = dynamic_cast< KKeyChooserItem * >(it.current());
if(pItem2 && pItem2 != ignoreItem)
{
int iSeq = keyConflict(cut, pItem2->shortcut());
if(iSeq > -1)
{
if(bWarnUser)
{
if(!promptForReassign(cut.seq(iSeq), pItem2->text(0), Application, this))
return true;
// else remove the shortcut from it
KShortcut cut2 = pItem2->shortcut();
removeFromShortcut(cut2, cut);
pItem2->setShortcut(cut2);
updateButtons();
emit keyChange();
}
}
}
}
return false;
}
示例3: setShortcut
void KKeyChooser::setShortcut(const KShortcut &cut)
{
kdDebug(125) << "KKeyChooser::setShortcut( " << cut.toString() << " )" << endl;
KKeyChooserItem *pItem = dynamic_cast< KKeyChooserItem * >(d->pList->currentItem());
if(!pItem)
return;
for(uint i = 0; i < cut.count(); i++)
{
const KKeySequence &seq = cut.seq(i);
const KKey &key = seq.key(0);
if(!d->bAllowLetterShortcuts && key.modFlags() == 0 && key.sym() < 0x3000 && QChar(key.sym()).isLetterOrNumber())
{
QString s = i18n(
"In order to use the '%1' key as a shortcut, "
"it must be combined with the "
"Win, Alt, Ctrl, and/or Shift keys.")
.arg(QChar(key.sym()));
KMessageBox::sorry(this, s, i18n("Invalid Shortcut Key"));
return;
}
}
// If key isn't already in use,
if(!isKeyPresent(cut))
{
// Set new key code
pItem->setShortcut(cut);
// Update display
updateButtons();
emit keyChange();
}
}
示例4: slotCapturedShortcut
void FolderShortcutDialog::slotCapturedShortcut( const KShortcut& sc )
{
if ( sc == mKeyButton->shortcut() ) return;
if ( sc.toString().isNull() ) {
// null is fine, that's reset, but sc.іsNull() will be false :/
mKeyButton->setShortcut( KShortcut::null(), false );
} else {
if( !mMainWidget->shortcutIsValid( sc ) ) {
QString msg( i18n( "The selected shortcut is already used, "
"please select a different one." ) );
KMessageBox::sorry( mMainWidget, msg );
} else {
mKeyButton->setShortcut( sc, false );
}
}
}
示例5: slotCapturedShortcut
void SnippetDlg::slotCapturedShortcut(const KShortcut &sc)
{
if(sc == keyButton->shortcut()) return;
if(sc.toString().isNull())
{
// null is fine, that's reset, but sc.іsNull() will be false :/
keyButton->setShortcut(KShortcut::null(), false);
}
else
{
if(!shortcutIsValid(actionCollection, sc))
{
QString msg(i18n("The selected shortcut is already used, "
"please select a different one."));
KMessageBox::sorry(this, msg);
}
else
{
keyButton->setShortcut(sc, false);
}
}
}
示例6: slotShortcutCaptured
void ActionConfigDialog::slotShortcutCaptured(const KShortcut &shortcut)
{
QString shortcutText = shortcut.toString();
QString shortcutText2;
int pos = shortcutText.find(';');
if (pos != -1)
{
shortcutText2 = shortcutText.mid(pos + 1);
shortcutText = shortcutText.left(pos);
}
QString s = shortcutText;
s.replace('+', "\\+");
QRegExp shortcutRx("\\(" + s + "\\)|" + s + "$|" + s + ";");
s = shortcutText2;
s.replace('+', "\\+");
QRegExp shortcutRx2("\\(" + s + "\\)|" + s + "$|" + s + ";");
QString global;
//check for conflicting global shortcuts
QMap<QString, QString>::Iterator it;
for ( it = globalShortcuts.begin(); it != globalShortcuts.end(); ++it )
{
if (it.data().contains(shortcutRx))
{
global = it.key();
break;
}
if (!shortcutText2.isEmpty() && it.data().contains(shortcutRx2))
{
shortcutText = shortcutText2;
global = it.key();
break;
}
}
if (global.isEmpty())
{
QPtrList<KXMLGUIClient> clients = m_mainWindow->guiFactory()->clients();
for( QPtrListIterator<KXMLGUIClient> it( clients ); it.current(); ++it )
{
KActionCollection *ac = (*it)->actionCollection();
for (uint i = 0; i < ac->count(); i++)
{
KAction *action = ac->action(i);
if (action != currentAction && action->shortcut().toString().contains(shortcutRx))
{
global = action->text();
break;
}
if (!shortcutText2.isEmpty() && action != currentAction && action->shortcut().toString().contains(shortcutRx))
{
shortcutText = shortcutText2;
global = action->text();
break;
}
}
if (!global.isEmpty())
break;
}
}
if (global.isEmpty())
{
shortcutKeyButton->setText(shortcutText);
buttonApply->setEnabled(true);
selectedShortcut = shortcut;
} else
{
global.replace('&',"");
QString s = i18n("The '%1' key combination has already been allocated "
"to the \"%2\" action.\n"
"Please choose a unique key combination.").
arg(shortcutText).arg(global);
KMessageBox::sorry( this, s, i18n("Conflicting Shortcuts"));
}
}