From 78eb30b41d093052703f5876d84117019c65206a Mon Sep 17 00:00:00 2001 From: FanPengCheng Date: Thu, 27 May 2021 21:22:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=93=9D=E7=89=99?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=80=89=E4=B8=AD=E5=90=8E=E6=9C=89=E8=B7=B3?= =?UTF-8?q?=E5=8A=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 应该是开发理解有误,特意加了这个效果,现在去除掉 Log: 修复蓝牙列表选中后有跳动的问题 Bug: https://pms.uniontech.com/zentao/bug-view-81687.html Change-Id: I060615a36c851e5e91805d51e681f02cd2e0f88c --- .../componments/bluetoothadapteritem.cpp | 32 ++----------------- .../componments/bluetoothadapteritem.h | 9 +----- plugins/sound/soundapplet.cpp | 27 +--------------- plugins/sound/soundapplet.h | 9 +----- 4 files changed, 5 insertions(+), 72 deletions(-) diff --git a/plugins/bluetooth/componments/bluetoothadapteritem.cpp b/plugins/bluetooth/componments/bluetoothadapteritem.cpp index b664bf74d..050a4c5aa 100644 --- a/plugins/bluetooth/componments/bluetoothadapteritem.cpp +++ b/plugins/bluetooth/componments/bluetoothadapteritem.cpp @@ -36,31 +36,6 @@ #include #include -ItemDelegate::ItemDelegate(QAbstractItemView *parent) - : DStyledItemDelegate(parent) -{ - -} - -/** - * @brief ItemDelegate::paint 绘制鼠标移动到蓝牙列表某条item上的选中效果 - * @param painter - * @param option - * @param index - */ -void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - QStyleOptionViewItem styleOption = option; - - if ((styleOption.state & QStyle::State_MouseOver)) { - styleOption.showDecorationSelected = true; - styleOption.state |= QStyle::State_Selected; - styleOption.rect += QMargins(1, 1, 1, 1); - } - - DStyledItemDelegate::paint(painter, styleOption, index); -} - BluetoothDeviceItem::BluetoothDeviceItem(QStyle *style, const Device *device, DListView *parent) : m_style(style) , m_device(device) @@ -154,13 +129,10 @@ BluetoothAdapterItem::BluetoothAdapterItem(Adapter *adapter, QWidget *parent) , m_adapterLabel(new SettingLabel(adapter->name(), this)) , m_adapterStateBtn(new DSwitchButton(this)) , m_deviceListview(new DListView(this)) - , m_itemDelegate(new ItemDelegate(m_deviceListview)) + , m_itemDelegate(new DStyledItemDelegate(m_deviceListview)) , m_deviceModel(new QStandardItemModel(m_deviceListview)) , m_refreshBtn(new RefreshButton(this)) - , m_bluetoothInter(new DBusBluetooth("com.deepin.daemon.Bluetooth", - "/com/deepin/daemon/Bluetooth", - QDBusConnection::sessionBus(), - this)) + , m_bluetoothInter(new DBusBluetooth("com.deepin.daemon.Bluetooth", "/com/deepin/daemon/Bluetooth", QDBusConnection::sessionBus(), this)) , m_showUnnamedDevices(false) , m_seperator(new HorizontalSeperator(this)) , m_bottomSeperator(new HorizontalSeperator(this)) diff --git a/plugins/bluetooth/componments/bluetoothadapteritem.h b/plugins/bluetooth/componments/bluetoothadapteritem.h index a93b1eef8..72e7880b0 100644 --- a/plugins/bluetooth/componments/bluetoothadapteritem.h +++ b/plugins/bluetooth/componments/bluetoothadapteritem.h @@ -54,13 +54,6 @@ class HorizontalSeperator; const QString LightString = QString(":/light/buletooth_%1_light.svg"); const QString DarkString = QString(":/dark/buletooth_%1_dark.svg"); -class ItemDelegate : public DStyledItemDelegate -{ -public: - ItemDelegate(QAbstractItemView *parent = nullptr); - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; -}; - class BluetoothDeviceItem : public QObject { Q_OBJECT @@ -139,7 +132,7 @@ private: SettingLabel *m_adapterLabel; DSwitchButton *m_adapterStateBtn; DListView *m_deviceListview; - ItemDelegate *m_itemDelegate; + DStyledItemDelegate *m_itemDelegate; QStandardItemModel *m_deviceModel; RefreshButton *m_refreshBtn; DBusBluetooth *m_bluetoothInter; diff --git a/plugins/sound/soundapplet.cpp b/plugins/sound/soundapplet.cpp index 0fd1ade7f..edccf139d 100644 --- a/plugins/sound/soundapplet.cpp +++ b/plugins/sound/soundapplet.cpp @@ -50,31 +50,6 @@ DWIDGET_USE_NAMESPACE DGUI_USE_NAMESPACE using namespace Dock; -ItemDelegate::ItemDelegate(QAbstractItemView *parent) - : DStyledItemDelegate(parent) -{ - -} - -/** - * @brief ItemDelegate::paint 绘制鼠标移动到音频列表某条item上的选中效果 - * @param painter - * @param option - * @param index - */ -void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - QStyleOptionViewItem styleOption = option; - - if ((styleOption.state & QStyle::State_MouseOver)) { - styleOption.showDecorationSelected = true; - styleOption.state |= QStyle::State_Selected; - styleOption.rect += QMargins(1, 1, 1, 1); - } - - DStyledItemDelegate::paint(painter, styleOption, index); -} - Q_DECLARE_METATYPE(const Port *) Port::Port(QObject *parent) @@ -147,7 +122,7 @@ SoundApplet::SoundApplet(QWidget *parent) , m_defSinkInter(nullptr) , m_listView(new DListView(this)) , m_model(new QStandardItemModel(m_listView)) - , m_itemDelegate(new ItemDelegate(m_listView)) + , m_itemDelegate(new DStyledItemDelegate(m_listView)) , m_deviceInfo("") , m_lastPort(nullptr) , m_gsettings(Utils::ModuleSettingsPtr("sound", QByteArray(), this)) diff --git a/plugins/sound/soundapplet.h b/plugins/sound/soundapplet.h index 0064a79c4..e9c57210e 100644 --- a/plugins/sound/soundapplet.h +++ b/plugins/sound/soundapplet.h @@ -47,13 +47,6 @@ namespace Dock{ class TipsWidget; } -class ItemDelegate : public DStyledItemDelegate -{ -public: - ItemDelegate(QAbstractItemView *parent = nullptr); - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; -}; - class Port : public QObject { Q_OBJECT @@ -164,7 +157,7 @@ private: DBusSink *m_defSinkInter; DTK_WIDGET_NAMESPACE::DListView *m_listView; QStandardItemModel *m_model; - ItemDelegate *m_itemDelegate; + DStyledItemDelegate *m_itemDelegate; QList m_ports; QString m_deviceInfo; QPointer m_lastPort;//最后一个因为只有一个设备而被直接移除的设备