コード例 #1
0
ファイル: qlabel.cpp プロジェクト: muromec/qtopia-ezx
/*!\reimp
*/
bool QLabel::event(QEvent *e)
{
    Q_D(QLabel);
    QEvent::Type type = e->type();

#ifndef QT_NO_SHORTCUT
    if (type == QEvent::Shortcut) {
        QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
        if (se->shortcutId() == d->shortcutId) {
            QWidget * w = d->buddy;
            QAbstractButton *button = qobject_cast<QAbstractButton *>(w);
            if (w->focusPolicy() != Qt::NoFocus)
                w->setFocus(Qt::ShortcutFocusReason);
            if (button && !se->isAmbiguous())
                button->animateClick();
            else
                window()->setAttribute(Qt::WA_KeyboardFocusChange);
            return true;
        }
    } else
#endif
    if (type == QEvent::Resize) {
        if (d->control)
            d->textLayoutDirty = true;
    } else if (e->type() == QEvent::StyleChange
#ifdef Q_WS_MAC
               || e->type() == QEvent::MacSizeChange
#endif
               ) {
        d->setLayoutItemMargins(QStyle::SE_LabelLayoutItem);
        d->updateLabel();
    }

    return QFrame::event(e);
}
コード例 #2
0
bool QQuickShortcut::event(QEvent *event)
{
    if (m_enabled && event->type() == QEvent::Shortcut) {
        QShortcutEvent *se = static_cast<QShortcutEvent *>(event);
        if (se->shortcutId() == m_id && se->key() == m_shortcut){
            if (se->isAmbiguous())
                emit activatedAmbiguously();
            else
                emit activated();
            return true;
        }
    }
    return false;
}
コード例 #3
0
/*! \reimp */
bool QAbstractButton::event(QEvent *e)
{
    // as opposed to other widgets, disabled buttons accept mouse
    // events. This avoids surprising click-through scenarios
    if (!isEnabled()) {
        switch(e->type()) {
        case QEvent::TabletPress:
        case QEvent::TabletRelease:
        case QEvent::TabletMove:
        case QEvent::MouseButtonPress:
        case QEvent::MouseButtonRelease:
        case QEvent::MouseButtonDblClick:
        case QEvent::MouseMove:
        case QEvent::HoverMove:
        case QEvent::HoverEnter:
        case QEvent::HoverLeave:
        case QEvent::ContextMenu:
#ifndef QT_NO_WHEELEVENT
        case QEvent::Wheel:
#endif
            return true;
        default:
            break;
        }
    }

#ifndef QT_NO_SHORTCUT
    if (e->type() == QEvent::Shortcut) {
        Q_D(QAbstractButton);
        QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
        if (d->shortcutId != se->shortcutId())
            return false;
        if (!se->isAmbiguous()) {
            if (!d->animateTimer.isActive())
                animateClick();
        } else {
            if (focusPolicy() != Qt::NoFocus)
                setFocus(Qt::ShortcutFocusReason);
            window()->setAttribute(Qt::WA_KeyboardFocusChange);
        }
        return true;
    }
#endif
    return QWidget::event(e);
}
コード例 #4
0
ファイル: qaction.cpp プロジェクト: 3163504123/phantomjs
/*!
  \reimp
*/
bool
QAction::event(QEvent *e)
{
#ifndef QT_NO_SHORTCUT
    if (e->type() == QEvent::Shortcut) {
        QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
        Q_ASSERT_X(se->key() == d_func()->shortcut || d_func()->alternateShortcuts.contains(se->key()),
                   "QAction::event",
                   "Received shortcut event from incorrect shortcut");
        if (se->isAmbiguous())
            qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData());
        else
            activate(Trigger);
        return true;
    }
#endif
    return QObject::event(e);
}
コード例 #5
0
bool QQuickAction::event(QEvent *e)
{
    if (!m_enabled)
        return false;

    if (e->type() != QEvent::Shortcut)
        return false;

    QShortcutEvent *se = static_cast<QShortcutEvent *>(e);

    Q_ASSERT_X(se->key() == m_shortcut || se->key() == m_mnemonic,
               "QQuickAction::event",
               "Received shortcut event from incorrect shortcut");
    if (se->isAmbiguous()) {
        qWarning("QQuickAction::event: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData());
        return false;
    }

    trigger();

    return true;
}
コード例 #6
0
ファイル: qshortcut.cpp プロジェクト: FlavioFalcao/qt5
/*!
    \internal
*/
bool QShortcut::event(QEvent *e)
{
    Q_D(QShortcut);
    bool handled = false;
    if (d->sc_enabled && e->type() == QEvent::Shortcut) {
        QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
        if (se->shortcutId() == d->sc_id && se->key() == d->sc_sequence){
#ifndef QT_NO_WHATSTHIS
            if (QWhatsThis::inWhatsThisMode()) {
                QWhatsThis::showText(QCursor::pos(), d->sc_whatsthis);
                handled = true;
            } else
#endif
            if (se->isAmbiguous())
                emit activatedAmbiguously();
            else
                emit activated();
            handled = true;
        }
    }
    return handled;
}
コード例 #7
0
ファイル: Global.cpp プロジェクト: zedd4x/vpaint
bool Global::eventFilter(QObject * /*watched*/, QEvent * event)
{
    // Every single event delivered by Qt go through this method first before
    // going to its target object, so keep it as lightweight as possible

    // It is used as a convenient way to fix a few event behaviours that were
    // not quite right out of the box.

    // --------------------- Detect modifier key presses --------------

    // Detect modifier key presses (Shift, Ctrl, Alt, etc.) and update application
    // state accordingly (e.g., indicate which modifiers are pressed in the status bar, or
    // redraw the scene, since highlighting color depends on which modifiers are pressed)

    // If a modifier is pressed or released, update the modifier state, and emit a signal
    // if this state has changed
    // If a modifier is pressed or released, update the modifier state, and emit a signal
    // if this state has changed
    if(event->type() == QEvent::KeyPress ||
       event->type() == QEvent::KeyRelease)
    {
        QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
        if(keyEvent)
        {
            // Workaround for Mac delete key
            // This is needed because of a bug in QT 5 that has not been resolved as of 5.5.0
#ifdef Q_OS_MAC
            if(keyEvent->key() == Qt::Key_Backspace)
            {
                scene()->smartDelete();
            }
#endif
            if(keyEvent->key() == Qt::Key_Shift ||
               keyEvent->key() == Qt::Key_Alt ||
               keyEvent->key() == Qt::Key_Meta ||
               keyEvent->key() == Qt::Key_AltGr ||
               keyEvent->key() == Qt::Key_Control)
            {
                updateModifiers();
            }
        }

        // Continue normal processing of the event
        return false;
    }
    else if(event->type() == QEvent::FocusIn )
    {
        updateModifiers();

        // Continue normal processing of the event
        return false;
    }

    // --------------------- Resolve shortcut overloads --------------

    // Resolve shortcut overloads
    else if(event->type() == QEvent::Shortcut)
    {
        QShortcutEvent * shortcutEvent = static_cast<QShortcutEvent *>(event);

        if(shortcutEvent->isAmbiguous())
        {
            QKeySequence key = shortcutEvent->key();
            resolveAmbiguousShortcuts(key);

            // Stop processing of the event
            return true;

        }
        else
        {
            // Continue normal processing of the event
            return false;
        }
    }

    // --------------------- Keep standard behaviour --------------

    // Continue normal processing of the event
    return false;
}