Files

220 lines
4.9 KiB
C++
Raw Permalink Normal View History

2020-10-24 11:21:24 +08:00
#include "tools_Index2.h"
2020-06-04 18:20:13 +08:00
#include "ui_tools_Index2.h"
Tools_Index2::Tools_Index2(QWidget *parent) :
QWidget(parent),
ui(new Ui::Tools_Index2)
{
ui->setupUi(this);
2022-01-04 16:31:48 +08:00
m_parent = parent;
2020-06-04 18:20:13 +08:00
//load qss
QFile file(":/qss/Setting.qss");
file.open(QFile::ReadOnly);
QTextStream filetext(&file);
QString stylesheet = filetext.readAll();
this->setStyleSheet(stylesheet);
file.close();
2021-11-13 20:06:59 +08:00
this->setTop(true);
2020-08-19 22:21:48 +08:00
ui->horizontalSlider->hide();
2020-10-16 17:06:18 +08:00
PlayState = false;
ui->pushButton_Play->setFixedSize(150,50);
2020-12-15 13:47:14 +08:00
ui->pushButton_LastFrame->setFixedSize(150,50);
ui->pushButton_NextFrame->setFixedSize(150,50);
2021-11-13 20:06:59 +08:00
ui->pushButton_setPercent->setFixedSize(150,50);
ui->doubleSpinBox_setPercent->setFixedSize(150,50);
ui->comboBox_MultiSpeed->setFixedSize(150,50);
ui->label_percent->setFixedSize(150,50);
2022-01-22 15:28:20 +08:00
ui->pushButton_CSV->setFixedHeight(50);
2020-12-15 13:47:14 +08:00
2022-02-10 14:26:23 +08:00
ui->pushButton_CSV->hide();
2020-12-15 13:47:14 +08:00
2021-11-13 20:06:59 +08:00
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);
2022-02-10 14:26:23 +08:00
//ui->comboBox_MultiSpeed->addItem("X100",100);
//ui->comboBox_MultiSpeed->addItem("X200",200);
//ui->comboBox_MultiSpeed->addItem("X500",500);
//ui->comboBox_MultiSpeed->addItem("X1000",1000);
2020-12-15 13:47:14 +08:00
2020-10-16 17:06:18 +08:00
2020-06-04 18:20:13 +08:00
}
Tools_Index2::~Tools_Index2()
{
delete ui;
}
2021-11-13 20:06:59 +08:00
void Tools_Index2::resizeEvent(QResizeEvent *event)
2020-10-24 11:21:24 +08:00
{
2021-11-13 20:06:59 +08:00
Q_UNUSED(event)
update();
2020-10-24 11:21:24 +08:00
}
2021-11-13 20:06:59 +08:00
void Tools_Index2::closeEvent(QCloseEvent *event)
2020-10-24 11:21:24 +08:00
{
2021-11-13 20:06:59 +08:00
setFloat();
event->ignore();
2020-10-24 11:21:24 +08:00
}
void Tools_Index2::setFloat(void)
{
if(this->parent())
{
this->setParent(nullptr);
QScreen *screen=QGuiApplication::primaryScreen ();;
this->move((screen->availableGeometry().width()-this->width())/2,(screen->availableGeometry().height()-this->height())/2);
2022-01-22 15:28:20 +08:00
this->resize(400,380);
2020-10-24 11:21:24 +08:00
this->show();
}
else
{
this->setParent(m_parent);
2021-11-13 20:06:59 +08:00
2020-10-24 11:21:24 +08:00
this->move(0,0);
2022-01-22 15:28:20 +08:00
//this->hide();
this->show();
this->resize(m_parent->size());
2021-11-13 20:06:59 +08:00
update();
2020-10-24 11:21:24 +08:00
}
}
2020-08-19 22:21:48 +08:00
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;
2020-12-15 13:47:14 +08:00
2020-08-19 22:21:48 +08:00
emit setPlay(PlayState);//暂停播放,跟底层关联起来
emit setFileName(fileName);
ui->horizontalSlider->show();
}
}
2020-06-04 18:20:13 +08:00
2020-08-19 22:21:48 +08:00
void Tools_Index2::setCurrentPercentage(float value)
{
ui->horizontalSlider->setValue(value * ui->horizontalSlider->maximum());
2020-12-16 16:49:51 +08:00
//ui->doubleSpinBox_Percent->setValue(value * 100);
ui->label_percent->setText(QString::number(value * 100));
2020-08-19 22:21:48 +08:00
}
void Tools_Index2::ReplayComplete()
{
PlayState = false;
2020-10-16 17:06:18 +08:00
ui->pushButton_Play->setText(tr("play"));
2020-08-19 22:21:48 +08:00
}
void Tools_Index2::on_horizontalSlider_sliderReleased()
{
2020-08-20 17:48:09 +08:00
if(isMove == false)
{
//读取暂停和播放状态
PlayState = PlayState?false:true;
//暂停和播放
emit setPlay(PlayState);
2020-10-16 17:06:18 +08:00
if(PlayState)//true
{
ui->pushButton_Play->setText(tr("pause"));
}
else
{
ui->pushButton_Play->setText(tr("play"));
}
2020-08-20 17:48:09 +08:00
}
2020-08-19 22:21:48 +08:00
}
void Tools_Index2::on_horizontalSlider_sliderPressed()
{
2020-08-20 17:48:09 +08:00
isMove = false;
2020-08-19 22:21:48 +08:00
}
2020-06-04 18:20:13 +08:00
2020-08-19 22:21:48 +08:00
void Tools_Index2::on_horizontalSlider_sliderMoved(int position)
{
2020-08-20 17:48:09 +08:00
isMove = true;
2020-08-19 22:21:48 +08:00
//设置比例
2020-12-15 13:47:14 +08:00
//qDebug() << (float)position/ui->horizontalSlider->maximum();
2020-08-19 22:21:48 +08:00
emit setPercentage((float)position/ui->horizontalSlider->maximum());
}
2020-10-16 17:06:18 +08:00
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"));
}
}
2020-12-15 13:47:14 +08:00
void Tools_Index2::on_comboBox_MultiSpeed_currentIndexChanged(int index)
{
2021-11-13 20:06:59 +08:00
qDebug() << ui->comboBox_MultiSpeed->currentData(Qt::UserRole).toDouble();
2020-12-15 13:47:14 +08:00
emit setMultiple(ui->comboBox_MultiSpeed->currentData(Qt::UserRole).toDouble());
}
void Tools_Index2::on_pushButton_NextFrame_clicked()
{
}
void Tools_Index2::on_pushButton_LastFrame_clicked()
{
}
2021-11-13 20:06:59 +08:00
void Tools_Index2::on_doubleSpinBox_setPercent_valueChanged(double arg1)
2020-12-15 13:47:14 +08:00
{
//emit setPercentage(arg1);
}
void Tools_Index2::on_pushButton_setPercent_clicked()
{
double p = ui->doubleSpinBox_setPercent->value() * 0.01;
qDebug() << "p" << p;
emit setPercentage(p);
}
2021-11-13 20:06:59 +08:00
void Tools_Index2::on_pushButton_CSV_clicked()
{
qDebug() << "emit csv";
emit CreateCSV();
}