83 lines
2.0 KiB
C++
83 lines
2.0 KiB
C++
#include "fracsel.h"
|
|
#include "ui_fracsel.h"
|
|
#include <QFile>
|
|
#include <QTextStream>
|
|
|
|
double g_SDepthFac = 0;
|
|
double g_EDepthFac = 0;
|
|
QString g_SelectMFac = "";
|
|
|
|
FracSel::FracSel(QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::FracSel)
|
|
{
|
|
ui->setupUi(this);
|
|
//加载样式
|
|
//setStyleSheet("QDialog { background-color: #FFFFFF; } QComboBox,QLineEdit {border-width:1px; border-radius:0px;}");
|
|
loadStyle(":/qrc/qss/flatgray.css");
|
|
|
|
//
|
|
connect(ui->ok, SIGNAL(clicked()), this, SLOT(slotOkClicked()));
|
|
connect(ui->cancel, SIGNAL(clicked()), this, SLOT(slotCancelClicked()));
|
|
}
|
|
|
|
FracSel::~FracSel()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void FracSel::loadStyle(const QString &qssFile)
|
|
{
|
|
//加载样式表
|
|
QString qss;
|
|
QFile file(qssFile);
|
|
if (file.open(QFile::ReadOnly)) {
|
|
//用QTextStream读取样式文件不用区分文件编码 带bom也行
|
|
QStringList list;
|
|
QTextStream in(&file);
|
|
//in.setCodec("utf-8");
|
|
while (!in.atEnd()) {
|
|
QString line;
|
|
in >> line;
|
|
list << line;
|
|
}
|
|
|
|
file.close();
|
|
qss = list.join("\n");
|
|
QString paletteColor = qss.mid(20, 7);
|
|
this->setPalette(QPalette(paletteColor));
|
|
//用时主要在下面这句
|
|
this->setStyleSheet(qss);
|
|
}
|
|
}
|
|
|
|
|
|
void FracSel::setInfo(double right_Hight, QList <FAC_DEF> FracDef)
|
|
{
|
|
ui->doubleSpinBox_1->setValue(-right_Hight);
|
|
ui->doubleSpinBox_2->setValue(-right_Hight+1);
|
|
for(int i=0; i<FracDef.size(); i++)
|
|
{
|
|
ui->comboBox->addItem(FracDef[i].mFac);
|
|
}
|
|
}
|
|
|
|
//
|
|
void FracSel::slotOkClicked()
|
|
{
|
|
g_SDepthFac = ui->doubleSpinBox_1->value();
|
|
g_EDepthFac = ui->doubleSpinBox_2->value();
|
|
g_SelectMFac = ui->comboBox->currentText();
|
|
|
|
//关闭
|
|
accept(); // 让 QDialog::exec() 返回 QDialog::Accepted
|
|
//QDialog::close();
|
|
}
|
|
|
|
//
|
|
void FracSel::slotCancelClicked()
|
|
{
|
|
reject(); // 让 QDialog::exec() 返回 QDialog::Rejected
|
|
//QDialog::close();
|
|
}
|