chore: Adapter Qt5.11

This commit is contained in:
leiyu 2021-12-03 14:24:31 +08:00
commit 11c76d5c2c
5 changed files with 51 additions and 30 deletions

View file

@ -116,9 +116,17 @@ QStringList AdbProcess::getDevicesSerialFromStdOut()
{ {
// get devices serial by adb devices // get devices serial by adb devices
QStringList serials; QStringList serials;
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QStringList devicesInfoList = m_standardOutput.split(QRegExp("\r\n|\n"), Qt::SkipEmptyParts); 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) { for (QString deviceInfo : devicesInfoList) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QStringList deviceInfos = deviceInfo.split(QRegExp("\t"), Qt::SkipEmptyParts); 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")) { if (2 == deviceInfos.count() && 0 == deviceInfos[1].compare("device")) {
serials << deviceInfos[0]; serials << deviceInfos[0];
} }

View file

@ -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; qint32 vScroll = from->angleDelta().y() == 0 ? 0 : from->angleDelta().y() / abs(from->angleDelta().y()) * 2;
// pos // pos
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QPointF pos = from->position(); QPointF pos = from->position();
#else
QPointF pos = from->posF();
#endif
// convert pos // convert pos
pos.setX(pos.x() * frameSize.width() / showSize.width()); pos.setX(pos.x() * frameSize.width() / showSize.width());
pos.setY(pos.y() * frameSize.height() / showSize.height()); pos.setY(pos.y() * frameSize.height() / showSize.height());

View file

@ -627,6 +627,7 @@ void VideoForm::mouseDoubleClickEvent(QMouseEvent *event)
void VideoForm::wheelEvent(QWheelEvent *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_videoWidget->geometry().contains(event->position().toPoint())) {
if (!m_device) { if (!m_device) {
return; return;
@ -634,6 +635,17 @@ void VideoForm::wheelEvent(QWheelEvent *event)
QPointF pos = m_videoWidget->mapFrom(this, event->position().toPoint()); QPointF pos = m_videoWidget->mapFrom(this, event->position().toPoint());
QWheelEvent wheelEvent( QWheelEvent wheelEvent(
pos, event->globalPosition(), event->pixelDelta(), event->angleDelta(), event->buttons(), event->modifiers(), event->phase(), event->inverted()); 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()); emit m_device->wheelEvent(&wheelEvent, m_videoWidget->frameSize(), m_videoWidget->size());
} }
} }

View file

@ -203,7 +203,11 @@ void Dialog::execAdbCmd()
} }
QString cmd = ui->adbCommandEdt->text().trimmed(); QString cmd = ui->adbCommandEdt->text().trimmed();
outLog("adb " + cmd, false); outLog("adb " + cmd, false);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
m_adb.execute(ui->serialBox->currentText().trimmed(), cmd.split(" ", Qt::SkipEmptyParts)); 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) void Dialog::delayMs(int ms)
@ -521,14 +525,13 @@ void Dialog::on_usbConnectBtn_clicked()
on_startServerBtn_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)
{ {
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) {
bool isWifi = regIP.exactMatch(ui->serialBox->itemText(i)); bool isWifi = regIP.exactMatch(ui->serialBox->itemText(i));
bool found = wifi ? isWifi : !isWifi; bool found = wifi ? isWifi : !isWifi;
if(found) if (found) {
{
return i; return i;
} }
} }
@ -599,15 +602,12 @@ void Dialog::on_updateNameBtn_clicked()
void Dialog::on_useSingleModeCheck_clicked() void Dialog::on_useSingleModeCheck_clicked()
{ {
if(ui->useSingleModeCheck->isChecked()) if (ui->useSingleModeCheck->isChecked()) {
{
ui->configGroupBox->hide(); ui->configGroupBox->hide();
ui->adbGroupBox->hide(); ui->adbGroupBox->hide();
ui->wirelessGroupBox->hide(); ui->wirelessGroupBox->hide();
ui->usbGroupBox->hide(); ui->usbGroupBox->hide();
} } else {
else
{
ui->configGroupBox->show(); ui->configGroupBox->show();
ui->adbGroupBox->show(); ui->adbGroupBox->show();
ui->wirelessGroupBox->show(); ui->wirelessGroupBox->show();

View file

@ -207,9 +207,6 @@
<property name="currentText"> <property name="currentText">
<string notr="true">Mbps</string> <string notr="true">Mbps</string>
</property> </property>
<property name="placeholderText">
<string notr="true"/>
</property>
<item> <item>
<property name="text"> <property name="text">
<string notr="true">Mbps</string> <string notr="true">Mbps</string>