コード例 #1
0
bool K3bPushButton::eventFilter( QObject* o, QEvent* ev )
{
    if( dynamic_cast<K3bPushButton*>(o) == this ) {

        // Popup the menu when the left mousebutton is pressed and the mouse
        // is moved by a small distance.
        if( popup() ) {
            if( ev->type() == QEvent::MouseButtonPress ) {
                QMouseEvent* mev = static_cast<QMouseEvent*>(ev);
                d->mousePressPos = mev->pos();
                d->popupTimer->start( QApplication::startDragTime() );
            }
            else if( ev->type() == QEvent::MouseMove ) {
                QMouseEvent* mev = static_cast<QMouseEvent*>(ev);
                if( ( mev->pos() - d->mousePressPos).manhattanLength() > KGlobalSettings::dndEventDelay() ) {
                    d->popupTimer->stop();
                    slotDelayedPopup();
                    return true;
                }
            }
        }
    }

    return KPushButton::eventFilter( o, ev );
}
コード例 #2
0
void K3bPushButton::setDelayedPopupMenu( QPopupMenu* popup )
{
    if( !d->popupTimer ) {
        d->popupTimer = new QTimer( this );
        connect( d->popupTimer, SIGNAL(timeout()), this, SLOT(slotDelayedPopup()) );
    }

    setPopup( popup );

    // we need to do the popup handling ourselves so we cheat a little
    // QPushButton connects a popup slot to the pressed signal which we disconnect here
    disconnect( this );
}
コード例 #3
0
void BrowserButton::initialize( const QString& icon, const QString& path )
{
    _icon = icon;

    // Don't parent to this, so that the tear of menu is not always-on-top.
    topMenu = new PanelBrowserMenu( path );
    setPopup(topMenu);

    _menuTimer = new QTimer( this );
    connect( _menuTimer, SIGNAL(timeout()), SLOT(slotDelayedPopup()) );

    QToolTip::add(this, i18n("Browse: %1").arg(path));
    setTitle( path );
    setIcon ( _icon );
}