diff --git a/QtScrcpy/adb/adbprocess.cpp b/QtScrcpy/adb/adbprocess.cpp index ad14835..c0bc626 100644 --- a/QtScrcpy/adb/adbprocess.cpp +++ b/QtScrcpy/adb/adbprocess.cpp @@ -116,9 +116,17 @@ QStringList AdbProcess::getDevicesSerialFromStdOut() { // get devices serial by adb devices QStringList serials; +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) QStringList devicesInfoList = m_standardOutput.split(QRegExp("\r\n|\n"), Qt::SkipEmptyParts); +#else + QStringList devicesInfoList = m_standardOutput.split(QRegExp("\r\n|\n"), QString::SkipEmptyParts); +#endif for (QString deviceInfo : devicesInfoList) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) QStringList deviceInfos = deviceInfo.split(QRegExp("\t"), Qt::SkipEmptyParts); +#else + QStringList deviceInfos = deviceInfo.split(QRegExp("\t"), QString::SkipEmptyParts); +#endif if (2 == deviceInfos.count() && 0 == deviceInfos[1].compare("device")) { serials << deviceInfos[0]; } @@ -131,7 +139,7 @@ QString AdbProcess::getDeviceIPFromStdOut() QString ip = ""; #if 0 QString strIPExp = "inet [\\d.]*"; - QRegExp ipRegExp(strIPExp,Qt::CaseInsensitive); + QRegExp ipRegExp(strIPExp, Qt::CaseInsensitive); if (ipRegExp.indexIn(m_standardOutput) != -1) { ip = ipRegExp.cap(0); ip = ip.right(ip.size() - 5); diff --git a/QtScrcpy/device/controller/inputconvert/inputconvertnormal.cpp b/QtScrcpy/device/controller/inputconvert/inputconvertnormal.cpp index a19be58..d90862c 100644 --- a/QtScrcpy/device/controller/inputconvert/inputconvertnormal.cpp +++ b/QtScrcpy/device/controller/inputconvert/inputconvertnormal.cpp @@ -47,9 +47,9 @@ void InputConvertNormal::mouseEvent(const QMouseEvent *from, const QSize &frameS } controlMsg->setInjectTouchMsgData( static_cast(POINTER_ID_MOUSE), action, - convertMouseButtons(from->buttons()), - QRect(pos.toPoint(), frameSize), - AMOTION_EVENT_ACTION_DOWN == action? 1.0f : 0.0f); + convertMouseButtons(from->buttons()), + QRect(pos.toPoint(), frameSize), + AMOTION_EVENT_ACTION_DOWN == action ? 1.0f : 0.0f); sendControlMsg(controlMsg); } @@ -64,7 +64,11 @@ void InputConvertNormal::wheelEvent(const QWheelEvent *from, const QSize &frameS qint32 vScroll = from->angleDelta().y() == 0 ? 0 : from->angleDelta().y() / abs(from->angleDelta().y()) * 2; // pos +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) QPointF pos = from->position(); +#else + QPointF pos = from->posF(); +#endif // convert pos pos.setX(pos.x() * frameSize.width() / showSize.width()); pos.setY(pos.y() * frameSize.height() / showSize.height()); diff --git a/QtScrcpy/device/ui/videoform.cpp b/QtScrcpy/device/ui/videoform.cpp index adef612..07281a0 100644 --- a/QtScrcpy/device/ui/videoform.cpp +++ b/QtScrcpy/device/ui/videoform.cpp @@ -627,6 +627,7 @@ void VideoForm::mouseDoubleClickEvent(QMouseEvent *event) void VideoForm::wheelEvent(QWheelEvent *event) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) if (m_videoWidget->geometry().contains(event->position().toPoint())) { if (!m_device) { return; @@ -634,6 +635,17 @@ void VideoForm::wheelEvent(QWheelEvent *event) QPointF pos = m_videoWidget->mapFrom(this, event->position().toPoint()); QWheelEvent wheelEvent( 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) { + return; + } + QPointF pos = m_videoWidget->mapFrom(this, event->pos()); + + QWheelEvent wheelEvent( + 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()); } } diff --git a/QtScrcpy/dialog.cpp b/QtScrcpy/dialog.cpp index 8cfebad..009a65c 100644 --- a/QtScrcpy/dialog.cpp +++ b/QtScrcpy/dialog.cpp @@ -89,11 +89,11 @@ Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) m_hideIcon->setContextMenu(m_menu); m_hideIcon->show(); connect(m_showWindow, &QAction::triggered, this, &Dialog::slotShow); - connect(m_quit, &QAction::triggered, this, [this](){ + connect(m_quit, &QAction::triggered, this, [this]() { m_hideIcon->hide(); qApp->quit(); }); - connect(m_hideIcon, &QSystemTrayIcon::activated,this,&Dialog::slotActivated); + connect(m_hideIcon, &QSystemTrayIcon::activated, this, &Dialog::slotActivated); } Dialog::~Dialog() @@ -152,9 +152,9 @@ void Dialog::updateBootConfig(bool toView) if (toView) { UserBootConfig config = Config::getInstance().getUserBootConfig(); - if(config.bitRate == 0) { + if (config.bitRate == 0) { ui->bitRateBox->setCurrentText("Mbps"); - } else if(config.bitRate % 1000000 == 0) { + } else if (config.bitRate % 1000000 == 0) { ui->bitRateEdit->setText(QString::number(config.bitRate / 1000000)); ui->bitRateBox->setCurrentText("Mbps"); } else { @@ -203,7 +203,11 @@ void Dialog::execAdbCmd() } QString cmd = ui->adbCommandEdt->text().trimmed(); outLog("adb " + cmd, false); +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) m_adb.execute(ui->serialBox->currentText().trimmed(), cmd.split(" ", Qt::SkipEmptyParts)); +#else + m_adb.execute(ui->serialBox->currentText().trimmed(), cmd.split(" ", QString::SkipEmptyParts)); +#endif } void Dialog::delayMs(int ms) @@ -249,9 +253,9 @@ void Dialog::closeEvent(QCloseEvent *event) { this->hide(); m_hideIcon->showMessage(tr("Notice"), - tr("Hidden here!"), - QSystemTrayIcon::Information, - 3000); + tr("Hidden here!"), + QSystemTrayIcon::Information, + 3000); event->ignore(); } @@ -521,14 +525,13 @@ void Dialog::on_usbConnectBtn_clicked() on_startServerBtn_clicked(); } -int Dialog::findDeviceFromeSerialBox(bool wifi) { +int Dialog::findDeviceFromeSerialBox(bool wifi) +{ QRegExp regIP("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\:([0-9]|[1-9]\\d|[1-9]\\d{2}|[1-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])\\b"); - for (int i = 0; i < ui->serialBox->count(); ++i) - { + for (int i = 0; i < ui->serialBox->count(); ++i) { bool isWifi = regIP.exactMatch(ui->serialBox->itemText(i)); bool found = wifi ? isWifi : !isWifi; - if(found) - { + if (found) { return i; } } @@ -582,8 +585,8 @@ void Dialog::on_connectedPhoneList_itemDoubleClicked(QListWidgetItem *item) void Dialog::on_updateNameBtn_clicked() { - if(ui->serialBox->count()!=0) { - if(ui->userNameEdt->text().isEmpty()) { + if (ui->serialBox->count() != 0) { + if (ui->userNameEdt->text().isEmpty()) { Config::getInstance().setNickName(ui->serialBox->currentText(), "Phone"); } else { Config::getInstance().setNickName(ui->serialBox->currentText(), ui->userNameEdt->text()); @@ -591,30 +594,27 @@ void Dialog::on_updateNameBtn_clicked() on_updateDevice_clicked(); - qDebug()<<"Update OK!"; + qDebug() << "Update OK!"; } else { - qWarning()<<"No device is connected!"; + qWarning() << "No device is connected!"; } } void Dialog::on_useSingleModeCheck_clicked() { - if(ui->useSingleModeCheck->isChecked()) - { + if (ui->useSingleModeCheck->isChecked()) { ui->configGroupBox->hide(); ui->adbGroupBox->hide(); ui->wirelessGroupBox->hide(); ui->usbGroupBox->hide(); - } - else - { + } else { ui->configGroupBox->show(); ui->adbGroupBox->show(); ui->wirelessGroupBox->show(); ui->usbGroupBox->show(); } - QTimer::singleShot(0, this, [this](){ + QTimer::singleShot(0, this, [this]() { resize(width(), layout()->sizeHint().height()); }); } @@ -627,5 +627,5 @@ void Dialog::on_serialBox_currentIndexChanged(const QString &arg1) quint32 Dialog::getBitRate() { return ui->bitRateEdit->text().trimmed().toUInt() * - (ui->bitRateBox->currentText() == QString("Mbps") ? 1000000 : 1000); + (ui->bitRateBox->currentText() == QString("Mbps") ? 1000000 : 1000); } diff --git a/QtScrcpy/dialog.ui b/QtScrcpy/dialog.ui index 6968d5c..d99bafe 100644 --- a/QtScrcpy/dialog.ui +++ b/QtScrcpy/dialog.ui @@ -207,9 +207,6 @@ Mbps - - - Mbps