本文整理汇总了C++中Shortcut::shortcut方法的典型用法代码示例。如果您正苦于以下问题:C++ Shortcut::shortcut方法的具体用法?C++ Shortcut::shortcut怎么用?C++ Shortcut::shortcut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shortcut
的用法示例。
在下文中一共展示了Shortcut::shortcut方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qWarning
/*!
\brief Makes a \a shortcut known to the system under the specified \a id.
Returns a command object that represents the shortcut in the application and is
owned by the ActionManager. You can registered several shortcuts with the
same \a id as long as the \a context is different. In this case
a trigger of the actual shortcut is forwarded to the registered QShortcut
for the currently active context.
A scriptable shortcut can be called from a script without the need for the user
to interact with it.
*/
Command *ActionManager::registerShortcut(QShortcut *shortcut, const Id &id, const Context &context, bool scriptable)
{
Shortcut *sc = 0;
if (CommandPrivate *c = m_instance->d->m_idCmdMap.value(id, 0)) {
sc = qobject_cast<Shortcut *>(c);
if (!sc) {
qWarning() << "registerShortcut: id" << id.name()
<< "is registered with a different command type.";
return c;
}
} else {
sc = new Shortcut(id);
m_instance->d->m_idCmdMap.insert(id, sc);
}
if (sc->shortcut()) {
qWarning() << "registerShortcut: action already registered, id" << id.name() << ".";
return sc;
}
if (!m_instance->d->hasContext(context))
shortcut->setEnabled(false);
shortcut->setObjectName(id.toString());
shortcut->setParent(ICore::mainWindow());
sc->setShortcut(shortcut);
sc->setScriptable(scriptable);
if (context.isEmpty())
sc->setContext(Context(0));
else
sc->setContext(context);
emit m_instance->commandListChanged();
emit m_instance->commandAdded(id.toString());
if (isPresentationModeEnabled())
connect(sc->shortcut(), SIGNAL(activated()), m_instance->d, SLOT(shortcutTriggered()));
return sc;
}
示例2: unregisterShortcut
/*!
Removes the knowledge about a shortcut under the specified \a id.
Usually you do not need to unregister shortcuts. The only valid use case for unregistering
shortcuts, is for shortcuts that represent user definable actions. If the user removes such an action,
a corresponding shortcut also has to be unregistered from the action manager,
to make it disappear from shortcut settings etc.
*/
void ActionManager::unregisterShortcut(Id id)
{
Shortcut *sc = 0;
CommandPrivate *c = d->m_idCmdMap.value(id, 0);
QTC_ASSERT(c, return);
sc = qobject_cast<Shortcut *>(c);
if (!sc) {
qWarning() << "unregisterShortcut: id" << id.name()
<< "is registered with a different command type.";
return;
}
delete sc->shortcut();
d->m_idCmdMap.remove(id);
delete sc;
emit m_instance->commandListChanged();
}
示例3: qWarning
Command *ActionManagerPrivate::registerShortcut(QShortcut *shortcut, const QString &id, const QList<int> &context)
{
Shortcut *sc = 0;
int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
if (CommandPrivate * c = m_idCmdMap.value(uid, 0)) {
sc = qobject_cast<Shortcut *>(c);
if (!sc) {
qWarning() << "registerShortcut: id" << id << "is registered with a different command type.";
return c;
}
} else {
sc = new Shortcut(uid);
m_idCmdMap.insert(uid, sc);
}
if (sc->shortcut()) {
qWarning() << "registerShortcut: action already registered (id" << id << ".";
return sc;
}
if (!hasContext(context)) {
shortcut->setEnabled(false);
}
shortcut->setObjectName(id);
shortcut->setParent(m_mainWnd);
sc->setShortcut(shortcut);
if (context.isEmpty()) {
sc->setContext(QList<int>() << 0);
} else {
sc->setContext(context);
}
sc->setKeySequence(shortcut->key());
sc->setDefaultKeySequence(QKeySequence());
return sc;
}