diff --git a/QtScrcpy/CMakeLists.txt b/QtScrcpy/CMakeLists.txt index 97f6943..b21a9ba 100755 --- a/QtScrcpy/CMakeLists.txt +++ b/QtScrcpy/CMakeLists.txt @@ -124,6 +124,13 @@ set(QC_UI_SOURCES ) source_group(ui FILES ${QC_UI_SOURCES}) +# group controller +set(QC_GROUP_CONTROLLER + groupcontroller/groupcontroller.h + groupcontroller/groupcontroller.cpp +) +source_group(groupcontroller FILES ${QC_GROUP_CONTROLLER}) + # util set(QC_UTIL_SOURCES util/config.h @@ -196,6 +203,7 @@ set(QC_PROJECT_SOURCES ${QC_UI_SOURCES} ${QC_UTIL_SOURCES} ${QC_MAIN_SOURCES} + ${QC_GROUP_CONTROLLER} ${QC_PLANTFORM_SOURCES} ) diff --git a/QtScrcpy/QtScrcpyCore/include/QtScrcpyCore.h b/QtScrcpy/QtScrcpyCore/include/QtScrcpyCore.h index 551d135..c27ab4e 100644 --- a/QtScrcpy/QtScrcpyCore/include/QtScrcpyCore.h +++ b/QtScrcpy/QtScrcpyCore/include/QtScrcpyCore.h @@ -27,6 +27,47 @@ public: } virtual void updateFPS(quint32 fps) { Q_UNUSED(fps); } virtual void grabCursor(bool grab) {Q_UNUSED(grab);} + + virtual void mouseEvent(const QMouseEvent *from, const QSize &frameSize, const QSize &showSize) { + Q_UNUSED(from); + Q_UNUSED(frameSize); + Q_UNUSED(showSize); + } + virtual void wheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize) { + Q_UNUSED(from); + Q_UNUSED(frameSize); + Q_UNUSED(showSize); + } + virtual void keyEvent(const QKeyEvent *from, const QSize &frameSize, const QSize &showSize) { + Q_UNUSED(from); + Q_UNUSED(frameSize); + Q_UNUSED(showSize); + } + + virtual void postGoBack() {} + virtual void postGoHome() {} + virtual void postGoMenu() {} + virtual void postAppSwitch() {} + virtual void postPower() {} + virtual void postVolumeUp() {} + virtual void postVolumeDown() {} + virtual void postCopy() {} + virtual void postCut() {} + virtual void setScreenPowerMode(bool open) { Q_UNUSED(open); } + virtual void expandNotificationPanel() {} + virtual void collapsePanel() {} + virtual void postBackOrScreenOn(bool down) { Q_UNUSED(down); } + virtual void postTextInput(QString &text) { Q_UNUSED(text); } + virtual void requestDeviceClipboard() {} + virtual void setDeviceClipboard(bool pause = true) { Q_UNUSED(pause); } + virtual void clipboardPaste() {} + virtual void pushFileRequest(const QString &file, const QString &devicePath) { + Q_UNUSED(file); + Q_UNUSED(devicePath); + } + virtual void installApkRequest(const QString &apkFile) { Q_UNUSED(apkFile); } + virtual void screenshot() {} + virtual void showTouch(bool show) { Q_UNUSED(show); } }; class IDevice : public QObject { diff --git a/QtScrcpy/QtScrcpyCore/src/device/device.cpp b/QtScrcpy/QtScrcpyCore/src/device/device.cpp index bfcf87c..7938606 100644 --- a/QtScrcpy/QtScrcpyCore/src/device/device.cpp +++ b/QtScrcpy/QtScrcpyCore/src/device/device.cpp @@ -328,6 +328,10 @@ void Device::postGoBack() return; } m_controller->postGoBack(); + + for (const auto& item : m_deviceObservers) { + item->postGoBack(); + } } void Device::postGoHome() @@ -336,6 +340,10 @@ void Device::postGoHome() return; } m_controller->postGoHome(); + + for (const auto& item : m_deviceObservers) { + item->postGoHome(); + } } void Device::postGoMenu() @@ -344,6 +352,10 @@ void Device::postGoMenu() return; } m_controller->postGoMenu(); + + for (const auto& item : m_deviceObservers) { + item->postGoMenu(); + } } void Device::postAppSwitch() @@ -352,6 +364,10 @@ void Device::postAppSwitch() return; } m_controller->postAppSwitch(); + + for (const auto& item : m_deviceObservers) { + item->postAppSwitch(); + } } void Device::postPower() @@ -360,6 +376,10 @@ void Device::postPower() return; } m_controller->postPower(); + + for (const auto& item : m_deviceObservers) { + item->postPower(); + } } void Device::postVolumeUp() @@ -368,6 +388,10 @@ void Device::postVolumeUp() return; } m_controller->postVolumeUp(); + + for (const auto& item : m_deviceObservers) { + item->postVolumeUp(); + } } void Device::postVolumeDown() @@ -376,6 +400,10 @@ void Device::postVolumeDown() return; } m_controller->postVolumeDown(); + + for (const auto& item : m_deviceObservers) { + item->postVolumeDown(); + } } void Device::postCopy() @@ -384,6 +412,10 @@ void Device::postCopy() return; } m_controller->copy(); + + for (const auto& item : m_deviceObservers) { + item->postCopy(); + } } void Device::postCut() @@ -392,6 +424,10 @@ void Device::postCut() return; } m_controller->cut(); + + for (const auto& item : m_deviceObservers) { + item->postCut(); + } } void Device::setScreenPowerMode(bool open) @@ -406,6 +442,10 @@ void Device::setScreenPowerMode(bool open) mode = ControlMsg::SPM_OFF; } m_controller->setScreenPowerMode(mode); + + for (const auto& item : m_deviceObservers) { + item->setScreenPowerMode(open); + } } void Device::expandNotificationPanel() @@ -414,6 +454,10 @@ void Device::expandNotificationPanel() return; } m_controller->expandNotificationPanel(); + + for (const auto& item : m_deviceObservers) { + item->expandNotificationPanel(); + } } void Device::collapsePanel() @@ -422,6 +466,10 @@ void Device::collapsePanel() return; } m_controller->collapsePanel(); + + for (const auto& item : m_deviceObservers) { + item->collapsePanel(); + } } void Device::postBackOrScreenOn(bool down) @@ -430,6 +478,10 @@ void Device::postBackOrScreenOn(bool down) return; } m_controller->postBackOrScreenOn(down); + + for (const auto& item : m_deviceObservers) { + item->postBackOrScreenOn(down); + } } void Device::postTextInput(QString &text) @@ -438,6 +490,10 @@ void Device::postTextInput(QString &text) return; } m_controller->postTextInput(text); + + for (const auto& item : m_deviceObservers) { + item->postTextInput(text); + } } void Device::requestDeviceClipboard() @@ -446,6 +502,10 @@ void Device::requestDeviceClipboard() return; } m_controller->requestDeviceClipboard(); + + for (const auto& item : m_deviceObservers) { + item->requestDeviceClipboard(); + } } void Device::setDeviceClipboard(bool pause) @@ -454,6 +514,10 @@ void Device::setDeviceClipboard(bool pause) return; } m_controller->setDeviceClipboard(pause); + + for (const auto& item : m_deviceObservers) { + item->setDeviceClipboard(pause); + } } void Device::clipboardPaste() @@ -462,6 +526,10 @@ void Device::clipboardPaste() return; } m_controller->clipboardPaste(); + + for (const auto& item : m_deviceObservers) { + item->clipboardPaste(); + } } void Device::pushFileRequest(const QString &file, const QString &devicePath) @@ -470,6 +538,10 @@ void Device::pushFileRequest(const QString &file, const QString &devicePath) return; } m_fileHandler->onPushFileRequest(getSerial(), file, devicePath); + + for (const auto& item : m_deviceObservers) { + item->pushFileRequest(file, devicePath); + } } void Device::installApkRequest(const QString &apkFile) @@ -478,6 +550,10 @@ void Device::installApkRequest(const QString &apkFile) return; } m_fileHandler->onInstallApkRequest(getSerial(), apkFile); + + for (const auto& item : m_deviceObservers) { + item->installApkRequest(apkFile); + } } void Device::mouseEvent(const QMouseEvent *from, const QSize &frameSize, const QSize &showSize) @@ -486,6 +562,10 @@ void Device::mouseEvent(const QMouseEvent *from, const QSize &frameSize, const Q return; } m_controller->mouseEvent(from, frameSize, showSize); + + for (const auto& item : m_deviceObservers) { + item->mouseEvent(from, frameSize, showSize); + } } void Device::wheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize) @@ -494,6 +574,10 @@ void Device::wheelEvent(const QWheelEvent *from, const QSize &frameSize, const Q return; } m_controller->wheelEvent(from, frameSize, showSize); + + for (const auto& item : m_deviceObservers) { + item->wheelEvent(from, frameSize, showSize); + } } void Device::keyEvent(const QKeyEvent *from, const QSize &frameSize, const QSize &showSize) @@ -502,6 +586,10 @@ void Device::keyEvent(const QKeyEvent *from, const QSize &frameSize, const QSize return; } m_controller->keyEvent(from, frameSize, showSize); + + for (const auto& item : m_deviceObservers) { + item->keyEvent(from, frameSize, showSize); + } } bool Device::isCurrentCustomKeymap() diff --git a/QtScrcpy/QtScrcpyCore/src/device/device.h b/QtScrcpy/QtScrcpyCore/src/device/device.h index 492728c..835fa64 100644 --- a/QtScrcpy/QtScrcpyCore/src/device/device.h +++ b/QtScrcpy/QtScrcpyCore/src/device/device.h @@ -68,7 +68,6 @@ public: void screenshot() override; void showTouch(bool show) override; - //void grabCursor(bool grab); bool isReversePort(quint16 port) override; const QString &getSerial() override; diff --git a/QtScrcpy/groupcontroller/groupcontroller.cpp b/QtScrcpy/groupcontroller/groupcontroller.cpp new file mode 100644 index 0000000..23393f1 --- /dev/null +++ b/QtScrcpy/groupcontroller/groupcontroller.cpp @@ -0,0 +1,440 @@ +#include + +#include "groupcontroller.h" +#include "videoform.h" + +GroupController::GroupController(QObject *parent) : QObject(parent) +{ + +} + +bool GroupController::isHost(const QString &serial) +{ + auto data = qsc::IDeviceManage::getInstance().getDevice(serial)->getUserData(); + if (!data) { + return true; + } + + return static_cast(data)->isHost(); +} + +QSize GroupController::getFrameSize(const QString &serial) +{ + auto data = qsc::IDeviceManage::getInstance().getDevice(serial)->getUserData(); + if (!data) { + return QSize(); + } + + return static_cast(data)->frameSize(); +} + +GroupController &GroupController::instance() +{ + static GroupController gc; + return gc; +} + +void GroupController::updateDeviceState(const QString &serial) +{ + if (!m_devices.contains(serial)) { + return; + } + + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + return; + } + + if (isHost(serial)) { + device->registerDeviceObserver(this); + } else { + device->deRegisterDeviceObserver(this); + } +} + +void GroupController::addDevice(const QString &serial) +{ + if (m_devices.contains(serial)) { + return; + } + + m_devices.append(serial); +} + +void GroupController::removeDevice(const QString &serial) +{ + if (!m_devices.contains(serial)) { + return; + } + + m_devices.removeOne(serial); + + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + return; + } + + if (isHost(serial)) { + device->deRegisterDeviceObserver(this); + } +} + +void GroupController::mouseEvent(const QMouseEvent *from, const QSize &frameSize, const QSize &showSize) +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->mouseEvent(from, getFrameSize(serial), showSize); + } +} + +void GroupController::wheelEvent(const QWheelEvent *from, const QSize &frameSize, const QSize &showSize) +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->wheelEvent(from, getFrameSize(serial), showSize); + } +} + +void GroupController::keyEvent(const QKeyEvent *from, const QSize &frameSize, const QSize &showSize) +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->keyEvent(from, getFrameSize(serial), showSize); + } +} + +void GroupController::postGoBack() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->postGoBack(); + } +} + +void GroupController::postGoHome() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->postGoHome(); + } +} + +void GroupController::postGoMenu() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->postGoMenu(); + } +} + +void GroupController::postAppSwitch() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->postAppSwitch(); + } +} + +void GroupController::postPower() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->postPower(); + } +} + +void GroupController::postVolumeUp() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->postVolumeUp(); + } +} + +void GroupController::postVolumeDown() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->postVolumeDown(); + } +} + +void GroupController::postCopy() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->postCopy(); + } +} + +void GroupController::postCut() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->postCut(); + } +} + +void GroupController::setScreenPowerMode(bool open) +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->setScreenPowerMode(open); + } +} + +void GroupController::expandNotificationPanel() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->expandNotificationPanel(); + } +} + +void GroupController::collapsePanel() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->collapsePanel(); + } +} + +void GroupController::postBackOrScreenOn(bool down) +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->postBackOrScreenOn(down); + } +} + +void GroupController::postTextInput(QString &text) +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->postTextInput(text); + } +} + +void GroupController::requestDeviceClipboard() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->requestDeviceClipboard(); + } +} + +void GroupController::setDeviceClipboard(bool pause) +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->setDeviceClipboard(pause); + } +} + +void GroupController::clipboardPaste() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->clipboardPaste(); + } +} + +void GroupController::pushFileRequest(const QString &file, const QString &devicePath) +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->pushFileRequest(file, devicePath); + } +} + +void GroupController::installApkRequest(const QString &apkFile) +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->installApkRequest(apkFile); + } +} + +void GroupController::screenshot() +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->screenshot(); + } +} + +void GroupController::showTouch(bool show) +{ + for (const auto& serial : m_devices) { + if (true == isHost(serial)) { + continue; + } + auto device = qsc::IDeviceManage::getInstance().getDevice(serial); + if (!device) { + continue; + } + + device->showTouch(show); + } +} diff --git a/QtScrcpy/groupcontroller/groupcontroller.h b/QtScrcpy/groupcontroller/groupcontroller.h new file mode 100644 index 0000000..bb2136d --- /dev/null +++ b/QtScrcpy/groupcontroller/groupcontroller.h @@ -0,0 +1,56 @@ +#ifndef GROUPCONTROLLER_H +#define GROUPCONTROLLER_H + +#include +#include + +#include "QtScrcpyCore.h" + +class GroupController : public QObject, public qsc::DeviceObserver +{ + Q_OBJECT +public: + static GroupController& instance(); + + void updateDeviceState(const QString& serial); + void addDevice(const QString& serial); + void removeDevice(const QString& serial); + +private: + // DeviceObserver + 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 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; + void screenshot() override; + void showTouch(bool show) override; + +private: + explicit GroupController(QObject *parent = nullptr); + bool isHost(const QString& serial); + QSize getFrameSize(const QString& serial); + +private: + QVector m_devices; +}; + +#endif // GROUPCONTROLLER_H diff --git a/QtScrcpy/main.cpp b/QtScrcpy/main.cpp index 7471877..b85d218 100644 --- a/QtScrcpy/main.cpp +++ b/QtScrcpy/main.cpp @@ -22,7 +22,7 @@ int main(int argc, char *argv[]) { // set env #ifdef Q_OS_WIN32 - qputenv("QTSCRCPY_ADB_PATH", "../../../QtScrcpy/QtScrcpyCore/src/third_party/adb/win/adb.exe"); + qputenv("QTSCRCPY_ADB_PATH", "D:/android/sdk/platform-tools/adb.exe"); qputenv("QTSCRCPY_SERVER_PATH", "../../../QtScrcpy/QtScrcpyCore/src/third_party/scrcpy-server"); qputenv("QTSCRCPY_KEYMAP_PATH", "../../../keymap"); qputenv("QTSCRCPY_CONFIG_PATH", "../../../config"); diff --git a/QtScrcpy/ui/dialog.cpp b/QtScrcpy/ui/dialog.cpp index 1ee65e4..1683cf6 100644 --- a/QtScrcpy/ui/dialog.cpp +++ b/QtScrcpy/ui/dialog.cpp @@ -9,6 +9,7 @@ #include "dialog.h" #include "ui_dialog.h" #include "videoform.h" +#include "../groupcontroller/groupcontroller.h" QString s_keyMapPath = ""; @@ -457,10 +458,13 @@ void Dialog::onDeviceConnected(bool success, const QString &serial, const QStrin videoForm->setGeometry(rc); } + GroupController::instance().addDevice(serial); } void Dialog::onDeviceDisconnected(QString serial) { + GroupController::instance().removeDevice(serial); + auto data = qsc::IDeviceManage::getInstance().getDevice(serial)->getUserData(); if (data) { VideoForm* vf = static_cast(data); diff --git a/QtScrcpy/ui/toolform.cpp b/QtScrcpy/ui/toolform.cpp index d9f1332..f9e0ba8 100644 --- a/QtScrcpy/ui/toolform.cpp +++ b/QtScrcpy/ui/toolform.cpp @@ -7,6 +7,7 @@ #include "toolform.h" #include "ui_toolform.h" #include "videoform.h" +#include "../groupcontroller/groupcontroller.h" ToolForm::ToolForm(QWidget *adsorbWidget, AdsorbPositions adsorbPos) : MagneticWidget(adsorbWidget, adsorbPos), ui(new Ui::ToolForm) { @@ -14,6 +15,8 @@ ToolForm::ToolForm(QWidget *adsorbWidget, AdsorbPositions adsorbPos) : MagneticW setWindowFlags(windowFlags() | Qt::FramelessWindowHint); //setWindowFlags(windowFlags() & ~Qt::WindowMinMaxButtonsHint); + updateGroupControl(); + initStyle(); } @@ -27,6 +30,11 @@ void ToolForm::setSerial(const QString &serial) m_serial = serial; } +bool ToolForm::isHost() +{ + return m_isHost; +} + void ToolForm::initStyle() { IconHelper::Instance()->SetIcon(ui->fullScreenBtn, QChar(0xf0b2), 15); @@ -48,10 +56,13 @@ void ToolForm::initStyle() void ToolForm::updateGroupControl() { - auto device = qsc::IDeviceManage::getInstance().getDevice(m_serial); - if (!device) { - return; + if (m_isHost) { + ui->groupControlBtn->setStyleSheet("color: red"); + } else { + ui->groupControlBtn->setStyleSheet("color: green"); } + + GroupController::instance().updateDeviceState(m_serial); } void ToolForm::mousePressEvent(QMouseEvent *event) @@ -130,7 +141,7 @@ void ToolForm::on_appSwitchBtn_clicked() if (!device) { return; } - emit device->postAppSwitch(); + device->postAppSwitch(); } void ToolForm::on_powerBtn_clicked() @@ -139,7 +150,7 @@ void ToolForm::on_powerBtn_clicked() if (!device) { return; } - emit device->postPower(); + device->postPower(); } void ToolForm::on_screenShotBtn_clicked() @@ -157,7 +168,7 @@ void ToolForm::on_volumeUpBtn_clicked() if (!device) { return; } - emit device->postVolumeUp(); + device->postVolumeUp(); } void ToolForm::on_volumeDownBtn_clicked() @@ -166,7 +177,7 @@ void ToolForm::on_volumeDownBtn_clicked() if (!device) { return; } - emit device->postVolumeDown(); + device->postVolumeDown(); } void ToolForm::on_closeScreenBtn_clicked() @@ -175,7 +186,7 @@ void ToolForm::on_closeScreenBtn_clicked() if (!device) { return; } - emit device->setScreenPowerMode(false); + device->setScreenPowerMode(false); } void ToolForm::on_expandNotifyBtn_clicked() @@ -184,7 +195,7 @@ void ToolForm::on_expandNotifyBtn_clicked() if (!device) { return; } - emit device->expandNotificationPanel(); + device->expandNotificationPanel(); } void ToolForm::on_touchBtn_clicked() @@ -200,7 +211,8 @@ void ToolForm::on_touchBtn_clicked() void ToolForm::on_groupControlBtn_clicked() { - + m_isHost = !m_isHost; + updateGroupControl(); } void ToolForm::on_openScreenBtn_clicked() @@ -209,5 +221,5 @@ void ToolForm::on_openScreenBtn_clicked() if (!device) { return; } - emit device->setScreenPowerMode(true); + device->setScreenPowerMode(true); } diff --git a/QtScrcpy/ui/toolform.h b/QtScrcpy/ui/toolform.h index df75d7d..0848638 100644 --- a/QtScrcpy/ui/toolform.h +++ b/QtScrcpy/ui/toolform.h @@ -22,6 +22,7 @@ public: ~ToolForm(); void setSerial(const QString& serial); + bool isHost(); protected: void mousePressEvent(QMouseEvent *event); @@ -56,6 +57,7 @@ private: QPoint m_dragPosition; QString m_serial; bool m_showTouch = false; + bool m_isHost = false; }; #endif // TOOLFORM_H diff --git a/QtScrcpy/ui/toolform.ui b/QtScrcpy/ui/toolform.ui index cabb9e9..82d94af 100644 --- a/QtScrcpy/ui/toolform.ui +++ b/QtScrcpy/ui/toolform.ui @@ -22,6 +22,9 @@ + + group control + diff --git a/QtScrcpy/ui/videoform.cpp b/QtScrcpy/ui/videoform.cpp index 11eaf14..839f11a 100644 --- a/QtScrcpy/ui/videoform.cpp +++ b/QtScrcpy/ui/videoform.cpp @@ -506,6 +506,11 @@ void VideoForm::switchFullScreen() } } +bool VideoForm::isHost() +{ + return m_toolForm->isHost(); +} + void VideoForm::updateFPS(quint32 fps) { //qDebug() << "FPS:" << fps; diff --git a/QtScrcpy/ui/videoform.h b/QtScrcpy/ui/videoform.h index 0a442d7..9f79aef 100644 --- a/QtScrcpy/ui/videoform.h +++ b/QtScrcpy/ui/videoform.h @@ -33,6 +33,8 @@ public: void showFPS(bool show); void switchFullScreen(); + bool isHost(); + private: void onFrame(int width, int height, uint8_t* dataY, uint8_t* dataU, uint8_t* dataV, int linesizeY, int linesizeU, int linesizeV) override;