#ifndef NUMERINPUTDIALOG_H
#define NUMERINPUTDIALOG_H

#include <QDialog>
#include "mybutton.h"
#include "setcontrolstyle.h"

namespace Ui {
class NumerInputDialog;
}

class NumerInputDialog : public QDialog
{
    Q_OBJECT

public:
    explicit NumerInputDialog(QWidget *parent = 0);
    ~NumerInputDialog();

private:
    Ui::NumerInputDialog *ui;

private:
    int64_t m_value;
    int64_t m_min;
    int64_t m_max;
    int m_afterPoint;
    int64_t m_defVal;

private:
    int m_defFlag;
    int m_pointFlag;    // 小数点标志
    QString m_unitStr;
    QList<QPushButton*> m_leftNumberBtnList;
    QList<QPushButton*> m_rightNumberBtnList;

private:
    QString getShowString(int64_t val, int pointflag);
    int checkValueRange(int64_t val, int pointflag);
    int64_t fixValue( int64_t val, int pointflag);
    int getPointMuti(int pointflag);
    void showValue();
    void showRange();
    void addNum(int num);
    void changeValue(int weights);

private:
    void initControl();//初始化窗体控件，包括位置、尺寸、样式
    void initResolution1910();//初始化窗体控件为1920x1080分辨率
    void initResolution1006();
    void initControlStyle();//初始化窗体控件样式
    void initArabControlPos();//设置阿拉伯语时控件对齐方式

public:
    void initDialog();//初始化窗体
    void setTitleStr(QString str);//设置标题
    void setUnitStr(QString str);
    void setValueAndRange(int64_t val, int64_t min, int64_t max, int afterpoint, int defen = 0, int64_t defvalue = 1);
    int64_t getValue();

private slots:
    void on_buttonClean_clicked();
    void on_buttonNum00_clicked();
    void on_buttonDelete_clicked();
    void on_buttonNum7_clicked();
    void on_buttonNum8_clicked();
    void on_buttonNum9_clicked();
    void on_buttonNum4_clicked();
    void on_buttonNum5_clicked();
    void on_buttonNum6_clicked();
    void on_buttonNum1_clicked();
    void on_buttonNum2_clicked();
    void on_buttonNum3_clicked();
    void on_buttonPlusMinus_clicked();
    void on_buttonNum0_clicked();
    void on_buttonPoint_clicked();
    void on_buttonDec1000_clicked();
    void on_buttonInc1000_clicked();
    void on_buttonDec100_clicked();
    void on_buttonInc100_clicked();
    void on_buttonDec10_clicked();
    void on_buttonInc10_clicked();
    void on_buttonDec1_clicked();
    void on_buttonInc1_clicked();
    void on_buttonDec01_clicked();
    void on_buttonInc01_clicked();
    void on_buttonOk_clicked();
    void on_buttonCancel_clicked();
};

#endif // NUMERINPUTDIALOG_H
