|
@@ -171,12 +171,12 @@ void MainWindow::readSocket()
|
|
|
data_to_server = QByteArray::number(tab->id);
|
|
|
|
|
|
else if(isMatchString(posterCommand, {"GETTABCOUNT"}))//Получить число вкладок
|
|
|
- data_to_server = QByteArray::number(tabs.count());
|
|
|
+ data_to_server = QByteArray::number(tabs.count());
|
|
|
|
|
|
else if(isMatchString(posterCommand, {"JSERROR"}))//Получить ошибки в JS
|
|
|
data_to_server = tab->JS_Errors().toLocal8Bit();
|
|
|
|
|
|
- else if(isMatchString(posterCommand, {"CLEARJSERRORS"}))//Очистить список ошибок JS
|
|
|
+ else if(isMatchString(posterCommand, {"CLEARJSERRORS", "JSCLEARERRORS"}))//Очистить список ошибок JS
|
|
|
tab->clearJS_errors();
|
|
|
|
|
|
else if(isMatchString(posterCommand, {"ADDTAB"}))//Открыть новую вкладку
|
|
@@ -224,6 +224,9 @@ void MainWindow::readSocket()
|
|
|
else if(isMatchString(posterCommand, {"ISTABNAMEEXISTS"}))//Проверить открыта ли вкладка с указанным именем
|
|
|
data_to_server = QByteArray::number(isTabNameExist(TaskList.at(1)));
|
|
|
|
|
|
+ else if(isMatchString(posterCommand, {"TABFOCUS"}))//переключиться на вкладку
|
|
|
+ data_to_server = QByteArray::number(tabFocus(tab->id));
|
|
|
+
|
|
|
else if(isMatchString(posterCommand, {"EVALJS"}))//выполнить JavaScript на странице
|
|
|
data_to_server = tab->runJavaScript(TaskList.at(1));
|
|
|
|
|
@@ -455,39 +458,65 @@ void MainWindow::scrollToClickPoint(QPoint *point)
|
|
|
}
|
|
|
|
|
|
bool MainWindow::performeMouseEmulation(Tab *tab, QString *posterCommand, QPoint *point){
|
|
|
+ QWidget *eventsReciverWidget = nullptr;
|
|
|
+ for(auto *o : tab->children()){
|
|
|
+ QWidget *wgt = qobject_cast<QWidget*>(o);
|
|
|
+ if (wgt) {
|
|
|
+ eventsReciverWidget = wgt;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!eventsReciverWidget) return false;
|
|
|
+
|
|
|
if(isMatchString(*posterCommand, {"LBUTTONCLICK", "LBC"})){//клик левой кнопкой мыши
|
|
|
// scrollToClickPoint(point);
|
|
|
QMouseEvent event(QEvent::MouseButtonPress, *point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
|
|
- QCoreApplication::sendEvent(tab->children().at(2), &event);
|
|
|
+ QCoreApplication::sendEvent(eventsReciverWidget, &event);
|
|
|
|
|
|
QMouseEvent event1(QEvent::MouseButtonRelease, *point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
|
|
- QCoreApplication::sendEvent(tab->children().at(2), &event1);
|
|
|
+ QCoreApplication::sendEvent(eventsReciverWidget, &event1);
|
|
|
}
|
|
|
else if(isMatchString(*posterCommand, {"RBUTTONCLICK", "RBC"})){//клик правой кнопкой мыши
|
|
|
scrollToClickPoint(point);
|
|
|
QMouseEvent event(QEvent::MouseButtonPress, *point, Qt::RightButton, Qt::RightButton, Qt::NoModifier);
|
|
|
- QCoreApplication::sendEvent(tab->children().at(2), &event);
|
|
|
+ QCoreApplication::sendEvent(eventsReciverWidget, &event);
|
|
|
|
|
|
QMouseEvent event1(QEvent::MouseButtonRelease, *point, Qt::RightButton, Qt::RightButton, Qt::NoModifier);
|
|
|
- QCoreApplication::sendEvent(tab->children().at(2), &event1);
|
|
|
+ QCoreApplication::sendEvent(eventsReciverWidget, &event1);
|
|
|
}
|
|
|
else if(isMatchString(*posterCommand, {"LBUTTONPRESS", "LBP"})){//нажали левой кнопкой мыши
|
|
|
scrollToClickPoint(point);
|
|
|
QMouseEvent event(QEvent::MouseButtonPress, *point, Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
|
|
|
|
|
|
- QCoreApplication::sendEvent(tab->children().at(2), &event);
|
|
|
+ QCoreApplication::sendEvent(eventsReciverWidget, &event);
|
|
|
}
|
|
|
else if(isMatchString(*posterCommand, {"LBUTTONRELEASE", "LBR"})){//отпускаем левую кнопку мыши
|
|
|
scrollToClickPoint(point);
|
|
|
QMouseEvent event(QEvent::MouseButtonRelease, *point, Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
|
|
|
- QCoreApplication::sendEvent(tab->children().at(2), &event);
|
|
|
+ QCoreApplication::sendEvent(eventsReciverWidget, &event);
|
|
|
}
|
|
|
else if(isMatchString(*posterCommand, {"MOUSEMOVE"})){//эмуляция движения мышу в заданную точку
|
|
|
// scrollToClickPoint(point);
|
|
|
QMouseEvent event(QEvent::MouseMove, *point, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
|
|
|
- QCoreApplication::sendEvent(tab->children().at(2), &event);
|
|
|
+ QCoreApplication::sendEvent(eventsReciverWidget, &event);
|
|
|
}
|
|
|
else return false;
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
+//int indext = 0;
|
|
|
+//void MainWindow::on_pushButton_3_clicked()
|
|
|
+//{
|
|
|
+//// tabFocus(indext++);
|
|
|
+
|
|
|
+// return;
|
|
|
+
|
|
|
+
|
|
|
+//// Tab *tab = getTabById();
|
|
|
+//// QMouseEvent event(QEvent::MouseButtonPress, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
|
|
+//// QCoreApplication::sendEvent(tab->page(), &event);
|
|
|
+
|
|
|
+//// QMouseEvent event1(QEvent::MouseButtonRelease, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
|
|
+//// QCoreApplication::sendEvent(tab->page(), &event1);
|
|
|
+//}
|