refactor: move videoform to outside of device

This commit is contained in:
Barry 2022-05-23 09:33:36 +08:00
parent 767bb71e7a
commit ea0d55b175
15 changed files with 471 additions and 321 deletions

View file

@ -105,6 +105,13 @@ set(QC_COMMON_SOURCES
)
source_group(common FILES ${QC_COMMON_SOURCES})
# include
set(QC_INCLUDE_SOURCES
include/QtScrcpyCore.h
include/QtScrcpyCoreDef.h
)
source_group(include FILES ${QC_INCLUDE_SOURCES})
# device
set(QC_DEVICE_SOURCES
device/device.h
@ -259,6 +266,7 @@ qt5_add_translation(QC_QM_FILES ${QC_TS_FILES})
# all sources
set(QC_PROJECT_SOURCES
${QC_INCLUDE_SOURCES}
${QC_ADB_SOURCES}
${QC_COMMON_SOURCES}
${QC_DEVICE_SOURCES}

View file

@ -42,6 +42,7 @@ SOURCES += \
main.cpp
# 子工程
include ($$PWD/include/include.pri)
include ($$PWD/common/common.pri)
include ($$PWD/adb/adb.pri)
include ($$PWD/uibase/uibase.pri)

View file

@ -8,13 +8,14 @@
#include "decoder.h"
#include "device.h"
#include "filehandler.h"
#include "mousetap/mousetap.h"
#include "recorder.h"
#include "server.h"
#include "stream.h"
#include "videoform.h"
Device::Device(DeviceParams params, QObject *parent) : QObject(parent), m_params(params)
namespace qsc {
Device::Device(DeviceParams params, QObject *parent) : IDevice(parent), m_params(params)
{
if (!params.display && m_params.recordFileName.trimmed().isEmpty()) {
qCritical("not display must be recorded");
@ -23,8 +24,8 @@ Device::Device(DeviceParams params, QObject *parent) : QObject(parent), m_params
if (params.display) {
m_decoder = new Decoder([this](int width, int height, uint8_t* dataY, uint8_t* dataU, uint8_t* dataV, int linesizeY, int linesizeU, int linesizeV) {
if (m_videoForm) {
m_videoForm->updateRender(width, height, dataY, dataU, dataV, linesizeY, linesizeU, linesizeV);
for (const auto& item : m_deviceObservers) {
item->onFrame(width, height, dataY, dataU, dataV, linesizeY, linesizeU, linesizeV);
}
}, this);
m_fileHandler = new FileHandler(this);
@ -35,8 +36,6 @@ Device::Device(DeviceParams params, QObject *parent) : QObject(parent), m_params
return m_server->getControlSocket()->write(buffer.data(), buffer.length());
}, params.gameScript, this);
m_videoForm = new VideoForm(params.framelessWindow, Config::getInstance().getSkin());
m_videoForm->setDevice(this);
}
m_stream = new Stream([this](quint8 *buf, qint32 bufSize) -> qint32 {
@ -57,17 +56,27 @@ Device::Device(DeviceParams params, QObject *parent) : QObject(parent), m_params
Device::~Device()
{
disconnectDevice();
Device::disconnectDevice();
}
VideoForm *Device::getVideoForm()
void Device::setUserData(void *data)
{
return m_videoForm;
m_userData = data;
}
Server *Device::getServer()
void *Device::getUserData()
{
return m_server;
return m_userData;
}
void Device::registerDeviceObserver(DeviceObserver *observer)
{
m_deviceObservers.insert(observer);
}
void Device::deRegisterDeviceObserver(DeviceObserver *observer)
{
m_deviceObservers.erase(observer);
}
const QString &Device::getSerial()
@ -75,15 +84,6 @@ const QString &Device::getSerial()
return m_params.serial;
}
const QSize Device::frameSize()
{
QSize size;
if (!m_videoForm) {
return size;
}
return m_videoForm->frameSize();
}
void Device::updateScript(QString script)
{
if (m_controller) {
@ -119,34 +119,26 @@ void Device::showTouch(bool show)
qInfo() << getSerial() << " show touch " << (show ? "enable" : "disable");
}
bool Device::isReversePort(quint16 port)
{
if (m_server && m_server->isReverse() && port == m_server->getParams().localPort) {
return true;
}
return false;
}
void Device::initSignals()
{
if (m_controller) {
connect(m_controller, &Controller::grabCursor, this, &Device::grabCursor);
}
if (m_controller) {
/*
connect(this, &Device::postAppSwitch, m_controller, &Controller::onPostAppSwitch);
connect(this, &Device::postPower, m_controller, &Controller::onPostPower);
connect(this, &Device::postVolumeUp, m_controller, &Controller::onPostVolumeUp);
connect(this, &Device::postVolumeDown, m_controller, &Controller::onPostVolumeDown);
connect(this, &Device::postCopy, m_controller, &Controller::onCopy);
connect(this, &Device::postCut, m_controller, &Controller::onCut);
connect(this, &Device::setScreenPowerMode, m_controller, &Controller::onSetScreenPowerMode);
connect(this, &Device::expandNotificationPanel, m_controller, &Controller::onExpandNotificationPanel);
connect(this, &Device::collapsePanel, m_controller, &Controller::onCollapsePanel);
connect(this, &Device::mouseEvent, m_controller, &Controller::onMouseEvent);
connect(this, &Device::wheelEvent, m_controller, &Controller::onWheelEvent);
connect(this, &Device::keyEvent, m_controller, &Controller::onKeyEvent);
connect(this, &Device::postBackOrScreenOn, m_controller, &Controller::onPostBackOrScreenOn);
connect(this, &Device::setDeviceClipboard, m_controller, &Controller::onSetDeviceClipboard);
connect(this, &Device::clipboardPaste, m_controller, &Controller::onClipboardPaste);
connect(this, &Device::postTextInput, m_controller, &Controller::onPostTextInput);
*/
connect(m_controller, &Controller::grabCursor, this, [this](bool grab){
for (const auto& item : m_deviceObservers) {
item->grabCursor(grab);
}
});
}
if (m_fileHandler) {
connect(m_fileHandler, &FileHandler::fileHandlerResult, this, [this](FileHandler::FILE_HANDLER_RESULT processResult, bool isApk) {
connect(m_fileHandler, &FileHandler::fileHandlerResult, this, [](FileHandler::FILE_HANDLER_RESULT processResult, bool isApk) {
QString tipsType = "";
if (isApk) {
tipsType = tr("install apk");
@ -174,29 +166,6 @@ void Device::initSignals()
double diff = m_startTimeCount.elapsed() / 1000.0;
qInfo() << QString("server start finish in %1s").arg(diff).toStdString().c_str();
// update ui
if (m_videoForm) {
// must be show before updateShowSize
m_videoForm->show();
QString name = Config::getInstance().getNickName(m_params.serial);
if (name.isEmpty()) {
name = Config::getInstance().getTitle();
}
m_videoForm->setWindowTitle(name + "-" + m_params.serial);
m_videoForm->updateShowSize(size);
bool deviceVer = size.height() > size.width();
QRect rc = Config::getInstance().getRect(getSerial());
bool rcVer = rc.height() > rc.width();
// same width/height rate
if (rc.isValid() && (deviceVer == rcVer)) {
// mark: resize is for fix setGeometry magneticwidget bug
m_videoForm->resize(rc.size());
m_videoForm->setGeometry(rc);
}
}
// init recorder
if (m_recorder) {
m_recorder->setFrameSize(size);
@ -272,7 +241,11 @@ void Device::initSignals()
}
if (m_decoder) {
connect(m_decoder, &Decoder::updateFPS, m_videoForm, &VideoForm::updateFPS);
connect(m_decoder, &Decoder::updateFPS, this, [this](quint32 fps) {
for (const auto& item : m_deviceObservers) {
item->updateFPS(fps);
}
});
}
}
@ -333,10 +306,6 @@ void Device::disconnectDevice()
}
m_recorder->close();
}
if (m_videoForm) {
m_videoForm->close();
m_videoForm->deleteLater();
}
emit deviceDisconnected(m_params.serial);
}
@ -413,11 +382,17 @@ void Device::postCut()
m_controller->cut();
}
void Device::setScreenPowerMode(ControlMsg::ScreenPowerMode mode)
void Device::setScreenPowerMode(bool open)
{
if (!m_controller) {
return;
}
ControlMsg::ScreenPowerMode mode{};
if (open) {
mode = ControlMsg::SPM_NORMAL;
} else {
mode = ControlMsg::SPM_OFF;
}
m_controller->setScreenPowerMode(mode);
}
@ -517,15 +492,6 @@ void Device::keyEvent(const QKeyEvent *from, const QSize &frameSize, const QSize
m_controller->keyEvent(from, frameSize, showSize);
}
void Device::grabCursor(bool grab)
{
if (!m_videoForm) {
return;
}
QRect rc = m_videoForm->getGrabCursorRect();
MouseTap::getInstance()->enableMouseEventTap(rc, grab);
}
bool Device::isCurrentCustomKeymap()
{
if (!m_controller) {
@ -562,3 +528,5 @@ bool Device::saveFrame(int width, int height, uint8_t* dataRGB32)
qInfo() << "screenshot save to " << absFilePath;
return true;
}
}

View file

@ -1,10 +1,13 @@
#ifndef DEVICE_H
#define DEVICE_H
#include <set>
#include <QElapsedTimer>
#include <QPointer>
#include <QTime>
#include "../include/QtScrcpyCore.h"
#include "controlmsg.h"
class QMouseEvent;
@ -19,76 +22,59 @@ class Stream;
class VideoForm;
class Controller;
struct AVFrame;
class Device : public QObject
namespace qsc {
class Device : public IDevice
{
Q_OBJECT
public:
struct DeviceParams
{
QString serverLocalPath = ""; // 本地安卓server路径
QString serverRemotePath = ""; // 要推送到远端设备的server路径
QString recordFileName = ""; // 视频录制文件名
QString recordPath = ""; // 视频保存路径
QString serial = ""; // 设备序列号
quint16 localPort = 27183; // reverse时本地监听端口
quint16 maxSize = 720; // 视频分辨率
quint32 bitRate = 2000000; // 视频比特率
quint32 maxFps = 60; // 视频最大帧率
bool closeScreen = false; // 启动时自动息屏
bool useReverse = true; // true:先使用adb reverse失败后自动使用adb forwardfalse:直接使用adb forward
bool display = true; // 是否显示画面(或者仅仅后台录制)
QString gameScript = ""; // 游戏映射脚本
bool renderExpiredFrames = false; // 是否渲染延迟视频帧
int lockVideoOrientation = -1; // 是否锁定视频方向
bool stayAwake = false; // 是否保持唤醒
bool framelessWindow = false; // 是否无边框窗口
};
explicit Device(DeviceParams params, QObject *parent = nullptr);
virtual ~Device();
bool connectDevice();
void disconnectDevice();
void postGoBack();
void postGoHome();
void postGoMenu();
void postAppSwitch();
void postPower();
void postVolumeUp();
void postVolumeDown();
void postCopy();
void postCut();
void setScreenPowerMode(ControlMsg::ScreenPowerMode mode);
void expandNotificationPanel();
void collapsePanel();
void postBackOrScreenOn(bool down);
void postTextInput(QString &text);
void requestDeviceClipboard();
void setDeviceClipboard(bool pause = true);
void clipboardPaste();
void pushFileRequest(const QString &file, const QString &devicePath = "");
void installApkRequest(const QString &apkFile);
void setUserData(void* data) override;
void* getUserData() override;
void registerDeviceObserver(DeviceObserver* observer) override;
void deRegisterDeviceObserver(DeviceObserver* observer) override;
bool connectDevice() override;
void disconnectDevice() override;
// key map
void mouseEvent(const QMouseEvent *from, const QSize &frameSize, const QSize &showSize);
void wheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize);
void keyEvent(const QKeyEvent *from, const QSize &frameSize, const QSize &showSize);
void mouseEvent(const QMouseEvent *from, const QSize &frameSize, const QSize &showSize) override;
void wheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize) override;
void keyEvent(const QKeyEvent *from, const QSize &frameSize, const QSize &showSize) override;
void screenshot();
void showTouch(bool show);
void grabCursor(bool grab);
void postGoBack() override;
void postGoHome() override;
void postGoMenu() override;
void postAppSwitch() override;
void postPower() override;
void postVolumeUp() override;
void postVolumeDown() override;
void postCopy() override;
void postCut() override;
void setScreenPowerMode(bool open) override;
void expandNotificationPanel() override;
void collapsePanel() override;
void postBackOrScreenOn(bool down) override;
void postTextInput(QString &text) override;
void requestDeviceClipboard() override;
void setDeviceClipboard(bool pause = true) override;
void clipboardPaste() override;
void pushFileRequest(const QString &file, const QString &devicePath = "") override;
void installApkRequest(const QString &apkFile) override;
VideoForm *getVideoForm();
Server *getServer();
const QString &getSerial();
const QSize frameSize();
void screenshot() override;
void showTouch(bool show) override;
//void grabCursor(bool grab);
void updateScript(QString script);
bool isCurrentCustomKeymap();
bool isReversePort(quint16 port) override;
const QString &getSerial() override;
signals:
void deviceConnected(bool success, const QString& serial, const QString& deviceName, const QSize& size);
void deviceDisconnected(QString serial);
void updateScript(QString script) override;
bool isCurrentCustomKeymap() override;
private:
void initSignals();
@ -103,11 +89,12 @@ private:
QPointer<Stream> m_stream;
QPointer<Recorder> m_recorder = Q_NULLPTR;
// ui
QPointer<VideoForm> m_videoForm;
QElapsedTimer m_startTimeCount;
DeviceParams m_params;
std::set<DeviceObserver*> m_deviceObservers;
void* m_userData = nullptr;
};
}
#endif // DEVICE_H

View file

@ -6,14 +6,30 @@
#include "devicemanage.h"
#include "server.h"
#include "videoform.h"
#include "device.h"
namespace qsc {
#define DM_MAX_DEVICES_NUM 1000
DeviceManage::DeviceManage(QObject *parent) : QObject(parent) {}
IDeviceManage& IDeviceManage::getInstance() {
static DeviceManage dm;
return dm;
}
DeviceManage::DeviceManage() {}
DeviceManage::~DeviceManage() {}
bool DeviceManage::connectDevice(Device::DeviceParams params)
QPointer<IDevice> DeviceManage::getDevice(const QString &serial)
{
if (!m_devices.contains(serial)) {
return QPointer<IDevice>();
}
return m_devices[serial];
}
bool DeviceManage::connectDevice(qsc::DeviceParams params)
{
if (params.serial.trimmed().isEmpty()) {
return false;
@ -39,7 +55,7 @@ bool DeviceManage::connectDevice(Device::DeviceParams params)
}
}
*/
Device *device = new Device(params);
IDevice *device = new Device(params);
connect(device, &Device::deviceConnected, this, &DeviceManage::onDeviceConnected);
connect(device, &Device::deviceDisconnected, this, &DeviceManage::onDeviceDisconnected);
if (!device->connectDevice()) {
@ -56,7 +72,7 @@ bool DeviceManage::connectDevice(Device::DeviceParams params)
void DeviceManage::updateScript(QString script)
{
m_script = script;
QMapIterator<QString, QPointer<Device>> i(m_devices);
QMapIterator<QString, QPointer<IDevice>> i(m_devices);
while (i.hasNext()) {
i.next();
if (i.value()) {
@ -65,36 +81,6 @@ void DeviceManage::updateScript(QString script)
}
}
bool DeviceManage::staysOnTop(const QString &serial)
{
if (!serial.isEmpty() && m_devices.contains(serial)) {
auto it = m_devices.find(serial);
if (!it->data()) {
return false;
}
if (!it->data()->getVideoForm()) {
return false;
}
it->data()->getVideoForm()->staysOnTop();
}
return true;
}
void DeviceManage::showFPS(const QString &serial, bool show)
{
if (!serial.isEmpty() && m_devices.contains(serial)) {
auto it = m_devices.find(serial);
if (!it->data()) {
return;
}
if (!it->data()->getVideoForm()) {
return;
}
it->data()->getVideoForm()->showFPS(show);
}
return;
}
bool DeviceManage::disconnectDevice(const QString &serial)
{
bool ret = false;
@ -110,7 +96,7 @@ bool DeviceManage::disconnectDevice(const QString &serial)
void DeviceManage::disconnectAllDevice()
{
QMapIterator<QString, QPointer<Device>> i(m_devices);
QMapIterator<QString, QPointer<IDevice>> i(m_devices);
while (i.hasNext()) {
i.next();
if (i.value()) {
@ -121,16 +107,16 @@ void DeviceManage::disconnectAllDevice()
void DeviceManage::onDeviceConnected(bool success, const QString &serial, const QString &deviceName, const QSize &size)
{
emit deviceConnected(success, serial, deviceName, size);
if (!success) {
removeDevice(serial);
}
emit deviceConnected(success, serial, deviceName, size);
}
void DeviceManage::onDeviceDisconnected(QString serial)
{
removeDevice(serial);
emit deviceDisconnected(serial);
removeDevice(serial);
}
quint16 DeviceManage::getFreePort()
@ -138,11 +124,11 @@ quint16 DeviceManage::getFreePort()
quint16 port = m_localPortStart;
while (port < m_localPortStart + DM_MAX_DEVICES_NUM) {
bool used = false;
QMapIterator<QString, QPointer<Device>> i(m_devices);
QMapIterator<QString, QPointer<IDevice>> i(m_devices);
while (i.hasNext()) {
i.next();
auto device = i.value();
if (device && device->getServer() && device->getServer()->isReverse() && port == device->getServer()->getParams().localPort) {
if (device && device->isReversePort(port)) {
used = true;
break;
}
@ -162,3 +148,5 @@ void DeviceManage::removeDevice(const QString &serial)
m_devices.remove(serial);
}
}
}

View file

@ -4,26 +4,24 @@
#include <QMap>
#include <QPointer>
#include "device.h"
#include "../include/QtScrcpyCore.h"
class DeviceManage : public QObject
namespace qsc {
class DeviceManage : public IDeviceManage
{
Q_OBJECT
public:
explicit DeviceManage(QObject *parent = nullptr);
explicit DeviceManage();
virtual ~DeviceManage();
bool connectDevice(Device::DeviceParams params);
bool disconnectDevice(const QString &serial);
void disconnectAllDevice();
virtual QPointer<IDevice> getDevice(const QString& serial) override;
void updateScript(QString script);
bool staysOnTop(const QString &serial);
void showFPS(const QString &serial, bool show);
bool connectDevice(qsc::DeviceParams params) override;
bool disconnectDevice(const QString &serial) override;
void disconnectAllDevice() override;
signals:
void deviceConnected(bool success, const QString& serial, const QString& deviceName, const QSize& size);
void deviceDisconnected(QString serial);
void updateScript(QString script) override;
protected slots:
void onDeviceConnected(bool success, const QString& serial, const QString& deviceName, const QSize& size);
@ -34,9 +32,10 @@ private:
void removeDevice(const QString& serial);
private:
QMap<QString, QPointer<Device>> m_devices;
QMap<QString, QPointer<IDevice>> m_devices;
quint16 m_localPortStart = 27183;
QString m_script;
};
}
#endif // DEVICEMANAGE_H

View file

@ -0,0 +1,93 @@
#pragma once
#include <QMouseEvent>
#include "QtScrcpyCoreDef.h"
namespace qsc {
class DeviceObserver {
protected:
DeviceObserver() {
}
virtual ~DeviceObserver() {
}
public:
virtual void onFrame(int width, int height, uint8_t* dataY, uint8_t* dataU, uint8_t* dataV, int linesizeY, int linesizeU, int linesizeV) {}
virtual void updateFPS(quint32 fps) {}
virtual void grabCursor(bool grab) {}
};
class IDevice : public QObject {
Q_OBJECT
public:
IDevice(QObject *parent = nullptr) : QObject(parent) {}
virtual ~IDevice(){}
signals:
void deviceConnected(bool success, const QString& serial, const QString& deviceName, const QSize& size);
void deviceDisconnected(QString serial);
public:
virtual void setUserData(void* data) = 0;
virtual void* getUserData() = 0;
virtual void registerDeviceObserver(DeviceObserver* observer) = 0;
virtual void deRegisterDeviceObserver(DeviceObserver* observer) = 0;
virtual bool connectDevice() = 0;
virtual void disconnectDevice() = 0;
virtual void mouseEvent(const QMouseEvent *from, const QSize &frameSize, const QSize &showSize) = 0;
virtual void wheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize) = 0;
virtual void keyEvent(const QKeyEvent *from, const QSize &frameSize, const QSize &showSize) = 0;
virtual void postGoBack() = 0;
virtual void postGoHome() = 0;
virtual void postGoMenu() = 0;
virtual void postAppSwitch() = 0;
virtual void postPower() = 0;
virtual void postVolumeUp() = 0;
virtual void postVolumeDown() = 0;
virtual void postCopy() = 0;
virtual void postCut() = 0;
virtual void setScreenPowerMode(bool open) = 0;
virtual void expandNotificationPanel() = 0;
virtual void collapsePanel() = 0;
virtual void postBackOrScreenOn(bool down) = 0;
virtual void postTextInput(QString &text) = 0;
virtual void requestDeviceClipboard() = 0;
virtual void setDeviceClipboard(bool pause = true) = 0;
virtual void clipboardPaste() = 0;
virtual void pushFileRequest(const QString &file, const QString &devicePath = "") = 0;
virtual void installApkRequest(const QString &apkFile) = 0;
virtual void screenshot() = 0;
virtual void showTouch(bool show) = 0;
virtual bool isReversePort(quint16 port) = 0;
virtual const QString &getSerial() = 0;
virtual void updateScript(QString script) = 0;
virtual bool isCurrentCustomKeymap() = 0;
};
class IDeviceManage : public QObject {
Q_OBJECT
public:
static IDeviceManage& getInstance();
virtual QPointer<IDevice> getDevice(const QString& serial) = 0;
virtual bool connectDevice(DeviceParams params) = 0;
virtual bool disconnectDevice(const QString &serial) = 0;
virtual void disconnectAllDevice() = 0;
virtual void updateScript(QString script) = 0;
signals:
void deviceConnected(bool success, const QString& serial, const QString& deviceName, const QSize& size);
void deviceDisconnected(QString serial);
};
}

View file

@ -0,0 +1,26 @@
#pragma once
#include <QString>
namespace qsc {
struct DeviceParams {
QString serverLocalPath = ""; // 本地安卓server路径
QString serverRemotePath = ""; // 要推送到远端设备的server路径
QString recordFileName = ""; // 视频录制文件名
QString recordPath = ""; // 视频保存路径
QString serial = ""; // 设备序列号
quint16 localPort = 27183; // reverse时本地监听端口
quint16 maxSize = 720; // 视频分辨率
quint32 bitRate = 2000000; // 视频比特率
quint32 maxFps = 60; // 视频最大帧率
bool closeScreen = false; // 启动时自动息屏
bool useReverse = true; // true:先使用adb reverse失败后自动使用adb forwardfalse:直接使用adb forward
bool display = true; // 是否显示画面(或者仅仅后台录制)
QString gameScript = ""; // 游戏映射脚本
bool renderExpiredFrames = false; // 是否渲染延迟视频帧
int lockVideoOrientation = -1; // 是否锁定视频方向
bool stayAwake = false; // 是否保持唤醒
bool framelessWindow = false; // 是否无边框窗口
};
}

View file

@ -0,0 +1,3 @@
HEADERS += \
$$PWD/QtScrcpyCore.h \
$$PWD/QtScrcpyCoreDef.h

View file

@ -95,15 +95,15 @@ Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog)
});
connect(m_hideIcon, &QSystemTrayIcon::activated, this, &Dialog::slotActivated);
connect(&m_deviceManage, &DeviceManage::deviceConnected, this, &Dialog::onDeviceConnected);
connect(&m_deviceManage, &DeviceManage::deviceDisconnected, this, &Dialog::onDeviceDisconnected);
connect(&qsc::IDeviceManage::getInstance(), &qsc::IDeviceManage::deviceConnected, this, &Dialog::onDeviceConnected);
connect(&qsc::IDeviceManage::getInstance(), &qsc::IDeviceManage::deviceDisconnected, this, &Dialog::onDeviceDisconnected);
}
Dialog::~Dialog()
{
qDebug() << "~Dialog()";
updateBootConfig(false);
m_deviceManage.disconnectAllDevice();
qsc::IDeviceManage::getInstance().disconnectAllDevice();
delete ui;
}
@ -280,7 +280,7 @@ void Dialog::on_startServerBtn_clicked()
// this is ok that "native" toUshort is 0
quint16 videoSize = ui->maxSizeBox->currentText().trimmed().toUShort();
Device::DeviceParams params;
qsc::DeviceParams params;
params.serial = ui->serialBox->currentText().trimmed();
params.maxSize = videoSize;
params.bitRate = getBitRate();
@ -298,17 +298,12 @@ void Dialog::on_startServerBtn_clicked()
params.serverLocalPath = getServerPath();
params.serverRemotePath = Config::getInstance().getServerPath();
m_deviceManage.connectDevice(params);
if (ui->alwaysTopCheck->isChecked()) {
m_deviceManage.staysOnTop(params.serial);
}
m_deviceManage.showFPS(params.serial, ui->fpsCheck->isChecked());
qsc::IDeviceManage::getInstance().connectDevice(params);
}
void Dialog::on_stopServerBtn_clicked()
{
if (m_deviceManage.disconnectDevice(ui->serialBox->currentText().trimmed())) {
if (qsc::IDeviceManage::getInstance().disconnectDevice(ui->serialBox->currentText().trimmed())) {
outLog("stop server");
}
}
@ -423,12 +418,51 @@ void Dialog::getIPbyIp()
void Dialog::onDeviceConnected(bool success, const QString &serial, const QString &deviceName, const QSize &size)
{
if (!success) {
return;
}
auto videoForm = new VideoForm(ui->framelessCheck->isChecked(), Config::getInstance().getSkin());
videoForm->setSerial(serial);
qsc::IDeviceManage::getInstance().getDevice(serial)->setUserData(static_cast<void*>(videoForm));
qsc::IDeviceManage::getInstance().getDevice(serial)->registerDeviceObserver(videoForm);
videoForm->showFPS(ui->fpsCheck->isChecked());
if (ui->alwaysTopCheck->isChecked()) {
videoForm->staysOnTop();
}
// must be show before updateShowSize
videoForm->show();
QString name = Config::getInstance().getNickName(serial);
if (name.isEmpty()) {
name = Config::getInstance().getTitle();
}
videoForm->setWindowTitle(name + "-" + serial);
videoForm->updateShowSize(size);
bool deviceVer = size.height() > size.width();
QRect rc = Config::getInstance().getRect(serial);
bool rcVer = rc.height() > rc.width();
// same width/height rate
if (rc.isValid() && (deviceVer == rcVer)) {
// mark: resize is for fix setGeometry magneticwidget bug
videoForm->resize(rc.size());
videoForm->setGeometry(rc);
}
}
void Dialog::onDeviceDisconnected(QString serial)
{
auto data = qsc::IDeviceManage::getInstance().getDevice(serial)->getUserData();
if (data) {
VideoForm* vf = static_cast<VideoForm*>(data);
qsc::IDeviceManage::getInstance().getDevice(serial)->deRegisterDeviceObserver(vf);
vf->close();
vf->deleteLater();
}
}
void Dialog::on_wirelessDisConnectBtn_clicked()
@ -474,7 +508,7 @@ void Dialog::on_clearOut_clicked()
void Dialog::on_stopAllServerBtn_clicked()
{
m_deviceManage.disconnectAllDevice();
qsc::IDeviceManage::getInstance().disconnectAllDevice();
}
void Dialog::on_refreshGameScriptBtn_clicked()
@ -497,7 +531,7 @@ void Dialog::on_refreshGameScriptBtn_clicked()
void Dialog::on_applyScriptBtn_clicked()
{
m_deviceManage.updateScript(getGameScript(ui->gameBox->currentText()));
qsc::IDeviceManage::getInstance().updateScript(getGameScript(ui->gameBox->currentText()));
}
void Dialog::on_recordScreenCheck_clicked(bool checked)

View file

@ -10,7 +10,7 @@
#include "adbprocess.h"
#include "devicemanage.h"
#include "../include/QtScrcpyCore.h"
namespace Ui
{
@ -76,7 +76,6 @@ protected:
private:
Ui::Dialog *ui;
AdbProcess m_adb;
DeviceManage m_deviceManage;
QSystemTrayIcon *m_hideIcon;
QMenu *m_menu;
QAction *m_showWindow;

View file

@ -3,7 +3,6 @@
#include <QMouseEvent>
#include <QShowEvent>
#include "device.h"
#include "iconhelper.h"
#include "toolform.h"
#include "ui_toolform.h"
@ -23,12 +22,9 @@ ToolForm::~ToolForm()
delete ui;
}
void ToolForm::setDevice(Device *device)
void ToolForm::setSerial(const QString &serial)
{
if (!device) {
return;
}
m_device = device;
m_serial = serial;
}
void ToolForm::initStyle()
@ -52,7 +48,8 @@ void ToolForm::initStyle()
void ToolForm::updateGroupControl()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
}
@ -92,7 +89,8 @@ void ToolForm::hideEvent(QHideEvent *event)
void ToolForm::on_fullScreenBtn_clicked()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
@ -101,105 +99,115 @@ void ToolForm::on_fullScreenBtn_clicked()
void ToolForm::on_returnBtn_clicked()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
m_device->postGoBack();
device->postGoBack();
}
void ToolForm::on_homeBtn_clicked()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
m_device->postGoHome();
device->postGoHome();
}
void ToolForm::on_menuBtn_clicked()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
m_device->postGoMenu();
device->postGoMenu();
}
void ToolForm::on_appSwitchBtn_clicked()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->postAppSwitch();
emit device->postAppSwitch();
}
void ToolForm::on_powerBtn_clicked()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->postPower();
emit device->postPower();
}
void ToolForm::on_screenShotBtn_clicked()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
m_device->screenshot();
device->screenshot();
}
void ToolForm::on_volumeUpBtn_clicked()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->postVolumeUp();
emit device->postVolumeUp();
}
void ToolForm::on_volumeDownBtn_clicked()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->postVolumeDown();
emit device->postVolumeDown();
}
void ToolForm::on_closeScreenBtn_clicked()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->setScreenPowerMode(ControlMsg::SPM_OFF);
emit device->setScreenPowerMode(false);
}
void ToolForm::on_expandNotifyBtn_clicked()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->expandNotificationPanel();
emit device->expandNotificationPanel();
}
void ToolForm::on_touchBtn_clicked()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
m_showTouch = !m_showTouch;
m_device->showTouch(m_showTouch);
device->showTouch(m_showTouch);
}
void ToolForm::on_groupControlBtn_clicked()
{
if (!m_device) {
return;
}
}
void ToolForm::on_openScreenBtn_clicked()
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->setScreenPowerMode(ControlMsg::SPM_NORMAL);
emit device->setScreenPowerMode(true);
}

View file

@ -4,7 +4,7 @@
#include <QPointer>
#include <QWidget>
#include "device.h"
#include "../include/QtScrcpyCore.h"
#include "magneticwidget.h"
namespace Ui
@ -21,7 +21,7 @@ public:
explicit ToolForm(QWidget *adsorbWidget, AdsorbPositions adsorbPos);
~ToolForm();
void setDevice(Device *device);
void setSerial(const QString& serial);
protected:
void mousePressEvent(QMouseEvent *event);
@ -54,7 +54,7 @@ private:
private:
Ui::ToolForm *ui;
QPoint m_dragPosition;
QPointer<Device> m_device;
QString m_serial;
bool m_showTouch = false;
};

View file

@ -15,10 +15,10 @@
#include "config.h"
#include "controller.h"
#include "device.h"
#include "iconhelper.h"
#include "qyuvopenglwidget.h"
#include "toolform.h"
#include "mousetap/mousetap.h"
#include "ui_videoform.h"
#include "videoform.h"
extern "C"
@ -161,11 +161,16 @@ void VideoForm::updateRender(int width, int height, uint8_t* dataY, uint8_t* dat
m_videoWidget->updateTextures(dataY, dataU, dataV, linesizeY, linesizeU, linesizeV);
}
void VideoForm::setSerial(const QString &serial)
{
m_serial = serial;
}
void VideoForm::showToolForm(bool show)
{
if (!m_toolForm) {
m_toolForm = new ToolForm(this, ToolForm::AP_OUTSIDE_RIGHT);
m_toolForm->setDevice(m_device);
m_toolForm->setSerial(m_serial);
}
m_toolForm->move(pos().x() + geometry().width(), pos().y() + 30);
m_toolForm->setVisible(show);
@ -190,7 +195,8 @@ void VideoForm::installShortcut()
shortcut = new QShortcut(QKeySequence("Ctrl+f"), this);
shortcut->setAutoRepeat(false);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
switchFullScreen();
@ -210,138 +216,152 @@ void VideoForm::installShortcut()
shortcut = new QShortcut(QKeySequence("Ctrl+h"), this);
shortcut->setAutoRepeat(false);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
m_device->postGoHome();
device->postGoHome();
});
// postGoBack
shortcut = new QShortcut(QKeySequence("Ctrl+b"), this);
shortcut->setAutoRepeat(false);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
m_device->postGoBack();
device->postGoBack();
});
// postAppSwitch
shortcut = new QShortcut(QKeySequence("Ctrl+s"), this);
shortcut->setAutoRepeat(false);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->postAppSwitch();
emit device->postAppSwitch();
});
// postGoMenu
shortcut = new QShortcut(QKeySequence("Ctrl+m"), this);
shortcut->setAutoRepeat(false);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
m_device->postGoMenu();
device->postGoMenu();
});
// postVolumeUp
shortcut = new QShortcut(QKeySequence("Ctrl+up"), this);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->postVolumeUp();
emit device->postVolumeUp();
});
// postVolumeDown
shortcut = new QShortcut(QKeySequence("Ctrl+down"), this);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->postVolumeDown();
emit device->postVolumeDown();
});
// postPower
shortcut = new QShortcut(QKeySequence("Ctrl+p"), this);
shortcut->setAutoRepeat(false);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->postPower();
emit device->postPower();
});
// setScreenPowerMode(ControlMsg::SPM_OFF)
shortcut = new QShortcut(QKeySequence("Ctrl+o"), this);
shortcut->setAutoRepeat(false);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->setScreenPowerMode(ControlMsg::SPM_OFF);
emit device->setScreenPowerMode(ControlMsg::SPM_OFF);
});
// expandNotificationPanel
shortcut = new QShortcut(QKeySequence("Ctrl+n"), this);
shortcut->setAutoRepeat(false);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->expandNotificationPanel();
emit device->expandNotificationPanel();
});
// collapsePanel
shortcut = new QShortcut(QKeySequence("Ctrl+Shift+n"), this);
shortcut->setAutoRepeat(false);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->collapsePanel();
emit device->collapsePanel();
});
// copy
shortcut = new QShortcut(QKeySequence("Ctrl+c"), this);
shortcut->setAutoRepeat(false);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->postCopy();
emit device->postCopy();
});
// cut
shortcut = new QShortcut(QKeySequence("Ctrl+x"), this);
shortcut->setAutoRepeat(false);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->postCut();
emit device->postCut();
});
// clipboardPaste
shortcut = new QShortcut(QKeySequence("Ctrl+v"), this);
shortcut->setAutoRepeat(false);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->setDeviceClipboard();
emit device->setDeviceClipboard();
});
// setDeviceClipboard
shortcut = new QShortcut(QKeySequence("Ctrl+Shift+v"), this);
shortcut->setAutoRepeat(false);
connect(shortcut, &QShortcut::activated, this, [this]() {
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->clipboardPaste();
emit device->clipboardPaste();
});
}
@ -420,7 +440,7 @@ void VideoForm::updateShowSize(const QSize &newSize)
showSize.setHeight(showSize.width() / m_widthHeightRatio);
}
if (isFullScreen() && m_device) {
if (isFullScreen() && qsc::IDeviceManage::getInstance().getDevice(m_serial)) {
switchFullScreen();
}
@ -501,6 +521,17 @@ void VideoForm::updateFPS(quint32 fps)
m_fpsLabel->setText(QString("FPS:%1").arg(fps));
}
void VideoForm::grabCursor(bool grab)
{
QRect rc = getGrabCursorRect();
MouseTap::getInstance()->enableMouseEventTap(rc, grab);
}
void VideoForm::onFrame(int width, int height, uint8_t *dataY, uint8_t *dataU, uint8_t *dataV, int linesizeY, int linesizeU, int linesizeV)
{
updateRender(width, height, dataY, dataU, dataV, linesizeY, linesizeU, linesizeV);
}
void VideoForm::staysOnTop(bool top)
{
bool needShow = false;
@ -516,33 +547,29 @@ void VideoForm::staysOnTop(bool top)
}
}
void VideoForm::setDevice(Device *device)
{
m_device = device;
}
void VideoForm::mousePressEvent(QMouseEvent *event)
{
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (event->button() == Qt::MiddleButton) {
if (m_device && !m_device->isCurrentCustomKeymap()) {
m_device->postGoHome();
if (device && !device->isCurrentCustomKeymap()) {
device->postGoHome();
return;
}
}
if (event->button() == Qt::RightButton) {
if (m_device && !m_device->isCurrentCustomKeymap()) {
m_device->postGoBack();
if (device && !device->isCurrentCustomKeymap()) {
device->postGoBack();
return;
}
}
if (m_videoWidget->geometry().contains(event->pos())) {
if (!m_device) {
if (!device) {
return;
}
event->setLocalPos(m_videoWidget->mapFrom(this, event->localPos().toPoint()));
emit m_device->mouseEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
emit device->mouseEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
// debug keymap pos
if (event->button() == Qt::LeftButton) {
@ -561,8 +588,9 @@ void VideoForm::mousePressEvent(QMouseEvent *event)
void VideoForm::mouseReleaseEvent(QMouseEvent *event)
{
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (m_dragPosition.isNull()) {
if (!m_device) {
if (!device) {
return;
}
event->setLocalPos(m_videoWidget->mapFrom(this, event->localPos().toPoint()));
@ -581,7 +609,7 @@ void VideoForm::mouseReleaseEvent(QMouseEvent *event)
local.setY(m_videoWidget->height());
}
event->setLocalPos(local);
emit m_device->mouseEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
emit device->mouseEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
} else {
m_dragPosition = QPoint(0, 0);
}
@ -589,12 +617,13 @@ void VideoForm::mouseReleaseEvent(QMouseEvent *event)
void VideoForm::mouseMoveEvent(QMouseEvent *event)
{
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (m_videoWidget->geometry().contains(event->pos())) {
if (!m_device) {
if (!device) {
return;
}
event->setLocalPos(m_videoWidget->mapFrom(this, event->localPos().toPoint()));
emit m_device->mouseEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
emit device->mouseEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
} else if (!m_dragPosition.isNull()) {
if (event->buttons() & Qt::LeftButton) {
move(event->globalPos() - m_dragPosition);
@ -605,30 +634,32 @@ void VideoForm::mouseMoveEvent(QMouseEvent *event)
void VideoForm::mouseDoubleClickEvent(QMouseEvent *event)
{
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (event->button() == Qt::LeftButton && !m_videoWidget->geometry().contains(event->pos())) {
if (!isMaximized()) {
removeBlackRect();
}
}
if (event->button() == Qt::RightButton && m_device && !m_device->isCurrentCustomKeymap()) {
emit m_device->postBackOrScreenOn(event->type() == QEvent::MouseButtonPress);
if (event->button() == Qt::RightButton && device && !device->isCurrentCustomKeymap()) {
emit device->postBackOrScreenOn(event->type() == QEvent::MouseButtonPress);
}
if (m_videoWidget->geometry().contains(event->pos())) {
if (!m_device) {
if (!device) {
return;
}
event->setLocalPos(m_videoWidget->mapFrom(this, event->localPos().toPoint()));
emit m_device->mouseEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
emit device->mouseEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
}
}
void VideoForm::wheelEvent(QWheelEvent *event)
{
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
if (m_videoWidget->geometry().contains(event->position().toPoint())) {
if (!m_device) {
if (!device) {
return;
}
QPointF pos = m_videoWidget->mapFrom(this, event->position().toPoint());
@ -636,7 +667,7 @@ void VideoForm::wheelEvent(QWheelEvent *event)
pos, event->globalPosition(), event->pixelDelta(), event->angleDelta(), event->buttons(), event->modifiers(), event->phase(), event->inverted());
#else
if (m_videoWidget->geometry().contains(event->pos())) {
if (!m_device) {
if (!device) {
return;
}
QPointF pos = m_videoWidget->mapFrom(this, event->pos());
@ -645,28 +676,30 @@ void VideoForm::wheelEvent(QWheelEvent *event)
pos, event->globalPosF(), event->pixelDelta(), event->angleDelta(), event->delta(), event->orientation(),
event->buttons(), event->modifiers(), event->phase(), event->source(), event->inverted());
#endif
emit m_device->wheelEvent(&wheelEvent, m_videoWidget->frameSize(), m_videoWidget->size());
emit device->wheelEvent(&wheelEvent, m_videoWidget->frameSize(), m_videoWidget->size());
}
}
void VideoForm::keyPressEvent(QKeyEvent *event)
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
if (Qt::Key_Escape == event->key() && !event->isAutoRepeat() && isFullScreen()) {
switchFullScreen();
}
emit m_device->keyEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
emit device->keyEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
}
void VideoForm::keyReleaseEvent(QKeyEvent *event)
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
emit m_device->keyEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
emit device->keyEvent(event, m_videoWidget->frameSize(), m_videoWidget->size());
}
void VideoForm::paintEvent(QPaintEvent *paint)
@ -715,11 +748,12 @@ void VideoForm::resizeEvent(QResizeEvent *event)
void VideoForm::closeEvent(QCloseEvent *event)
{
Q_UNUSED(event)
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
Config::getInstance().setRect(m_device->getSerial(), geometry());
m_device->disconnectDevice();
Config::getInstance().setRect(device->getSerial(), geometry());
device->disconnectDevice();
}
void VideoForm::dragEnterEvent(QDragEnterEvent *event)
@ -739,7 +773,8 @@ void VideoForm::dragLeaveEvent(QDragLeaveEvent *event)
void VideoForm::dropEvent(QDropEvent *event)
{
if (!m_device) {
auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial);
if (!device) {
return;
}
const QMimeData *qm = event->mimeData();
@ -755,9 +790,9 @@ void VideoForm::dropEvent(QDropEvent *event)
}
if (fileInfo.isFile() && fileInfo.suffix() == "apk") {
emit m_device->installApkRequest(file);
emit device->installApkRequest(file);
continue;
}
emit m_device->pushFileRequest(file, Config::getInstance().getPushFilePath() + fileInfo.fileName());
emit device->pushFileRequest(file, Config::getInstance().getPushFilePath() + fileInfo.fileName());
}
}

View file

@ -4,17 +4,18 @@
#include <QPointer>
#include <QWidget>
#include "../include/QtScrcpyCore.h"
namespace Ui
{
class videoForm;
}
class ToolForm;
class Device;
class FileHandler;
class QYUVOpenGLWidget;
class QLabel;
class VideoForm : public QWidget
class VideoForm : public QWidget, public qsc::DeviceObserver
{
Q_OBJECT
public:
@ -24,7 +25,7 @@ public:
void staysOnTop(bool top = true);
void updateShowSize(const QSize &newSize);
void updateRender(int width, int height, uint8_t* dataY, uint8_t* dataU, uint8_t* dataV, int linesizeY, int linesizeU, int linesizeV);
void setDevice(Device *device);
void setSerial(const QString& serial);
QRect getGrabCursorRect();
const QSize &frameSize();
void resizeSquare();
@ -32,10 +33,12 @@ public:
void showFPS(bool show);
void switchFullScreen();
public slots:
void updateFPS(quint32 fps);
private:
void onFrame(int width, int height, uint8_t* dataY, uint8_t* dataU, uint8_t* dataV,
int linesizeY, int linesizeU, int linesizeV) override;
void updateFPS(quint32 fps) override;
void grabCursor(bool grab) override;
void updateStyleSheet(bool vertical);
QMargins getMargins(bool vertical);
void initUI();
@ -78,9 +81,7 @@ private:
float m_widthHeightRatio = 0.5f;
bool m_skin = true;
QPoint m_fullScreenBeforePos;
//outside member
QPointer<Device> m_device;
QString m_serial;
};
#endif // VIDEOFORM_H