bool ShortcutManager::setEnabled(bool enabled_) { if(enabled_) { if(enabled) return true; if(!enabled) { enabled = registerShortcut(sequence); return enabled; } } if(!enabled_) { if(!enabled) return true; if(enabled) { unregisterShortcut(); return true; } } return false; }
ShortcutManager::ShortcutManager(QKeySequence sequence, QObject * parent) : QObject(parent), sequence(sequence) { enabled = false; QAbstractEventDispatcher::instance()->installNativeEventFilter(this); enabled = registerShortcut(sequence); }
bool ShortcutManager::setShortcut(QKeySequence sequence) { if(enabled) { unregisterShortcut(); enabled = false; } this->sequence = sequence; enabled = registerShortcut(sequence); return enabled; }
bool QtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) { Qt::KeyboardModifiers allMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier; key = shortcut.isEmpty() ? Qt::Key(0) : Qt::Key((shortcut[0] ^ allMods) & shortcut[0]); mods = shortcut.isEmpty() ? Qt::KeyboardModifiers(0) : Qt::KeyboardModifiers(shortcut[0] & allMods); const quint32 nativeKey = nativeKeycode(key); const quint32 nativeMods = nativeModifiers(mods); const bool res = registerShortcut(nativeKey, nativeMods); shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p()); if (!res) qWarning() << "QtGlobalShortcut failed to register:" << QKeySequence(key + mods).toString(); return res; }
void QgsShortcutsManager::registerAllChildShortcuts( QObject *object, bool recursive ) { if ( recursive ) { QList< QShortcut * > shortcuts = object->findChildren< QShortcut * >(); const auto constShortcuts = shortcuts; for ( QShortcut *s : constShortcuts ) { registerShortcut( s, s->key().toString( QKeySequence::NativeText ) ); } } else { const auto constChildren = object->children(); for ( QObject *child : constChildren ) { if ( QShortcut *s = qobject_cast<QShortcut *>( child ) ) { registerShortcut( s, s->key().toString( QKeySequence::NativeText ) ); } } } }
bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence &shortcut) { Q_Q(QxtGlobalShortcut); Qt::KeyboardModifiers allMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier; key = shortcut.isEmpty() ? Qt::Key(0) : Qt::Key((shortcut[0] ^ allMods) & shortcut[0]); mods = shortcut.isEmpty() ? Qt::KeyboardModifiers(Qt::NoModifier) : Qt::KeyboardModifiers(shortcut[0] & allMods); const quint32 nativeKey = nativeKeycode(key); const quint32 nativeMods = nativeModifiers(mods); const bool res = registerShortcut(nativeKey, nativeMods); if (res) shortcuts.insert({nativeKey, nativeMods}, q); else qWarning("QxtGlobalShortcut failed to register: %s", qPrintable(QKeySequence(key + mods).toString())); return res; }
SharedAxisBoxItem::SharedAxisBoxItem(View *parent) : ViewItem(parent), _layout(0), _loaded(false), _firstPaint(true), _dirty(false), _shareX(true), _shareY(true), _xAxisZoomMode(PlotAxis::Auto), _yAxisZoomMode(PlotAxis::Auto), _sharedIsDirty(false) { setTypeName("Shared Axis Box"); setBrush(Qt::transparent); _breakAction = new QAction(tr("Break Shared Axis Box"), this); _breakAction->setShortcut(Qt::Key_B); registerShortcut(_breakAction); connect(_breakAction, SIGNAL(triggered()), this, SLOT(breakShare())); connect(this, SIGNAL(breakShareSignal()), this, SLOT(breakShare())); }
bool ShortcutManager::setDisabled(bool disabled) { if(disabled) { unregisterShortcut(); enabled = false; return true; } if(!disabled) { if(enabled) return true; if(!enabled) { enabled = registerShortcut(sequence); return enabled; } } return false; }