2019-09-02 21:40:52 +00:00
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
#include "rle.h"
|
|
|
|
|
|
|
|
|
|
#include <QMatrix>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QPainter>
|
2019-09-03 12:19:09 +00:00
|
|
|
|
#include <QDesktopWidget>
|
2019-09-04 12:28:16 +00:00
|
|
|
|
#include <QPaintEvent>
|
2019-09-02 21:40:52 +00:00
|
|
|
|
|
|
|
|
|
bool rdpimg2QImage(QImage& out, int w, int h, int bitsPerPixel, bool isCompressed, uint8_t* dat, uint32_t len) {
|
|
|
|
|
switch(bitsPerPixel) {
|
|
|
|
|
case 15:
|
|
|
|
|
if(isCompressed) {
|
|
|
|
|
uint8_t* _dat = (uint8_t*)calloc(1, w*h*2);
|
|
|
|
|
if(!bitmap_decompress1(_dat, w, h, dat, len)) {
|
|
|
|
|
free(_dat);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
out = QImage(_dat, w, h, QImage::Format_RGB555);
|
|
|
|
|
free(_dat);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
out = QImage(dat, w, h, QImage::Format_RGB555).transformed(QMatrix(1.0, 0.0, 0.0, -1.0, 0.0, 0.0)) ;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 16:
|
|
|
|
|
if(isCompressed) {
|
|
|
|
|
uint8_t* _dat = (uint8_t*)calloc(1, w*h*2);
|
|
|
|
|
if(!bitmap_decompress2(_dat, w, h, dat, len)) {
|
|
|
|
|
free(_dat);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2019-09-03 12:19:09 +00:00
|
|
|
|
|
2019-09-04 20:21:29 +00:00
|
|
|
|
// TODO: 这里需要进一步优化,直接操作QImage的buffer。
|
|
|
|
|
|
|
|
|
|
out = QImage(w, h, QImage::Format_RGB16);
|
|
|
|
|
for(int y = 0; y < h; y++) {
|
|
|
|
|
for(int x = 0; x < w; x++) {
|
|
|
|
|
uint16 a = ((uint16*)_dat)[y * w + x];
|
|
|
|
|
uint8 r = ((a & 0xf800) >> 11) * 255 / 31;
|
|
|
|
|
uint8 g = ((a & 0x07e0) >> 5) * 255 / 63;
|
|
|
|
|
uint8 b = (a & 0x001f) * 255 / 31;
|
|
|
|
|
out.setPixelColor(x, y, QColor(r,g,b));
|
2019-09-04 12:28:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-02 21:40:52 +00:00
|
|
|
|
free(_dat);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
out = QImage(dat, w, h, QImage::Format_RGB16).transformed(QMatrix(1.0, 0.0, 0.0, -1.0, 0.0, 0.0)) ;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 24:
|
|
|
|
|
qDebug() << "--------NOT support 24";
|
|
|
|
|
break;
|
|
|
|
|
case 32:
|
|
|
|
|
qDebug() << "--------NOT support 32";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
|
|
|
QMainWindow(parent),
|
|
|
|
|
ui(new Ui::MainWindow)
|
|
|
|
|
{
|
|
|
|
|
m_shown = false;
|
2019-09-08 19:30:31 +00:00
|
|
|
|
m_show_default = true;
|
|
|
|
|
m_bar_shown = false;
|
2019-09-09 18:04:23 +00:00
|
|
|
|
m_bar_fade_in = false;
|
|
|
|
|
m_bar_fading = false;
|
|
|
|
|
m_bar_opacity = 1.0;
|
2019-09-04 12:28:16 +00:00
|
|
|
|
memset(&m_pt, 0, sizeof(TS_RECORD_RDP_POINTER));
|
2019-09-02 21:40:52 +00:00
|
|
|
|
|
2019-09-09 18:04:23 +00:00
|
|
|
|
m_thr_play = nullptr;
|
|
|
|
|
m_play_state = PLAY_STATE_UNKNOWN;
|
|
|
|
|
|
2019-09-02 21:40:52 +00:00
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
ui->centralWidget->setMouseTracking(true);
|
|
|
|
|
setMouseTracking(true);
|
|
|
|
|
|
2019-09-02 21:40:52 +00:00
|
|
|
|
// frame-less window.
|
|
|
|
|
//#ifdef __APPLE__
|
|
|
|
|
// setWindowFlags(Qt::FramelessWindowHint | Qt::MSWindowsFixedSizeDialogHint | Qt::Window);
|
|
|
|
|
// OSXCode::fixWin(winId());
|
|
|
|
|
//#else
|
|
|
|
|
// setWindowFlags(Qt::FramelessWindowHint | Qt::MSWindowsFixedSizeDialogHint | windowFlags());
|
|
|
|
|
//#endif //__APPLE__
|
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
m_pt_normal.load(":/tp-player/res/cursor.png");
|
|
|
|
|
m_default_bg.load(":/tp-player/res/bg.png");
|
2019-09-02 21:40:52 +00:00
|
|
|
|
|
2019-09-03 12:19:09 +00:00
|
|
|
|
setWindowFlags(windowFlags()&~Qt::WindowMaximizeButtonHint); // 禁止最大化按钮
|
2019-09-08 19:30:31 +00:00
|
|
|
|
setFixedSize(m_default_bg.width(), m_default_bg.height()); // 禁止拖动窗口大小
|
2019-09-03 12:19:09 +00:00
|
|
|
|
|
2019-09-09 12:15:53 +00:00
|
|
|
|
if(!m_bar.init(this)) {
|
|
|
|
|
qDebug("bar init failed.");
|
2019-09-06 12:07:13 +00:00
|
|
|
|
return;
|
2019-09-09 12:15:53 +00:00
|
|
|
|
}
|
2019-09-06 12:07:13 +00:00
|
|
|
|
|
2019-09-09 18:04:23 +00:00
|
|
|
|
// connect(&m_thr_play, SIGNAL(signal_update_data(update_data*)), this, SLOT(_do_update_data(update_data*)));
|
|
|
|
|
connect(&m_timer_bar_fade, SIGNAL(timeout()), this, SLOT(_do_bar_fade()));
|
|
|
|
|
connect(&m_timer_bar_delay_hide, SIGNAL(timeout()), this, SLOT(_do_bar_delay_hide()));
|
2019-09-02 21:40:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
|
{
|
2019-09-09 18:04:23 +00:00
|
|
|
|
if(m_thr_play) {
|
|
|
|
|
m_thr_play->stop();
|
|
|
|
|
m_thr_play->wait();
|
|
|
|
|
|
|
|
|
|
disconnect(m_thr_play, SIGNAL(signal_update_data(update_data*)), this, SLOT(_do_update_data(update_data*)));
|
|
|
|
|
|
|
|
|
|
delete m_thr_play;
|
|
|
|
|
m_thr_play = nullptr;
|
|
|
|
|
}
|
2019-09-02 21:40:52 +00:00
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-09 18:04:23 +00:00
|
|
|
|
void MainWindow::_start_play_thread() {
|
|
|
|
|
if(m_thr_play) {
|
|
|
|
|
m_thr_play->stop();
|
|
|
|
|
m_thr_play->wait();
|
|
|
|
|
|
|
|
|
|
disconnect(m_thr_play, SIGNAL(signal_update_data(update_data*)), this, SLOT(_do_update_data(update_data*)));
|
|
|
|
|
|
|
|
|
|
delete m_thr_play;
|
|
|
|
|
m_thr_play = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_thr_play = new ThreadPlay;
|
|
|
|
|
connect(m_thr_play, SIGNAL(signal_update_data(update_data*)), this, SLOT(_do_update_data(update_data*)));
|
|
|
|
|
m_thr_play->speed(m_bar.get_speed());
|
|
|
|
|
m_thr_play->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::speed(int s) {
|
|
|
|
|
if(m_thr_play)
|
|
|
|
|
m_thr_play->speed(s);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
void MainWindow::paintEvent(QPaintEvent *e)
|
2019-09-02 21:40:52 +00:00
|
|
|
|
{
|
|
|
|
|
QPainter painter(this);
|
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
if(m_show_default) {
|
|
|
|
|
painter.drawPixmap(e->rect(), m_default_bg, e->rect());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
painter.drawPixmap(e->rect(), m_canvas, e->rect());
|
2019-09-02 21:40:52 +00:00
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
QRect rcpt(m_pt_normal.rect());
|
|
|
|
|
rcpt.moveTo(m_pt.x - m_pt_normal.width()/2, m_pt.y-m_pt_normal.height()/2);
|
|
|
|
|
if(e->rect().intersects(rcpt)) {
|
|
|
|
|
painter.drawPixmap(m_pt.x-m_pt_normal.width()/2, m_pt.y-m_pt_normal.height()/2, m_pt_normal);
|
2019-09-04 20:21:29 +00:00
|
|
|
|
}
|
2019-09-02 21:40:52 +00:00
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
// 绘制浮动控制窗
|
2019-09-09 18:04:23 +00:00
|
|
|
|
if(m_bar_fading) {
|
|
|
|
|
painter.setOpacity(m_bar_opacity);
|
|
|
|
|
m_bar.draw(painter, e->rect());
|
|
|
|
|
}
|
|
|
|
|
else if(m_bar_shown) {
|
2019-09-08 19:30:31 +00:00
|
|
|
|
m_bar.draw(painter, e->rect());
|
2019-09-09 18:04:23 +00:00
|
|
|
|
}
|
2019-09-02 21:40:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
if(!m_shown) {
|
|
|
|
|
m_shown = true;
|
2019-09-09 18:04:23 +00:00
|
|
|
|
//m_thr_play.start();
|
|
|
|
|
_start_play_thread();
|
2019-09-08 19:30:31 +00:00
|
|
|
|
}
|
2019-09-02 21:40:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-09 18:04:23 +00:00
|
|
|
|
void MainWindow::pause() {
|
|
|
|
|
if(m_play_state != PLAY_STATE_RUNNING)
|
|
|
|
|
return;
|
|
|
|
|
m_thr_play->pause();
|
|
|
|
|
m_play_state = PLAY_STATE_PAUSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::resume() {
|
|
|
|
|
if(m_play_state == PLAY_STATE_PAUSE)
|
|
|
|
|
m_thr_play->resume();
|
|
|
|
|
else if(m_play_state == PLAY_STATE_STOP)
|
|
|
|
|
//m_thr_play->start();
|
|
|
|
|
_start_play_thread();
|
|
|
|
|
|
|
|
|
|
m_play_state = PLAY_STATE_RUNNING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::_do_update_data(update_data* dat) {
|
2019-09-02 21:40:52 +00:00
|
|
|
|
if(!dat)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
UpdateDataHelper data_helper(dat);
|
|
|
|
|
|
2019-09-02 21:40:52 +00:00
|
|
|
|
if(dat->data_type() == TYPE_DATA) {
|
|
|
|
|
|
|
|
|
|
if(dat->data_len() <= sizeof(TS_RECORD_PKG)) {
|
|
|
|
|
qDebug() << "invalid record package(1).";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TS_RECORD_PKG* pkg = (TS_RECORD_PKG*)dat->data_buf();
|
|
|
|
|
|
|
|
|
|
if(pkg->type == TS_RECORD_TYPE_RDP_POINTER) {
|
|
|
|
|
if(dat->data_len() != sizeof(TS_RECORD_PKG) + sizeof(TS_RECORD_RDP_POINTER)) {
|
|
|
|
|
qDebug() << "invalid record package(2).";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
TS_RECORD_RDP_POINTER pt;
|
|
|
|
|
memcpy(&pt, &m_pt, sizeof(TS_RECORD_RDP_POINTER));
|
2019-09-04 20:21:29 +00:00
|
|
|
|
|
|
|
|
|
// 更新虚拟鼠标信息,这样下一次绘制界面时就会在新的位置绘制出虚拟鼠标
|
2019-09-02 21:40:52 +00:00
|
|
|
|
memcpy(&m_pt, dat->data_buf() + sizeof(TS_RECORD_PKG), sizeof(TS_RECORD_RDP_POINTER));
|
2019-09-04 20:21:29 +00:00
|
|
|
|
update(m_pt.x - m_pt_normal.width()/2, m_pt.y - m_pt_normal.width()/2, m_pt_normal.width(), m_pt_normal.height());
|
2019-09-08 19:30:31 +00:00
|
|
|
|
|
|
|
|
|
update(pt.x - m_pt_normal.width()/2, pt.y - m_pt_normal.width()/2, m_pt_normal.width(), m_pt_normal.height());
|
2019-09-02 21:40:52 +00:00
|
|
|
|
}
|
|
|
|
|
else if(pkg->type == TS_RECORD_TYPE_RDP_IMAGE) {
|
|
|
|
|
if(dat->data_len() <= sizeof(TS_RECORD_PKG) + sizeof(TS_RECORD_RDP_IMAGE_INFO)) {
|
|
|
|
|
qDebug() << "invalid record package(3).";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TS_RECORD_RDP_IMAGE_INFO* info = (TS_RECORD_RDP_IMAGE_INFO*)(dat->data_buf() + sizeof(TS_RECORD_PKG));
|
|
|
|
|
uint8_t* img_dat = dat->data_buf() + sizeof(TS_RECORD_PKG) + sizeof(TS_RECORD_RDP_IMAGE_INFO);
|
|
|
|
|
uint32_t img_len = dat->data_len() - sizeof(TS_RECORD_PKG) - sizeof(TS_RECORD_RDP_IMAGE_INFO);
|
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
QImage img_update;
|
|
|
|
|
rdpimg2QImage(img_update, info->width, info->height, info->bitsPerPixel, (info->format == TS_RDP_IMG_BMP) ? true : false, img_dat, img_len);
|
2019-09-04 12:28:16 +00:00
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
int x = info->destLeft;
|
|
|
|
|
int y = info->destTop;
|
|
|
|
|
int w = info->destRight - info->destLeft + 1;
|
|
|
|
|
int h = info->destBottom - info->destTop + 1;
|
2019-09-02 21:40:52 +00:00
|
|
|
|
|
2019-09-04 20:21:29 +00:00
|
|
|
|
QPainter pp(&m_canvas);
|
2019-09-08 19:30:31 +00:00
|
|
|
|
pp.drawImage(x, y, img_update, 0, 0, w, h, Qt::AutoColor);
|
2019-09-02 21:40:52 +00:00
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
update(x, y, w, h);
|
2019-09-02 21:40:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
if(dat->data_type() == TYPE_TIMER) {
|
|
|
|
|
m_bar.update_passed_time(dat->passed_ms());
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-09-02 21:40:52 +00:00
|
|
|
|
|
2019-09-09 18:04:23 +00:00
|
|
|
|
// 这是播放开始时收到的第一个数据包
|
2019-09-02 21:40:52 +00:00
|
|
|
|
if(dat->data_type() == TYPE_HEADER_INFO) {
|
|
|
|
|
if(dat->data_len() != sizeof(TS_RECORD_HEADER)) {
|
|
|
|
|
qDebug() << "invalid record header.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
memcpy(&m_rec_hdr, dat->data_buf(), sizeof(TS_RECORD_HEADER));
|
|
|
|
|
|
|
|
|
|
qDebug() << "resize (" << m_rec_hdr.basic.width << "," << m_rec_hdr.basic.height << ")";
|
|
|
|
|
if(m_rec_hdr.basic.width > 0 && m_rec_hdr.basic.height > 0) {
|
2019-09-04 12:28:16 +00:00
|
|
|
|
|
2019-09-09 18:04:23 +00:00
|
|
|
|
if(m_canvas.width() != m_rec_hdr.basic.width && m_canvas.height() != m_rec_hdr.basic.height) {
|
|
|
|
|
m_canvas = QPixmap(m_rec_hdr.basic.width, m_rec_hdr.basic.height);
|
2019-09-04 12:28:16 +00:00
|
|
|
|
|
2019-09-09 18:04:23 +00:00
|
|
|
|
//m_win_board_w = frameGeometry().width() - geometry().width();
|
|
|
|
|
//m_win_board_h = frameGeometry().height() - geometry().height();
|
2019-09-03 12:19:09 +00:00
|
|
|
|
|
2019-09-09 18:04:23 +00:00
|
|
|
|
QDesktopWidget *desktop = QApplication::desktop(); // =qApp->desktop();也可以
|
|
|
|
|
qDebug("desktop w:%d,h:%d, this w:%d,h:%d", desktop->width(), desktop->height(), width(), height());
|
|
|
|
|
//move((desktop->width() - this->width())/2, (desktop->height() - this->height())/2);
|
|
|
|
|
move(10, (desktop->height() - m_rec_hdr.basic.height)/2);
|
|
|
|
|
|
|
|
|
|
//setFixedSize(m_rec_hdr.basic.width + m_win_board_w, m_rec_hdr.basic.height + m_win_board_h);
|
|
|
|
|
//resize(m_rec_hdr.basic.width + m_win_board_w, m_rec_hdr.basic.height + m_win_board_h);
|
|
|
|
|
//resize(m_rec_hdr.basic.width, m_rec_hdr.basic.height);
|
|
|
|
|
setFixedSize(m_rec_hdr.basic.width, m_rec_hdr.basic.height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_canvas.fill(QColor(38, 73, 111));
|
2019-09-03 12:19:09 +00:00
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
m_show_default = false;
|
|
|
|
|
repaint();
|
|
|
|
|
|
|
|
|
|
m_bar.start(m_rec_hdr.info.time_ms, 640);
|
2019-09-09 18:04:23 +00:00
|
|
|
|
m_bar_shown = true;
|
|
|
|
|
m_play_state = PLAY_STATE_RUNNING;
|
|
|
|
|
|
|
|
|
|
update(m_bar.rc());
|
|
|
|
|
|
|
|
|
|
m_bar_fade_in = false;
|
|
|
|
|
m_bar_fading = true;
|
|
|
|
|
m_timer_bar_delay_hide.start(2000);
|
2019-09-02 21:40:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString title;
|
|
|
|
|
if (m_rec_hdr.basic.conn_port == 3389)
|
|
|
|
|
title.sprintf("[%s] %s@%s [Teleport-RDP录像回放]", m_rec_hdr.basic.acc_username, m_rec_hdr.basic.user_username, m_rec_hdr.basic.conn_ip);
|
|
|
|
|
else
|
|
|
|
|
title.sprintf("[%s] %s@%s:%d [Teleport-RDP录像回放]", m_rec_hdr.basic.acc_username, m_rec_hdr.basic.user_username, m_rec_hdr.basic.conn_ip, m_rec_hdr.basic.conn_port);
|
|
|
|
|
|
|
|
|
|
setWindowTitle(title);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
if(dat->data_type() == TYPE_END) {
|
|
|
|
|
m_bar.end();
|
2019-09-09 18:04:23 +00:00
|
|
|
|
m_play_state = PLAY_STATE_STOP;
|
2019-09-08 19:30:31 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2019-09-02 21:40:52 +00:00
|
|
|
|
}
|
2019-09-08 19:30:31 +00:00
|
|
|
|
|
2019-09-09 18:04:23 +00:00
|
|
|
|
void MainWindow::_do_bar_delay_hide() {
|
|
|
|
|
m_bar_fading = true;
|
|
|
|
|
m_timer_bar_delay_hide.stop();
|
|
|
|
|
m_timer_bar_fade.stop();
|
|
|
|
|
m_timer_bar_fade.start(50);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::_do_bar_fade() {
|
|
|
|
|
if(m_bar_fade_in) {
|
|
|
|
|
if(m_bar_opacity < 1.0)
|
|
|
|
|
m_bar_opacity += 0.3;
|
|
|
|
|
if(m_bar_opacity >= 1.0) {
|
|
|
|
|
m_bar_opacity = 1.0;
|
|
|
|
|
m_bar_shown = true;
|
|
|
|
|
m_bar_fading = false;
|
|
|
|
|
m_timer_bar_fade.stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if(m_bar_opacity > 0.0)
|
|
|
|
|
m_bar_opacity -= 0.2;
|
|
|
|
|
if(m_bar_opacity <= 0.0) {
|
|
|
|
|
m_bar_opacity = 0.0;
|
|
|
|
|
m_bar_shown = false;
|
|
|
|
|
m_bar_fading = false;
|
|
|
|
|
m_timer_bar_fade.stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update(m_bar.rc());
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-08 19:30:31 +00:00
|
|
|
|
void MainWindow::mouseMoveEvent(QMouseEvent *e) {
|
|
|
|
|
if(!m_show_default) {
|
|
|
|
|
QRect rc = m_bar.rc();
|
|
|
|
|
if(e->y() > rc.top() - 20 && e->y() < rc.bottom() + 20) {
|
2019-09-09 18:04:23 +00:00
|
|
|
|
if((!m_bar_shown && !m_bar_fading) || (m_bar_fading && !m_bar_fade_in)) {
|
|
|
|
|
m_bar_fade_in = true;
|
|
|
|
|
m_bar_fading = true;
|
|
|
|
|
|
|
|
|
|
m_timer_bar_delay_hide.stop();
|
|
|
|
|
m_timer_bar_fade.stop();
|
|
|
|
|
m_timer_bar_fade.start(50);
|
2019-09-08 19:30:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-09 18:04:23 +00:00
|
|
|
|
if(rc.contains(e->pos()))
|
2019-09-08 19:30:31 +00:00
|
|
|
|
m_bar.onMouseMove(e->x(), e->y());
|
|
|
|
|
}
|
|
|
|
|
else {
|
2019-09-09 18:04:23 +00:00
|
|
|
|
if((m_bar_shown && !m_bar_fading) || (m_bar_fading && m_bar_fade_in)) {
|
|
|
|
|
m_bar_fade_in = false;
|
|
|
|
|
m_bar_fading = true;
|
|
|
|
|
m_timer_bar_fade.stop();
|
|
|
|
|
m_timer_bar_delay_hide.stop();
|
|
|
|
|
|
|
|
|
|
if(m_bar_opacity != 1.0)
|
|
|
|
|
m_timer_bar_fade.start(50);
|
|
|
|
|
else
|
|
|
|
|
m_timer_bar_delay_hide.start(1000);
|
2019-09-08 19:30:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-09 18:04:23 +00:00
|
|
|
|
void MainWindow::mousePressEvent(QMouseEvent *e) {
|
|
|
|
|
if(!m_show_default) {
|
|
|
|
|
QRect rc = m_bar.rc();
|
|
|
|
|
if(rc.contains(e->pos())) {
|
|
|
|
|
m_bar.onMousePress(e->x(), e->y());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|