Files
gcs-nf/App/ToolsUI/tools_Index2/tools_Index2.cpp
T
2020-12-16 16:49:51 +08:00

218 lines
4.6 KiB
C++

#include "tools_Index2.h"
#include "ui_tools_Index2.h"
Tools_Index2::Tools_Index2(QWidget *parent) :
QWidget(parent),
ui(new Ui::Tools_Index2)
{
ui->setupUi(this);
m_parent = parent;
//load qss
QFile file(":/qss/Setting.qss");
file.open(QFile::ReadOnly);
QTextStream filetext(&file);
QString stylesheet = filetext.readAll();
this->setStyleSheet(stylesheet);
file.close();
ui->horizontalSlider->hide();
PlayState = false;
ui->pushButton_Play->setFixedSize(150,50);
ui->pushButton_LastFrame->setFixedSize(150,50);
ui->pushButton_NextFrame->setFixedSize(150,50);
ui->comboBox_MultiSpeed->addItem("X1",1000);
ui->comboBox_MultiSpeed->addItem("X2",500);
ui->comboBox_MultiSpeed->addItem("X5",200);
ui->comboBox_MultiSpeed->addItem("X10",100);
//ui->comboBox_MultiSpeed->addItem("X100",10);
}
Tools_Index2::~Tools_Index2()
{
delete ui;
}
void Tools_Index2::closeEvent(QCloseEvent *event)
{
setFloat();
event->ignore();
}
void Tools_Index2::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = new QMenu(this);
QAction *pAction = new QAction("float",this);
connect(pAction,SIGNAL(triggered(bool)),
this,SLOT(setFloat()));
menu->addAction(pAction);
menu->move(cursor().pos());
menu->show();
}
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);
this->setWindowFlags(Qt::WindowStaysOnTopHint);
this->resize(600,320);
this->show();
}
else
{
this->setParent(m_parent);
this->move(0,0);
this->hide();
//qDebug() << m_parent->children();
}
}
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);
}