Introduced a new `NetworkService` for posting account and device data efficiently. Improved the transaction UI with styled tables and added lazy content loading. Changed screenshot handling to return JPEG data directly, and restructured device processing for better error handling and data integration.
38 lines
1.3 KiB
C++
38 lines
1.3 KiB
C++
#include "DeviceWidget.h"
|
|
#include <QVBoxLayout>
|
|
#include <QLabel>
|
|
#include <QPixmap>
|
|
#include <QImage>
|
|
|
|
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);
|
|
}
|