src/gui/widgets/qabstractbutton.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   163     :
   163     :
   164 #ifndef QT_NO_SHORTCUT
   164 #ifndef QT_NO_SHORTCUT
   165     shortcutId(0),
   165     shortcutId(0),
   166 #endif
   166 #endif
   167     checkable(false), checked(false), autoRepeat(false), autoExclusive(false),
   167     checkable(false), checked(false), autoRepeat(false), autoExclusive(false),
   168     down(false), blockRefresh(false),
   168     down(false), blockRefresh(false), pressed(false),
   169 #ifndef QT_NO_BUTTONGROUP
   169 #ifndef QT_NO_BUTTONGROUP
   170     group(0),
   170     group(0),
   171 #endif
   171 #endif
   172     autoRepeatDelay(AUTO_REPEAT_DELAY),
   172     autoRepeatDelay(AUTO_REPEAT_DELAY),
   173     autoRepeatInterval(AUTO_REPEAT_INTERVAL),
   173     autoRepeatInterval(AUTO_REPEAT_INTERVAL),
  1088         e->ignore();
  1088         e->ignore();
  1089         return;
  1089         return;
  1090     }
  1090     }
  1091     if (hitButton(e->pos())) {
  1091     if (hitButton(e->pos())) {
  1092         setDown(true);
  1092         setDown(true);
       
  1093         d->pressed = true;
  1093         repaint(); //flush paint event before invoking potentially expensive operation
  1094         repaint(); //flush paint event before invoking potentially expensive operation
  1094         QApplication::flush();
  1095         QApplication::flush();
  1095         d->emitPressed();
  1096         d->emitPressed();
  1096         e->accept();
  1097         e->accept();
  1097     } else {
  1098     } else {
  1101 
  1102 
  1102 /*! \reimp */
  1103 /*! \reimp */
  1103 void QAbstractButton::mouseReleaseEvent(QMouseEvent *e)
  1104 void QAbstractButton::mouseReleaseEvent(QMouseEvent *e)
  1104 {
  1105 {
  1105     Q_D(QAbstractButton);
  1106     Q_D(QAbstractButton);
       
  1107     d->pressed = false;
       
  1108 
  1106     if (e->button() != Qt::LeftButton) {
  1109     if (e->button() != Qt::LeftButton) {
  1107         e->ignore();
  1110         e->ignore();
  1108         return;
  1111         return;
  1109     }
  1112     }
  1110 
  1113 
  1125 
  1128 
  1126 /*! \reimp */
  1129 /*! \reimp */
  1127 void QAbstractButton::mouseMoveEvent(QMouseEvent *e)
  1130 void QAbstractButton::mouseMoveEvent(QMouseEvent *e)
  1128 {
  1131 {
  1129     Q_D(QAbstractButton);
  1132     Q_D(QAbstractButton);
  1130     if (!(e->buttons() & Qt::LeftButton)) {
  1133     if (!(e->buttons() & Qt::LeftButton) || !d->pressed) {
  1131         e->ignore();
  1134         e->ignore();
  1132         return;
  1135         return;
  1133     }
  1136     }
  1134 
  1137 
  1135     if (hitButton(e->pos()) != d->down) {
  1138     if (hitButton(e->pos()) != d->down) {