bool QgsShortcutsManager::setObjectKeySequence( QObject *object, const QString &sequence ) { if ( QAction *action = qobject_cast< QAction * >( object ) ) return setKeySequence( action, sequence ); else if ( QShortcut *shortcut = qobject_cast< QShortcut * >( object ) ) return setKeySequence( shortcut, sequence ); else return false; }
bool QgsShortcutsManager::setKeySequence( const QString &name, const QString &sequence ) { if ( QAction *action = actionByName( name ) ) return setKeySequence( action, sequence ); else if ( QShortcut *shortcut = shortcutByName( name ) ) return setKeySequence( shortcut, sequence ); else return false; }
/*! Constructs a QKeySequenceEdit widget with the given \a keySequence and \a parent. */ QKeySequenceEdit::QKeySequenceEdit(const QKeySequence &keySequence, QWidget *parent) : QWidget(*new QKeySequenceEditPrivate, parent, 0) { Q_D(QKeySequenceEdit); d->init(); setKeySequence(keySequence); }
ShortcutEditWidget::ShortcutEditWidget(QWidget *viewport, const QKeySequence &defaultSeq, const QKeySequence &activeSeq, bool allowLetterShortcuts) : TabConnectedWidget(viewport), m_defaultKeySequence(defaultSeq), m_isUpdating(false) { QGridLayout *layout = new QGridLayout(this); m_defaultRadio = new QRadioButton(i18n("Default:"), this); m_defaultLabel = new QLabel(i18nc("No shortcut defined", "None"), this); QString defaultText = defaultSeq.toString(QKeySequence::NativeText); if (defaultText.isEmpty()) defaultText = i18nc("No shortcut defined", "None"); m_defaultLabel->setText(defaultText); m_customRadio = new QRadioButton(i18n("Custom:"), this); m_customEditor = new KKeySequenceWidget(this); m_customEditor->setModifierlessAllowed(allowLetterShortcuts); layout->addWidget(m_defaultRadio, 0, 0); layout->addWidget(m_defaultLabel, 0, 1); layout->addWidget(m_customRadio, 1, 0); layout->addWidget(m_customEditor, 1, 1); layout->setColumnStretch(2, 1); setKeySequence(activeSeq); connect(m_defaultRadio, SIGNAL(toggled(bool)), this, SLOT(defaultToggled(bool))); connect(m_customEditor, SIGNAL(keySequenceChanged(QKeySequence)), this, SLOT(setCustom(QKeySequence))); connect(m_customEditor, SIGNAL(stealShortcut(QKeySequence,KAction*)), this, SIGNAL(stealShortcut(QKeySequence,KAction*))); }
void QtKeySequenceEdit::slotClearShortcut() { if (m_keySequence.isEmpty()) return; setKeySequence(QKeySequence()); emit keySequenceChanged(m_keySequence); }
void InputSelectionWidget::slotAttachKey() { AssignHotKey ahk(this, m_keySequence); if (ahk.exec() == QDialog::Accepted) { setKeySequence(QKeySequence(ahk.keySequence())); emit keySequenceChanged(m_keySequence); } }
RazorShortcutButton::RazorShortcutButton(QWidget *parent) : QToolButton(parent), d_ptr(new RazorShortcutButtonPrivate(this)) { setFocusPolicy(Qt::StrongFocus); setPopupMode(QToolButton::MenuButtonPopup); setCheckable(true); Q_D(RazorShortcutButton); QAction *a = d->mMenu.addAction("Clear"); connect(a, SIGNAL(triggered()), d, SLOT(clear())); QAction *a_def = d->mMenu.addAction("Default"); connect(a_def, &QAction::triggered, [=]() { setKeySequence(QKeySequence("Alt+Space")); }); setMenu(&d->mMenu); connect(this, SIGNAL(toggled(bool)), d, SLOT(activate(bool))); setKeySequence(""); }
int QtKeySequenceEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: keySequenceChanged((*reinterpret_cast< const QKeySequence(*)>(_a[1]))); break; case 1: setKeySequence((*reinterpret_cast< const QKeySequence(*)>(_a[1]))); break; case 2: slotClearShortcut(); break; default: ; } _id -= 3; } return _id; }
RazorShortcutButton::RazorShortcutButton(QWidget *parent) : QToolButton(parent), d_ptr(new RazorShortcutButtonPrivate(this)) { libTranslate("librazorqt"); setFocusPolicy(Qt::StrongFocus); setPopupMode(QToolButton::MenuButtonPopup); setCheckable(true); Q_D(RazorShortcutButton); QAction *a = d->mMenu.addAction(tr("Clear")); connect(a, SIGNAL(triggered()), d, SLOT(clear())); setMenu(&d->mMenu); connect(this, SIGNAL(toggled(bool)), d, SLOT(activate(bool))); setKeySequence(""); }
//slot void ShortcutEditWidget::setCustom(const QKeySequence &seq) { if (m_isUpdating) return; // seq is a const reference to a private variable of KKeySequenceWidget. // Somewhere below we possible change that one. But we want to emit seq // whatever happens. So we make a copy. QKeySequence original = seq; m_isUpdating = true; // Check if the user typed in the default sequence into the custom field. // We do this by calling setKeySequence which will do the right thing. setKeySequence(original); emit keySequenceChanged(original); m_isUpdating = false; }
void Action::setDefaultKeySequence(const QKeySequence &key) { if (!m_isKeyInitialized) setKeySequence(key); m_defaultKey = key; }
void RazorShortcutButton::setKeySequence(const QString &sequence) { setKeySequence(QKeySequence(sequence)); }
//slot void FcitxQtKeySequenceWidget::clearKeySequence() { setKeySequence(QKeySequence()); d->side = MS_Unknown; }
void InputSelectionWidget::slotDetachKey() { setKeySequence(QKeySequence()); emit keySequenceChanged(m_keySequence); }
/*! Clear key sequence. \sa setKeySequence */ void QKeySequenceWidget::clearKeySequence() { setKeySequence(QKeySequence()); }
//slot void KShortcutsEditorDelegate::itemActivated(QModelIndex index) { //As per our constructor our parent *is* a QTreeWidget QTreeWidget *view = static_cast<QTreeWidget *>(parent()); KShortcutsEditorItem *item = KShortcutsEditorPrivate::itemFromIndex(view, index); if (!item) { //that probably was a non-leaf (type() !=ActionItem) item return; } int column = index.column(); if (column == Name) { // If user click in the name column activate the (Global|Local)Primary // column if possible. if (!view->header()->isSectionHidden(LocalPrimary)) { column = LocalPrimary; } else if (!view->header()->isSectionHidden(GlobalPrimary)) { column = GlobalPrimary; } else { // do nothing. } index = index.sibling(index.row(), column); view->selectionModel()->select(index, QItemSelectionModel::SelectCurrent); } // Check if the models wants us to edit the item at index if (!index.data(ShowExtensionIndicatorRole).value<bool>()) { return; } if (!isExtended(index)) { //we only want maximum ONE extender open at any time. if (m_editingIndex.isValid()) { KShortcutsEditorItem *oldItem = KShortcutsEditorPrivate::itemFromIndex(view, m_editingIndex); Q_ASSERT(oldItem); //here we really expect nothing but a real KShortcutsEditorItem oldItem->setNameBold(false); contractItem(m_editingIndex); } m_editingIndex = index; QWidget *viewport = static_cast<QAbstractItemView*>(parent())->viewport(); if (column >= LocalPrimary && column <= GlobalAlternate) { ShortcutEditWidget *editor = new ShortcutEditWidget(viewport, index.data(DefaultShortcutRole).value<QKeySequence>(), index.data(ShortcutRole).value<QKeySequence>(), m_allowLetterShortcuts); if (column==GlobalPrimary) { QObject *action = index.data(ObjectRole).value<QObject*>(); connect( action, SIGNAL(globalShortcutChanged(QKeySequence)), editor, SLOT(setKeySequence(QKeySequence))); editor->setMultiKeyShortcutsAllowed(false); QString componentName = action->property("componentName").toString(); if (componentName.isEmpty()) { componentName = QCoreApplication::applicationName(); } editor->setComponentName(componentName); } m_editor = editor; // For global shortcuts check against the kde standard shortcuts if (column == GlobalPrimary || column == GlobalAlternate) { editor->setCheckForConflictsAgainst( KKeySequenceWidget::LocalShortcuts | KKeySequenceWidget::GlobalShortcuts | KKeySequenceWidget::StandardShortcuts ); } editor->setCheckActionCollections(m_checkActionCollections); connect(m_editor, SIGNAL(keySequenceChanged(QKeySequence)), this, SLOT(keySequenceChanged(QKeySequence))); connect(m_editor, SIGNAL(stealShortcut(QKeySequence,QAction*)), this, SLOT(stealShortcut(QKeySequence,QAction*))); } else if (column == RockerGesture) {
/*! \brief Clears the current key sequence. */ void QKeySequenceEdit::clear() { setKeySequence(QKeySequence()); }
void KeySequenceWidget::clear() { setKeySequence(QKeySequence()); // setKeySequence() won't emit a signal when we're not recording emit keySequenceChanged(QKeySequence()); }
int QKeySequenceWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 11) qt_static_metacall(this, _c, _id, _a); _id -= 11; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QKeySequence*>(_v) = keySequence(); break; case 1: *reinterpret_cast< QKeySequenceWidget::ClearButtonShow*>(_v) = clearButtonShow(); break; case 2: *reinterpret_cast< QString*>(_v) = noneText(); break; case 3: *reinterpret_cast< QIcon*>(_v) = clearButtonIcon(); break; } _id -= 4; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setKeySequence(*reinterpret_cast< QKeySequence*>(_v)); break; case 1: setClearButtonShow(*reinterpret_cast< QKeySequenceWidget::ClearButtonShow*>(_v)); break; case 2: setNoneText(*reinterpret_cast< QString*>(_v)); break; case 3: setClearButtonIcon(*reinterpret_cast< QIcon*>(_v)); break; } _id -= 4; } else if (_c == QMetaObject::ResetProperty) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 4; } #endif // QT_NO_PROPERTIES return _id; }