#include "dialogadvancedsetting.h"
#include "ui_dialogadvancedsetting.h"

#include "mainwindow.h"

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

    ui->comboBox_DICOM_CharacterSet->addItem("EUC-KR");
    ui->comboBox_DICOM_CharacterSet->addItem("UTF-8");
    ui->comboBox_DICOM_CharacterSet->addItem("ASCII");

    ui->comboBox_ScreenSaver->addItem("None");
    ui->comboBox_ScreenSaver->addItem("1");
    ui->comboBox_ScreenSaver->addItem("2");
    ui->comboBox_ScreenSaver->addItem("5");
    ui->comboBox_ScreenSaver->addItem("10");
    ui->comboBox_ScreenSaver->addItem("60");


    CommonData* pCommonData = MainWindow::GetCommonData();
    bool bIsAutoVideoCapture = pCommonData->IsAutoVideoCapture();
    bool bIsAutoCaptureSendDICOM = pCommonData->IsAutoCaptureSendDICOM();
    bool bIsAutoExitCaptureSendDICOM = pCommonData->IsAutoExitCaptureSendDICOM();
    bool bIsAutoCloseSendFinish = pCommonData->IsAutoCloseSendFinish();
    bool bIsAutoLogin = pCommonData->IsAutoLogin();
    bool bIsCropMode = (bool)pCommonData->GetCropMode();
    bool bIsUseFixWidthLevel = (bool)pCommonData->GetUseFixWidthLevel();
    bool bIsUseLogLevel = false;
    bool bIsUseUSBBackup = (bool)pCommonData->IsUseUSBBackup();
    int nScreenSaverTime = pCommonData->GetScreenSaverTime();
    if(pCommonData->GetLogLevel()>0)
    {
        bIsUseLogLevel = true;
    }
    QString strDICOMCharacterSet = pCommonData->GetDICOMCharacterSet();

    ui->checkBox_AutoVideoCapture->setChecked(bIsAutoVideoCapture);
    ui->checkBox_AutoCaptureSendDICOM->setChecked(bIsAutoCaptureSendDICOM);
    ui->checkBox_AutoExitCaptureSendDICOM->setChecked(bIsAutoExitCaptureSendDICOM);
    ui->checkBox_AutoCloseSendFinish->setChecked(bIsAutoCloseSendFinish);
    ui->checkBox_AutoLogin->setChecked(bIsAutoLogin);
    ui->checkBox_Crop->setChecked(bIsCropMode);
    ui->checkBox_FixWidthLevel->setChecked(bIsUseFixWidthLevel);
    ui->checkBox_LogLevel->setChecked(bIsUseLogLevel);
    ui->checkBox_UsbBackup->setChecked(bIsUseUSBBackup);


    ui->comboBox_DICOM_CharacterSet->setCurrentText(strDICOMCharacterSet);

    switch(nScreenSaverTime)
    {
    case 0:
        ui->comboBox_ScreenSaver->setCurrentIndex(0);
        break;
    case 1:
        ui->comboBox_ScreenSaver->setCurrentIndex(1);
        break;
    case 2:
        ui->comboBox_ScreenSaver->setCurrentIndex(2);
        break;
    case 5:
        ui->comboBox_ScreenSaver->setCurrentIndex(3);
        break;
    case 10:
        ui->comboBox_ScreenSaver->setCurrentIndex(4);
        break;
    case 60:
        ui->comboBox_ScreenSaver->setCurrentIndex(5);
        break;
    }


}

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

void DialogAdvancedSetting::on_comboBox_DICOM_CharacterSet_currentIndexChanged(const QString &arg1)
{
    m_strCharacterSet = arg1;
}

QString DialogAdvancedSetting::GetDICOM_CharacterSet()
{
    return m_strCharacterSet;
}








bool DialogAdvancedSetting::IsAutoVideoCapture()
{
    return ui->checkBox_AutoVideoCapture->isChecked();
}

bool DialogAdvancedSetting::IsAutoCaptureSendDICOM()
{
    return ui->checkBox_AutoCaptureSendDICOM->isChecked();
}

bool DialogAdvancedSetting::IsAutoExitCaptureSendDICOM()
{
    return ui->checkBox_AutoExitCaptureSendDICOM->isChecked();
}

void DialogAdvancedSetting::on_pushButton_Save_clicked()
{
    done(QDialog::Accepted);
}

void DialogAdvancedSetting::on_pushButton_Cancel_clicked()
{
    done(QDialog::Rejected);
}

bool DialogAdvancedSetting::IsAutoCloseSendFinish()
{
    return ui->checkBox_AutoCloseSendFinish->isChecked();
}

bool DialogAdvancedSetting::IsAutoLogin()
{
    return ui->checkBox_AutoLogin->isChecked();
}

bool DialogAdvancedSetting::IsCropMode()
{
    return ui->checkBox_Crop->isChecked();
}

bool DialogAdvancedSetting::IsUseFixWidthLevel()
{
    return ui->checkBox_FixWidthLevel->isChecked();
}

bool DialogAdvancedSetting::IsUseLogLevel()
{
    return ui->checkBox_LogLevel->isChecked();
}

bool DialogAdvancedSetting::IsUseUSBBackup()
{
    return ui->checkBox_UsbBackup->isChecked();
}

int DialogAdvancedSetting::GetScreenSaverTime()
{
    int nTime = 0;

    int nItem = ui->comboBox_ScreenSaver->currentIndex();

    //ui->comboBox_ScreenSaver->addItem("None");
    //ui->comboBox_ScreenSaver->addItem("1");
    //ui->comboBox_ScreenSaver->addItem("2");
    //ui->comboBox_ScreenSaver->addItem("5");
    //ui->comboBox_ScreenSaver->addItem("10");
    //ui->comboBox_ScreenSaver->addItem("60");

    switch(nItem)
    {
    case 0:
        nTime = 0;
        break;
    case 1:
        nTime = 1;
        break;
    case 2:
        nTime = 2;
        break;
    case 3:
        nTime = 5;
        break;
    case 4:
        nTime = 10;
        break;
    case 5:
        nTime = 60;
        break;
    }


    return nTime;
}



