手机发送特殊字符串,控制电脑端截屏

This commit is contained in:
sonichy 2022-11-24 16:08:57 +08:00
parent 5cd65b237b
commit ed78634032
3 changed files with 12 additions and 1 deletions

BIN
FileTrans

Binary file not shown.

View File

@ -123,8 +123,16 @@ void MainWindow::readyRead()
type = JO.value("type").toString();
if (type == "text") {
QString message = JO.value("message").toString();
if (message == "Capture") {
QScreen *screen = QApplication::primaryScreen();
QPixmap pixmap = screen->grabWindow(QApplication::desktop()->winId());
QDateTime time = QDateTime::currentDateTime();
QString filename = time.toString("yyyyMMddhhmmss") + ".jpg";
QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/" + filename;
pixmap.save(path, nullptr, 100);
}
ui->textBrowser->append("[" + QDateTime::currentDateTime().toString("HH:mm:ss") + "] [" + IP_remote + "]" + message);
} else if(type == "file") {
} else if (type == "file") {
fileName = JO.value("fileName").toString();
lastModified = JO.value("lastModified").toDouble()/1000;
ui->textBrowser->append("[" + QDateTime::currentDateTime().toString("HH:mm:ss") + "] [" + IP_remote + "]" + fileName);

View File

@ -19,6 +19,9 @@
#include <QDropEvent>
#include <QDragEnterEvent>
#include <QMimeData>
#include <QScreen>
#include <QDesktopWidget>
#include <QStandardPaths>
namespace Ui {
class MainWindow;