-
Notifications
You must be signed in to change notification settings - Fork 0
/
deviceinfo.cpp
50 lines (42 loc) · 1.65 KB
/
deviceinfo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <QVBoxLayout>
#include "deviceinfo.h"
DeviceInfo::DeviceInfo(QWidget *parent) : QWidget(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
deviceModel = new QLabel("Device Model", this);
deviceBrand = new QLabel("Device Brand", this);
deviceAndroidRelease = new QLabel("Device Android Release", this);
connectButton = new QPushButton("connect", this);
mainLayout->addWidget(deviceModel);
mainLayout->addWidget(deviceBrand);
mainLayout->addWidget(deviceAndroidRelease);
mainLayout->addWidget(connectButton);
connect(connectButton, &QPushButton::clicked, this, &DeviceInfo::onButtonClicked);
CurrentDeviceManager *CDM = CurrentDeviceManager::getInstance();
connect(CDM, &CurrentDeviceManager::currentDeviceChanged, this, &DeviceInfo::setDeviceInfo);
connect(CDM, &CurrentDeviceManager::deviceUnMounted, this, &DeviceInfo::clearDeviceInfo);
this->setLayout(mainLayout);
}
void DeviceInfo::onButtonClicked()
{
CurrentDeviceManager *CDM = CurrentDeviceManager::getInstance();
if (CDM->getCurrentDevice()->getIsMounted()) {
CDM->getMtpTool()->unmount();
} else {
CDM->getMtpTool()->mount();
}
}
void DeviceInfo::setDeviceInfo(Device *device)
{
deviceModel->setText(device->getModel());
deviceBrand->setText(device->getBrand());
deviceAndroidRelease->setText("Android: " + device->getAndroidRelease());
connectButton->setText("disconnect");
}
void DeviceInfo::clearDeviceInfo()
{
deviceModel->setText("Device Model");
deviceBrand->setText("Device Brand");
deviceAndroidRelease->setText("Device Android Release");
connectButton->setText("connect");
}