diff --git a/frame/util/horizontalseperator.cpp b/frame/util/horizontalseperator.cpp index f56524c5f..66d0531ed 100644 --- a/frame/util/horizontalseperator.cpp +++ b/frame/util/horizontalseperator.cpp @@ -44,7 +44,5 @@ void HorizontalSeperator::paintEvent(QPaintEvent *e) QColor c = palette().color(QPalette::BrightText); c.setAlpha(int(0.1 * 255)); - painter.setPen(c); - painter.setBrush(c); painter.fillRect(rect(), c); } diff --git a/plugins/bluetooth/componments/bluetoothadapteritem.cpp b/plugins/bluetooth/componments/bluetoothadapteritem.cpp index 08e631c1d..5c3cc9573 100644 --- a/plugins/bluetooth/componments/bluetoothadapteritem.cpp +++ b/plugins/bluetooth/componments/bluetoothadapteritem.cpp @@ -54,8 +54,6 @@ BluetoothDeviceItem::~BluetoothDeviceItem() delete m_loading; m_loading = nullptr; } - - delete m_standarditem; } void BluetoothDeviceItem::initActionList() @@ -183,8 +181,6 @@ void BluetoothAdapterItem::updateIconTheme(DGuiApplicationHelper::ColorType type m_refreshBtn->setRotateIcon(":/wireless/resources/wireless/refresh_dark.svg"); else m_refreshBtn->setRotateIcon(":/wireless/resources/wireless/refresh.svg"); - - setItemHoverColor(); } int BluetoothAdapterItem::currentDeviceCount() @@ -264,22 +260,13 @@ void BluetoothAdapterItem::onDeviceNameUpdated(const Device *device) } } -/** - * @brief BluetoothAdapterItem::setItemHoverColor 通过代理方式根据当前主题设置蓝牙列表文字颜色和item选中颜色 - */ -void BluetoothAdapterItem::setItemHoverColor() -{ - QPalette hoverBackgroud = m_deviceListview->palette(); - if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) { - hoverBackgroud.setColor(QPalette::Normal, QPalette::Highlight, QColor(0, 0, 0, 30)); - hoverBackgroud.setColor(QPalette::Normal, QPalette::HighlightedText, Qt::black); - } else { - hoverBackgroud.setColor(QPalette::Normal, QPalette::Highlight, QColor(255, 255, 255, 30)); - hoverBackgroud.setColor(QPalette::Normal, QPalette::HighlightedText, Qt::white); - } - m_deviceListview->setPalette(hoverBackgroud); - m_deviceListview->setItemDelegate(m_itemDelegate); -} +///** +// * @brief BluetoothAdapterItem::setItemHoverColor 通过代理方式根据当前主题设置蓝牙列表文字颜色和item选中颜色 +// */ +//void BluetoothAdapterItem::setItemHoverColor() +//{ +// m_deviceListview->setItemDelegate(m_itemDelegate); +//} void BluetoothAdapterItem::initUi() { @@ -301,7 +288,6 @@ void BluetoothAdapterItem::initUi() m_deviceListview->setAccessibleName("DeviceItemList"); m_deviceListview->setModel(m_deviceModel); - updateIconTheme(DGuiApplicationHelper::instance()->themeType()); m_deviceListview->setItemSize(QSize(ItemWidth, DeviceItemHeight)); m_deviceListview->setBackgroundType(DStyledItemDelegate::ClipCornerBackground); m_deviceListview->setItemRadius(0); @@ -317,6 +303,8 @@ void BluetoothAdapterItem::initUi() mainLayout->addWidget(m_deviceListview); mainLayout->addWidget(m_bottomSeperator); + m_deviceListview->setItemDelegate(m_itemDelegate); + updateIconTheme(DGuiApplicationHelper::instance()->themeType()); if (m_adapter->discover()) { m_refreshBtn->startRotate(); diff --git a/plugins/bluetooth/componments/bluetoothadapteritem.h b/plugins/bluetooth/componments/bluetoothadapteritem.h index 72e7880b0..b7f230e30 100644 --- a/plugins/bluetooth/componments/bluetoothadapteritem.h +++ b/plugins/bluetooth/componments/bluetoothadapteritem.h @@ -123,7 +123,7 @@ signals: private: void initData(); - void setItemHoverColor(); +// void setItemHoverColor(); void initUi(); void initConnect(); void setUnnamedDevicesVisible(bool isShow); diff --git a/plugins/bluetooth/componments/bluetoothapplet.cpp b/plugins/bluetooth/componments/bluetoothapplet.cpp index 94dca0df8..f07194187 100644 --- a/plugins/bluetooth/componments/bluetoothapplet.cpp +++ b/plugins/bluetooth/componments/bluetoothapplet.cpp @@ -44,33 +44,19 @@ SettingLabel::SettingLabel(QString text, QWidget *parent) , m_label(new DLabel(text, this)) , m_layout(new QHBoxLayout(this)) { - updateIconTheme(); setAccessibleName("BluetoothSettingLabel"); setContentsMargins(0, 0, 0, 0); m_layout->setMargin(0); m_layout->addSpacing(20); m_layout->addWidget(m_label, 0, Qt::AlignLeft | Qt::AlignHCenter); m_layout->addStretch(); - connect(DApplicationHelper::instance(), &DApplicationHelper::themeTypeChanged, this, &SettingLabel::updateIconTheme); -} -/** - * @brief SettingLabel::updateIconTheme 根据主题的深浅设置字体的颜色,控件的背景颜色 - */ -void SettingLabel::updateIconTheme() -{ - QPalette backgroud; - QPalette textColor; - if(DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType){ - //蓝牙设置,电脑用户名文字显示高亮 - textColor.setColor(QPalette::WindowText, QPalette::BrightText); - } else { - textColor.setColor(QPalette::WindowText, Qt::white); - } - m_label->setPalette(textColor); - backgroud.setColor(QPalette::Background, Qt::transparent); - this->setAutoFillBackground(true); - this->setPalette(backgroud); + setAutoFillBackground(true); + QPalette p = this->palette(); + p.setColor(QPalette::Background, Qt::transparent); + this->setPalette(p); + + m_label->setForegroundRole(QPalette::BrightText); } void SettingLabel::addButton(QWidget *button, int space) diff --git a/plugins/bluetooth/componments/bluetoothapplet.h b/plugins/bluetooth/componments/bluetoothapplet.h index e079788d8..7bd79dff7 100644 --- a/plugins/bluetooth/componments/bluetoothapplet.h +++ b/plugins/bluetooth/componments/bluetoothapplet.h @@ -52,6 +52,7 @@ public: explicit SettingLabel(QString text, QWidget *parent = nullptr); void addButton(QWidget *button, int space); DLabel *label() { return m_label; } + signals: void clicked(); @@ -59,8 +60,6 @@ protected: void mousePressEvent(QMouseEvent *ev) override; void paintEvent(QPaintEvent *event) override; -private: - void updateIconTheme(); private: DLabel *m_label; diff --git a/plugins/sound/soundapplet.cpp b/plugins/sound/soundapplet.cpp index 1a80eed94..0c804d550 100644 --- a/plugins/sound/soundapplet.cpp +++ b/plugins/sound/soundapplet.cpp @@ -245,8 +245,9 @@ void SoundApplet::initUi() setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_centralWidget->setAutoFillBackground(false); viewport()->setAutoFillBackground(false); + m_listView->setItemDelegate(m_itemDelegate); - m_secondSeperator->setVisible(m_model->rowCount() > 0); + m_secondSeperator->setVisible(m_model->rowCount() > 1); updateVolumeSliderStatus(Utils::SettingValue("com.deepin.dde.dock.module.sound", QByteArray(), "Enabled").toString()); connect(m_gsettings, &QGSettings::changed, [ = ] (const QString &key) { @@ -529,7 +530,7 @@ void SoundApplet::addPort(const Port *port) } m_model->appendRow(pi); m_model->sort(0); - m_secondSeperator->setVisible(m_model->rowCount() > 0); + m_secondSeperator->setVisible(m_model->rowCount() > 1); updateListHeight(); } @@ -549,7 +550,7 @@ void SoundApplet::removePort(const QString &portId, const uint &cardId) }; rmFunc(m_model); - m_secondSeperator->setVisible(m_model->rowCount() > 0); + m_secondSeperator->setVisible(m_model->rowCount() > 1); updateListHeight(); } @@ -673,7 +674,7 @@ void SoundApplet::updateListHeight() } int visualHeight = 0; - for (int i = 0; i < count; i++) + for (int i = 1; i < count; i++) visualHeight += m_listView->visualRect(m_model->index(i, 0)).height(); int listMargin = m_listView->contentsMargins().top() + m_listView->contentsMargins().bottom();