diff --git a/QtScrcpy/toolform.cpp b/QtScrcpy/toolform.cpp index 0afd7f8..0003203 100644 --- a/QtScrcpy/toolform.cpp +++ b/QtScrcpy/toolform.cpp @@ -9,6 +9,7 @@ ToolForm::ToolForm(QWidget* adsorbWidget, AdsorbPositions adsorbPos) { ui->setupUi(this); //setWindowFlags(windowFlags() | Qt::FramelessWindowHint); + setWindowFlags(windowFlags() & ~Qt::WindowMinMaxButtonsHint); } ToolForm::~ToolForm() diff --git a/QtScrcpy/toolform.ui b/QtScrcpy/toolform.ui index fa542b9..8b195dc 100644 --- a/QtScrcpy/toolform.ui +++ b/QtScrcpy/toolform.ui @@ -6,12 +6,12 @@ 0 0 - 118 + 80 497 - Form + diff --git a/QtScrcpy/videoform.cpp b/QtScrcpy/videoform.cpp index 96992b1..e43fa8c 100644 --- a/QtScrcpy/videoform.cpp +++ b/QtScrcpy/videoform.cpp @@ -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(); diff --git a/QtScrcpy/videoform.h b/QtScrcpy/videoform.h index 1c688fd..20b7cb4 100644 --- a/QtScrcpy/videoform.h +++ b/QtScrcpy/videoform.h @@ -2,6 +2,7 @@ #define VIDEOFORM_H #include +#include #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 m_toolForm; }; #endif // VIDEOFORM_H diff --git a/QtScrcpy/videoform.ui b/QtScrcpy/videoform.ui index 79545d6..9864cc2 100644 --- a/QtScrcpy/videoform.ui +++ b/QtScrcpy/videoform.ui @@ -59,20 +59,8 @@ 0 - + - - - 170 - 170 - - - - - 170 - 170 - - false