void PlayerInputStruct::fromGameEvent(const GameControl &control, bool state) { switch(control) { case GameControl::ACTION: setAction(state); break; case GameControl::UP: if(state) setUp(100000); else setUp(0); break; case GameControl::DOWN: if(state) setDown(100000); else setDown(0); break; case GameControl::LEFT: if(state) setLeft(100000); else setLeft(0); break; case GameControl::RIGHT: if(state) setRight(100000); else setRight(0); break; case GameControl::BUTTON1: setButton1(state); break; case GameControl::BUTTON2: setButton2(state); break; case GameControl::BUTTON3: setButton3(state); break; case GameControl::BUTTON4: setButton4(state); break; case GameControl::BUTTON5: setButton5(state); break; case GameControl::BUTTON6: setButton6(state); break; default: //Nothing to do; control is not handled by the automatic conversion. break; } }
void ToolButton::mouseReleaseEvent(QMouseEvent* e) { m_pressTimer.stop(); if (e->button() == Qt::MiddleButton && rect().contains(e->pos())) { emit middleMouseClicked(); setDown(false); } else if (e->button() == Qt::LeftButton && rect().contains(e->pos()) && e->modifiers() == Qt::ControlModifier) { emit controlClicked(); setDown(false); } else { QToolButton::mouseReleaseEvent(e); } }
Snake::Snake():AnimUT() { #ifdef debug qDebug("Snake launched"); #endif controls->addAnimationControl(animate, 200); cellSize = 15; nbCells = 20; // controls snakeItem = new SnakeItem(cellSize, nbCells); controls->addLabel("Movements"); QPushButton *upBtn = controls->addButton("Up"); connect(upBtn, SIGNAL(released()), snakeItem, SLOT(setUp())); QPushButton *downBtn = controls->addButton("Down"); connect(downBtn, SIGNAL(released()), snakeItem, SLOT(setDown())); QPushButton *leftBtn = controls->addButton("Left"); connect(leftBtn, SIGNAL(released()), snakeItem, SLOT(setLeft())); QPushButton *rightBtn = controls->addButton("Right"); connect(rightBtn, SIGNAL(released()), snakeItem, SLOT(setRight())); controls->addDivider(); score = controls->addLabel("Score : 0"); connect(snakeItem, SIGNAL(updateScore(int)), this, SLOT(updateScore(int))); // viewer drawBorders(); viewer->addItem(snakeItem); }
void QgsFontButton::mouseMoveEvent( QMouseEvent *e ) { //handle dragging fonts from button if ( !( e->buttons() & Qt::LeftButton ) ) { //left button not depressed, so not a drag QToolButton::mouseMoveEvent( e ); return; } if ( ( e->pos() - mDragStartPosition ).manhattanLength() < QApplication::startDragDistance() ) { //mouse not moved, so not a drag QToolButton::mouseMoveEvent( e ); return; } //user is dragging font QDrag *drag = new QDrag( this ); switch ( mMode ) { case ModeTextRenderer: drag->setMimeData( mFormat.toMimeData() ); break; case ModeQFont: drag->setMimeData( QgsFontUtils::toMimeData( mFont ) ); break; } drag->setPixmap( createDragIcon() ); drag->exec( Qt::CopyAction ); setDown( false ); }
void QgsColorButton::mouseMoveEvent( QMouseEvent *e ) { if ( mPickingColor ) { setButtonBackground( sampleColor( e->globalPos() ) ); e->accept(); return; } //handle dragging colors from button QColor c = linkedProjectColor(); if ( !c.isValid() ) c = mColor; if ( !( e->buttons() & Qt::LeftButton ) || !c.isValid() ) { //left button not depressed or no color set, so not a drag QToolButton::mouseMoveEvent( e ); return; } if ( ( e->pos() - mDragStartPosition ).manhattanLength() < QApplication::startDragDistance() ) { //mouse not moved, so not a drag QToolButton::mouseMoveEvent( e ); return; } //user is dragging color QDrag *drag = new QDrag( this ); drag->setMimeData( QgsSymbolLayerUtils::colorToMimeData( c ) ); drag->setPixmap( QgsColorWidget::createDragIcon( c ) ); drag->exec( Qt::CopyAction ); setDown( false ); }
void QuickButton::mouseMoveEvent(QMouseEvent *e) { if((e->state() & LeftButton) == 0) return; QPoint p(e->pos() - _dragPos); if(p.manhattanLength() <= KGlobalSettings::dndEventDelay()) return; DEBUGSTR << "dragstart" << endl << flush; setDown(false); if(_dragEnabled) { KURL::List uris; uris.append(_qurl->kurl()); DEBUGSTR << "creating KURLDrag" << endl << flush; KURLDrag *dd = new KURLDrag(uris, this); dd->setPixmap(_icon); // PIX DEBUGSTR << "ready to drag" << endl << flush; grabKeyboard(); dd->drag(); releaseKeyboard(); } else { setCursor(Qt::ForbiddenCursor); } }
void ToolButton::mousePressEvent(QMouseEvent* e) { if (popupMode() == QToolButton::DelayedPopup) m_pressTimer.start(); if (e->buttons() == Qt::LeftButton && menu() && popupMode() == QToolButton::InstantPopup) { setDown(true); showMenu(); } else if (e->buttons() == Qt::RightButton && menu()) { setDown(true); showMenu(); } else { QToolButton::mousePressEvent(e); } }
/*! \reimp */ void QAbstractButton::mouseReleaseEvent(QMouseEvent *e) { Q_D(QAbstractButton); d->pressed = false; if (e->button() != Qt::LeftButton) { e->ignore(); return; } if (!d->down) { // refresh is required by QMacStyle to resume the default button animation d->refresh(); e->ignore(); return; } if (hitButton(e->pos())) { d->repeatTimer.stop(); d->click(); e->accept(); } else { setDown(false); e->ignore(); } }
void SiteIcon::mouseMoveEvent(QMouseEvent* e) { if (!m_locationBar || e->buttons() != Qt::LeftButton) { ToolButton::mouseMoveEvent(e); return; } int manhattanLength = (e->pos() - m_dragStartPosition).manhattanLength(); if (manhattanLength <= QApplication::startDragDistance()) { ToolButton::mouseMoveEvent(e); return; } const QUrl url = m_locationBar->webView()->url(); const QString title = m_locationBar->webView()->title(); if (url.isEmpty() || title.isEmpty()) { ToolButton::mouseMoveEvent(e); return; } QDrag* drag = new QDrag(this); QMimeData* mime = new QMimeData; mime->setUrls(QList<QUrl>() << url); mime->setText(title); mime->setImageData(icon().pixmap(16).toImage()); drag->setMimeData(mime); drag->setPixmap(QzTools::createPixmapForSite(icon(), title, url.toString())); drag->exec(); // Restore Down state setDown(false); }
void KeySequenceWidget::startRecording() { keySequence() = KeySequence(); setDown(true); setFocus(); grabKeyboard(); setStatus(Recording); }
UWPButton::UWPButton(QWidget *parent) : QPushButton(parent) { setDown(false); setFocusPolicy(Qt::NoFocus); res = 0.9; //qDebug() << res; }
/*! Shows (pops up) the associated popup menu. If there is no such menu, this function does nothing. This function does not return until the popup menu has been closed by the user. */ void QPushButton::showMenu() { Q_D(QPushButton); if (!d || !d->menu) return; setDown(true); d->_q_popupPressed(); }
void PanelPopupButton::showMenu() { if (isDown()) { if (m_popup) { m_popup->hide(); } setDown(false); return; } setDown(true); update(); slotExecMenu(); }
void ToolButton::mouseReleaseEvent(QMouseEvent* e) { if (e->button() == Qt::MiddleButton && rect().contains(e->pos())) { emit middleMouseClicked(); setDown(false); return; } if (e->button() == Qt::LeftButton && rect().contains(e->pos()) && e->modifiers() == Qt::ControlModifier) { emit controlClicked(); setDown(false); return; } QToolButton::mouseReleaseEvent(e); setDown(false); }
void QuickButton::launch() { setDown(false); repaint(); KIconEffect::visualActivate(this, rect()); _qurl->run(); emit executed(_qurl->menuId()); }
void MToolButton::setButtonPressed(bool press) { if(!bCommon) { bPress = press; setDown(press); } }
void QgsRatioLockButton::buttonClicked() { mLocked = !mLocked; setDown( mLocked ); emit lockChanged( mLocked ); drawButton(); }
void KColorButton::mouseMoveEvent( QMouseEvent *e) { if( (e->buttons() & Qt::LeftButton) && (e->pos()-d->mPos).manhattanLength() > KGlobalSettings::dndEventDelay() ) { KColorMimeData::createDrag(color(),this)->start(); setDown(false); } }
void MToolButton::setButtonState(int state) { if(expandToolBar != NULL) { expandToolBar->hide(); bExpand = false; } int id = -1; QList<int> idlist; idlist = buttonIdCssMap.keys(); for(QList<int>::iterator itr = idlist.begin();itr != idlist.end();itr++ ) { if(buttonIdCssMap[*itr] == state) { id = *itr; break; } } if(id == -1) { return; } toolButtonGroup->button(0)->setStyleSheet(buttonCssDefaultMap[buttonIdCssMap[id]]); toolButtonGroup->button(0)->setToolTip(buttonTipsMap[buttonIdCssMap[id]]); toolButtonGroup->button(0)->setStatusTip(buttonTipsMap[buttonIdCssMap[id]]); int css0 = buttonIdCssMap[0]; buttonIdCssMap[0] = buttonIdCssMap[id]; buttonIdCssMap[id] = css0; QMap<int, int>::iterator i; for (i = buttonIdCssMap.begin(); i != buttonIdCssMap.end(); ++i) { if(i.key() != 0) { toolButtonGroup->button(i.key())->setStyleSheet(buttonCssMap[buttonIdCssMap[i.key()]]); toolButtonGroup->button(i.key())->setToolTip(buttonTipsMap[buttonIdCssMap[id]]); toolButtonGroup->button(i.key())->setStatusTip(buttonTipsMap[buttonIdCssMap[id]]); } } nState = buttonIdCssMap[0]; if(!bCommon) { setDown(true); bPress = true; } emit buttonClicked(nState); if(!bCommon) { emit buttonClickedList(this); } }
void PanelPopupButton::menuAboutToHide() { if (!m_popup) { return; } setDown(false); KickerTip::enableTipping(true); }
void KColorButton::mouseMoveEvent(QMouseEvent *e) { if((e->state() & LeftButton) && (e->pos() - mPos).manhattanLength() > KGlobalSettings::dndEventDelay()) { // Drag color object KColorDrag *dg = new KColorDrag(color(), this); dg->dragCopy(); setDown(false); } }
void winlist::mousePressEvent(QMouseEvent *event) { if(event->button() == QMouseEvent::RightButton) // hidden to foreground { setDown(TRUE); hidden_win(); } else if(event->button() == QMouseEvent::LeftButton) start_popup(); }
void winlist::popup_list(void) { xwindow *win; QString wname; Window rw,cw; int rx,ry,wx,wy; unsigned mr; for(win = clients.first(); win != NULL; win = clients.next()) { if(win->iswithdrawn() || ((win->get_pflags() & qapp::WindowListSkip) && ! win->hidden_win())) continue; wname = ""; QTextOStream wnm(&wname); if(! win->isVisible()) wnm << '<'; wnm << win->ccaption().left(100); if(! win->isVisible()) wnm << '>'; if(win->get_tnumber()) wnm << '<' << win->get_tnumber() << '>'; if(! win->getmachine().isNull()) wnm << " (" << win->getmachine().left(20) << ')'; wmenu->insertItem(wname, win, SLOT(focus_mouse_wlist()), 0, clients.at()); } if(! defaults::show_winlist || qapp::smode) // show at mouse position { XQueryPointer(qt_xdisplay(), qt_xrootwin(), &rw, &cw, &rx, &ry, &wx, &wy, &mr); wmenu->exec(QPoint(rx, ry)); } else { if(! defaults::toolbar_top) // menu above button { QPoint p = mapToGlobal(QPoint(0, 0)); QSize s(wmenu->sizeHint()); p.setY(p.y()-s.height()); wmenu->exec(p); } else wmenu->exec(mapToGlobal(QPoint(0, height()))); } wmenu->clear(); setDown(FALSE); }
void QButton::keyPressEvent( QKeyEvent *e ) { switch ( e->key() ) { case Key_Enter: case Key_Return: if ( inherits("QPushButton") ) emit clicked(); else e->ignore(); break; case Key_Space: if ( !e->isAutoRepeat() ) { if ( got_a_release ) setDown( TRUE ); else { buttonDown = TRUE; repaint( FALSE ); } if ( inherits("QPushButton") ) emit pressed(); else e->ignore(); } break; case Key_Up: case Key_Left: #ifndef QT_NO_BUTTONGROUP if ( group() ) group()->moveFocus( e->key() ); else #endif focusNextPrevChild( FALSE ); break; case Key_Right: case Key_Down: #ifndef QT_NO_BUTTONGROUP if ( group() ) group()->moveFocus( e->key() ); else #endif focusNextPrevChild( TRUE ); break; case Key_Escape: if ( buttonDown ) { buttonDown = FALSE; update(); break; } // fall through default: e->ignore(); } }
void AMControlMoveButton::press(bool down) { if(!isEnabled()) return; // press if(down) { if(!isDown()) { setDown(true); emit pressed(); } } // release, only if already pressed. else { if(isDown()) { setDown(false); emit released(); emit clicked(); } } }
void ToolButton::mousePressEvent(QMouseEvent* e) { if (e->buttons() == Qt::LeftButton && menu() && popupMode() == QToolButton::InstantPopup) { setDown(true); showMenu(); return; } if (e->buttons() == Qt::RightButton && menu()) { setDown(true); showMenu(); return; } if (e->buttons() == Qt::MiddleButton) { setDown(true); } QToolButton::mousePressEvent(e); }
/*! Check/Uncheck a the item \param on check/uncheck \sa setItemMode() */ void QwtLegendLabel::setChecked( bool on ) { if ( d_data->itemMode == QwtLegendData::Checkable ) { const bool isBlocked = signalsBlocked(); blockSignals( true ); setDown( on ); blockSignals( isBlocked ); } }
//! Handle mouse press events void QwtLegendLabel::mousePressEvent( QMouseEvent *e ) { if ( e->button() == Qt::LeftButton ) { switch ( d_data->itemMode ) { case QwtLegendData::Clickable: { setDown( true ); return; } case QwtLegendData::Checkable: { setDown( !isDown() ); return; } default:; } } QwtTextLabel::mousePressEvent( e ); }
void ColorButton::mouseMoveEvent(QMouseEvent *e) { if (! mousepressed) return; if ((presspos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { mousepressed = FALSE; setDown(FALSE); QColorDrag *cd = new QColorDrag(color(), this); cd->dragCopy(); } }
void menu::start_popup(void) { Window rw,cw; int rx,ry,wx,wy; unsigned mr; if(qapp::menu_open) return; xwindow *focusclient = qapp::focusclient; qapp::menu_open = TRUE; setDown(TRUE); if(! defaults::show_menu || qapp::smode) // show at mouse position { XQueryPointer(QX11Info::display(), QX11Info::appRootWindow(), &rw, &cw, &rx, &ry, &wx, &wy, &mr); basemenu->exec(QPoint(rx, ry)); } else { if(! defaults::toolbar_top) // menu above button { QPoint p = mapToGlobal(QPoint(0, 0)); QSize s(basemenu->sizeHint()); p.setY(p.y()-s.height()); basemenu->exec(p); } else basemenu->exec(mapToGlobal(QPoint(0, height()))); } qapp::menu_open = FALSE; setDown(FALSE); XSetInputFocus(QX11Info::display(), QX11Info::appRootWindow(), RevertToPointerRoot, CurrentTime); if(focusclient != NULL && clients.indexOf(focusclient) != -1) focusclient->setchildfocus(CurrentTime); }