From 4f95c21031ceb5b60ca809da504007bcc2c43080 Mon Sep 17 00:00:00 2001 From: FanPengCheng Date: Fri, 28 May 2021 13:57:29 +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=97=B4=E9=9A=94=E4=B8=8E=E6=BB=91=E5=8A=A8?= =?UTF-8?q?=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-81649.html Change-Id: Id85b8bede51f1cff9c1933f494d2eefe70fbb69b --- frame/util/horizontalseperator.cpp | 3 +++ .../componments/bluetoothadapteritem.cpp | 7 ------- .../bluetooth/componments/bluetoothapplet.cpp | 3 +-- plugins/sound/soundapplet.cpp | 21 ++++++++++--------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/frame/util/horizontalseperator.cpp b/frame/util/horizontalseperator.cpp index 8f24e81c2..f56524c5f 100644 --- a/frame/util/horizontalseperator.cpp +++ b/frame/util/horizontalseperator.cpp @@ -43,5 +43,8 @@ void HorizontalSeperator::paintEvent(QPaintEvent *e) QPainter painter(this); 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 050a4c5aa..08e631c1d 100644 --- a/plugins/bluetooth/componments/bluetoothadapteritem.cpp +++ b/plugins/bluetooth/componments/bluetoothadapteritem.cpp @@ -302,14 +302,8 @@ void BluetoothAdapterItem::initUi() m_deviceListview->setAccessibleName("DeviceItemList"); m_deviceListview->setModel(m_deviceModel); updateIconTheme(DGuiApplicationHelper::instance()->themeType()); - m_deviceListview->setItemSpacing(1); m_deviceListview->setItemSize(QSize(ItemWidth, DeviceItemHeight)); m_deviceListview->setBackgroundType(DStyledItemDelegate::ClipCornerBackground); - //设置蓝牙列表DListView背景为透明 - QPalette backgroud; - backgroud.setColor(QPalette::Base, Qt::transparent); - m_deviceListview->setAutoFillBackground(true); - m_deviceListview->setPalette(backgroud); m_deviceListview->setItemRadius(0); m_deviceListview->setEditTriggers(QAbstractItemView::NoEditTriggers); m_deviceListview->setSelectionMode(QAbstractItemView::NoSelection); @@ -319,7 +313,6 @@ void BluetoothAdapterItem::initUi() m_deviceListview->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); mainLayout->addWidget(m_adapterLabel); - mainLayout->addSpacing(2); mainLayout->addWidget(m_seperator); mainLayout->addWidget(m_deviceListview); mainLayout->addWidget(m_bottomSeperator); diff --git a/plugins/bluetooth/componments/bluetoothapplet.cpp b/plugins/bluetooth/componments/bluetoothapplet.cpp index f06f3d974..94dca0df8 100644 --- a/plugins/bluetooth/componments/bluetoothapplet.cpp +++ b/plugins/bluetooth/componments/bluetoothapplet.cpp @@ -174,8 +174,7 @@ void BluetoothApplet::onAdapterAdded(Adapter *adapter) connect(adapterItem, &BluetoothAdapterItem::requestRefreshAdapter, m_adaptersManager, &AdaptersManager::adapterRefresh); m_adapterItems.insert(adapter->id(), adapterItem); - //插入分割线 -// m_contentLayout->insertWidget(0, m_Separator, Qt::AlignTop | Qt::AlignVCenter); + m_contentLayout->insertWidget(0, adapterItem, Qt::AlignTop | Qt::AlignVCenter); updateBluetoothPowerState(); updateSize(); diff --git a/plugins/sound/soundapplet.cpp b/plugins/sound/soundapplet.cpp index 9d3505714..1a80eed94 100644 --- a/plugins/sound/soundapplet.cpp +++ b/plugins/sound/soundapplet.cpp @@ -169,13 +169,14 @@ SoundApplet::SoundApplet(QWidget *parent) void SoundApplet::initUi() { // setControlBackground(); + m_listView->setFrameShape(QFrame::NoFrame); m_listView->setEditTriggers(DListView::NoEditTriggers); m_listView->setSelectionMode(QAbstractItemView::NoSelection); m_listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_listView->setItemRadius(0); m_listView->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); m_listView->setFixedHeight(0); - m_listView->setItemSpacing(1); + m_listView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); m_listView->setModel(m_model); m_centralWidget->setAccessibleName("volumn-centralwidget"); @@ -208,6 +209,7 @@ void SoundApplet::initUi() // 标题部分 QHBoxLayout *deviceLayout = new QHBoxLayout; deviceLayout->setSpacing(0); + deviceLayout->setMargin(0); deviceLayout->setContentsMargins(20, 0, 10, 0); deviceLayout->addWidget(m_deviceLabel, 0, Qt::AlignLeft); deviceLayout->addWidget(m_soundShow, 0, Qt::AlignRight); @@ -215,12 +217,14 @@ void SoundApplet::initUi() // 音量滑动条 QHBoxLayout *volumeCtrlLayout = new QHBoxLayout; volumeCtrlLayout->setSpacing(0); + volumeCtrlLayout->setMargin(0); volumeCtrlLayout->setContentsMargins(12, 0, 12, 0); volumeCtrlLayout->addWidget(m_volumeIconMin); volumeCtrlLayout->addWidget(m_volumeSlider); volumeCtrlLayout->addWidget(m_volumeIconMax); m_centralLayout = new QVBoxLayout(this); + m_centralLayout->setContentsMargins(0, 0, 0, 0); m_centralLayout->setMargin(0); m_centralLayout->setSpacing(0); m_centralLayout->addLayout(deviceLayout); @@ -228,15 +232,11 @@ void SoundApplet::initUi() m_centralLayout->addLayout(volumeCtrlLayout); // 需要判断是否有声音端口 m_centralLayout->addWidget(m_secondSeperator); - m_secondSeperator->setVisible(m_model->rowCount() > 0); - // setItemHoverColor(); - m_centralLayout->setContentsMargins(0, 0, 0, 10); - m_centralLayout->setSpacing(0); m_centralLayout->addWidget(m_listView); m_centralWidget->setLayout(m_centralLayout); m_centralWidget->setFixedWidth(WIDTH); - m_centralWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + m_centralWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); setFixedWidth(WIDTH); setWidget(m_centralWidget); @@ -246,6 +246,8 @@ void SoundApplet::initUi() m_centralWidget->setAutoFillBackground(false); viewport()->setAutoFillBackground(false); + m_secondSeperator->setVisible(m_model->rowCount() > 0); + updateVolumeSliderStatus(Utils::SettingValue("com.deepin.dde.dock.module.sound", QByteArray(), "Enabled").toString()); connect(m_gsettings, &QGSettings::changed, [ = ] (const QString &key) { if (key == GSETTING_SOUND_OUTPUT_SLIDER) { @@ -676,7 +678,7 @@ void SoundApplet::updateListHeight() int listMargin = m_listView->contentsMargins().top() + m_listView->contentsMargins().bottom(); //显示声音设备列表高度 = 设备的高度 + 间隔 + 边距 - int viewHeight = visualHeight + m_listView->spacing() * count * 2 + listMargin; + int viewHeight = visualHeight + m_listView->spacing() * (count - 1) + listMargin; // 设备信息高度 = 设备标签 + 分隔线 + 滚动条 + 间隔 int labelHeight = m_deviceLabel->height() > m_soundShow->height() ? m_deviceLabel->height() : m_soundShow->height(); int infoHeight = labelHeight + m_seperator->height() + m_volumeSlider->height() + m_centralLayout->spacing() * 3 + DEVICE_SPACING; @@ -684,10 +686,9 @@ void SoundApplet::updateListHeight() //整个界面高度 = 显示声音设备列表高度 + 设备信息高度 + 边距 int totalHeight = viewHeight + infoHeight + margain; //加上分割线占用的高度,否则显示界面高度不够显示,会造成音频列表item最后一项比其它项的高度小 - m_listView->setFixedHeight(viewHeight + SEPARATOR_HEIGHT); + m_listView->setFixedHeight(viewHeight); setFixedHeight(totalHeight); - m_centralWidget->setFixedHeight(totalHeight + SEPARATOR_HEIGHT); - update(); + m_centralWidget->setFixedHeight(totalHeight); } void SoundApplet::portEnableChange(unsigned int cardId, QString portId)