Exemplo n.º 1
0
void IconsWidget::leaveEvent(QEvent *)
{
    QCursor curs;
    QPoint cursPos = mapFromGlobal(curs.pos());
    if (!rect().contains(cursPos))
        toolTip->hide();
}
Exemplo n.º 2
0
void CircuitsWidget::wireSlot(int, Component *c) {
	QCursor cr;
	cr.setShape(Qt::CrossCursor);
	setCursor(cr);
	connectingComponent = true;
	componentOnConnection = c;
}
Exemplo n.º 3
0
void QDragManager::updateCursor()
{
#ifndef QT_NO_CURSOR
    if (willDrop) {
        if (qt_qws_dnd_deco)
            qt_qws_dnd_deco->show();
        if (currentActionForOverrideCursor != global_accepted_action) {
            QApplication::changeOverrideCursor(QCursor(dragCursor(global_accepted_action), 0, 0));
            currentActionForOverrideCursor = global_accepted_action;
        }
    } else {
        QCursor *overrideCursor = QApplication::overrideCursor();
        if (!overrideCursor || overrideCursor->shape() != Qt::ForbiddenCursor) {
            QApplication::changeOverrideCursor(QCursor(Qt::ForbiddenCursor));
            currentActionForOverrideCursor = Qt::IgnoreAction;
        }
#ifndef EMSCRIPTEN
        // Hiding the pixmap feels weird, and doesn't match the desktop behaving;
        // so I've disabled it for Emscripten.
        if (qt_qws_dnd_deco)
            qt_qws_dnd_deco->hide();
#endif
    }
#endif
}
Exemplo n.º 4
0
QVariant Util::decorationForVariant(const QVariant &value)
{
  switch (value.type()) {
  case QVariant::Brush:
  {
    const QBrush b = value.value<QBrush>();
    if (b.style() != Qt::NoBrush) {
      QPixmap p(16, 16);
      p.fill(QColor(0, 0, 0, 0));
      QPainter painter(&p);
      painter.setBrush(b);
      painter.drawRect(0, 0, p.width() - 1, p.height() - 1);
      return p;
    }
  }
  case QVariant::Color:
  {
    const QColor c = value.value<QColor>();
    if (c.isValid()) {
      QPixmap p(16, 16);
      QPainter painter(&p);
      painter.setBrush(QBrush(c));
      painter.drawRect(0, 0, p.width() - 1, p.height() - 1);
      return p;
    }
  }
  case QVariant::Cursor:
  {
    const QCursor c = value.value<QCursor>();
    if (!c.pixmap().isNull()) {
      return c.pixmap().scaled(16, 16, Qt::KeepAspectRatio, Qt::FastTransformation);
    }
  }
  case QVariant::Icon:
  {
    return value;
  }
  case QVariant::Pen:
  {
    const QPen pen = value.value<QPen>();
    if (pen.style() != Qt::NoPen) {
      QPixmap p(16, 16);
      p.fill(QColor(0, 0, 0, 0));
      QPainter painter(&p);
      painter.setPen(pen);
      painter.translate(0, 8 - pen.width() / 2);
      painter.drawLine(0, 0, p.width(), 0);
      return p;
    }
  }
  case QVariant::Pixmap:
  {
    const QPixmap p = value.value<QPixmap>();
    return QVariant::fromValue(p.scaled(16, 16, Qt::KeepAspectRatio, Qt::FastTransformation));
  }
  default: break;
  }

  return QVariant();
}
Exemplo n.º 5
0
void OpenGLWidget::mouseMoveEvent(QMouseEvent * mouseEvent)
{
    // Ignore events that return mouse to center.
    if(mouseEvent->pos() == QPoint(this->width() / 2, this->height() / 2))
    {
        return;
    }

    const int xDelta = mouseEvent->x() - (this->width() / 2);
    const int yDelta = mouseEvent->y() - (this->height() / 2);
    static const float sensitivity = 0.25f;
    m_yawRotation += xDelta * sensitivity;
    m_pitchRotation -= yDelta * sensitivity;

    if(m_pitchRotation < -89.0f)
    {
        m_pitchRotation = -89.0f;
    }
    if(m_pitchRotation > 89.0f)
    {
        m_pitchRotation = 89.0f;
    }

    const float yawRad = m_yawRotation * 3.14 / 180;
    const float pitchRad = m_pitchRotation * 3.14 / 180;

    m_cameraFront.setX(std::cos(pitchRad) * std::cos(yawRad));
    m_cameraFront.setY(std::sin(pitchRad));
    m_cameraFront.setZ(std::cos(pitchRad) * std::sin(yawRad));

    QCursor cursor = this->cursor();
    cursor.setPos(mapToGlobal(QPoint(this->width() / 2, this->height() / 2)));
    setCursor(cursor);
}
Exemplo n.º 6
0
SetWaitCursor::~SetWaitCursor()
{
    if (m_guiApp) {

        RG_DEBUG << "SetWaitCursor::SetWaitCursor() : restoring normal cursor\n";
        QWidget* viewport = 0;
        QCursor currentCompositionViewCursor;

        if ((m_guiApp->getView() &&
                m_guiApp->getView()->getTrackEditor() &&
                m_guiApp->getView()->getTrackEditor()->getCompositionView() &&
                m_guiApp->getView()->getTrackEditor()->getCompositionView()->viewport())) {
            viewport = m_guiApp->getView()->getTrackEditor()->getCompositionView()->viewport();
            currentCompositionViewCursor = viewport->cursor();
        }

        m_guiApp->setCursor(m_saveCursor);

        if (viewport) {
            if (currentCompositionViewCursor.shape() == Qt::WaitCursor) {
                viewport->setCursor(m_saveCompositionViewCursor);
            } else {
                viewport->setCursor(currentCompositionViewCursor); // because m_guiApp->setCursor() has replaced it
            }
        }

        // otherwise, it's been modified elsewhere, so leave it as is

    }

}
void OpenGLWindow::ShowCursor()
{
	cursorClip = false;
	QCursor c = cursor();
	c.setShape(Qt::ArrowCursor);
	setCursor(c);
}
Exemplo n.º 8
0
void MainDialog::onStateChanged(int state, short disconnectStatus)
{
    QColor clr = BTN_RED;
    if( state == CloseWaitState || state == ProgressState ) {
        QCursor* ovrCur = QApplication::overrideCursor();
        if( ovrCur == NULL || ovrCur->shape() != Qt::WaitCursor )
            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
        clr = BTN_YELLOW;
    }
    if( state == EstablishState ) {
        QApplication::restoreOverrideCursor();
        startButton_->setEnabled( false );
        stopButton_->setEnabled( true );
        clr = BTN_GREEN;
    }
    else {
        QApplication::restoreOverrideCursor();
        startButton_->setEnabled(true);
        stopButton_->setEnabled(false);
    }

    QPalette pal;
    pal.setColor(QPalette::Button, clr);
    colorButton_->setPalette(pal);
}
void OpenGLWindow::HideCursor()
{
	skipClipFrame = true;
	cursorClip = true;
	QCursor c = cursor();
	c.setShape(Qt::BlankCursor);
	setCursor(c);
}
Exemplo n.º 10
0
void GenericCodeEditor::hideMouseCursor()
{
#ifdef Q_OS_MAC
    return; // LATER: for some reason this crashes on osx. we should try to figure out why
#endif
    QCursor * overrideCursor = QApplication::overrideCursor();
    if (!overrideCursor || overrideCursor->shape() != Qt::BlankCursor)
        QApplication::setOverrideCursor( Qt::BlankCursor );
}
Exemplo n.º 11
0
 void mousePressEvent(QMouseEvent *)
 {
     // Toggle cursor
     QCursor newCursor = (cursor().shape() == m_cursor.shape()) ? QCursor() : m_cursor;
     if (newCursor.shape() == Qt::ArrowCursor)
         unsetCursor();
     else
         setCursor(newCursor);
 }
Exemplo n.º 12
0
void GL_insert_ball_layer_2::keyPressEvent(QKeyEvent *e) {
	switch (e->key()) {
		case Qt::Key_Control:
//			widget->cursor()->setShape(Qt::CrossCursor);
			QCursor c = widget->get_default_cursor();
			c.setShape(Qt::CrossCursor);
			widget->setCursor(c);
			break;
	}
}
Exemplo n.º 13
0
void GL_navigate_layer_2::mouseReleaseEvent(QMouseEvent *e) {
	switch (s) {
		case PAN:
			s = NONE;
			break;
		case ZOOM:
			s = NONE;
			break;
		case ZOOM_RECT:
			rubber_band->hide();
			delete rubber_band;
			rubber_band = 0;
			widget->repaintGL();

			if((e->x() != first_x) && (e->y() != first_y)) {
				double x, y, xfirst2, yfirst2;
				x = widget->x_real(e->x());
				y = widget->y_real(e->y());
				xfirst2 = widget->x_real(first_x);
				yfirst2 = widget->y_real(first_y);

				double	xmin, xmax, ymin, ymax;
				if(x < xfirst2) {xmin = x; xmax = xfirst2;}
				else {xmin = xfirst2; xmax = x;};
				if(y < yfirst2) {ymin = y; ymax = yfirst2;}
				else {ymin = yfirst2; ymax = y;};

				if (is_alt(e)) widget->set_window(xmin, xmax, ymin, ymax);
				else smooth_zoom(xmin, xmax, ymin, ymax);
			} else if (widget->has_boundingbox()) {
				// jump to bounding box
				double x_min = widget->get_bounding_xmin();
				double x_max = widget->get_bounding_xmax();
				double y_min = widget->get_bounding_ymin();
				double y_max = widget->get_bounding_ymax();
				if (x_min != x_max && y_min != y_max)	{
					double margin_percent= BOUNDING_BOX_MARGIN_PERCENT;
					double x_margin = (x_max - x_min) * margin_percent;
					double y_margin = (y_max - y_min) * margin_percent;
					x_min -= x_margin;	x_max += x_margin;
					y_min -= y_margin;	y_max += y_margin;
					if (is_alt(e)) widget->set_window(x_min, x_max, y_min, y_max);
					else smooth_zoom(x_min, x_max, y_min, y_max);
				}
			}
			s = NONE;
			break;
	}
	if (is_pure(e) || is_alt(e) || is_shift(e)) widget->setCursor(QCursor( QPixmap( (const char**)hand_xpm)));
	else {
			QCursor c = widget->get_default_cursor();
			c.setShape(Qt::CrossCursor);
			widget->setCursor(c);
	}
}
Exemplo n.º 14
0
/*
	鼠标右键菜单
*/
void MainWindow::contextMenuEvent(QContextMenuEvent *event)
{
	QCursor cur = this->cursor();

	//创建一个属于该窗口的子菜单
	QMenu *menu = new QMenu(this);

	//字体设置
	QFont font;
	font.setFamily(QStringLiteral("SAO UI"));
	font.setPointSize(12);
	//用户信息
	menuAction[0] = new QAction(QIcon("image/user"), tr("User"), this);
	menuAction[0]->setFont(font);
	connect(menuAction[0], &QAction::triggered, this, &MainWindow::UserAction);
	menu->addAction(menuAction[0]);

	//数据库选择Database
	menuAction[1] = new QAction(QIcon("image/window"), tr("GUI"), this);
	menuAction[1]->setFont(font);
	connect(menuAction[1], &QAction::triggered, this, &MainWindow::DatabaseAction);
	menu->addAction(menuAction[1]);
	menuAction[1]->setDisabled(true);

	//命令行
	menuAction[2] = new QAction(QIcon("image/eye"), tr("Command"), this);
	menuAction[2]->setFont(font);
	connect(menuAction[2], &QAction::triggered, this, &MainWindow::CommandAction);
	menu->addAction(menuAction[2]);
	menuAction[2]->setDisabled(true);
	
	//Help
	menuAction[3] = new QAction(QIcon("image/help"), tr("Help"), this);
	menuAction[3]->setFont(font);
	connect(menuAction[3], &QAction::triggered, this, &MainWindow::HelpAction);
	menu->addAction(menuAction[3]);
	
	//退出选择键
	menuAction[4] = new QAction(QIcon("image/exit"), tr("Exit"), this);
	menuAction[4]->setFont(font);
	connect(menuAction[4], &QAction::triggered, this, &MainWindow::ExitAction);
	menu->addAction(menuAction[4]);

	//判断菜单的隐藏,在没登陆之前这些菜单需要隐藏
	if (userWindows.isLogin)
	{
		menuAction[1]->setDisabled(false);
		menuAction[2]->setDisabled(false);
	}
	//菜单弹出位置
	menu->exec(cur.pos());

}
Exemplo n.º 15
0
//Tekla bat sakatzean sortzen den ekintza
void Mandomugitu::keyPressEvent( QKeyEvent * event )
{
    // X eta Y ardatzetako posizioa bertan gordeko dira
    int posx,posy;
    QCursor pos;
    //X eta Y ardatzeko posizioa lortzeko x() eta y() funtzioak erabiltzeko objektuaren erazagupena
    QPoint posiz;
    //rfcomm0 portua ireki
    FILE * portua = fopen ("/dev/rfcomm0", "w");
    //fputc funtzioan char motakoak bidali behar direnez posx eta posy aldagaien 'karaktere' motako aldagaiak
    char cposx,cposy;
    //idatzitako teklaren kodea jasotzen da
    const int botoi = event->key();
        //Tekla bakoitzaren kodearekin konparatzen da, eta koinziditzen badute, letra hori bidaltzen zaio pololuri
        switch (botoi)
        {

            //A letraren kodea,Wiimote-ko A botoia sakatzen dagoen bitartean kurtsorearen posizioak bidaliko zaizkio robotaren programari
            case Qt::Key_A :
            //posiz objektuan pos() funtzioak itzultzen dituen pantailako uneko x eta y balioak gordeko dira
            posiz = QCursor::pos();
            //Pantailak har dezakeen X eta Y posiziorik altuena 1365 eta 767 direnez da,eta balio hauek handiegiak direnez 13,65 eta 7,67 balioarengatik zatituko da
            //Horrela  posx eta posy-k izango duten baliorik handiena 100 izango da
            //posx aldagaiean posiz objektuko x posizioa esleituko da
            posx = posiz.x()/13.65;
            //posy aldagaiean posiz objektuko y posizioa esleituko da
            posy = posiz.y()/7.67;
            //Robotaren programari bidaliko zaion 'a' tekla esleitzen da
            tekla = 'a';
            //fputc erabili ahal izateko egiten den (char) castinga cposx eta cposy-en esleituz
            cposx =(char)posx;
            cposy =(char)posy;
             //'a' tekla bidaliko zaio robotaren programari Wiimote-ko 'A' botoia sakatu dela jakinarazteko
            fputc(tekla, portua);
            //Kurtsorearen uneko x eta y posizioak bidaliko zaizkio robotaren programari RFCOMM0 portutik
            fputc(cposy, portua);
            fputc(cposx, portua);
            break;
            //B tekla bidaliko zaio robotak frenatzea nahi dugunean
            case Qt::Key_B :
            tekla = 'b';
            fputc(tekla, portua);
            break;
            //Pantailaren posizioa kalibratzen da
            case Qt::Key_1:
            pos.setPos(683,384);
            break;

        }

         fclose(portua);
}
void Cocos2dWidget::contextMenuEvent(QContextMenuEvent * e) 
{ 
    if (g_mainScene){
        if (g_mainScene->onClickMouseKey(e->x(), e->y())){
            QCursor cur = this->cursor(); 
            QMenu *menu=new QMenu(this); 
            menu->addAction(m_actDelete); 
			int x = cur.pos().x();
			int y = cur.pos().y();
            menu->exec(cur.pos()); 
        }
    }
} 
Exemplo n.º 17
0
void IconsWidget::showToolTip()
{
    if (crashed)
        return;
    if (newToolTip)
        makeToolTip();
    QCursor curs;
    QPoint cursPos = mapFromGlobal(curs.pos());
    if (rect().contains(cursPos)) {
        toolTip->show();
        this->setFocus();
    }
}
Exemplo n.º 18
0
void ReportViewWidget::ScrollArea::keyPressEvent(QKeyEvent* ev)
{
	if(ev->modifiers() == Qt::ControlModifier) {
		static QCursor c;
		if(c.bitmap() == NULL) {
			QBitmap b1(":/qf/qmlwidgets/images/zoomin_cursor_bitmap.png");
			QBitmap b2(":/qf/qmlwidgets/images/zoomin_cursor_mask.png");
			c = QCursor(b1, b2, 18, 12);
		}
		setCursor(c);
	}
	QAbstractScrollArea::keyPressEvent(ev);
}
Exemplo n.º 19
0
void Preview::initializeGL()
{
	CommonGraphicsCommands::initializeGlobalGraphics();
	GameObjectManager::globalGameObjectManager.initialize();
	std::string err;
	ShaderInfo* shader = GraphicsShaderManager::globalShaderManager.createShaderInfo( FileReader( "assets/shaders/VertexShader.glsl" ).c_str() , FileReader( "assets/shaders/FragmentShader.glsl" ).c_str() , &err );
	std::cout << err.c_str() << std::endl;

	renderable = GraphicsRenderingManager::globalRenderingManager.addRenderable();
	renderable->geometryInfo = 0;
	renderable->shaderInfo = shader;
	renderable->culling = CT_BACK;
	renderable->depthTestEnabled = true;
	renderable->sharedUniforms = &GraphicsSharedUniformManager::globalSharedUniformManager;
	renderable->initialize( 10 , 1 );

	colorTexture = GraphicsTextureManager::globalTextureManager.addTexture( 0 , 0 , 0 , 0 );
	renderable->addTexture( colorTexture );

	GameObject* previewModel = GameObjectManager::globalGameObjectManager.addGameObject();
	previewModel->addComponent( renderable );
	
	animation = new AnimationRenderingInfo;
	previewModel->addComponent( animation );

	Camera* camera = GraphicsCameraManager::globalCameraManager.addCamera();
	camera->direction = glm::normalize( glm::vec3( -1 , 0 , -1 ) );
	camera->initializeRenderManagers();
	camera->nearestObject = 0.01f;
	camera->addRenderList( &GraphicsRenderingManager::globalRenderingManager );
	fpsInput = new FirstPersonCameraInput;
	fpsInput->moveSensitivity = 1;
	fpsInput->rotationSensitivity = 0.1f;
	GameObject* cameraMan = GameObjectManager::globalGameObjectManager.addGameObject();
	cameraMan->translate = glm::vec3( 6 , 5 , 15 );
	cameraMan->addComponent( camera );
	cameraMan->addComponent( fpsInput );

	MouseInput::globalMouseInput.updateOldMousePosition = false;

	setMouseTracking( true );
	QCursor c = cursor();
	c.setPos( mapToGlobal( QPoint( width() / 2 , height() / 2 ) ) );
	c.setShape( Qt::BlankCursor );
	setCursor( c );
	MouseInput::globalMouseInput.updateMousePosition( glm::vec2( width() / 2 , height() / 2 ) );
	timer = new QTimer();
	connect( timer , SIGNAL( timeout() ) , this , SLOT( update() ) );
	timer->start( 0 );
}
Exemplo n.º 20
0
void OpenGLWindow::mouseReleaseEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
    {
        QCursor c = cursor();
        c.setShape(Qt::OpenHandCursor);
        setCursor(c);

        leftButton = false;

    }

    event->accept();
}
Exemplo n.º 21
0
void GLWidget::updateCursor()
{
    QCursor cursor = this->cursor();
    cursor.setShape(Qt::ArrowCursor);
    if(leftMouseButtonMode == ROTATE)
    {
        cursor.setShape(Qt::SizeAllCursor);
    }
    else if(leftMouseButtonMode == PANNING)
    {
        cursor.setShape(Qt::SizeAllCursor);
    }
    QWidget::setCursor(cursor);
}
Exemplo n.º 22
0
void OpenGLWindow::mousePressEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
    {
        QCursor c = cursor();
        c.setShape(Qt::DragMoveCursor);
        setCursor(c);

        leftButton = true;
        currentMousePos.x = event->x();
        currentMousePos.y = event->y();
    }

    event->accept();
}
Exemplo n.º 23
0
/*
 * Makes the specified cursor appear above a specific native window group
 * Called from QSymbianControl and QApplication::restoreOverrideCursor
 *
 * Window server is needed for this, so there is no equivalent when using
 * the sprite workaround.
 */
void qt_symbian_setWindowGroupCursor(const QCursor &cursor, RWindowTreeNode &node)
{
    Qt::HANDLE handle = cursor.handle();
    if (handle) {
        RWsPointerCursor *pcurs = reinterpret_cast<RWsPointerCursor *> (handle);
        node.SetCustomPointerCursor(*pcurs);
    } else
#ifdef Q_SYMBIAN_HAS_SYSTEM_CURSORS
    {
        TInt shape = qt_symbian_translate_cursor_shape(cursor.shape());
        node.SetPointerCursor(shape);
    }
#else
    qWarning("qt_s60_setWindowGroupCursor - null handle");
#endif
}
Exemplo n.º 24
0
void Vruler::mouseMoveEvent(QMouseEvent *m)
{
	if (Mpressed)
	{
		rulerGesture->mouseMoveEvent(m);
	}
	else
	{
		QCursor* cursor = qApp->overrideCursor();
		Qt::CursorShape shape = cursor ? cursor->shape() : Qt::ArrowCursor;
		if ((shape == Qt::SplitHCursor) || (shape == Qt::SplitVCursor))
		{
			qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
		}
	}
}
Exemplo n.º 25
0
void
PlayField::changeCursor(const QCursor& c) {
  if (cursor_.handle() == c.handle()) return;

  cursor_ = c;
  QWidget::setCursor(c);
}
Exemplo n.º 26
0
void GameView::mousePressEvent(QMouseEvent*)
{
	if (m_editor->isGameMode())
	{
		setFocus();
		setMouseTracking(true);
		grabMouse();
		grabKeyboard();
		QCursor c = cursor();
		c.setPos(mapToGlobal(QPoint(width() / 2, height() / 2)));
		c.setShape(Qt::BlankCursor);
		setCursor(c);
		m_editor->getEngine().getInputSystem().enable(true);
		m_isInputHandling = true;
	}
}
Exemplo n.º 27
0
void QgsSpatialQueryDialog::showRubberFeature( QgsVectorLayer* lyr, QgsFeatureId id )
{
  mRubberSelectId->reset();

  Qt::CursorShape shapeCurrent = cursor().shape();

  QCursor c;
  c.setShape( Qt::WaitCursor );
  setCursor( c );

  mRubberSelectId->addFeature( lyr, id );
  mRubberSelectId->show();

  c.setShape( shapeCurrent );
  setCursor( c );
} // void QgsSpatialQueryDialog::showRubberFeature( QgsVectorLayer* lyr, int id )
Exemplo n.º 28
0
// static
QCursor MapEditorTool::scaledToScreen(const QCursor& unscaled_cursor)
{
	auto scale = Settings::getInstance().getSetting(Settings::General_PixelsPerInch).toReal() / 96.0;
	if (unscaled_cursor.shape() == Qt::BitmapCursor
	    && scale > 1.5)
	{
		// Need to scale our low res image for high DPI screen
		const auto unscaled_pixmap = unscaled_cursor.pixmap();
		const auto scaled_hotspot = QPointF{ unscaled_cursor.hotSpot() } * scale;
		return QCursor{ unscaled_pixmap.scaledToWidth(unscaled_pixmap.width() * scale, Qt::SmoothTransformation),
		                qRound(scaled_hotspot.x()), qRound(scaled_hotspot.y()) };
	}
	else
	{
		return unscaled_cursor;
	}
}
Exemplo n.º 29
0
 CursorWidget(QCursor cursor, QColor color)
 :m_cursor(cursor)
 ,m_color(color)
 {
     if (cursor.shape() == Qt::ArrowCursor)
         unsetCursor();
     else
         setCursor(cursor);
 }
Exemplo n.º 30
0
int QtCursorDatabase::cursorToValue(const QCursor &cursor) const
{
#ifndef QT_NO_CURSOR
    Qt::CursorShape shape = cursor.shape();
    if (m_cursorShapeToValue.contains(shape))
        return m_cursorShapeToValue[shape];
#endif
    return -1;
}