本文整理汇总了C++中KShortcut::primary方法的典型用法代码示例。如果您正苦于以下问题:C++ KShortcut::primary方法的具体用法?C++ KShortcut::primary怎么用?C++ KShortcut::primary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KShortcut
的用法示例。
在下文中一共展示了KShortcut::primary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stealShortcut
void KShortcutsEditorDelegate::stealShortcut(
const QKeySequence &seq,
KAction *action)
{
QTreeWidget *view = static_cast<QTreeWidget *>(parent());
// Iterate over all items
QTreeWidgetItemIterator it(view, QTreeWidgetItemIterator::NoChildren);
for (; (*it); ++it) {
KShortcutsEditorItem* item = dynamic_cast<KShortcutsEditorItem *>(*it);
if (item && item->data(0, ObjectRole).value<QObject*>() == action) {
// We found the action, snapshot the current state. Steal the
// shortcut. We will save the change later.
KShortcut cut = action->shortcut();
if ( cut.primary().matches(seq) != QKeySequence::NoMatch
|| seq.matches(cut.primary()) != QKeySequence::NoMatch) {
item->setKeySequence(LocalPrimary, QKeySequence());
}
if ( cut.alternate().matches(seq) != QKeySequence::NoMatch
|| seq.matches(cut.alternate()) != QKeySequence::NoMatch) {
item->setKeySequence(LocalAlternate, QKeySequence());
}
break;
}
}
}
示例2: testSaveRestore
void KGlobalShortcutTest::testSaveRestore()
{
setupTest("testSaveRestore");
//It /would be nice/ to test persistent storage. That is not so easy...
KShortcut cutA = m_actionA->globalShortcut();
// Delete the action
delete m_actionA;
// Recreate it
m_actionA = new KAction("Text For Action A", this);
m_actionA->setObjectName("Action A:testSaveRestore");
// Now it's empty
QVERIFY(m_actionA->globalShortcut().isEmpty());
m_actionA->setGlobalShortcut(KShortcut());
// Now it's restored
QCOMPARE(m_actionA->globalShortcut(), cutA);
// And again
delete m_actionA;
m_actionA = new KAction("Text For Action A", this);
m_actionA->setObjectName("Action A:testSaveRestore");
m_actionA->setGlobalShortcut(KShortcut(QKeySequence(), cutA.primary()));
QCOMPARE(m_actionA->globalShortcut(), cutA);
}
示例3: parsing
void parsing()
{
KShortcut cut;
cut = KShortcut(";, Alt+;; ;, Alt+A, ;");
QVERIFY(cut.primary() == QKeySequence::fromString(";, Alt+;"));
QVERIFY(cut.alternate() == QKeySequence::fromString(";, Alt+A, ;"));
cut = KShortcut("Win+E");
//QTest::ignoreMessage(QtWarningMsg, "QKeySequence::fromString: Unknown modifier 'win+'");
QEXPECT_FAIL("", "Qt Bug 205255 - QKeySequence silently discards unknown key modifiers", Continue);
QVERIFY(cut.isEmpty());
cut = KShortcut("Meta+E");
QVERIFY(cut.primary()[0] == (Qt::META | Qt::Key_E));
//qDebug() << QKeySequence(Qt::ALT | Qt::Key_Plus).toString();
//qDebug() << QKeySequence(Qt::ALT | Qt::Key_Minus).toString();
cut = KShortcut("Alt+Plus"); // KDE3 said "Alt+Plus", while Qt4 says "Alt++", so KShortcut has to handle this
QVERIFY(cut.primary()[0] == (Qt::ALT | Qt::Key_Plus));
cut = KShortcut("Alt+Minus"); // KDE3 said "Alt+Minus", while Qt4 says "Alt+-", so KShortcut has to handle this
QVERIFY(cut.primary()[0] == (Qt::ALT | Qt::Key_Minus));
}