From 33541697382c252e2200609e739245d2335204ac Mon Sep 17 00:00:00 2001 From: fpc_diesel Date: Thu, 14 May 2020 19:57:49 +0800 Subject: [PATCH] fix:format code --- plugins/bluetooth/bluetoothapplet.cpp | 7 +++---- plugins/bluetooth/bluetoothitem.cpp | 14 +++++++------- plugins/bluetooth/bluetoothitem.h | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/plugins/bluetooth/bluetoothapplet.cpp b/plugins/bluetooth/bluetoothapplet.cpp index 319d320ba..1401239a8 100644 --- a/plugins/bluetooth/bluetoothapplet.cpp +++ b/plugins/bluetooth/bluetoothapplet.cpp @@ -61,6 +61,8 @@ BluetoothApplet::BluetoothApplet(QWidget *parent) , m_appletName(new QLabel(this)) , m_centralWidget(new QWidget) , m_centrealLayout(new QVBoxLayout) + , m_adapterLayout(new QVBoxLayout) + , m_menueLayout(new QHBoxLayout) , m_openControlCenter(new MenueItem(this)) , m_adaptersManager(new AdaptersManager(this)) { @@ -79,20 +81,17 @@ BluetoothApplet::BluetoothApplet(QWidget *parent) m_openControlCenter->setFixedHeight(ITEMHEIGHT); m_openControlCenter->setVisible(false); - auto appletNameLayout = new QHBoxLayout; + QHBoxLayout *appletNameLayout = new QHBoxLayout; appletNameLayout->setMargin(0); appletNameLayout->setSpacing(0); appletNameLayout->addSpacing(MARGIN); appletNameLayout->addWidget(m_appletName); appletNameLayout->addStretch(); - m_menueLayout = new QHBoxLayout; m_menueLayout->setMargin(0); m_menueLayout->setSpacing(0); m_menueLayout->addSpacing(MARGIN); - m_adapterLayout = new QVBoxLayout; - m_centrealLayout->setMargin(0); m_centrealLayout->setSpacing(0); m_centrealLayout->addLayout(appletNameLayout); diff --git a/plugins/bluetooth/bluetoothitem.cpp b/plugins/bluetooth/bluetoothitem.cpp index e9f2d8f8d..58166b083 100644 --- a/plugins/bluetooth/bluetoothitem.cpp +++ b/plugins/bluetooth/bluetoothitem.cpp @@ -43,12 +43,12 @@ BluetoothItem::BluetoothItem(QWidget *parent) : QWidget(parent) , m_tipsLabel(new TipsWidget(this)) , m_applet(new BluetoothApplet(this)) - , m_timer(new QTimer(this)) + , m_refreshIconTimer(new QTimer(this)) { m_applet->setVisible(false); m_adapterPowered = m_applet->poweredInitState(); - - connect(m_timer, &QTimer::timeout, this, &BluetoothItem::refreshIcon); + m_refreshIconTimer->setInterval(100); + connect(m_refreshIconTimer, &QTimer::timeout, this, &BluetoothItem::refreshIcon); connect(m_applet, &BluetoothApplet::powerChanged, [&](bool powered) { m_adapterPowered = powered; refreshIcon(); @@ -58,8 +58,8 @@ BluetoothItem::BluetoothItem(QWidget *parent) refreshIcon(); }); connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &BluetoothItem::refreshIcon); - connect(m_applet, SIGNAL(noAdapter()), this, SIGNAL(noAdapter())); - connect(m_applet, SIGNAL(justHasAdapter()), this, SIGNAL(justHasAdapter())); + connect(m_applet,&BluetoothApplet::noAdapter,this,&BluetoothItem::noAdapter); + connect(m_applet,&BluetoothApplet::justHasAdapter,this,&BluetoothItem::justHasAdapter); } QWidget *BluetoothItem::tipsWidget() @@ -134,7 +134,7 @@ void BluetoothItem::refreshIcon() stateString = "active"; break; case Device::StateAvailable: { - m_timer->start(); + m_refreshIconTimer->start(); stateString = "waiting"; iconString = QString("bluetooth-%1-symbolic").arg(stateString); const qreal ratio = devicePixelRatioF(); @@ -155,7 +155,7 @@ void BluetoothItem::refreshIcon() stateString = "disable"; } - m_timer->stop(); + m_refreshIconTimer->stop(); iconString = QString("bluetooth-%1-symbolic").arg(stateString); const qreal ratio = devicePixelRatioF(); diff --git a/plugins/bluetooth/bluetoothitem.h b/plugins/bluetooth/bluetoothitem.h index a82745afd..1f5cc764c 100644 --- a/plugins/bluetooth/bluetoothitem.h +++ b/plugins/bluetooth/bluetoothitem.h @@ -65,7 +65,7 @@ private: Device::State m_devState; bool m_adapterPowered; - QTimer *m_timer; + QTimer *m_refreshIconTimer; }; #endif // BLUETOOTHITEM_H