#include "wnewprogram.h"
#include "ui_wnewprogram.h"

wNewProgram::wNewProgram(QWidget *parent) :
    LoQDialog(parent),
    ui(new Ui::wNewProgram)
{
    ui->setupUi(this);
    //ui->pName->setText(tr("New") + QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
    ui->pName->setText(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
    ui->pWidth->setValue(512);
    ui->pHeight->setValue(512);
    ui->pRemarks->setText("");
    connect(this, SIGNAL(accepted()), this, SLOT(onAccepted()));
}

wNewProgram::wNewProgram(QString name, QSize res, QString remarks, QWidget *parent, bool lockName) :
    LoQDialog(parent),
    ui(new Ui::wNewProgram)
{
    ui->setupUi(this);
    ui->pName->setText(name);
    ui->pName->setDisabled(lockName);
    ui->pWidth->setValue(res.width());
    ui->pHeight->setValue(res.height());
    ui->pRemarks->setText(remarks);
    connect(this, SIGNAL(accepted()), this, SLOT(onAccepted()));
}

wNewProgram::~wNewProgram()
{
    delete ui;
}

void wNewProgram::onAccepted()
{
    emit sigAcceptData(ui->pName->text(),
                       QSize(ui->pWidth->value(), ui->pHeight->value()),
                       ui->pRemarks->document()->toPlainText());
}
