#include "settingForm.h"
#include "ui_settingForm.h"
#include "preDefine.h"
#include "DTools/configManger.h"
#include <QSound>

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

    // 初始化打印机选项
//    QString printer = ConfigManger::GetInstance().GetPrinterName();
//    QStringList printerList = QPrinterInfo::availablePrinterNames();
//    for(int i=0; i<printerList.count(); i++)
//    {
//        QString name = printerList[i];
//        ui->settingCbxPrinter->addItem(name);
//        if(!name.compare(printer))
//        {
//            ui->settingCbxPrinter->setCurrentIndex(i);
//        }
//    }

    _Init();
}

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

void SettingForm::_Init()
{
    setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
    setAttribute(Qt::WA_TranslucentBackground);
    setModal(true);
}

void SettingForm::on_settingCbxPrinter_currentIndexChanged(const QString &text)
{
    ConfigManger::GetInstance().SetPrinterName(text);
}

void SettingForm::on_settingBtnPrintTest_clicked()
{
}

void SettingForm::on_settingBtnSoundTest_clicked()
{
    QSound::play(QString("%1/wav/msg.wav").arg(QApplication::applicationDirPath()));
}
