InfoTemplate::InfoTemplate(QWidget *parent) :
    QWidget(parent)
{
    widget1 = new QWidget();
    widget2 = new QWidget();
    widget3 = new QWidget();

    // widget 1 initialization

    QVBoxLayout* widget1_vlayout=  new QVBoxLayout(widget1);
    QHBoxLayout* widget1_vlayout_hlayout = new QHBoxLayout();
    qDebug()<<"2";

    addButton = new QPushButton("Add");
    lineEdit = new QLineEdit();
    removeButton = new QPushButton("Remove");

    widget1_vlayout_hlayout->addWidget(lineEdit);
    widget1_vlayout_hlayout->addWidget(addButton);

    itemList = new QListWidget();

    widget1_vlayout->addLayout(widget1_vlayout_hlayout);
    widget1_vlayout->addWidget(itemList);
    widget1_vlayout->addWidget(removeButton);

    // widget 2 initialization

    QVBoxLayout* widget2_vlayout=  new QVBoxLayout(widget2);
    textEdit = new QPlainTextEdit();


    qDebug()<<"3";
    widget2_vlayout->addWidget(textEdit);

    // widget 3 initialization
    phoneBody = new QLabel(widget3);
    QVBoxLayout* widget3_vlayout=  new QVBoxLayout(widget3);


    phoneBody->setFixedSize(327,639);
    phoneBody->setStyleSheet("background-image: url(:/images/phone.png)");

    phoneWidget = new QStackedWidget(phoneBody);
    phoneWidget->setStyleSheet("background: black; color: white; font-size: 30px");
    phoneWidget->setGeometry(30,95,270,447);

    backButton = new QPushButton("<-");
    backButton->setFixedWidth(phoneWidget->width());

    generateButton = new QPushButton("Generate Application");
    generateButton->setFixedWidth(phoneWidget->width());

    widget3_vlayout->addWidget(phoneBody);
    widget3_vlayout->addWidget(backButton);
    widget3_vlayout->addWidget(generateButton);

    screen1 = new QWidget();
    screen2 = new QWidget();
    phoneWidget->addWidget(screen1);
    phoneWidget->addWidget(screen2);

    itemList_phone = new QListWidget(screen1);
    itemList_phone->setStyleSheet( "QListWidget::item { color: white; border-bottom: 0.5px solid #333333; }") ;
    itemList_phone->setFixedSize(phoneWidget->size());


    textLabel_phone= new QLabel(screen2);
    textLabel_phone->setFixedSize(phoneWidget->size());
    textLabel_phone->setAlignment(Qt::AlignTop);
//    textLabel_phone->setStyleSheet("background: yellow");
    textLabel_phone->setFixedSize(phoneWidget->size());
    textLabel_phone->setStyleSheet("background: black; color: white; font-size: 20px");
    textLabel_phone->setWordWrap(true);

    phoneWidget->setCurrentIndex(0);

    ///
    QHBoxLayout* hlayout = new QHBoxLayout(this);

    hlayout->addWidget(widget1);
    hlayout->addWidget(widget2);
    hlayout->addWidget(widget3);




    iProcess = new QProcess(this);

    // Signal and slots

    connect(addButton, SIGNAL(clicked()), this, SLOT(on_addButton_cicked()));
    connect(removeButton, SIGNAL(clicked()), this, SLOT(on_removedButton_cicked()));
    connect(itemList, SIGNAL(currentRowChanged(int)), this, SLOT(on_itemList_selected()));
    connect(textEdit, SIGNAL(textChanged()), this, SLOT(on_textEdit_textChanged()));
    connect(backButton, SIGNAL(clicked()), this, SLOT(on_backButton_clicked()));
    connect(itemList_phone, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(on_itemList_phone_selected()));
    connect(generateButton, SIGNAL(clicked()), this, SLOT(on_generateButton_clicked()));
}
QuizTemplate::QuizTemplate(QWidget *parent) :
    QWidget(parent)
{
    questionCounter = 0;
    noOfQues = 0;

    widget1 = new QWidget();
    widget2 = new QWidget();
    widget3 = new QWidget();

    iScrollArea = new QScrollArea();
    iScrollArea->setWidgetResizable(true);
    iScrollArea->setWidget(widget2);

    QVBoxLayout* widget1_vlayout=  new QVBoxLayout(widget1);

    widget1_vlayout->setSpacing(0);
    widget1_vlayout->setMargin(10);
    questionEdit =  new QTextEdit(widget1);
    option1Edit =  new QLineEdit(widget1);
    option2Edit =  new QLineEdit(widget1);
    option3Edit =  new QLineEdit(widget1);
    option4Edit =  new QLineEdit(widget1);
    addButton = new QPushButton("Add Question", widget1);
    questionLabel = new QLabel("Enter your question:", widget1);
    optionsLabel = new QLabel("Enter options", widget1);
    correctAnserLabel = new QLabel("Choose the correct answer", widget1);
    comboBox = new QComboBox(widget1);
    questionEdit->setFixedHeight(100);
    questionLabel->setFixedHeight(40);
    optionsLabel->setFixedHeight(40);

    connect(option1Edit, SIGNAL(editingFinished()), this, SLOT(optionAdded()));
    connect(option2Edit, SIGNAL(editingFinished()), this, SLOT(optionAdded()));
    connect(option3Edit, SIGNAL(editingFinished()), this, SLOT(optionAdded()));
    connect(option4Edit, SIGNAL(editingFinished()), this, SLOT(optionAdded()));

    questionLabel->setStyleSheet("font-size:24px;");
    optionsLabel->setStyleSheet("font-size:22px;");
    correctAnserLabel->setStyleSheet("font-size:22px;");

    widget1_vlayout->addWidget(questionLabel);
    widget1_vlayout->addWidget(questionEdit);
    widget1_vlayout->addWidget(optionsLabel);
    widget1_vlayout->addWidget(option1Edit);
    widget1_vlayout->addWidget(option2Edit);
    widget1_vlayout->addWidget(option3Edit);
    widget1_vlayout->addWidget(option4Edit);
    widget1_vlayout->addWidget(correctAnserLabel);
    widget1_vlayout->addWidget(comboBox);
    widget1_vlayout->addWidget(addButton);



    // widget 2 initialization

    widget2_vlayout=  new QVBoxLayout(widget2);
    widget2_vlayout->setMargin(1);
    widget2->setStyleSheet("background-color:grey");
    widget2_vlayout->update();

    startSimulation = new QPushButton("Start Simulation", widget3);
//    startSimulation->setGeometry(120,20,100,30);
    connect(startSimulation, SIGNAL(clicked()), this, SLOT(startSimulaton_clicked()));


    phoneBody = new QLabel(widget3);
    QVBoxLayout* widget3_vlayout=  new QVBoxLayout(widget3);

    phoneBody->setFixedSize(327,639);
    phoneBody->setStyleSheet("background-image: url(:/images/phone.png)");

    phoneWidget = new QStackedWidget(phoneBody);
    phoneWidget->setStyleSheet("background: #255593; color: white;");
    phoneWidget->setGeometry(30,95,270,447);

    backButton = new QPushButton("<-");
    backButton->setFixedWidth(phoneWidget->width());

    generateButton = new QPushButton("Generate Application");
    generateButton->setFixedWidth(phoneWidget->width());

    widget3_vlayout->addWidget(phoneBody);
    widget3_vlayout->addWidget(backButton);
    widget3_vlayout->addWidget(generateButton);

    screen1 = new QWidget();
    screen2 = new QWidget();
    screen3 = new QWidget();
    phoneWidget->addWidget(screen1);
    phoneWidget->addWidget(screen2);
    phoneWidget->addWidget(screen3);

    // screen 1
    QVBoxLayout* screen1_vlayout = new QVBoxLayout(screen1);
    screen1_vlayout->setSpacing(5);


    quizNameLabel_phone = new QLabel("Quiz Name");
    quizNameLabel_phone->setStyleSheet("background: transparent; color: white; font-size: 20px;padding:10px;");
    quizNameLabel_phone->setAlignment(Qt::AlignBottom|Qt::AlignCenter);
    quizAuthorLabel_phone= new QLabel("Author Name");
    quizAuthorLabel_phone->setStyleSheet("background: transparent; color: white; font-size: 20px;padding:10px;");
    quizAuthorLabel_phone->setAlignment(Qt::AlignTop|Qt::AlignHCenter);

    QLabel* line_screen1 = new QLabel(screen1);
    line_screen1->setFixedWidth(screen1->width()-20);
    line_screen1->setFixedHeight(1);
    line_screen1->setStyleSheet("background-color: white;");

    startQuiz_phone = new QPushButton("Start",screen1);
    startQuiz_phone->setStyleSheet("background-color: lightgrey; color: black;font-size:18px;");
    connect(startQuiz_phone, SIGNAL(clicked()), this, SLOT(startQuiz()));

    screen1_vlayout->addWidget(quizNameLabel_phone);
    screen1_vlayout->addWidget(line_screen1);
    screen1_vlayout->addWidget(quizAuthorLabel_phone);
    screen1_vlayout->addWidget(startQuiz_phone, 0, Qt::AlignCenter);

    screen1->setVisible(false);

    // screen 2
    QVBoxLayout* screen2_vlayout = new QVBoxLayout(screen2);
    screen2_vlayout->setSpacing(5);

    questionLabel_phone= new QLabel(screen2);
    //    textLabel_phone->setFixedSize(phoneWidget->size());
    questionLabel_phone->setAlignment(Qt::AlignTop);
    //    textLabel_phone->setStyleSheet("background: yellow");
    //    textLabel_phone->setFixedSize(phoneWidget->size());
    questionLabel_phone->setStyleSheet("background: transparent; color: white; font-size: 20px;");
    //    textLabel_phone->setWordWrap(true);
    questionLabel_phone->setFixedHeight(30);

    QLabel* line_screen2 = new QLabel(screen2);
    line_screen2->setFixedWidth(screen2->width()-10);
    line_screen2->setFixedHeight(1);
    line_screen2->setStyleSheet("background-color: white;");

    questionText_phone = new QLabel(screen2);
    questionText_phone->setAlignment(Qt::AlignTop);
    questionText_phone->setStyleSheet("background: transparent; color: white; font-size: 20px;");
    questionText_phone->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);

    option1_phone = new QRadioButton(screen2);
    option2_phone = new QRadioButton(screen2);
    option3_phone = new QRadioButton(screen2);
    option4_phone = new QRadioButton(screen2);

    optionsList_phone.append(option1_phone);
    optionsList_phone.append(option2_phone);
    optionsList_phone.append(option3_phone);
    optionsList_phone.append(option4_phone);

    option1_phone->setStyleSheet("background: transparent; color: white; font-size: 18px;");
    option2_phone->setStyleSheet("background: transparent; color: white; font-size: 18px;");
    option3_phone->setStyleSheet("background: transparent; color: white; font-size: 18px;");
    option4_phone->setStyleSheet("background: transparent; color: white; font-size: 18px;");

    submitButton_phone = new QPushButton("Submit", screen2);
    submitButton_phone->setStyleSheet("background-color: lightgrey; color: black;font-size:18px;");
    connect(submitButton_phone, SIGNAL(clicked()), this, SLOT(submitButton_phone_clicked()));

    screen2_vlayout->addWidget(questionLabel_phone);
    screen2_vlayout->addWidget(line_screen2);
    screen2_vlayout->addWidget(questionText_phone);
    screen2_vlayout->addWidget(option1_phone);
    screen2_vlayout->addWidget(option2_phone);
    screen2_vlayout->addWidget(option3_phone);
    screen2_vlayout->addWidget(option4_phone);
    screen2_vlayout->addWidget(submitButton_phone, 0, Qt::AlignCenter|Qt::AlignBottom);

    phoneWidget->setCurrentIndex(0);
//phoneWidget->setEnabled(false);

    ///
    QHBoxLayout* hlayout = new QHBoxLayout(this);

    hlayout->addWidget(widget1);
    hlayout->addWidget(iScrollArea);
    hlayout->addWidget(widget3);


    iProcess = new QProcess(this);

    // Signal and slots

    connect(addButton, SIGNAL(clicked()), this, SLOT(on_addButton_cicked()));
    connect(generateButton, SIGNAL(clicked()), this, SLOT(on_generateButton_clicked()));
}