123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #include "DialogUiOption.h"
- #include "../Common/Utility.h"
- #include "Common.h"
- DialogUiOption::DialogUiOption(int nWidth, int nHeight, QWidget *parent)
- : QDialog(parent)
- , m_nWidth(nWidth)
- , m_nHeight(nHeight)
- {
- ui.setupUi(this);
- // 对话框初始化
- this->initUI();
- }
- DialogUiOption::~DialogUiOption()
- {
- }
- /// <summary>
- /// 对话框初始化
- /// </summary>
- void DialogUiOption::initUI()
- {
- this->setWindowTitle(("UI Option"));
- // 对话框风格
- this->setAttribute(Qt::WA_QuitOnClose);
- this->setWindowModality(Qt::ApplicationModal);
- // 槽函数
- connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(onButtonOKClicked()));
- connect(ui.buttonResolution, SIGNAL(clicked()), this, SLOT(onButtonResolutionClicked()));
- connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
- // 固定窗体大小
- this->setFixedSize(495, 340);
- // 初始化数值显示
- ui.editWidth->setText(QString::number(m_nWidth));
- ui.editHeight->setText(QString::number(m_nHeight));
- }
- /// <summary>
- /// OK按钮
- /// </summary>
- void DialogUiOption::onButtonOKClicked()
- {
- m_nWidth = ui.editWidth->text().toInt();
- m_nHeight = ui.editHeight->text().toInt();
- // 检查数据有效性
- if (m_nWidth <= 0 || m_nHeight <=0 )
- {
- CRITICAL_MESSAGE("The width and height must > 0.");
- return;
- }
- this->accept();
- }
- /// <summary>
- /// 分辨率按钮
- /// </summary>
- void DialogUiOption::onButtonResolutionClicked()
- {
- QRect rect = QApplication::desktop()->screenGeometry();
- int with = rect.width();
- int heigh = rect.height();
- ui.editWidth->setText(QString::number(with));
- ui.editHeight->setText(QString::number(heigh));
- }
|