#include "newversionwidget.h"
#include "ui_newversionwidget.h"

NewVersionWidget::NewVersionWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::NewVersionWidget)
{
    ui->setupUi(this);
    setWindowFlags(Qt::SubWindow);
    setAttribute(Qt::WA_ShowModal,true);
}

void NewVersionWidget::initialize(VersionSelectWidget *versionSelectWidget, QString prevName)
{
    this->versionSelectWidget = versionSelectWidget;
    ui->prevVerValue->setText(prevName);
    validator = new QRegExpValidator(QRegExp("^[A-Za-z0-9]{20}$"));
    ui->lineEdit->setValidator(validator);
}


void NewVersionWidget::on_createButton_clicked()
{
    if(ui->lineEdit->text() != "")
    {
        versionSelectWidget->sendCopyEmit(ui->lineEdit->text());
        hide();
    }
}

void NewVersionWidget::on_cancelButton_clicked()
{
    hide();
}

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

void NewVersionWidget::on_lineEdit_inputRejected()
{
     QToolTip::showText(QCursor::pos(),tr("Only Latin letters and numbers"));
}
