void MainWindow::crearCartasVisuales2(MazoPrincipal mazox, int x ,int y, int crecer){

   for(int i=0; i<mazox.cont; i++){
    QPixmap actual =  QPixmap(":/images/cards/Back.png");
    if(!mazox.recuperar(i)->carta->isCaraAbajo())
    {
     actual = mazox.recuperar(i)->carta->getImagen();
    }

    miLabel *a = new miLabel(this);
    //Label *a = new Label(this);
    a->nodo=mazox.recuperar(i);
    a->pertenece=&mazox;
    a->setPixmap(actual);
    a->setGeometry(x,y,99,135);
    connect(a, SIGNAL( Mouse_Pressed() ), this, SLOT(Mouse_Pressed()));
    a->raise();
    a->show();
    y+=crecer;
  }
}
void QLabelMouseTracking::mousePressEvent(QMouseEvent *ev)
{
    QWidget *mainWidget = this->parentWidget();
    //the Global-X Position add the width and subtract the position
    // that was mapped from the border to the parent
    rightBorderX  = ev->globalX() + mainWidget->geometry().width() -ev->x();

    //Needed to handle the position by moving MainWidget
    mousePressedGlobalX = ev->pos().x();
    mousePressedGlobalY = ev->pos().y();
    emit Mouse_Pressed();
}
void mouse_qlabel::mousePressEvent(QMouseEvent *ev)
{
    emit Mouse_Pressed();
}
Exemple #4
0
void Handle_One_Event() {
	static const long twentyTicks = time_in_ticks(20).asMilliseconds();
	static const long fortyTicks = time_in_ticks(40).asMilliseconds();
	
	through_sending();
	Handle_Update();
	
	//(cur_time - last_anim_time > 42)
	if((animTimer.getElapsedTime().asMilliseconds() >= fortyTicks) && (overall_mode != MODE_STARTUP) && (anim_onscreen) && get_bool_pref("DrawTerrainAnimation", true)
	   && (!gInBackground)) {
		animTimer.restart();
		draw_terrain();
	}
	if((animTimer.getElapsedTime().asMilliseconds() > twentyTicks) && (overall_mode == MODE_STARTUP)) {
		animTimer.restart();
		draw_startup_anim(true);
	}
	
	clear_sound_memory();
	
	if(map_visible && mini_map.pollEvent(event)){
		if(event.type == sf::Event::Closed) {
			mini_map.setVisible(false);
			map_visible = false;
		} else if(event.type == sf::Event::GainedFocus)
			makeFrontWindow(mainPtr);
	}
	if(!mainPtr.pollEvent(event)) {
		if(changed_display_mode) {
			changed_display_mode = false;
			adjust_window_mode();
		}
		flushingInput = false;
		redraw_screen(REFRESH_NONE);
		return;
	}
	switch(event.type) {
		case sf::Event::KeyPressed:
			if(flushingInput) return;
			if(!(event.key.*systemKey))
				handle_keystroke(event);
			
			break;
			
		case sf::Event::MouseButtonPressed:
			if(flushingInput) return;
			Mouse_Pressed();
			break;
			
		case sf::Event::MouseLeft:
			// Make sure we don't have an arrow cursor when it's outside the window
			make_cursor_sword();
			break;
			
		case sf::Event::GainedFocus:
			Handle_Update();
			makeFrontWindow(mainPtr);
		case sf::Event::MouseMoved:
			if(!gInBackground) {
				location where(event.mouseMove.x, event.mouseMove.y);
				change_cursor(where);
			}
			break;
			
		case sf::Event::MouseWheelMoved:
			if(flushingInput) return;
			handle_scroll(event);
			break;
			
		case sf::Event::Closed:
			if(overall_mode == MODE_STARTUP) {
				if(party_in_memory) {
					std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show();
					if(choice == "cancel") break;
					if(choice == "save") {
						fs::path file = nav_put_party();
						if(!file.empty()) break;
						save_party(file, univ);
					}
				}
				All_Done = true;
				break;
			}
			if(overall_mode > MODE_TOWN){
				std::string choice = cChoiceDlog("quit-confirm-nosave", {"quit", "cancel"}).show();
				if(choice == "cancel")
					break;
			}
			else {
				std::string choice = cChoiceDlog("quit-confirm-save", {"save", "quit", "cancel"}).show();
				if(choice == "cancel")
					break;
				if(choice == "save")
					save_party(univ.file, univ);
			}
			All_Done = true;
		default:
			break; // There's several events we don't need to handle at all
	}
	flushingInput = false; // TODO: Could there be a case when the key and mouse input that needs to be flushed has other events interspersed?
}
ImageWindows::ImageWindows(QImage image, QString name, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ImageWindows)
{
    ui->setupUi(this);

    imageLbl=new qlabel_image();

    //Signal émit par la class qlabel_image pour la lecture en dynamique de la position des pixels
    connect(imageLbl, SIGNAL(Mouse_Pos()), this, SLOT(Mouse_current_pos()));
    connect(imageLbl, SIGNAL(Mouse_Pressed()), this, SLOT(Mouse_pressed()));
    connect(imageLbl, SIGNAL(Mouse_ClickLeft()), this, SLOT(MouseClickLeft()));
    connect(imageLbl, SIGNAL(Mouse_ReleasePos()), this, SLOT(Mouse_release_pos()));
    imageLbl->setMouseTracking(true);

   // setFixedHeight(image.height());
   // setFixedWidth(image.width());
    image_ihm = image;
    m_coeffZoom=1;
    affichageImage(image_ihm,m_coeffZoom,ui->scrollArea_Image);
     /*QLabel *imageLabel = new QLabel;
     imageLabel->setBackgroundRole(QPalette::Base);
     imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
     imageLabel->setScaledContents(true);
     imageLabel -> setPixmap(QPixmap::fromImage(image));
     ui->scrollArea_Image->setBackgroundRole(QPalette::Dark);
     ui->scrollArea_Image->setWidget(imageLabel);

*/
    //ui ->label_Image -> setPixmap(QPixmap::fromImage(*image));
    QString txt =  QString::number(image.width())  + " x " + QString::number(image.height());
    ui->lbl_imageSize->setText(txt);

    if(image_ihm.isGrayscale())
        ui->lbl_imageDepth->setText("niveau de gris");
    else
        ui->lbl_imageDepth->setText("couleur");




    /*int index = pathImage.lastIndexOf("/");
    std::cout << "index : " << index;
    m_StrImageName = pathImage.left(index);*/
    m_StrImageName = name;
    setWindowTitle(m_StrImageName);


    QPixmap pixmap("actions/document-save-3.ico");
    QIcon ButtonIcon(pixmap);
    ui->pushB_Save->setIcon(ButtonIcon);
    QSize size = pixmap.rect().size();
    size.setHeight(size.height() -10);
    size.setWidth(size.width() -10);
    ui->pushB_Save->setIconSize(size);


    QPixmap pixmap2("actions/zoom-in-3.ico");
    QIcon ButtonIcon2(pixmap2);
    ui->pushB_ZoomIn->setIcon(ButtonIcon2);
    QSize size1 = pixmap2.rect().size();
    size1.setHeight(size1.height() -10);
    size1.setWidth(size1.width() -10);
    ui->pushB_ZoomIn->setIconSize(size1);


    QPixmap pixmap3("actions/zoom-out-3.ico");
    QIcon ButtonIcon3(pixmap3);
    ui->pushB_ZoomOut->setIcon(ButtonIcon3);
    QSize size2 = pixmap3.rect().size();
    size2.setHeight(size2.height() -10);
    size2.setWidth(size2.width() -10);
    ui->pushB_ZoomOut->setIconSize(size2);



}