170 lines
3.3 KiB
C++
170 lines
3.3 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);
|
|
|
|
}
|
|
|
|
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->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());
|
|
}
|
|
|
|
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;
|
|
//设置比例
|
|
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"));
|
|
}
|
|
|
|
}
|