#include "scansettings.h"
#include "ui_scansettings.h"

ScanSettings::ScanSettings(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ScanSettings)
{
    ui->setupUi(this);

    connect(ui->btn_cancel, SIGNAL(clicked()), this, SLOT(deleteLater()));
    connect(ui->btn_ok, SIGNAL(clicked()), this->parent(), SLOT(slot_MainWindow_set_scan_ok()));
    connect(ui->sldr_samples, SIGNAL(valueChanged(int)), this, SLOT(slot_ScanSettings_show_samples(int)));
    connect(ui->sldr_speed, SIGNAL(valueChanged(int)), this, SLOT(slot_ScanSettings_show_speed(int)));
}

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

void ScanSettings::changeEvent(QEvent *e)
{
    QDialog::changeEvent(e);
    switch (e->type())
    {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

void ScanSettings::updateWidgets(LbtSettings &s)//předání starého nastavení a inicializace widgetů
{
    new_settings = s;
    ui->sldr_samples->setSliderPosition(s.samples);
    ui->samples_cnt_label->setNum(s.samples);
    ui->sldr_speed->setSliderPosition(s.speed);
    ui->speed_cnt_label->setNum(s.speed);
}

void ScanSettings::slot_ScanSettings_show_samples(int samples)
{
    new_settings.samples = samples;
    ui->samples_cnt_label->setNum(samples);
}

void ScanSettings::slot_ScanSettings_show_speed(int speed)
{
    new_settings.speed = speed;
    ui->speed_cnt_label->setNum(speed);
}
