mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 03:25:02 +00:00
完善辅助功能
This commit is contained in:
parent
3dbd9c1e25
commit
3b7f28de35
5 changed files with 31 additions and 25 deletions
|
@ -9,6 +9,7 @@ ToolForm::ToolForm(QWidget* adsorbWidget, AdsorbPositions adsorbPos)
|
|||
{
|
||||
ui->setupUi(this);
|
||||
//setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowMinMaxButtonsHint);
|
||||
}
|
||||
|
||||
ToolForm::~ToolForm()
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>118</width>
|
||||
<width>80</width>
|
||||
<height>497</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -19,8 +19,7 @@ VideoForm::VideoForm(const QString& serial, QWidget *parent) :
|
|||
ui(new Ui::videoForm),
|
||||
m_serial(serial)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
ui->setupUi(this);
|
||||
initUI();
|
||||
|
||||
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
|
||||
QObject::connect(&m_decoder, &Decoder::onNewFrame, this, [this](){
|
||||
if (ui->videoWidget->isHidden()) {
|
||||
ui->loadingWidget->hide();
|
||||
ui->loadingWidget->close();
|
||||
ui->videoWidget->show();
|
||||
}
|
||||
m_frames.lock();
|
||||
|
@ -107,11 +106,7 @@ VideoForm::VideoForm(const QString& serial, QWidget *parent) :
|
|||
initStyle();
|
||||
|
||||
bool vertical = size().height() > size().width();
|
||||
updateStyleSheet(vertical);
|
||||
|
||||
ToolForm* mw = new ToolForm(this, ToolForm::AP_OUTSIDE_RIGHT);
|
||||
mw->move(pos().x() + geometry().width(), pos().y() + 30);
|
||||
mw->show();
|
||||
updateStyleSheet(vertical);
|
||||
}
|
||||
|
||||
VideoForm::~VideoForm()
|
||||
|
@ -130,12 +125,14 @@ void VideoForm::initUI()
|
|||
m_widthHeightRatio = 1.0f * phone.width() / phone.height();
|
||||
}
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
// 去掉标题栏
|
||||
setWindowFlags(Qt::FramelessWindowHint);
|
||||
// 根据图片构造异形窗口
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
|
||||
setMouseTracking(true);
|
||||
ui->loadingWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||
ui->videoWidget->setMouseTracking(true);
|
||||
ui->videoWidget->hide();
|
||||
|
||||
|
@ -145,6 +142,15 @@ void VideoForm::initUI()
|
|||
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()
|
||||
{
|
||||
//IconHelper::Instance()->SetIcon(ui->fullScrcenbtn, QChar(0xf0b2), 13);
|
||||
|
@ -212,8 +218,10 @@ void VideoForm::switchFullScreen()
|
|||
{
|
||||
if (isFullScreen()) {
|
||||
showNormal();
|
||||
showToolFrom(true);
|
||||
} else {
|
||||
showFullScreen();
|
||||
showToolFrom(false);
|
||||
showFullScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,6 +299,11 @@ void VideoForm::paintEvent(QPaintEvent *paint)
|
|||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
}
|
||||
|
||||
void VideoForm::showEvent(QShowEvent *event)
|
||||
{
|
||||
showToolFrom();
|
||||
}
|
||||
|
||||
void VideoForm::on_fullScrcenbtn_clicked()
|
||||
{
|
||||
switchFullScreen();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define VIDEOFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPointer>
|
||||
|
||||
#include "server.h"
|
||||
#include "decoder.h"
|
||||
|
@ -13,6 +14,7 @@ namespace Ui {
|
|||
class videoForm;
|
||||
}
|
||||
|
||||
class ToolForm;
|
||||
class VideoForm : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -27,6 +29,7 @@ private:
|
|||
void initStyle();
|
||||
void updateStyleSheet(bool vertical);
|
||||
void initUI();
|
||||
void showToolFrom(bool show = true);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
@ -37,6 +40,7 @@ protected:
|
|||
void keyReleaseEvent(QKeyEvent *event);
|
||||
|
||||
void paintEvent(QPaintEvent *);
|
||||
void showEvent(QShowEvent *event);
|
||||
|
||||
private slots:
|
||||
void on_fullScrcenbtn_clicked();
|
||||
|
@ -51,9 +55,9 @@ private:
|
|||
//InputConvertNormal m_inputConvert;
|
||||
InputConvertGame m_inputConvert;
|
||||
QString m_serial = "";
|
||||
|
||||
QPoint m_dragPosition;
|
||||
float m_widthHeightRatio = 0.5f;
|
||||
QPointer<ToolForm> m_toolForm;
|
||||
};
|
||||
|
||||
#endif // VIDEOFORM_H
|
||||
|
|
|
@ -59,20 +59,8 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignHCenter|Qt::AlignVCenter">
|
||||
<item>
|
||||
<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">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
|
|
Loading…
Add table
Reference in a new issue