mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
fix: 修复蓝牙列表抖动的问题
只有一个蓝牙设备时,鼠标放上去滚动会抖动 Log: Bug: https://pms.uniontech.com/zentao/bug-view-81649.html Change-Id: I745bcca6b2b1b71c12c231db6af17172a551e009
This commit is contained in:
parent
04d3f65802
commit
bf3063f150
@ -182,8 +182,15 @@ void BluetoothAdapterItem::updateIconTheme(DGuiApplicationHelper::ColorType type
|
||||
|
||||
QSize BluetoothAdapterItem::sizeHint() const
|
||||
{
|
||||
return QSize(ItemWidth, m_deviceListview->model()->rowCount() * DeviceItemHeight
|
||||
+ (m_deviceListview->model()->rowCount() > 0 ? m_seperator->sizeHint().height() : 0));// 加上割线的高度
|
||||
int visualHeight = 0;
|
||||
for (int i = 0; i < m_deviceListview->count(); i++)
|
||||
visualHeight += m_deviceListview->visualRect(m_deviceModel->index(i, 0)).height();
|
||||
|
||||
int listMargin = m_deviceListview->contentsMargins().top() + m_deviceListview->contentsMargins().bottom();
|
||||
//显示声音设备列表高度 = 设备的高度 + 间隔 + 边距
|
||||
int viewHeight = visualHeight + m_deviceListview->spacing() * (m_deviceListview->count() - 1) + listMargin;
|
||||
|
||||
return QSize(ItemWidth, m_adapterLabel->height() + (m_adapter->powered() ? m_seperator->sizeHint().height() + viewHeight : 0));// 加上分割线的高度
|
||||
}
|
||||
|
||||
int BluetoothAdapterItem::currentDeviceCount()
|
||||
@ -283,16 +290,19 @@ void BluetoothAdapterItem::initUi()
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_deviceListview->setAccessibleName("DeviceItemList");
|
||||
m_deviceListview->setModel(m_deviceModel);
|
||||
m_deviceListview->setItemSize(QSize(ItemWidth, DeviceItemHeight));
|
||||
m_deviceListview->setContentsMargins(0, 0, 0, 0);
|
||||
m_deviceListview->setBackgroundType(DStyledItemDelegate::ClipCornerBackground);
|
||||
m_deviceListview->setItemRadius(0);
|
||||
m_deviceListview->setFrameShape(QFrame::NoFrame);
|
||||
m_deviceListview->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
m_deviceListview->setSelectionMode(QAbstractItemView::NoSelection);
|
||||
m_deviceListview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_deviceListview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_deviceListview->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
|
||||
m_deviceListview->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
m_deviceListview->setItemSize(QSize(ItemWidth, DeviceItemHeight));
|
||||
m_deviceListview->setItemMargins(QMargins(0, 0, 0, 0));
|
||||
m_deviceListview->setModel(m_deviceModel);
|
||||
|
||||
mainLayout->addWidget(m_adapterLabel);
|
||||
mainLayout->addWidget(m_seperator);
|
||||
|
@ -125,7 +125,6 @@ signals:
|
||||
|
||||
private:
|
||||
void initData();
|
||||
// void setItemHoverColor();
|
||||
void initUi();
|
||||
void initConnect();
|
||||
void setUnnamedDevicesVisible(bool isShow);
|
||||
|
@ -212,9 +212,9 @@ void BluetoothApplet::initUi()
|
||||
m_settingLabel->setFixedHeight(DeviceItemHeight);
|
||||
DFontSizeManager::instance()->bind(m_settingLabel->label(), DFontSizeManager::T7);
|
||||
|
||||
m_contentWidget->setContentsMargins(0, 0, 0, 0);
|
||||
m_contentLayout->setMargin(0);
|
||||
m_contentLayout->setSpacing(0);
|
||||
m_contentLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_contentLayout->addWidget(m_seperator);
|
||||
m_contentLayout->addWidget(m_settingLabel, 0, Qt::AlignBottom | Qt::AlignVCenter);
|
||||
|
||||
@ -232,6 +232,7 @@ void BluetoothApplet::initUi()
|
||||
|
||||
m_mainLayout->setMargin(0);
|
||||
m_mainLayout->setSpacing(0);
|
||||
m_mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_mainLayout->addWidget(m_scroarea);
|
||||
updateSize();
|
||||
}
|
||||
@ -275,12 +276,12 @@ void BluetoothApplet::updateIconTheme()
|
||||
void BluetoothApplet::updateSize()
|
||||
{
|
||||
int height = 0;
|
||||
height += TitleSpace;
|
||||
foreach (const auto item, m_adapterItems) {
|
||||
height += TitleHeight;
|
||||
height += item->sizeHint().height();
|
||||
}
|
||||
|
||||
height += m_seperator->height();
|
||||
|
||||
// 加上蓝牙设置选项的高度
|
||||
height += DeviceItemHeight;
|
||||
|
||||
|
@ -43,7 +43,6 @@ DGUI_USE_NAMESPACE
|
||||
|
||||
extern const QString DarkType;
|
||||
extern const QString LightType;
|
||||
extern void initFontColor(QWidget *widget);
|
||||
|
||||
AccessPointWidget::AccessPointWidget(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
@ -57,7 +56,7 @@ AccessPointWidget::AccessPointWidget(QWidget *parent)
|
||||
m_ssidBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
|
||||
m_ssidBtn->setObjectName("Ssid");
|
||||
initFontColor(m_ssidBtn);
|
||||
m_ssidBtn->setForegroundRole(QPalette::BrightText);
|
||||
|
||||
bool isLight = (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType);
|
||||
|
||||
|
@ -36,7 +36,6 @@ DWIDGET_USE_NAMESPACE
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
extern const int ItemHeight = 30;
|
||||
extern void initFontColor(QWidget *widget);
|
||||
|
||||
DeviceControlWidget::DeviceControlWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@ -45,7 +44,7 @@ DeviceControlWidget::DeviceControlWidget(QWidget *parent)
|
||||
, m_loadingIndicator(new DLoadingIndicator(this))
|
||||
{
|
||||
m_deviceName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
initFontColor(m_deviceName);
|
||||
m_deviceName->setForegroundRole(QPalette::BrightText);
|
||||
|
||||
const QPixmap pixmap = DHiDPIHelper::loadNxPixmap(":/wireless/resources/wireless/refresh.svg");
|
||||
|
||||
|
@ -40,7 +40,6 @@ DGUI_USE_NAMESPACE
|
||||
const int ItemHeight = 36;
|
||||
extern const QString DarkType = "_dark.svg";
|
||||
extern const QString LightType = ".svg";
|
||||
extern void initFontColor(QWidget *widget);
|
||||
|
||||
WiredItem::WiredItem(WiredDevice *device, const QString &deviceName, QWidget *parent)
|
||||
: DeviceItem(device, parent)
|
||||
@ -61,7 +60,7 @@ WiredItem::WiredItem(WiredDevice *device, const QString &deviceName, QWidget *pa
|
||||
|
||||
m_connectedName->setText(m_deviceName);
|
||||
m_connectedName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
initFontColor(m_connectedName);
|
||||
m_connectedName->setForegroundRole(QPalette::BrightText);
|
||||
|
||||
auto connectionLayout = new QVBoxLayout(this);
|
||||
connectionLayout->setMargin(0);
|
||||
|
@ -26,24 +26,6 @@ const QString MenueSettings = "settings";
|
||||
#define TITLE_HEIGHT 46
|
||||
#define ITEM_HEIGHT 36
|
||||
|
||||
extern void initFontColor(QWidget *widget)
|
||||
{
|
||||
if (!widget)
|
||||
return;
|
||||
|
||||
auto fontChange = [&](QWidget * widget) {
|
||||
QPalette defaultPalette = widget->palette();
|
||||
defaultPalette.setBrush(QPalette::WindowText, defaultPalette.brightText());
|
||||
widget->setPalette(defaultPalette);
|
||||
};
|
||||
|
||||
fontChange(widget);
|
||||
|
||||
QObject::connect(DApplicationHelper::instance(), &DApplicationHelper::themeTypeChanged, widget, [ = ] {
|
||||
fontChange(widget);
|
||||
});
|
||||
}
|
||||
|
||||
NetworkItem::NetworkItem(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_tipsWidget(new Dock::TipsWidget(this))
|
||||
|
Loading…
x
Reference in New Issue
Block a user