mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
refactor(bluetooth&network):code self test
task21255 [任务栏]蓝牙和网络插件部分的代码自检 (cherry picked from commit 581050c5b811ccbd36202d74b0c8007d5d4b29f4)
This commit is contained in:
parent
0d835e0fec
commit
20bb074f01
@ -30,6 +30,10 @@
|
||||
#include "componments/bluetoothconstants.h"
|
||||
|
||||
#include <DApplicationHelper>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
extern void initFontColor(QWidget *widget)
|
||||
@ -60,7 +64,7 @@ BluetoothApplet::BluetoothApplet(QWidget *parent)
|
||||
{
|
||||
m_line->setVisible(false);
|
||||
|
||||
auto defaultFont = font();
|
||||
QFont defaultFont = font();
|
||||
auto titlefont = QFont(defaultFont.family(), defaultFont.pointSize() + 2);
|
||||
|
||||
m_appletName->setText(tr("Bluetooth"));
|
||||
@ -97,7 +101,7 @@ BluetoothApplet::BluetoothApplet(QWidget *parent)
|
||||
|
||||
void BluetoothApplet::setAdapterPowered(bool powered)
|
||||
{
|
||||
for (auto adapterItem : m_adapterItems) {
|
||||
for (AdapterItem *adapterItem : m_adapterItems) {
|
||||
if (adapterItem)
|
||||
adapterItem->setPowered(powered);
|
||||
}
|
||||
@ -113,15 +117,14 @@ bool BluetoothApplet::hasAadapter()
|
||||
return m_adaptersManager->adaptersCount();
|
||||
}
|
||||
|
||||
void BluetoothApplet::onPowerChanged(bool state)
|
||||
void BluetoothApplet::onPowerChanged()
|
||||
{
|
||||
Q_UNUSED(state)
|
||||
bool powerState = false;
|
||||
for (auto adapterItem : m_adapterItems) {
|
||||
if (adapterItem->isPowered()) {
|
||||
powerState = true;
|
||||
break;
|
||||
}
|
||||
for (AdapterItem *adapterItem : m_adapterItems) {
|
||||
if (adapterItem->isPowered()) {
|
||||
powerState = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
emit powerChanged(powerState);
|
||||
}
|
||||
@ -129,7 +132,7 @@ void BluetoothApplet::onPowerChanged(bool state)
|
||||
void BluetoothApplet::onDeviceStateChanged()
|
||||
{
|
||||
Device::State deviceState = Device::StateUnavailable;
|
||||
for (auto adapterItem : m_adapterItems) {
|
||||
for (AdapterItem *adapterItem : m_adapterItems) {
|
||||
if (Device::StateAvailable == adapterItem->currentDeviceState()) {
|
||||
deviceState = Device::StateAvailable;
|
||||
continue;
|
||||
@ -152,24 +155,24 @@ void BluetoothApplet::addAdapter(Adapter *adapter)
|
||||
emit justHasAdapter();
|
||||
}
|
||||
|
||||
auto adapterId = adapter->id();
|
||||
auto adatpterItem = new AdapterItem(m_adaptersManager, adapter);
|
||||
// m_adapterItems[adapterId] = adatpterItem;
|
||||
// m_centrealLayout->addWidget(adatpterItem);
|
||||
// getDevieInitState(adatpterItem);
|
||||
QString adapterId = adapter->id();
|
||||
auto adatpterItem = new AdapterItem(m_adaptersManager, adapter, this);
|
||||
m_adapterItems[adapterId] = adatpterItem;
|
||||
m_centrealLayout->addWidget(adatpterItem);
|
||||
getDevieInitState(adatpterItem);
|
||||
|
||||
// connect(adatpterItem, &AdapterItem::deviceStateChanged, this, &BluetoothApplet::onDeviceStateChanged);
|
||||
// connect(adatpterItem, &AdapterItem::powerChanged, this, &BluetoothApplet::onPowerChanged);
|
||||
// connect(adatpterItem, &AdapterItem::sizeChange, this, &BluetoothApplet::updateView);
|
||||
connect(adatpterItem, &AdapterItem::deviceStateChanged, this, &BluetoothApplet::onDeviceStateChanged);
|
||||
connect(adatpterItem, &AdapterItem::powerChanged, this, &BluetoothApplet::onPowerChanged);
|
||||
connect(adatpterItem, &AdapterItem::sizeChange, this, &BluetoothApplet::updateView);
|
||||
|
||||
// updateView();
|
||||
updateView();
|
||||
}
|
||||
|
||||
void BluetoothApplet::removeAdapter(Adapter *adapter)
|
||||
{
|
||||
if (adapter) {
|
||||
auto adapterId = adapter->id();
|
||||
auto adapterItem = m_adapterItems.value(adapterId);
|
||||
QString adapterId = adapter->id();
|
||||
AdapterItem *adapterItem = m_adapterItems.value(adapterId);
|
||||
if (adapterItem) {
|
||||
m_centrealLayout->removeWidget(adapterItem);
|
||||
delete adapterItem;
|
||||
@ -185,7 +188,7 @@ void BluetoothApplet::updateView()
|
||||
{
|
||||
int contentHeight = 0;
|
||||
int itemCount = 0;
|
||||
for (auto adapterItem : m_adapterItems) {
|
||||
for (AdapterItem *adapterItem : m_adapterItems) {
|
||||
if (adapterItem) {
|
||||
contentHeight += adapterItem->viewHeight();
|
||||
if (adapterItem->isPowered())
|
||||
@ -193,7 +196,7 @@ void BluetoothApplet::updateView()
|
||||
}
|
||||
}
|
||||
|
||||
auto adaptersCnt = m_adapterItems.size();
|
||||
int adaptersCnt = m_adapterItems.size();
|
||||
if (adaptersCnt > 1) {
|
||||
m_line->setVisible(true);
|
||||
m_appletName->setVisible(true);
|
||||
@ -218,7 +221,7 @@ void BluetoothApplet::getDevieInitState(AdapterItem *item)
|
||||
|
||||
Device::State deviceState = item->initDeviceState();
|
||||
Device::State otherDeviceState = Device::StateUnavailable;
|
||||
for (auto adapterItem : m_adapterItems) {
|
||||
for (AdapterItem *adapterItem : m_adapterItems) {
|
||||
if (adapterItem != item) {
|
||||
if (Device::StateAvailable == adapterItem->currentDeviceState()) {
|
||||
otherDeviceState = Device::StateAvailable;
|
||||
|
@ -26,9 +26,9 @@
|
||||
#include "componments/device.h"
|
||||
|
||||
#include <QScrollArea>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
class QLabel;
|
||||
class QVBoxLayout;
|
||||
class Adapter;
|
||||
class AdapterItem;
|
||||
class HorizontalSeparator;
|
||||
@ -43,17 +43,17 @@ public:
|
||||
bool hasAadapter();
|
||||
|
||||
public slots :
|
||||
void addAdapter(Adapter *constadapter);
|
||||
void addAdapter(Adapter *adapter);
|
||||
void removeAdapter(Adapter *adapter);
|
||||
|
||||
signals:
|
||||
void powerChanged(bool state);
|
||||
void powerChanged(bool powered);
|
||||
void deviceStateChanged(const Device::State state);
|
||||
void noAdapter();
|
||||
void justHasAdapter();
|
||||
|
||||
private slots:
|
||||
void onPowerChanged(bool state);
|
||||
void onPowerChanged();
|
||||
void onDeviceStateChanged();
|
||||
|
||||
private:
|
||||
|
@ -33,8 +33,8 @@
|
||||
#include <QPainter>
|
||||
|
||||
// menu actions
|
||||
#define SHIFT "shift"
|
||||
#define SETTINGS "settings"
|
||||
#define SHIFT "shift"
|
||||
#define SETTINGS "settings"
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
DGUI_USE_NAMESPACE
|
||||
@ -134,7 +134,7 @@ void BluetoothItem::refreshIcon()
|
||||
m_timer->start();
|
||||
stateString = "waiting";
|
||||
iconString = QString("bluetooth-%1-symbolic").arg(stateString);
|
||||
const auto ratio = devicePixelRatioF();
|
||||
const qreal ratio = devicePixelRatioF();
|
||||
int iconSize = PLUGIN_ICON_MAX_SIZE;
|
||||
if (height() <= PLUGIN_BACKGROUND_MIN_SIZE && DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType)
|
||||
iconString.append(PLUGIN_MIN_ICON_NAME);
|
||||
@ -155,7 +155,7 @@ void BluetoothItem::refreshIcon()
|
||||
m_timer->stop();
|
||||
iconString = QString("bluetooth-%1-symbolic").arg(stateString);
|
||||
|
||||
const auto ratio = devicePixelRatioF();
|
||||
const qreal ratio = devicePixelRatioF();
|
||||
int iconSize = PLUGIN_ICON_MAX_SIZE;
|
||||
if (height() <= PLUGIN_BACKGROUND_MIN_SIZE && DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType)
|
||||
iconString.append(PLUGIN_MIN_ICON_NAME);
|
||||
@ -170,9 +170,9 @@ bool BluetoothItem::hasAdapter()
|
||||
return m_applet->hasAadapter();
|
||||
}
|
||||
|
||||
void BluetoothItem::resizeEvent(QResizeEvent *e)
|
||||
void BluetoothItem::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(e);
|
||||
QWidget::resizeEvent(event);
|
||||
|
||||
const Dock::Position position = qApp->property(PROP_POSITION).value<Dock::Position>();
|
||||
// 保持横纵比
|
||||
@ -187,9 +187,9 @@ void BluetoothItem::resizeEvent(QResizeEvent *e)
|
||||
refreshIcon();
|
||||
}
|
||||
|
||||
void BluetoothItem::paintEvent(QPaintEvent *e)
|
||||
void BluetoothItem::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QWidget::paintEvent(e);
|
||||
QWidget::paintEvent(event);
|
||||
|
||||
QPainter painter(this);
|
||||
const QRectF &rf = QRectF(rect());
|
||||
|
@ -49,8 +49,8 @@ public:
|
||||
bool hasAdapter();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
signals:
|
||||
void requestContextMenu() const;
|
||||
|
@ -72,7 +72,7 @@ void Adapter::addDevice(const QJsonObject &deviceObj)
|
||||
|
||||
void Adapter::removeDevice(const QString &deviceId)
|
||||
{
|
||||
auto constDevice = m_devices.value(deviceId);
|
||||
const Device *constDevice = m_devices.value(deviceId);
|
||||
auto device = const_cast<Device *>(constDevice);
|
||||
if (device) {
|
||||
m_devices.remove(deviceId);
|
||||
@ -82,15 +82,15 @@ void Adapter::removeDevice(const QString &deviceId)
|
||||
}
|
||||
}
|
||||
|
||||
void Adapter::updateDevice(const QJsonObject &json)
|
||||
void Adapter::updateDevice(const QJsonObject &dviceJson)
|
||||
{
|
||||
const QString id = json["Path"].toString();
|
||||
const QString name = json["Alias"].toString();
|
||||
const bool paired = json["Paired"].toBool();
|
||||
const int rssi = json["RSSI"].toInt();
|
||||
const Device::State state = Device::State(json["State"].toInt());
|
||||
const QString id = dviceJson["Path"].toString();
|
||||
const QString name = dviceJson["Alias"].toString();
|
||||
const bool paired = dviceJson["Paired"].toBool();
|
||||
const int rssi = dviceJson["RSSI"].toInt();
|
||||
const Device::State state = Device::State(dviceJson["State"].toInt());
|
||||
|
||||
auto constdevice = m_devices.value(id);
|
||||
const Device *constdevice = m_devices.value(id);
|
||||
auto device = const_cast<Device *>(constdevice);
|
||||
if (device) {
|
||||
device->setId(id);
|
||||
@ -142,9 +142,9 @@ void Adapter::setPowered(bool powered)
|
||||
|
||||
void Adapter::initDevicesList(const QJsonDocument &doc)
|
||||
{
|
||||
auto arr = doc.array();
|
||||
QJsonArray arr = doc.array();
|
||||
for (QJsonValue val : arr) {
|
||||
auto deviceObj = val.toObject();
|
||||
QJsonObject deviceObj = val.toObject();
|
||||
const QString adapterId = deviceObj["AdapterPath"].toString();
|
||||
const QString id = deviceObj["Path"].toString();
|
||||
const QString name = deviceObj["Alias"].toString();
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
void initDevicesList(const QJsonDocument &doc);
|
||||
void addDevice(const QJsonObject &deviceObj);
|
||||
void removeDevice(const QString &deviceId);
|
||||
void updateDevice(const QJsonObject &json);
|
||||
void updateDevice(const QJsonObject &dviceJson);
|
||||
void removeAllDevices();
|
||||
const QMap<QString, const Device *> &paredDevices() const;
|
||||
int paredDevicesCount() const;
|
||||
|
@ -29,6 +29,9 @@
|
||||
|
||||
#include <DDBusSender>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
extern void initFontColor(QWidget *widget);
|
||||
|
||||
AdapterItem::AdapterItem(AdaptersManager *adapterManager, Adapter *adapter, QWidget *parent)
|
||||
@ -67,15 +70,15 @@ AdapterItem::AdapterItem(AdaptersManager *adapterManager, Adapter *adapter, QWid
|
||||
m_centralWidget->setAutoFillBackground(false);
|
||||
viewport()->setAutoFillBackground(false);
|
||||
|
||||
auto myDevices = adapter->devices();
|
||||
for (auto constDevice : myDevices) {
|
||||
QMap<QString, const Device *> myDevices = adapter->devices();
|
||||
for (const Device *constDevice : myDevices) {
|
||||
auto device = const_cast<Device *>(constDevice);
|
||||
if (device)
|
||||
createDeviceItem(device);
|
||||
}
|
||||
|
||||
m_initDeviceState = Device::StateUnavailable;
|
||||
for (auto constDevice : myDevices) {
|
||||
for (const Device *constDevice : myDevices) {
|
||||
auto device = const_cast<Device *>(constDevice);
|
||||
if (device) {
|
||||
if (device->state() == Device::StateAvailable) {
|
||||
@ -133,7 +136,7 @@ void AdapterItem::deviceItemPaired(const bool paired)
|
||||
{
|
||||
auto device = qobject_cast<Device *>(sender());
|
||||
if (device) {
|
||||
auto deviceItem = m_deviceItems.value(device->id());
|
||||
DeviceItem *deviceItem = m_deviceItems.value(device->id());
|
||||
if (paired) {
|
||||
m_sortUnConnect.removeOne(deviceItem);
|
||||
m_sortConnected << deviceItem;
|
||||
@ -149,8 +152,8 @@ void AdapterItem::deviceRssiChanged()
|
||||
{
|
||||
auto device = qobject_cast<Device *>(sender());
|
||||
if (device) {
|
||||
auto deviceItem = m_deviceItems.value(device->id());
|
||||
auto state = device->state();
|
||||
DeviceItem *deviceItem = m_deviceItems.value(device->id());
|
||||
Device::State state = device->state();
|
||||
if (deviceItem && Device::StateConnected == state)
|
||||
qSort(m_sortConnected);
|
||||
else
|
||||
@ -164,7 +167,7 @@ void AdapterItem::removeDeviceItem(const Device *device)
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
auto deviceItem = m_deviceItems.value(device->id());
|
||||
DeviceItem *deviceItem = m_deviceItems.value(device->id());
|
||||
if (deviceItem) {
|
||||
m_deviceItems.remove(device->id());
|
||||
m_sortConnected.removeOne(deviceItem);
|
||||
@ -196,7 +199,7 @@ void AdapterItem::deviceChangeState(const Device::State state)
|
||||
{
|
||||
auto device = qobject_cast<Device *>(sender());
|
||||
if (device) {
|
||||
auto deviceItem = m_deviceItems.value(device->id());
|
||||
DeviceItem *deviceItem = m_deviceItems.value(device->id());
|
||||
if (deviceItem) {
|
||||
switch (state) {
|
||||
case Device::StateUnavailable: {
|
||||
@ -254,7 +257,7 @@ void AdapterItem::createDeviceItem(Device *device)
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
auto deviceId = device->id();
|
||||
QString deviceId = device->id();
|
||||
auto deviceItem = new DeviceItem(device->name(), this);
|
||||
deviceItem->setDevice(device);
|
||||
m_deviceItems[deviceId] = deviceItem;
|
||||
@ -273,14 +276,14 @@ void AdapterItem::createDeviceItem(Device *device)
|
||||
|
||||
void AdapterItem::updateView()
|
||||
{
|
||||
auto contentHeight = m_switchItem->height();
|
||||
int contentHeight = m_switchItem->height();
|
||||
contentHeight += (m_deviceLayout->count() - 3) * ITEMHEIGHT;
|
||||
m_centralWidget->setFixedHeight(contentHeight);
|
||||
setFixedHeight(contentHeight);
|
||||
emit sizeChange();
|
||||
}
|
||||
|
||||
void AdapterItem::showDevices(bool change)
|
||||
void AdapterItem::showDevices(bool powered)
|
||||
{
|
||||
if (m_sortConnected.size())
|
||||
qSort(m_sortConnected);
|
||||
@ -291,15 +294,15 @@ void AdapterItem::showDevices(bool change)
|
||||
deviceItems << m_sortConnected << m_sortUnConnect;
|
||||
|
||||
for (DeviceItem *deviceItem : deviceItems) {
|
||||
if (change)
|
||||
if (powered)
|
||||
m_deviceLayout->addWidget(deviceItem);
|
||||
else
|
||||
m_deviceLayout->removeWidget(deviceItem);
|
||||
deviceItem->setVisible(change);
|
||||
deviceItem->setVisible(powered);
|
||||
}
|
||||
|
||||
auto itemCount = m_deviceItems.size();
|
||||
m_line->setVisible(change);
|
||||
int itemCount = m_deviceItems.size();
|
||||
m_line->setVisible(powered);
|
||||
m_openControlCenter->setVisible(!itemCount);
|
||||
updateView();
|
||||
}
|
||||
|
@ -26,10 +26,9 @@
|
||||
#include "device.h"
|
||||
|
||||
#include <QScrollArea>
|
||||
#include <QMap>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
class QLabel;
|
||||
class QVBoxLayout;
|
||||
class HorizontalSeparator;
|
||||
class Adapter;
|
||||
class SwitchItem;
|
||||
@ -65,7 +64,7 @@ private slots:
|
||||
private:
|
||||
void createDeviceItem(Device *device);
|
||||
void updateView();
|
||||
void showDevices(bool change);
|
||||
void showDevices(bool powered);
|
||||
|
||||
private:
|
||||
QWidget *m_centralWidget;
|
||||
@ -77,7 +76,7 @@ private:
|
||||
|
||||
Adapter *m_adapter;
|
||||
SwitchItem *m_switchItem;
|
||||
QMap<QString, DeviceItem*> m_deviceItems;
|
||||
QMap<QString, DeviceItem *> m_deviceItems;
|
||||
Device::State m_initDeviceState;
|
||||
Device::State m_currentDeviceState;
|
||||
QList<DeviceItem *> m_sortConnected;
|
||||
|
@ -35,6 +35,7 @@ AdaptersManager::AdaptersManager(QObject *parent)
|
||||
"/com/deepin/daemon/Bluetooth",
|
||||
QDBusConnection::sessionBus(),
|
||||
this))
|
||||
, m_defaultAdapterState(false)
|
||||
{
|
||||
connect(m_bluetoothInter, &DBusBluetooth::AdapterAdded, this, &AdaptersManager::addAdapter);
|
||||
connect(m_bluetoothInter, &DBusBluetooth::AdapterRemoved, this, &AdaptersManager::removeAdapter);
|
||||
@ -77,10 +78,7 @@ AdaptersManager::AdaptersManager(QObject *parent)
|
||||
for (int index = 0; index < arr.size(); index++) {
|
||||
auto *adapter = new Adapter(this);
|
||||
adapterAdd(adapter, arr[index].toObject());
|
||||
if (!index) {
|
||||
adapter->setCurrent(true);
|
||||
m_defaultAdapterState = adapter->powered();
|
||||
}
|
||||
m_defaultAdapterState |= adapter->powered();
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,7 +177,7 @@ void AdaptersManager::onDevicePropertiesChanged(const QString &json)
|
||||
{
|
||||
const QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
||||
const QJsonObject obj = doc.object();
|
||||
for (auto constAdapter : m_adapters) {
|
||||
for (const Adapter *constAdapter : m_adapters) {
|
||||
auto adapter = const_cast<Adapter *>(constAdapter);
|
||||
if (adapter)
|
||||
adapter->updateDevice(obj);
|
||||
@ -254,7 +252,7 @@ void AdaptersManager::adapterAdd(Adapter *adapter, const QJsonObject &adpterObj)
|
||||
if (!call.isError()) {
|
||||
QDBusReply<QString> reply = call.reply();
|
||||
const QString replyStr = reply.value();
|
||||
auto doc = QJsonDocument::fromJson(replyStr.toUtf8());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(replyStr.toUtf8());
|
||||
adapter->initDevicesList(doc);
|
||||
emit this->adapterIncreased(adapter);
|
||||
} else {
|
||||
@ -264,7 +262,7 @@ void AdaptersManager::adapterAdd(Adapter *adapter, const QJsonObject &adpterObj)
|
||||
delete watcher;
|
||||
});
|
||||
|
||||
auto id = adapter->id();
|
||||
QString id = adapter->id();
|
||||
if (!id.isEmpty()) {
|
||||
m_adapters[id] = adapter;
|
||||
}
|
||||
|
@ -86,11 +86,11 @@ bool DeviceItem::operator <(const DeviceItem &item)
|
||||
return this->device()->rssi() < item.device()->rssi();
|
||||
}
|
||||
|
||||
void DeviceItem::setDevice(Device *d)
|
||||
void DeviceItem::setDevice(Device *device)
|
||||
{
|
||||
if (d) {
|
||||
m_device = d;
|
||||
changeState(d->state());
|
||||
if (device) {
|
||||
m_device = device;
|
||||
changeState(device->state());
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,7 +105,6 @@ void DeviceItem::enterEvent(QEvent *event)
|
||||
QWidget::enterEvent(event);
|
||||
if (m_device) {
|
||||
if (Device::StateConnected == m_device->state()) {
|
||||
// m_state->setPixmap(QPixmap(":/notify_close_press@2x.png"));
|
||||
m_state->setPixmap(QPixmap(":/disconnect" + m_statSuffix));
|
||||
}
|
||||
}
|
||||
@ -116,7 +115,6 @@ void DeviceItem::leaveEvent(QEvent *event)
|
||||
QWidget::enterEvent(event);
|
||||
if (m_device) {
|
||||
if (Device::StateConnected == m_device->state()) {
|
||||
// m_state->setPixmap(QPixmap(":/list_select@2x.png"));
|
||||
m_state->setPixmap(QPixmap(":/select" + m_statSuffix));
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
|
||||
inline void setTitle(const QString &name) { m_title->setText(name); }
|
||||
|
||||
void setDevice(Device *d);
|
||||
void setDevice(Device *device);
|
||||
inline Device *device() { return m_device; }
|
||||
inline const Device *device() const { return m_device; }
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QFontMetrics>
|
||||
#include <QLabel>
|
||||
|
||||
extern void initFontColor(QWidget *widget);
|
||||
|
||||
@ -40,7 +41,7 @@ SwitchItem::SwitchItem(QWidget *parent)
|
||||
m_switchBtn->setFixedWidth(SWITCHBUTTONWIDTH);
|
||||
|
||||
setFixedHeight(CONTROLHEIGHT);
|
||||
auto switchLayout = new QHBoxLayout(this);
|
||||
auto switchLayout = new QHBoxLayout;
|
||||
switchLayout->setSpacing(0);
|
||||
switchLayout->setMargin(0);
|
||||
switchLayout->addSpacing(MARGIN);
|
||||
|
@ -25,10 +25,9 @@
|
||||
|
||||
#include <DSwitchButton>
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
class QLabel;
|
||||
class SwitchItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
Loading…
x
Reference in New Issue
Block a user