完善辅助功能

This commit is contained in:
Barry 2019-01-25 23:57:55 +08:00
commit 3b7f28de35
5 changed files with 31 additions and 25 deletions

View file

@ -9,6 +9,7 @@ ToolForm::ToolForm(QWidget* adsorbWidget, AdsorbPositions adsorbPos)
{ {
ui->setupUi(this); ui->setupUi(this);
//setWindowFlags(windowFlags() | Qt::FramelessWindowHint); //setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
setWindowFlags(windowFlags() & ~Qt::WindowMinMaxButtonsHint);
} }
ToolForm::~ToolForm() ToolForm::~ToolForm()

View file

@ -6,12 +6,12 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>118</width> <width>80</width>
<height>497</height> <height>497</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string/>
</property> </property>
</widget> </widget>
<resources/> <resources/>

View file

@ -19,8 +19,7 @@ VideoForm::VideoForm(const QString& serial, QWidget *parent) :
ui(new Ui::videoForm), ui(new Ui::videoForm),
m_serial(serial) m_serial(serial)
{ {
ui->setupUi(this); ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
initUI(); initUI();
connect(&m_inputConvert, &InputConvertGame::grabCursor, this, [this](bool grab){ connect(&m_inputConvert, &InputConvertGame::grabCursor, this, [this](bool grab){
@ -78,7 +77,7 @@ VideoForm::VideoForm(const QString& serial, QWidget *parent) :
// must be Qt::QueuedConnection, ui update must be main thread // must be Qt::QueuedConnection, ui update must be main thread
QObject::connect(&m_decoder, &Decoder::onNewFrame, this, [this](){ QObject::connect(&m_decoder, &Decoder::onNewFrame, this, [this](){
if (ui->videoWidget->isHidden()) { if (ui->videoWidget->isHidden()) {
ui->loadingWidget->hide(); ui->loadingWidget->close();
ui->videoWidget->show(); ui->videoWidget->show();
} }
m_frames.lock(); m_frames.lock();
@ -107,11 +106,7 @@ VideoForm::VideoForm(const QString& serial, QWidget *parent) :
initStyle(); initStyle();
bool vertical = size().height() > size().width(); bool vertical = size().height() > size().width();
updateStyleSheet(vertical); updateStyleSheet(vertical);
ToolForm* mw = new ToolForm(this, ToolForm::AP_OUTSIDE_RIGHT);
mw->move(pos().x() + geometry().width(), pos().y() + 30);
mw->show();
} }
VideoForm::~VideoForm() VideoForm::~VideoForm()
@ -130,12 +125,14 @@ void VideoForm::initUI()
m_widthHeightRatio = 1.0f * phone.width() / phone.height(); m_widthHeightRatio = 1.0f * phone.width() / phone.height();
} }
setAttribute(Qt::WA_DeleteOnClose);
// 去掉标题栏 // 去掉标题栏
setWindowFlags(Qt::FramelessWindowHint); setWindowFlags(Qt::FramelessWindowHint);
// 根据图片构造异形窗口 // 根据图片构造异形窗口
setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_TranslucentBackground);
setMouseTracking(true); setMouseTracking(true);
ui->loadingWidget->setAttribute(Qt::WA_DeleteOnClose);
ui->videoWidget->setMouseTracking(true); ui->videoWidget->setMouseTracking(true);
ui->videoWidget->hide(); ui->videoWidget->hide();
@ -145,6 +142,15 @@ void VideoForm::initUI()
ui->quickWidget->setClearColor(QColor(Qt::transparent)); ui->quickWidget->setClearColor(QColor(Qt::transparent));
} }
void VideoForm::showToolFrom(bool show)
{
if (!m_toolForm) {
m_toolForm = new ToolForm(this, ToolForm::AP_OUTSIDE_RIGHT);
m_toolForm->move(pos().x() + geometry().width(), pos().y() + 30);
}
m_toolForm->setVisible(show);
}
void VideoForm::initStyle() void VideoForm::initStyle()
{ {
//IconHelper::Instance()->SetIcon(ui->fullScrcenbtn, QChar(0xf0b2), 13); //IconHelper::Instance()->SetIcon(ui->fullScrcenbtn, QChar(0xf0b2), 13);
@ -212,8 +218,10 @@ void VideoForm::switchFullScreen()
{ {
if (isFullScreen()) { if (isFullScreen()) {
showNormal(); showNormal();
showToolFrom(true);
} else { } else {
showFullScreen(); showToolFrom(false);
showFullScreen();
} }
} }
@ -291,6 +299,11 @@ void VideoForm::paintEvent(QPaintEvent *paint)
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
} }
void VideoForm::showEvent(QShowEvent *event)
{
showToolFrom();
}
void VideoForm::on_fullScrcenbtn_clicked() void VideoForm::on_fullScrcenbtn_clicked()
{ {
switchFullScreen(); switchFullScreen();

View file

@ -2,6 +2,7 @@
#define VIDEOFORM_H #define VIDEOFORM_H
#include <QWidget> #include <QWidget>
#include <QPointer>
#include "server.h" #include "server.h"
#include "decoder.h" #include "decoder.h"
@ -13,6 +14,7 @@ namespace Ui {
class videoForm; class videoForm;
} }
class ToolForm;
class VideoForm : public QWidget class VideoForm : public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -27,6 +29,7 @@ private:
void initStyle(); void initStyle();
void updateStyleSheet(bool vertical); void updateStyleSheet(bool vertical);
void initUI(); void initUI();
void showToolFrom(bool show = true);
protected: protected:
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event);
@ -37,6 +40,7 @@ protected:
void keyReleaseEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event);
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
void showEvent(QShowEvent *event);
private slots: private slots:
void on_fullScrcenbtn_clicked(); void on_fullScrcenbtn_clicked();
@ -51,9 +55,9 @@ private:
//InputConvertNormal m_inputConvert; //InputConvertNormal m_inputConvert;
InputConvertGame m_inputConvert; InputConvertGame m_inputConvert;
QString m_serial = ""; QString m_serial = "";
QPoint m_dragPosition; QPoint m_dragPosition;
float m_widthHeightRatio = 0.5f; float m_widthHeightRatio = 0.5f;
QPointer<ToolForm> m_toolForm;
}; };
#endif // VIDEOFORM_H #endif // VIDEOFORM_H

View file

@ -59,20 +59,8 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item alignment="Qt::AlignHCenter|Qt::AlignVCenter"> <item>
<widget class="QQuickWidget" name="quickWidget"> <widget class="QQuickWidget" name="quickWidget">
<property name="minimumSize">
<size>
<width>170</width>
<height>170</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>170</width>
<height>170</height>
</size>
</property>
<property name="autoFillBackground"> <property name="autoFillBackground">
<bool>false</bool> <bool>false</bool>
</property> </property>