Example #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);
    }
Example #2
0
DialogSouhait::DialogSouhait(Souhait *souhait, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DialogSouhait)
{
    ui->setupUi(this);
    m_souhait = souhait;
    changed = false;
    this->setWindowTitle("Liste des souhaits");

    // Création de la barre de menu
    m_menu.setupUi(ui->widget_barreMenu);
    m_menu.label_fenetre->setText("Souhait");
    m_menu.image_fenetre->setPixmap(QPixmap(":/app/bien96"));
    m_menu.pushButton_1->setToolTip("Valider");
    m_menu.pushButton_2->setToolTip("Annuler");
    m_menu.pushButton_3->setVisible(false);

    ui->label_NomClient->setText((m_souhait->getClient())->getNom());
    ui->lineEdit_BudgetMax->setText(QString::number(m_souhait->getBudget()));
    ui->lineEdit_SurfHabMin->setText(QString::number(m_souhait->getSurfaceHabitable()));
    ui->lineEdit_SurJardMin->setText(QString::number(m_souhait->getSurfaceJardin()));

    m_listeVilles = m_souhait->getVilles();
    for (int i=0; i<m_listeVilles.size(); i++)
    {
        ui->textEdit_Villes->append(m_listeVilles[i]->getNom()+" ("+m_listeVilles[i]->getCodePostal()+")");
    }

    // Signaux & slots
    QObject::connect(m_menu.pushButton_2,SIGNAL(clicked()),this,SLOT(fermer()));
    QObject::connect(m_menu.pushButton_1,SIGNAL(clicked()),this,SLOT(valider()));
    QObject::connect(ui->button_ChercherVilles,SIGNAL(clicked()),this,SLOT(chercherVilles()));

    QObject::connect(ui->lineEdit_BudgetMax,SIGNAL(textChanged(QString)), this, SLOT(setEtat(QString)));
    QObject::connect(ui->lineEdit_SurfHabMin,SIGNAL(textChanged(QString)), this, SLOT(setEtat(QString)));
    QObject::connect(ui->lineEdit_SurJardMin,SIGNAL(textChanged(QString)), this, SLOT(setEtat(QString)));
    QObject::connect(ui->comboBox_Ville,SIGNAL(activated(QString)), this, SLOT(copierVille(QString)));

}
Example #3
0
int password (Mix_Chunk* gSound, short* musique, Mix_Music* gMusic, short* onoff)
{
    SDL_Window* fenetrepass = NULL;
    char texte[PASSMAX] = {0};
    size_t passlen = 0, l;
    SDL_bool done = SDL_FALSE;
    SDL_Rect rect;
    SDL_Event ev;
    SDL_Surface* ValiderTTF = NULL;
    SDL_Rect ValiderRect;
    SDL_Color ValiderColor = {0, 0, 0, 0};
    int ValiderTTFW = 0;
    int ValiderTTFH = 0;
    SDL_Surface* AnnulerTTF = NULL;
    SDL_Rect AnnulerRect;
    SDL_Color AnnulerColor = {0, 0, 0, 0};
    int AnnulerTTFW = 0;
    int AnnulerTTFH = 0;
    TTF_Font* contfuFont = NULL;
    TTF_Font* helvFont = NULL;
    SDL_Surface* surface = NULL;
    helvFont = chargerPolice (helvFont, HELVFONT, 35);
    contfuFont = chargerPolice (contfuFont, CONTFUFONT, 50);
    SDL_Surface* surfaceTexte = NULL;
    SDL_Color color2 = {255, 255, 255, 0};
    SDL_Color color = {0, 0, 0, 0};
    fenetrepass = creerFenetre (fenetrepass, TITREJEU, LARGEUR_FENETREPASS, HAUTEUR_FENETREPASS);
    SDL_StartTextInput();

    while (!done)
    {
        SDL_WaitEvent (&ev);

        switch (ev.type)
        {
            case SDL_QUIT : // Ne marche pas, je sais pas pourquoi
                printf ("Good bye\n");
                done = SDL_TRUE;
                break;

            case SDL_KEYDOWN :
                if (ev.key.keysym.sym == SDLK_BACKSPACE && passlen > 0)
                {
                    texte[passlen - 1] = 0;
                    passlen--;
                    puts (texte);
                }
                else if (ev.key.keysym.sym == SDLK_ESCAPE)
                {
                    done = SDL_TRUE;
                }
                else if (ev.key.keysym.sym == SDLK_RETURN)
                {
                    printf ("testvalider\n");
                    valider (texte, gSound, musique, gMusic, onoff, &done);
                }

                break;

            case SDL_TEXTINPUT :
                l = strlen (ev.text.text);
                strncpy (texte + passlen, ev.text.text, PASSMAX - 1 - passlen);
                passlen += l;

                if (passlen > PASSMAX - 1)
                {
                    passlen = PASSMAX - 1;
                }

                puts (texte);
                break;

            case SDL_MOUSEBUTTONDOWN:
                playsound (3, gSound);

                if (clickMenu (helvFont, "Valider", ValiderTTFW, ValiderTTFH, ev, ValiderRect) )
                {
                    printf ("testvalider\n");
                    valider (texte, gSound, musique, gMusic, onoff, &done);
                    ev.type = SDL_KEYDOWN;
                    ev.key.keysym.sym = SDLK_1;
                    SDL_PushEvent (&ev);
                }

                if (clickMenu (helvFont, "Annuler", AnnulerTTFW, AnnulerTTFH, ev, AnnulerRect) )
                {
                    done = SDL_TRUE;
                }

                break;

            case SDL_MOUSEMOTION:
                ValiderColor.r = hoverMenu (helvFont, "Valider", ValiderTTFW, ValiderTTFH, ev, ValiderRect);
                AnnulerColor.r = hoverMenu (helvFont, "Annuler", AnnulerTTFW, AnnulerTTFH, ev, AnnulerRect);
                break;
        }

        surface = SDL_GetWindowSurface (fenetrepass);
        SDL_FillRect (surface, NULL, SDL_MapRGB (surface->format, 204, 72, 63) );
        surfaceTexte = creerTexte (surfaceTexte, METHODE_BELLE, contfuFont, "Mot de passe", color2);
        rect.x = (LARGEUR_FENETREPASS / 2) - (surfaceTexte->w / 2);
        rect.y = HAUTEUR_FENETREPASS / 8;
        SDL_BlitSurface (surfaceTexte, NULL, surface, &rect);
        SDL_FreeSurface (surfaceTexte);
        ValiderTTF = creerTexte (ValiderTTF, METHODE_RAPIDE, helvFont, "Valider", ValiderColor);
        ValiderRect.x = (LARGEUR_FENETREPASS / 4) - (ValiderTTF->w / 2);
        ValiderRect.y = (3 * HAUTEUR_FENETREPASS) / 4;
        SDL_BlitSurface (ValiderTTF, NULL, surface, &ValiderRect);
        SDL_FreeSurface (ValiderTTF);
        AnnulerTTF = creerTexte (AnnulerTTF, METHODE_RAPIDE, helvFont, "Annuler", AnnulerColor);
        AnnulerRect.x = (3 * LARGEUR_FENETREPASS / 4) - (AnnulerTTF->w / 2);
        AnnulerRect.y = (3 * HAUTEUR_FENETREPASS) / 4;
        SDL_BlitSurface (AnnulerTTF, NULL, surface, &AnnulerRect);
        SDL_FreeSurface (AnnulerTTF);
        SDL_UpdateWindowSurface (fenetrepass);

        if (passlen > 0)
        {
            surfaceTexte = creerTexte (surfaceTexte, METHODE_BELLE, helvFont, texte, color);
            rect.x = (LARGEUR_FENETREPASS / 2) - (surfaceTexte->w / 2);
            rect.y = HAUTEUR_FENETREPASS / 2;
            SDL_BlitSurface (surfaceTexte, NULL, surface, &rect);
            SDL_FreeSurface (surfaceTexte);
            SDL_UpdateWindowSurface (fenetrepass);
        }
    }

    SDL_StopTextInput();
    libererPolice (helvFont);
    libererPolice (contfuFont);
    SDL_DestroyWindow (fenetrepass);
    return 0;
}