//QWidget_home.cpp
 
    ui(new Ui::Home)
{
    ui->setupUi(this);
    inizio();
}
 
void Home::inizio()
    {
            databaseOn(); //read data from sql Database
            hideall();
            ui->Login->show(); //show the frame 1
 
            //set the image and labels in all frame
            QPixmap immagine
(":/immagine1.jpg");
             ui->labelimage->setPixmap(immagine);
            QPixmap immaginelogin
(":/loginlogo.png");
             ui->labelloginimage->setPixmap(immaginelogin);
            ui
->linePassword
->setEchoMode
(QLineEdit::Password);
            QPixmap immaginewelcome
(":/welcome.png");
             ui->labelWelcome->setPixmap(immaginewelcome);
   }
 
void Home::hideall(){ //hide all 
    ui->Login->hide();
    ui->Linkedin->hide();
    ui->ModificaProfilo->hide();
}
 
//[...]
 
void Home::on_pushButtonLogin_clicked()
{
 
    //convert data in form for the database (is a vector)
    bool logged=true;
    s[0]=ui->lineUsername->text();
    s[1]=ui->linePassword->text();
    try{
        cercami(s);
    }catch (errori){
        ui->lineUsername->clear();
        ui->linePassword->clear();
        logged=false;
    }
    //try to read data from vector
 
    try {
        scriviProfilo(logged); //try to complete the label of frame linkedin with database information
    } catch (errori) {}
 
    //show frame 2
    showLinkedin();
 
}
 
//[...]
 
void Home::showLinkedin() { //hide the frame1
 
 
    int dimensioneLarghezza=geometry().width()-24;
    int dimensioneAltezza=geometry().height()-24;
    int dimensioneX=12;//ui->Login->geometry().x();
    int dimensioneY=12;//ui->Login->geometry().y();
    int surplus=geometry().width()-24;
 
    QPropertyAnimation *animation = new QPropertyAnimation(ui->Login, "geometry");
    animation->setDuration(500);
    animation
->setStartValue
(QRect(dimensioneX,dimensioneY,dimensioneLarghezza ,dimensioneAltezza 
));
    animation
->setEndValue
(QRect(-(dimensioneX
+surplus
),dimensioneY, dimensioneLarghezza ,dimensioneAltezza
));
    animation->setEasingCurve(QEasingCurve::InOutExpo);
    animation->start(QAbstractAnimation::DeleteWhenStopped);
    connect(animation, SIGNAL(finished()), SLOT(hideLoginAnimationEnd())); //when is hide show frame 2
}
 
void Home::hideLoginAnimationEnd(){ //show frame 2
    ui->Login->hide();
 
    ui->Linkedin->show();
 
    qDebug()<<geometry().width();
    qDebug()<<geometry().height();
    int dimensioneLarghezza=geometry().width()-24;
    int dimensioneAltezza=geometry().height()-24;
    int dimensioneX=12;
    int dimensioneY=12;
    int surplus=geometry().width()-24;
 
 
 
    QPropertyAnimation *animation = new QPropertyAnimation(ui->Linkedin, "geometry");
    animation->setDuration(500);
    animation
->setStartValue
(QRect(dimensioneX
+surplus,dimensioneY, dimensioneLarghezza, dimensioneAltezza
));
    animation
->setEndValue
(QRect(dimensioneX,dimensioneY, dimensioneLarghezza, dimensioneAltezza
));
    animation->setEasingCurve(QEasingCurve::InOutExpo);
    animation->start();
}
        //QWidget_home.cpp
Home::Home(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Home)
{
    ui->setupUi(this);
    inizio();
}
void Home::inizio()
    {
            databaseOn(); //read data from sql Database
            hideall();
            ui->Login->show(); //show the frame 1
            //set the image and labels in all frame
            QPixmap immagine(":/immagine1.jpg");
            ui->labelimage->setPixmap(immagine);
            QPixmap immaginelogin(":/loginlogo.png");
            ui->labelloginimage->setPixmap(immaginelogin);
            ui->linePassword->setEchoMode(QLineEdit::Password);
            QPixmap immaginewelcome(":/welcome.png");
            ui->labelWelcome->setPixmap(immaginewelcome);
   }
void Home::hideall(){ //hide all 
    ui->Login->hide();
    ui->Linkedin->hide();
    ui->ModificaProfilo->hide();
}
//[...]
void Home::on_pushButtonLogin_clicked()
{
    //convert data in form for the database (is a vector)
    bool logged=true;
    QString * s= new QString[2];
    s[0]=ui->lineUsername->text();
    s[1]=ui->linePassword->text();
    try{
        cercami(s);
    }catch (errori){
        ui->lineUsername->clear();
        ui->linePassword->clear();
        logged=false;
    }
    //try to read data from vector
    try {
        scriviProfilo(logged); //try to complete the label of frame linkedin with database information
    } catch (errori) {}
    //show frame 2
    showLinkedin();
}
//[...]
void Home::showLinkedin() { //hide the frame1
    int dimensioneLarghezza=geometry().width()-24;
    int dimensioneAltezza=geometry().height()-24;
    int dimensioneX=12;//ui->Login->geometry().x();
    int dimensioneY=12;//ui->Login->geometry().y();
    int surplus=geometry().width()-24;
    QPropertyAnimation *animation = new QPropertyAnimation(ui->Login, "geometry");
    animation->setDuration(500);
    animation->setStartValue(QRect(dimensioneX,dimensioneY,dimensioneLarghezza ,dimensioneAltezza ));
    animation->setEndValue(QRect(-(dimensioneX+surplus),dimensioneY, dimensioneLarghezza ,dimensioneAltezza));
    animation->setEasingCurve(QEasingCurve::InOutExpo);
    animation->start(QAbstractAnimation::DeleteWhenStopped);
    connect(animation, SIGNAL(finished()), SLOT(hideLoginAnimationEnd())); //when is hide show frame 2
}
void Home::hideLoginAnimationEnd(){ //show frame 2
    ui->Login->hide();
    ui->Linkedin->show();
    qDebug()<<geometry().width();
    qDebug()<<geometry().height();
    int dimensioneLarghezza=geometry().width()-24;
    int dimensioneAltezza=geometry().height()-24;
    int dimensioneX=12;
    int dimensioneY=12;
    int surplus=geometry().width()-24;
    QPropertyAnimation *animation = new QPropertyAnimation(ui->Linkedin, "geometry");
    animation->setDuration(500);
    animation->setStartValue(QRect(dimensioneX+surplus,dimensioneY, dimensioneLarghezza, dimensioneAltezza));
    animation->setEndValue(QRect(dimensioneX,dimensioneY, dimensioneLarghezza, dimensioneAltezza));
    animation->setEasingCurve(QEasingCurve::InOutExpo);
    animation->start();
}
To copy to clipboard, switch view to plain text mode 
  
Bookmarks