chore: Adapter Qt5.11

This commit is contained in:
leiyu 2021-12-03 14:24:31 +08:00 committed by Barry
parent 824ec72c71
commit b397fe6bb2
5 changed files with 51 additions and 30 deletions

View file

@ -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);

View file

@ -47,9 +47,9 @@ void InputConvertNormal::mouseEvent(const QMouseEvent *from, const QSize &frameS
}
controlMsg->setInjectTouchMsgData(
static_cast<quint64>(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());

View file

@ -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());
}
}

View file

@ -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);
}

View file

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