#include "tools_Index2.h" #include "ui_tools_Index2.h" Tools_Index2::Tools_Index2(QWidget *parent) : ToolsWidget(parent), ui(new Ui::Tools_Index2) { ui->setupUi(this); //load qss QFile file(":/qss/Setting.qss"); file.open(QFile::ReadOnly); QTextStream filetext(&file); QString stylesheet = filetext.readAll(); this->setStyleSheet(stylesheet); file.close(); this->setTop(true); ui->horizontalSlider->hide(); PlayState = false; ui->pushButton_Play->setFixedSize(150,50); ui->pushButton_LastFrame->setFixedSize(150,50); ui->pushButton_NextFrame->setFixedSize(150,50); ui->pushButton_setPercent->setFixedSize(150,50); ui->doubleSpinBox_setPercent->setFixedSize(150,50); ui->comboBox_MultiSpeed->setFixedSize(150,50); ui->label_percent->setFixedSize(150,50); ui->comboBox_MultiSpeed->addItem("X1",1); ui->comboBox_MultiSpeed->addItem("X2",2); ui->comboBox_MultiSpeed->addItem("X5",5); ui->comboBox_MultiSpeed->addItem("X10",10); ui->comboBox_MultiSpeed->addItem("X20",20); ui->comboBox_MultiSpeed->addItem("X50",50); ui->comboBox_MultiSpeed->addItem("X100",100); ui->comboBox_MultiSpeed->addItem("X200",200); ui->comboBox_MultiSpeed->addItem("X500",500); ui->comboBox_MultiSpeed->addItem("X1000",1000); } Tools_Index2::~Tools_Index2() { delete ui; } void Tools_Index2::on_pushButton_file_clicked() { QFileDialog *dlg = new QFileDialog(this); QString fileName = dlg->getOpenFileName(this, tr("Open File"), "./Tlog/", tr("LogFile (*.Tlog *.log)")); if(!fileName.isEmpty()) { ui->pushButton_file->setText(fileName); PlayState = false; emit setPlay(PlayState);//暂停播放,跟底层关联起来 emit setFileName(fileName); ui->horizontalSlider->show(); } } void Tools_Index2::resizeEvent(QResizeEvent *event) { Q_UNUSED(event) update(); } void Tools_Index2::setCurrentPercentage(float value) { ui->horizontalSlider->setValue(value * ui->horizontalSlider->maximum()); //ui->doubleSpinBox_Percent->setValue(value * 100); ui->label_percent->setText(QString::number(value * 100)); } void Tools_Index2::ReplayComplete() { PlayState = false; ui->pushButton_Play->setText(tr("play")); } void Tools_Index2::on_horizontalSlider_sliderReleased() { if(isMove == false) { //读取暂停和播放状态 PlayState = PlayState?false:true; //暂停和播放 emit setPlay(PlayState); if(PlayState)//true { ui->pushButton_Play->setText(tr("pause")); } else { ui->pushButton_Play->setText(tr("play")); } } } void Tools_Index2::on_horizontalSlider_sliderPressed() { isMove = false; } void Tools_Index2::on_horizontalSlider_sliderMoved(int position) { isMove = true; //设置比例 //qDebug() << (float)position/ui->horizontalSlider->maximum(); emit setPercentage((float)position/ui->horizontalSlider->maximum()); } void Tools_Index2::on_pushButton_Play_clicked() { //读取暂停和播放状态 PlayState = PlayState?false:true; //暂停和播放 emit setPlay(PlayState); if(PlayState)//true { ui->pushButton_Play->setText(tr("pause")); } else { ui->pushButton_Play->setText(tr("play")); } } void Tools_Index2::on_comboBox_MultiSpeed_currentIndexChanged(int index) { //qDebug() << ui->comboBox_MultiSpeed->currentData(Qt::UserRole).toDouble(); emit setMultiple(ui->comboBox_MultiSpeed->currentData(Qt::UserRole).toDouble()); } void Tools_Index2::on_pushButton_NextFrame_clicked() { } void Tools_Index2::on_pushButton_LastFrame_clicked() { } void Tools_Index2::on_doubleSpinBox_Percent_valueChanged(double arg1) { //emit setPercentage(arg1); } void Tools_Index2::on_pushButton_setPercent_clicked() { double p = ui->doubleSpinBox_setPercent->value() * 0.01; qDebug() << "p" << p; emit setPercentage(p); } void Tools_Index2::on_pushButton_CSV_clicked() { qDebug() << "emit csv"; emit CreateCSV(); }