Пример #1
0
FenetreTaille::FenetreTaille(ImageRGB* image, QWidget *parent) :
    QDialog(parent)
{
    if(image != NULL)
    {
        setFixedSize(260,160);
        proportionnel = true;

        this->image = image;
        this->imagePrec = *image;

        this->valProp = (double)(image->width()) / (double)(image->height());

        QVBoxLayout *layout = new QVBoxLayout;

        QCheckBox* prop = new QCheckBox("Conserver les proportions", this);
        prop->setChecked(true);
        layout->addWidget(prop);
        connect(prop, SIGNAL(toggled(bool)), this, SLOT(changeProp(bool)));


        QLabel* text1 = new QLabel("hauteur", this);
        layout->addWidget(text1);

        BoxHauteur = new QSpinBox(this);
        BoxHauteur->setMinimum(1);
        BoxHauteur->setMaximum(10000);
        BoxHauteur->setValue(image->height());
        hauteurImage = image->height();
        layout->addWidget(BoxHauteur);
        connect(BoxHauteur, SIGNAL(valueChanged(int)), this, SLOT(changeHauteur(int)));


        QLabel* text2 = new QLabel("Largeur", this);
        layout->addWidget(text2);

        BoxLargeur = new QSpinBox(this);
        BoxLargeur->setMinimum(1);
        BoxLargeur->setMaximum(10000);
        BoxLargeur->setValue(image->width());
        largeurImage = image->width();
        layout->addWidget(BoxLargeur);
        connect(BoxLargeur, SIGNAL(valueChanged(int)), this, SLOT(changeLargeur(int)));


        QHBoxLayout* layout2 = new QHBoxLayout;
        QPushButton* bouton_annuler = new QPushButton("Annuler", this);
        layout2->addWidget(bouton_annuler);
        connect(bouton_annuler, SIGNAL(clicked()), this, SLOT(annuler()));

        QPushButton* bouton_ok = new QPushButton("OK", this);
        layout2->addWidget(bouton_ok);
        layout->addLayout(layout2);
        connect(bouton_ok, SIGNAL(clicked()), this, SLOT(valider()));

        this->changePourProp = false;

        this->setLayout(layout);
    }
Пример #2
0
int main (int argc, char * argv[])
{
	
	Coord_SDL clic;
	s_Menu menu;
	s_Interface interface;
	s_Board board;
	
	interface = Init();
	board = load_Board(interface);
	menu = load_Menu(interface);
	
	SDL_Event event;
	Plateau board_tab;
	Coordonnees_tab coord_tab;
	Couleur joueur_courant = bleu, dernier_joueur = bleu;
	menu.actualMenu = menu.mainMenu;
	bool quit = false, premier_coup = true, IA = false;
	int choix;
	
	coord_tab.abscisse = 0;
	coord_tab.ordonnee = 0;
	
	
	while (!quit)  //Boucle des évènements
	{
		SDL_WaitEvent(&event);
		
		if (IA)
			if (joueur_courant == rouge)
			{
				event.button.button = SDL_BUTTON_LEFT;
				event.type = SDL_MOUSEBUTTONDOWN;
			}
		
		switch (event.type)
		{
			case SDL_QUIT:
				quit = true;
				break;
				
			case SDL_MOUSEBUTTONDOWN:	//On clique sur la souris
				if (event.button.button == SDL_BUTTON_LEFT)
				{
					clic.CoordX = event.motion.x;
					clic.CoordY = event.motion.y;
					
					choix = choix_Menu(clic, menu);
					
					
					/********************* Menus ***********************/
					
					if (menu.actualMenu == menu.mainMenu)	//Menu principal
					{
						if (choix == 1)
							
						{
							menu.actualMenu = menu.playMenu;
							MaJ_Menu(menu, interface, nbPlayMenuChoice);
						}
						if (choix == 2)
						{
							initialiser_plateau(board_tab);
							chargement(board_tab);
							MaJ_Board(board, interface, board_tab);
							menu.actualMenu = menu.inGameMenu;
							MaJ_Menu(menu, interface, nbinGameMenuChoice);
							premier_coup = false;
						}
						if (choix == 3)
						{
							quit = true;
						}
					}
					
					
					else if (menu.actualMenu == menu.playMenu)	//Menu de sélection de partie
					{
						if (choix == 0)
						{
							menu.actualMenu = menu.inGameMenu;
							MaJ_Menu(menu, interface, nbinGameMenuChoice);
							nouvelle_partie(board_tab);
							MaJ_Board(board, interface, board_tab);
							joueur_courant = bleu;
							premier_coup = true;
							IA = false;
							MaJ_Infos(menu, interface, joueur_courant, premier_coup);

						}
						if (choix == 1)
						{
							menu.actualMenu = menu.inGameMenu;
							MaJ_Menu(menu, interface, nbinGameMenuChoice);
							nouvelle_partie(board_tab);
							MaJ_Board(board, interface, board_tab);
							joueur_courant = bleu;
							premier_coup = true;
							IA = true;
							MaJ_Infos(menu, interface, joueur_courant, premier_coup);
							
						}
						if (choix == 2)
						{
							menu.actualMenu = menu.inGameMenu;
							MaJ_Menu(menu, interface, nbinGameMenuChoice);
							nouvelle_partie(board_tab);
							MaJ_Board(board, interface, board_tab);
							joueur_courant = bleu;
							premier_coup = true;
							IA = true;
							MaJ_Infos(menu, interface, joueur_courant, premier_coup);
						}
						if (choix == 3)
						{
							if (premier_coup == true)
								menu.actualMenu = menu.mainMenu;
							else
								menu.actualMenu = menu.inGameMenu;
							MaJ_Menu(menu, interface, nbMenuChoice);
						}
					}
					
					
					else if (menu.actualMenu == menu.inGameMenu)	//Menu en jeu
					{
						if (choix == 0)
						{
							menu.actualMenu = menu.playMenu;
							MaJ_Menu(menu, interface, nbPlayMenuChoice);
						}
						if (choix == 1)
						{
							board_save(board_tab);
						}
						if (choix == 2)
						{
							if (joueur_courant != dernier_joueur)
							{
								if (!premier_coup)
								{
								annuler(board_tab);
								MaJ_Board(board, interface, board_tab);
								MaJ_Infos(menu, interface, joueur_courant, premier_coup);
								joueur_courant = changer_joueur(joueur_courant);
								}
							}
						}
						if (choix == 3)
						{
							quit = true;
						}
						
						
						/********************* Tour de jeu *********************/
						
						if (!IA)	//Partie humain vs humain
						{
							if (clic_on_board(clic, board))
							{
								coord_tab = pos_pion_tab(clic, board);
								if (coup_valide(board_tab, coord_tab))
								{
									placer_pion(board, coord_tab, joueur_courant, interface, board_tab);
								
									if (joueur_courant == bleu)
										dernier_joueur = bleu;
									else
										dernier_joueur = rouge;
									
									historique(premier_coup, coord_tab, joueur_courant);
									premier_coup = false;
									MaJ_Infos(menu, interface, joueur_courant,premier_coup);

									if (verify_win(board_tab[coord_tab.abscisse][coord_tab.ordonnee], board_tab))
									{
										affiche_vainqueur(menu, interface, joueur_courant);
										menu.actualMenu = menu.mainMenu;
										MaJ_Menu(menu, interface, nbMenuChoice);
										joueur_courant = neutre;
									}
									joueur_courant = changer_joueur(joueur_courant);
								}
							}
						}
						
						else if (IA)	//Partie humain vs IA
						{
							if (joueur_courant == bleu)
								coord_tab = pos_pion_tab(clic, board);
							else
							{
								coord_tab = coup_IA1 (board_tab);
								SDL_Delay(500);
							}
							
							if (coup_valide(board_tab, coord_tab))
							{
								placer_pion(board, coord_tab, joueur_courant, interface, board_tab);
								historique(premier_coup, coord_tab, joueur_courant);
								premier_coup = false;
								MaJ_Infos(menu, interface, joueur_courant,premier_coup);
								
								if (verify_win(board_tab[coord_tab.abscisse][coord_tab.ordonnee], board_tab))
								{
									affiche_vainqueur(menu, interface, joueur_courant);
									menu.actualMenu = menu.mainMenu;
									MaJ_Menu(menu, interface, nbMenuChoice);
									joueur_courant = neutre;
								}
								joueur_courant = changer_joueur(joueur_courant);
							}
						}
					}
				}
				break;
				
				
			case SDL_KEYDOWN:
				switch (event.key.keysym.sym)
			{
				case SDLK_ESCAPE: //On appuie sur la touche ECHAP
					quit = true;
					break;
			}
				break;
		}
		
			//Met à jour l'écran
		SDL_UpdateWindowSurface(interface.window);
	}
	
	return 0;
}
Пример #3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    nbonglet=0;
    mesonglets = new Onglet();
    ui->setupUi(this);
    QVBoxLayout* l = new QVBoxLayout();
    ui->centralWidget->setLayout(l);;
    l->addWidget(mesonglets);
    l->addWidget(ui->frame);
    mesonglets->setMaximumHeight(24);
    mesonglets->setTabsClosable(true);

    nouvelOnglet();

    QObject::connect(ui->num0,SIGNAL(clicked()),this,SLOT(num0Pressed()));
    QObject::connect(ui->num1,SIGNAL(clicked()),this,SLOT(num1Pressed()));
    QObject::connect(ui->num2,SIGNAL(clicked()),this,SLOT(num2Pressed()));
    QObject::connect(ui->num3,SIGNAL(clicked()),this,SLOT(num3Pressed()));
    QObject::connect(ui->num4,SIGNAL(clicked()),this,SLOT(num4Pressed()));
    QObject::connect(ui->num5,SIGNAL(clicked()),this,SLOT(num5Pressed()));
    QObject::connect(ui->num6,SIGNAL(clicked()),this,SLOT(num6Pressed()));
    QObject::connect(ui->num7,SIGNAL(clicked()),this,SLOT(num7Pressed()));
    QObject::connect(ui->num8,SIGNAL(clicked()),this,SLOT(num8Pressed()));
    QObject::connect(ui->num9,SIGNAL(clicked()),this,SLOT(num9Pressed()));
    QObject::connect(ui->sinButton,SIGNAL(clicked()),this,SLOT(SINPressed()));
    QObject::connect(ui->sinhButton,SIGNAL(clicked()),this,SLOT(SINHPressed()));
    QObject::connect(ui->cosButton,SIGNAL(clicked()),this,SLOT(COSPressed()));
    QObject::connect(ui->coshButton,SIGNAL(clicked()),this,SLOT(COSHPressed()));
    QObject::connect(ui->tanButton,SIGNAL(clicked()),this,SLOT(TANPressed()));
    QObject::connect(ui->tanhButton,SIGNAL(clicked()),this,SLOT(TANHPressed()));
    QObject::connect(ui->lnButton,SIGNAL(clicked()),this,SLOT(LNPressed()));
    QObject::connect(ui->logButton,SIGNAL(clicked()),this,SLOT(LOGPressed()));
    QObject::connect(ui->cubeButton,SIGNAL(clicked()),this,SLOT(CUBEPressed()));
    QObject::connect(ui->sqrButton,SIGNAL(clicked()),this,SLOT(SQRPressed()));
    QObject::connect(ui->sqrtButton,SIGNAL(clicked()),this,SLOT(SQRTPressed()));
    QObject::connect(ui->invButton,SIGNAL(clicked()),this,SLOT(INVPressed()));
    QObject::connect(ui->factButton,SIGNAL(clicked()),this,SLOT(FACTPressed()));
    QObject::connect(ui->addButton,SIGNAL(clicked()),this,SLOT(ADDPressed()));
    QObject::connect(ui->minusButton,SIGNAL(clicked()),this,SLOT(MINUSPressed()));
    QObject::connect(ui->multiplyButton,SIGNAL(clicked()),this,SLOT(MULTPressed()));
    QObject::connect(ui->divButton,SIGNAL(clicked()),this,SLOT(DIVPressed()));
    QObject::connect(ui->powButton,SIGNAL(clicked()),this,SLOT(POWPressed()));
    QObject::connect(ui->modButton,SIGNAL(clicked()),this,SLOT(MODPressed()));
    QObject::connect(ui->signButton,SIGNAL(clicked()),this,SLOT(SIGNPressed()));
    QObject::connect(ui->spaceButton,SIGNAL(clicked()),this,SLOT(spacePressed()));
    QObject::connect(ui->ratioButton,SIGNAL(clicked()),this,SLOT(ratioClicked()));
    QObject::connect(ui->realButton,SIGNAL(clicked()),this,SLOT(realClicked()));
    QObject::connect(ui->integerButton,SIGNAL(clicked()),this,SLOT(integerClicked()));
    QObject::connect(ui->degreButton,SIGNAL(clicked()),this,SLOT(degreClicked()));
    QObject::connect(ui->radianButton,SIGNAL(clicked()),this,SLOT(radianClicked()));
    QObject::connect(ui->trueComplexButton,SIGNAL(clicked()),this,SLOT(trueComplexClicked()));
    QObject::connect(ui->falseComplexButton,SIGNAL(clicked()),this,SLOT(falseComplexClicked()));
    QObject::connect(mesonglets,SIGNAL(tabCloseRequested(int)),this,SLOT(fermerOnglet(int)));
    QObject::connect(ui->actionNouvel_Onglet,SIGNAL(triggered()),this,SLOT(nouvelOnglet()));
    QObject::connect(ui->pointButton,SIGNAL(clicked()),this,SLOT(pointPressed()));
    QObject::connect(ui->slashButton,SIGNAL(clicked()),this,SLOT(slashPressed()));
    QObject::connect(ui->dollarButton,SIGNAL(clicked()),this,SLOT(dollarPressed()));
    QObject::connect(ui->quoteButton,SIGNAL(clicked()),this,SLOT(quotePressed()));
    QObject::connect(mesonglets,SIGNAL(currentChanged(int)),this,SLOT(changerOnglet(int)));
    QObject::connect(ui->evalButton,SIGNAL(clicked()),this,SLOT(evalPressed()));
    QObject::connect(ui->action_Quit,SIGNAL(triggered()),this,SLOT(Quitter()));
    QObject::connect(ui->actionAnnuler,SIGNAL(triggered()),this,SLOT(annuler()));
    QObject::connect(ui->actionR_tablir,SIGNAL(triggered()),this,SLOT(retablir()));

}
Пример #4
0
void IhmPopup::clickAnnuler()
{
    emit annuler();
}
Пример #5
0
AddressBook::AddressBook(QWidget *parent)
    : QWidget(parent)
{
    rechercheDialog = new FindDialog;

    QLabel *labelNom        =   new QLabel (tr("Nom :"));
    nomLineEdit             =   new QLineEdit;
    nomLineEdit->setReadOnly(true);

    QLabel *labelAdresse    =   new QLabel(tr("Adresse :"));
    adresseTextEdit         =   new QTextEdit;
    adresseTextEdit->setReadOnly(true);

    QGridLayout *gridLayout = new QGridLayout;
    QVBoxLayout *layoutBoutons = new QVBoxLayout;
    QHBoxLayout *layoutBoutonsNavigation = new QHBoxLayout;

    ajouterBouton = new QPushButton (tr ("Ajouter"));
    soumettreBouton = new QPushButton (tr ("Soumettre"));
    annulerBouton = new QPushButton (tr("Annuler"));
    previousBouton = new QPushButton (tr ("Précédent"));
    nextBouton = new QPushButton (tr ("Suivant"));
    editerBouton = new QPushButton (tr ("&Editer"));
    supprimerBouton = new QPushButton (tr ("&Supprimer"));
    chercherBouton = new QPushButton (tr("Chercher"));
    chargerBouton = new QPushButton (tr("Charger..."));
    chargerBouton->setToolTip(tr("Charger depuis un fichier"));
    sauverBouton= new QPushButton (tr ("Sauver..."));
    sauverBouton->setToolTip(tr("Sauvegarder dans fichier"));

    layoutBoutons->addWidget(ajouterBouton, Qt::AlignTop);
    layoutBoutons->addWidget(soumettreBouton);
    layoutBoutons->addWidget(annulerBouton);
    layoutBoutons->addWidget(editerBouton);
    layoutBoutons->addWidget(supprimerBouton);
    layoutBoutons->addWidget(chercherBouton);
    layoutBoutons->addWidget(chargerBouton);
    layoutBoutons->addWidget(sauverBouton);
    layoutBoutons->addStretch();

    layoutBoutonsNavigation->addWidget(previousBouton);
    layoutBoutonsNavigation->addWidget(nextBouton);

    gridLayout->addWidget(labelNom , 0 , 0);
    gridLayout->addWidget(nomLineEdit , 0 , 1);
    gridLayout->addWidget(labelAdresse , 1 , 0);
    gridLayout->addWidget(adresseTextEdit ,  1 , 1);
    gridLayout->addLayout(layoutBoutons , 1 , 2);
    gridLayout->addLayout(layoutBoutonsNavigation , 2 , 1);

    setLayout(gridLayout);
    setWindowTitle(tr("Carnet d'adresses"));

    updateInterface(NavigationMode);

    // Connecteurs
    QObject::connect(ajouterBouton , SIGNAL(clicked()) , this , SLOT (ajouterContact()));
    QObject::connect(soumettreBouton , SIGNAL (clicked()) , this , SLOT (soumettreContact()));
    QObject::connect(annulerBouton , SIGNAL(clicked()) , this , SLOT(annuler()));
    QObject::connect(previousBouton , SIGNAL(clicked()) , this ,SLOT (previous()));
    QObject::connect(nextBouton , SIGNAL(clicked()) , this , SLOT(next()));
    QObject::connect(editerBouton , SIGNAL(clicked()) ,this , SLOT(editerContact()));
    QObject::connect(supprimerBouton , SIGNAL(clicked()) , this , SLOT(supprimerContact()));
    QObject::connect(chercherBouton , SIGNAL(clicked()) , this , SLOT(trouverContact()));
    QObject::connect(chargerBouton , SIGNAL(clicked()) , this , SLOT(chargerFichier()));
    QObject::connect(sauverBouton , SIGNAL(clicked()) , this , SLOT(sauverFichier()));
}