Removed Scrcpy embedding code and related configurations for macOS. Commented out excessive debug logging in multiple files to reduce console noise. Simplified CMakeLists.txt by unifying platform-specific sections for improved build system clarity.
53 lines
1.8 KiB
C++
53 lines
1.8 KiB
C++
#include "DeviceWidget.h"
|
|
#include <QVBoxLayout>
|
|
#include <QLabel>
|
|
#include <QPixmap>
|
|
#include <QImage>
|
|
#include <QMouseEvent>
|
|
|
|
DeviceWidget::DeviceWidget(const DeviceInfo &device, QWidget *parent): QWidget(parent) {
|
|
auto *layout = new QVBoxLayout(this);
|
|
|
|
this->setStyleSheet("background-color: lightgray;padding: 10px;");
|
|
|
|
QImage img;
|
|
img.loadFromData(device.image, "JPG");
|
|
|
|
auto *imageLabel = new QLabel(this);
|
|
// qDebug() << "imageLabel" << img.width() ;
|
|
imageLabel->setPixmap(QPixmap::fromImage(img).scaled(200, 350, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
|
imageLabel->setAlignment(Qt::AlignCenter);
|
|
layout->addWidget(imageLabel);
|
|
|
|
const QString result = QString("%1, Android %2, battery %3% [%4x%5]")
|
|
.arg(device.name).arg(device.android).arg(device.battery).
|
|
arg(device.screenWidth).arg(device.screenHeight);
|
|
|
|
auto *statusLabel = new QLabel(result, this);
|
|
statusLabel->setAlignment(Qt::AlignCenter);
|
|
statusLabel->setMaximumWidth(200);
|
|
statusLabel->setWordWrap(true);
|
|
|
|
const QString styleSheet = QString("color: %1; font-weight: bold;")
|
|
.arg(device.status == "online" ? "green" : "red");
|
|
statusLabel->setStyleSheet(styleSheet);
|
|
|
|
// layout->setContentsMargins(10, 10, 10, 10);
|
|
layout->setSpacing(0);
|
|
layout->addWidget(statusLabel);
|
|
}
|
|
|
|
void DeviceWidget::mouseDoubleClickEvent(QMouseEvent *event) {
|
|
if (event->button() == Qt::LeftButton) {
|
|
if (scrcpyWindow == nullptr) {
|
|
scrcpyWindow = new ScrcpyWindow();
|
|
scrcpyWindow->show();
|
|
|
|
// Подключаем сигнал закрытия окна
|
|
connect(scrcpyWindow, &ScrcpyWindow::destroyed, this, [this]() {
|
|
scrcpyWindow = nullptr; // Освобождаем память, когда окно закрыто
|
|
});
|
|
}
|
|
}
|
|
}
|