Ignore:
Timestamp:
Nov 6, 2007, 11:27:57 PM (18 years ago)
Author:
dmik
Message:

Styles: Implemented the first version of the Warp4 style (contributed by Cornelis Bockemuehl).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/widgets/qspinwidget.cpp

    r2 r174  
    136136
    137137    uint oldButtonDown = d->buttonDown;
    138 
     138    d->buttonDown = 0;
     139
     140    // With Warp, the up and down buttons are diagonally separated,
     141    // so we are disabling the down button entirely and have to find
     142    // out the position of the click within the up button in order
     143    // to find out what the user wants!
     144    int guiStyle = style().styleHint( QStyle::SH_GUIStyle );
     145    if ( guiStyle == QStyle::PMStyle ) {
     146        if ( d->up.contains( e->pos() ) ) {
     147            QPoint rp = e->pos() - d->up.topLeft();
     148            if ( d->up.width() > (rp.x() + rp.y()) ) {
     149                if ( d->upEnabled )
     150                    d->buttonDown = 2;
     151            } else {
     152                if ( d->downEnabled )
     153                    d->buttonDown = 1;
     154            }
     155        }
     156    } else {
    139157    if ( d->down.contains( e->pos() ) && d->downEnabled )
    140158        d->buttonDown = 1;
    141159    else if ( d->up.contains( e->pos() ) && d->upEnabled )
    142160        d->buttonDown = 2;
    143     else
    144         d->buttonDown = 0;
     161    }
    145162
    146163    d->theButton = d->buttonDown;
     
    149166            repaint( d->down.unite( d->up ), FALSE );
    150167        } else if ( d->buttonDown & 1 ) {
     168            // do all with the "up" button in PM style - see note above
     169            if ( guiStyle == QStyle::PMStyle )
     170                repaint( d->up, FALSE );
     171            else
    151172            repaint( d->down, FALSE );
    152173            stepDown();
     174            if ( guiStyle == QStyle::PMStyle )
     175                d->startTimer( TRUE, 300 );
     176            else
    153177            d->startTimer( FALSE, 300 );
    154178        } else if ( d->buttonDown & 2 ) {
     
    245269    d->theButton = 0;
    246270    if ( oldButtonDown != d->theButton ) {
    247         if ( oldButtonDown & 1 )
     271        // do all with the "up" button in PM style -
     272        // see note in mousePressEvent
     273        int guiStyle = style().styleHint( QStyle::SH_GUIStyle );
     274        if ( guiStyle == QStyle::PMStyle )
     275            repaint( d->up, FALSE );
     276        else if ( oldButtonDown & 1 )
    248277            repaint( d->down, FALSE );
    249278        else if ( oldButtonDown & 2 )
     
    264293        return;
    265294
     295    // do all with the "up" button in PM style -
     296    // see note in mousePressEvent
     297    int guiStyle = style().styleHint( QStyle::SH_GUIStyle );
     298    uint clickButton = 0;
     299    if ( guiStyle == QStyle::PMStyle ) {
     300        if( d->up.contains( e->pos() ) ) {
     301            QPoint rp = e->pos() - d->up.topLeft();
     302            if ( d->up.width() > (rp.x() + rp.y()) )
     303                clickButton = 2;
     304            else
     305                clickButton = 1;
     306        }
     307    } else {
     308        if ( d->down.contains(e->pos()) )
     309            clickButton = 1;
     310        else if ( d->up.contains(e->pos()) )
     311            clickButton = 2;
     312    }
     313
    266314    uint oldButtonDown = d->theButton;
    267     if ( oldButtonDown & 1 && !d->down.contains( e->pos() ) ) {
     315    if ( (oldButtonDown & 1) && !(clickButton & 1) ) {
     316    //if ( oldButtonDown & 1 && !d->down.contains( e->pos() ) ) {
    268317        d->stopTimer();
    269318        d->theButton = 0;
     319        if ( guiStyle == QStyle::PMStyle )
     320            repaint( d->up, FALSE );
     321        else
    270322        repaint( d->down, FALSE );
    271     } else if ( oldButtonDown & 2 && !d->up.contains( e->pos() ) ) {
     323    } else if( (oldButtonDown & 2) && !(clickButton & 2) ) {
     324    //} else if ( oldButtonDown & 2 && !d->up.contains( e->pos() ) ) {
    272325        d->stopTimer();
    273326        d->theButton = 0;
    274327        repaint( d->up, FALSE );
    275     } else if ( !oldButtonDown && d->up.contains( e->pos() ) && d->buttonDown & 2 ) {
     328    } else if ( !oldButtonDown && (clickButton & 2) && (d->buttonDown & 2) ) {
     329    //} else if ( !oldButtonDown && d->up.contains( e->pos() ) && d->buttonDown & 2 ) {
    276330        d->startTimer( 500 );
    277331        d->theButton = 2;
    278332        repaint( d->up, FALSE );
    279     } else if ( !oldButtonDown && d->down.contains( e->pos() ) && d->buttonDown & 1 ) {
     333    } else if(!oldButtonDown && (clickButton & 1) && (d->buttonDown & 1)) {
     334    //} else if ( !oldButtonDown && d->down.contains( e->pos() ) && d->buttonDown & 1 ) {
    280335        d->startTimer( 500 );
    281336        d->theButton = 1;
     337        if ( guiStyle == QStyle::PMStyle )
     338            repaint( d->up, FALSE );
     339        else
    282340        repaint( d->down, FALSE );
    283341    }
Note: See TracChangeset for help on using the changeset viewer.