configmastervolumedlg.cpp 1.33 KB
#include "config.h"
#include "configmastervolumedlg.h"
#include "ui_configmastervolumedlg.h"

using namespace Define;

#define MAX_MASTER_VOL  7

ConfigMasterVolumeDlg::ConfigMasterVolumeDlg(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ConfigMasterVolumeDlg)
{
    Config* cfg = Config::getInstance();
    config_item item;
    ui->setupUi(this);
    this->setWindowFlags( Qt::FramelessWindowHint);
    this->setAttribute( Qt::WA_DeleteOnClose);

    item = cfg->getConfigValue(config_marster_vol);
    m_nCurMasterVol = item.d32;
    ui->ctrProgressLight->setMaxProgress(m_nCurMasterVol,MAX_MASTER_VOL);
}

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

void ConfigMasterVolumeDlg::on_ctrBtnOk_clicked()
{
    Config* cfg = Config::getInstance();
    config_item item;
    item.d32 = m_nCurMasterVol;
    cfg->setConfigValue(config_marster_vol,item);
    accept();
}

void ConfigMasterVolumeDlg::on_ctrBtnCancel_clicked()
{
    reject();
}

void ConfigMasterVolumeDlg::on_ctrBtnMinus_clicked()
{
    m_nCurMasterVol = m_nCurMasterVol > 0?m_nCurMasterVol-1:0;
    ui->ctrProgressLight->setCurrentProgress(m_nCurMasterVol);
}

void ConfigMasterVolumeDlg::on_ctrBtnPlus_clicked()
{
    m_nCurMasterVol = m_nCurMasterVol<MAX_MASTER_VOL?m_nCurMasterVol+1:MAX_MASTER_VOL;
    ui->ctrProgressLight->setCurrentProgress(m_nCurMasterVol);
}