Пример #1
0
void Preview::mouseMoveEvent( QMouseEvent* e )
{
	e;
	QCursor c = cursor();
	QPoint mapFromGlobal = this->mapFromGlobal( c.pos() );
	if ( GetAsyncKeyState( VK_LBUTTON ) < 0 && mapFromGlobal.x() >= 0 && mapFromGlobal.x() <= width() &&
		 mapFromGlobal.y() >= 0 && mapFromGlobal.y() <= height() && MouseInput::globalMouseInput.oldMousePosition != glm::vec2( c.pos().x() , c.pos().y() ) )
	{
		if ( !MouseInput::globalMouseInput.getDeltaTracking() )MouseInput::globalMouseInput.setDeltaTracking( true );
		glm::vec2 oldPos = MouseInput::globalMouseInput.oldMousePosition;
		MouseInput::globalMouseInput.updateMousePosition( glm::vec2( c.pos().x() , c.pos().y() ) );
		
		c.setPos( QPoint( oldPos.x , oldPos.y ) );
		c.setShape( Qt::BlankCursor );
	}
	else if ( MouseInput::globalMouseInput.oldMousePosition != glm::vec2( c.pos().x() , c.pos().y() ) )
	{
		c.setShape( Qt::ArrowCursor );
		if ( MouseInput::globalMouseInput.getDeltaTracking() )MouseInput::globalMouseInput.setDeltaTracking( false );
		MouseInput::globalMouseInput.oldMousePosition = glm::vec2( c.pos().x() , c.pos().y() );
		MouseInput::globalMouseInput.updateMousePosition( glm::vec2( c.pos().x() , c.pos().y() ) );
	}
	clearFocus();
	setCursor( c );
	setFocus();
}
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()); 
        }
    }
} 
Пример #3
0
void IconsWidget::leaveEvent(QEvent *)
{
    QCursor curs;
    QPoint cursPos = mapFromGlobal(curs.pos());
    if (!rect().contains(cursPos))
        toolTip->hide();
}
Пример #4
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());

}
Пример #5
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();
    }
}
Пример #6
0
void IconsWidget::mouseMoveEvent(QMouseEvent *event)
{
    if (crashed)
        return;

    QCursor cursor;
    QPoint  cursorPos = mapFromGlobal(cursor.pos());

    if (rect().contains(cursorPos)) {
        int border = 5;
        QPoint point  = mapToGlobal(event->pos());
        QPoint point2 = mapToGlobal(QPoint(0, 0));
        if (point2.y() - mainPix.height() - 6 > 0) {
            toolTip->setGeometry(point.x() - mainPix.width()/2, point2.y() - mainPix.height()-6,
                                 mainPix.width(), mainPix.height());
        } else {
            toolTip->setGeometry(point.x() - mainPix.width()/2, point2.y() + height() + border,
                                 mainPix.width(), mainPix.height());
        }
    }
}
void ComparisonLineChart::contextMenuEvent(QContextMenuEvent *event){
    QCursor cur = this->cursor();

    context_menu_->exec(cur.pos());
}
Пример #8
0
//std::string readShaderCode(const char *fileName)
//{
//	std::ifstream input(fileName);
//
//	if(!input.good())
//	{
//		qDebug() << "File not found" << fileName;
//		exit(1);
//	}
//	return std::string(std::istreambuf_iterator<char>(input),
//		std::istreambuf_iterator<char>());
//}
//void MyGLWindow::CompileShaders()
//{
//	GLuint vertexShaderID = glCreateShader(GL_VERTEX_SHADER);
//	GLuint fragShaderID=glCreateShader(GL_FRAGMENT_SHADER);
//	const char* adapter[1];
//	
//	std::string shaderCode= readShaderCode("../shaders/LightingVertexShaderCode.glsl");
//	adapter[0] = shaderCode.c_str();
//	glShaderSource(vertexShaderID,1,adapter,0);
//
//	shaderCode= readShaderCode("../shaders/LightingFragmentShaderCode.glsl");
//	adapter[0] = shaderCode.c_str();
//	glShaderSource(fragShaderID,1,adapter,0);
//
//	glCompileShader(vertexShaderID);
//	glCompileShader(fragShaderID);
//
//	GLint compileStatus;
//	glGetShaderiv(vertexShaderID,GL_COMPILE_STATUS,&compileStatus);
//	if(compileStatus != GL_TRUE)
//	{
//		GLint logLength;
//		glGetShaderiv(vertexShaderID,GL_INFO_LOG_LENGTH, &logLength);
//		char* buffer = new char [logLength];
//		GLsizei bitBucket;
//		glGetShaderInfoLog(vertexShaderID,logLength,&bitBucket,buffer);
//		qDebug() <<buffer;
//		delete [] buffer;
//	}
//	glGetShaderiv(fragShaderID,GL_COMPILE_STATUS,&compileStatus);
//	if(compileStatus != GL_TRUE)
//	{
//		GLint logLength;
//		glGetShaderiv(fragShaderID,GL_INFO_LOG_LENGTH, &logLength);
//		char* buffer = new char [logLength];
//		GLsizei bitBucket;
//		glGetShaderInfoLog(fragShaderID,logLength,&bitBucket,buffer);
//		qDebug() <<buffer;
//		delete [] buffer;
//	}
//
//	programID = glCreateProgram();
//	glAttachShader(programID,vertexShaderID);
//	glAttachShader(programID,fragShaderID);
//
//	glLinkProgram(programID);
//
//	glUseProgram(programID);
//
//	glDeleteShader(vertexShaderID);
//	glDeleteShader(fragShaderID);
//}
void MyGLWindow::myUpdate()
{
	if(GetAsyncKeyState('E'))
	{
	QCursor mouse = cursor();
	QPoint mousePosition = mouse.pos();
	cam.mouseUpdate(glm::vec2(mousePosition.x(),mousePosition.y()));
	}

	if(GetAsyncKeyState('W'))
	{
		cam.moveForward();
	}
	if(GetAsyncKeyState('S'))
	{
		cam.moveBackward();
	}
	if(GetAsyncKeyState('A'))
	{
		cam.strafeLeft();
	}
	if(GetAsyncKeyState('D'))
	{
		cam.strafeRight();
	}
	if(GetAsyncKeyState('R'))
	{
		cam.moveUp();
	}
	if(GetAsyncKeyState('F'))
	{
		cam.moveDown();
	}
	if(GetAsyncKeyState('Y'))
	{
		lightPosition[1]+=0.1f;
	}
	if(GetAsyncKeyState('H'))
	{
		lightPosition[1]-=0.1f;
	}
	if(GetAsyncKeyState('L'))
	{
		lightPosition[0]+=0.1f;
	}
	if(GetAsyncKeyState('J'))
	{
		lightPosition[0]-=0.1f;
	}
	if(GetAsyncKeyState('K'))
	{
		lightPosition[2]+=0.1f;
	}
	if(GetAsyncKeyState('I'))
	{
		lightPosition[2]-=0.1f;
	}
	if(lighting->isChecked())
	{
		lit=1.0f;
	}
	if(!lighting->isChecked())
	{
		lit=0.0f;
	}
	
	paintGL();
	swapBuffers();
}