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-81641.html Bug: https://pms.uniontech.com/zentao/bug-view-81667.html Bug: https://pms.uniontech.com/zentao/bug-view-83257.html Change-Id: I8afba4b9fb2d75c031b1b925544c1d398291abf6
This commit is contained in:
parent
4a8cbe24c6
commit
365a7e63a2
@ -64,7 +64,6 @@ void PluginLoader::run()
|
||||
continue;
|
||||
}
|
||||
plugins << file;
|
||||
|
||||
}
|
||||
for (auto plugin : plugins) {
|
||||
emit pluginFounded(pluginsDir.absoluteFilePath(plugin));
|
||||
|
@ -67,8 +67,6 @@ void BluetoothDeviceItem::initActionList()
|
||||
m_standarditem->setAccessibleText(m_device->alias());
|
||||
m_standarditem->setActionList(Qt::RightEdge, {m_stateAction});
|
||||
m_standarditem->setActionList(Qt::LeftEdge, {m_labelAction});
|
||||
//设置蓝牙列表item背景为透明
|
||||
m_standarditem->setBackground(Qt::transparent);
|
||||
|
||||
//蓝牙列表可用蓝牙设备信息文字显示高亮
|
||||
m_labelAction->setTextColorRole(DPalette::BrightText);
|
||||
@ -260,14 +258,6 @@ void BluetoothAdapterItem::onDeviceNameUpdated(const Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
///**
|
||||
// * @brief BluetoothAdapterItem::setItemHoverColor 通过代理方式根据当前主题设置蓝牙列表文字颜色和item选中颜色
|
||||
// */
|
||||
//void BluetoothAdapterItem::setItemHoverColor()
|
||||
//{
|
||||
// m_deviceListview->setItemDelegate(m_itemDelegate);
|
||||
//}
|
||||
|
||||
void BluetoothAdapterItem::initUi()
|
||||
{
|
||||
m_refreshBtn->setFixedSize(24, 24);
|
||||
@ -277,7 +267,7 @@ void BluetoothAdapterItem::initUi()
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
m_adapterLabel->setFixedSize(ItemWidth, TitleHeight);
|
||||
m_adapterLabel->addButton(m_refreshBtn, 0);
|
||||
m_adapterLabel->addButton(m_adapterStateBtn, 10);
|
||||
m_adapterLabel->addButton(m_adapterStateBtn, 0);
|
||||
DFontSizeManager::instance()->bind(m_adapterLabel->label(), DFontSizeManager::T4);
|
||||
|
||||
m_adapterStateBtn->setChecked(m_adapter->powered());
|
||||
@ -285,6 +275,7 @@ void BluetoothAdapterItem::initUi()
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->setSpacing(0);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_deviceListview->setAccessibleName("DeviceItemList");
|
||||
m_deviceListview->setModel(m_deviceModel);
|
||||
@ -303,6 +294,13 @@ void BluetoothAdapterItem::initUi()
|
||||
mainLayout->addWidget(m_deviceListview);
|
||||
mainLayout->addWidget(m_bottomSeperator);
|
||||
|
||||
m_seperator->setVisible(m_deviceListview->count() != 0);
|
||||
m_bottomSeperator->setVisible(m_deviceListview->count() != 0);
|
||||
connect(m_deviceListview, &DListView::rowCountChanged, this, [ = ] {
|
||||
m_seperator->setVisible(m_deviceListview->count() != 0);
|
||||
m_bottomSeperator->setVisible(m_deviceListview->count() != 0);
|
||||
});
|
||||
|
||||
m_deviceListview->setItemDelegate(m_itemDelegate);
|
||||
|
||||
updateIconTheme(DGuiApplicationHelper::instance()->themeType());
|
||||
@ -336,6 +334,7 @@ void BluetoothAdapterItem::initConnect()
|
||||
m_refreshBtn->setVisible(state);
|
||||
m_deviceListview->setVisible(state);
|
||||
m_seperator->setVisible(state);
|
||||
m_bottomSeperator->setVisible(state);
|
||||
m_adapterStateBtn->setChecked(state);
|
||||
m_adapterStateBtn->setEnabled(true);
|
||||
emit adapterPowerChanged();
|
||||
@ -346,6 +345,7 @@ void BluetoothAdapterItem::initConnect()
|
||||
m_deviceModel->clear();
|
||||
m_deviceListview->setVisible(false);
|
||||
m_seperator->setVisible(false);
|
||||
m_bottomSeperator->setVisible(false);
|
||||
m_adapterStateBtn->setEnabled(false);
|
||||
m_refreshBtn->setVisible(state);
|
||||
emit requestSetAdapterPower(m_adapter, state);
|
||||
|
@ -47,7 +47,8 @@ SettingLabel::SettingLabel(QString text, QWidget *parent)
|
||||
setAccessibleName("BluetoothSettingLabel");
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setMargin(0);
|
||||
m_layout->addSpacing(20);
|
||||
m_layout->setSpacing(4);
|
||||
m_layout->setContentsMargins(20, 0, 8, 0);
|
||||
m_layout->addWidget(m_label, 0, Qt::AlignLeft | Qt::AlignHCenter);
|
||||
m_layout->addStretch();
|
||||
|
||||
@ -79,7 +80,11 @@ void SettingLabel::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(Qt::transparent);
|
||||
if (DApplicationHelper::instance()->themeType() == DApplicationHelper::LightType) {
|
||||
painter.setBrush(QColor(0, 0, 0, 0.03 * 255));
|
||||
} else {
|
||||
painter.setBrush(QColor(255, 255, 255, 0.03 * 255));
|
||||
}
|
||||
painter.drawRoundedRect(rect(), 0, 0);
|
||||
|
||||
return QWidget::paintEvent(event);
|
||||
|
@ -54,12 +54,6 @@ AccessPointWidget::AccessPointWidget(QWidget *parent)
|
||||
, m_stateButton(new StateButton(this))
|
||||
, m_isEnter(false)
|
||||
{
|
||||
//设置wifi列表item背景色为透明
|
||||
QPalette backgroud;
|
||||
backgroud.setColor(QPalette::Background, Qt::transparent);
|
||||
this->setAutoFillBackground(true);
|
||||
this->setPalette(backgroud);
|
||||
|
||||
m_ssidBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
|
||||
m_ssidBtn->setObjectName("Ssid");
|
||||
|
@ -62,20 +62,19 @@ DeviceControlWidget::DeviceControlWidget(QWidget *parent)
|
||||
QHBoxLayout *infoLayout = new QHBoxLayout;
|
||||
infoLayout->setMargin(0);
|
||||
infoLayout->setSpacing(0);
|
||||
infoLayout->addSpacing(3);
|
||||
infoLayout->setContentsMargins(0, 0, 0, 0);
|
||||
infoLayout->addWidget(m_deviceName);
|
||||
infoLayout->addStretch();
|
||||
infoLayout->addWidget(m_loadingIndicator);
|
||||
infoLayout->addSpacing(10);
|
||||
infoLayout->addSpacing(4);
|
||||
infoLayout->addWidget(m_switchBtn);
|
||||
infoLayout->addSpacing(3);
|
||||
infoLayout->addSpacing(8);
|
||||
|
||||
QVBoxLayout *centralLayout = new QVBoxLayout;
|
||||
centralLayout->addStretch();
|
||||
centralLayout->addLayout(infoLayout);
|
||||
centralLayout->addStretch();
|
||||
centralLayout->setMargin(0);
|
||||
centralLayout->setSpacing(0);
|
||||
centralLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
setLayout(centralLayout);
|
||||
setFixedHeight(ItemHeight);
|
||||
|
@ -53,12 +53,6 @@ WirelessList::WirelessList(WirelessDevice *deviceIter, QWidget *parent)
|
||||
{
|
||||
setFixedHeight(ItemHeight);
|
||||
|
||||
//无线网络列表背景色设置为透明
|
||||
QPalette backgroud;
|
||||
backgroud.setColor(QPalette::Background, Qt::transparent);
|
||||
this->setAutoFillBackground(true);
|
||||
this->setPalette(backgroud);
|
||||
|
||||
m_updateAPTimer->setSingleShot(true);
|
||||
m_updateAPTimer->setInterval(100);
|
||||
|
||||
|
@ -49,11 +49,6 @@ WirelessItem::WirelessItem(WirelessDevice *device)
|
||||
m_refreshTimer->setSingleShot(true);
|
||||
m_refreshTimer->setInterval(10000);
|
||||
|
||||
QPalette backgroud;
|
||||
backgroud.setColor(QPalette::Background, Qt::transparent);
|
||||
m_wirelessApplet->setAutoFillBackground(true);
|
||||
m_wirelessApplet->setPalette(backgroud);
|
||||
|
||||
m_refreshLimitTimer->setSingleShot(true);
|
||||
m_refreshLimitTimer->setInterval(REFRESH_TRY_TIME_SECOND);
|
||||
|
||||
|
@ -92,11 +92,13 @@ NetworkItem::NetworkItem(QWidget *parent)
|
||||
|
||||
// 无线网络控制器
|
||||
QHBoxLayout *switchWirelessLayout = new QHBoxLayout;
|
||||
switchWirelessLayout->setContentsMargins(20, 0, 10, 0);
|
||||
switchWirelessLayout->setMargin(0);
|
||||
switchWirelessLayout->setSpacing(0);
|
||||
switchWirelessLayout->setContentsMargins(20, 0, 8, 0);
|
||||
switchWirelessLayout->addWidget(wirelessTitle);
|
||||
switchWirelessLayout->addStretch();
|
||||
switchWirelessLayout->addWidget(m_loadingIndicator);
|
||||
switchWirelessLayout->addSpacing(10);
|
||||
switchWirelessLayout->addSpacing(4);
|
||||
switchWirelessLayout->addWidget(m_switchWirelessBtn);
|
||||
m_wirelessControlPanel->setLayout(switchWirelessLayout);
|
||||
m_wirelessControlPanel->setFixedHeight(TITLE_HEIGHT);
|
||||
@ -137,7 +139,7 @@ NetworkItem::NetworkItem(QWidget *parent)
|
||||
//TODO 先暂时这样写,后面要重构,届时布局要重新修改,直接使用dlistview
|
||||
m_wirelessControlPanel->setVisible(m_wirelessItems.count() > 0);
|
||||
m_firstSeparator->setVisible(m_wirelessItems.count() > 0);
|
||||
m_secondSeparator->setVisible(m_wirelessItems.count() > 0);
|
||||
m_secondSeparator->setVisible(m_wirelessItems.count() > 0 && m_wiredItems.count() > 0);
|
||||
|
||||
centralLayout->addWidget(m_wiredControlPanel);
|
||||
centralLayout->addWidget(m_thirdSeparator);
|
||||
@ -271,7 +273,7 @@ void NetworkItem::updateDeviceItems(QMap<QString, WiredItem *> &wiredItems, QMap
|
||||
|
||||
m_wirelessControlPanel->setVisible(m_wirelessItems.count() > 0);
|
||||
m_firstSeparator->setVisible(m_wirelessItems.count() > 0);
|
||||
m_secondSeparator->setVisible(m_wirelessItems.count() > 0);
|
||||
m_secondSeparator->setVisible(m_wirelessItems.count() > 0 && m_wiredItems.count() > 0);
|
||||
|
||||
updateSelf();
|
||||
}
|
||||
@ -556,7 +558,7 @@ void NetworkItem::wirelessEnable(bool enable)
|
||||
}
|
||||
}
|
||||
//禁用无线网络时对应的分割线设置为不可见防止两分割线叠加增加分割线高度与下面分割线高度不一样
|
||||
m_secondSeparator->setVisible(enable);
|
||||
m_secondSeparator->setVisible(enable && m_wiredItems.count() > 0);
|
||||
}
|
||||
|
||||
void NetworkItem::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType)
|
||||
@ -1192,7 +1194,7 @@ void NetworkItem::updateMasterControlSwitch()
|
||||
/* 更新无线适配器总开关状态(阻塞信号是为了防止重复设置适配器启用状态) */
|
||||
m_switchWirelessBtn->blockSignals(true);
|
||||
m_switchWirelessBtn->setChecked(m_switchWirelessBtnState);
|
||||
m_secondSeparator->setVisible(m_switchWirelessBtnState);
|
||||
m_secondSeparator->setVisible(m_switchWirelessBtnState && m_wiredItems.count() > 0);
|
||||
m_switchWirelessBtn->blockSignals(false);
|
||||
/* 根据无线适配器启用状态增/删布局中的组件 */
|
||||
for (WirelessItem *wirelessItem : m_wirelessItems) {
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <DApplication>
|
||||
#include <DStandardItem>
|
||||
#include <DFontSizeManager>
|
||||
#include <DApplicationHelper>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QIcon>
|
||||
@ -123,7 +124,6 @@ SoundApplet::SoundApplet(QWidget *parent)
|
||||
, m_defSinkInter(nullptr)
|
||||
, m_listView(new DListView(this))
|
||||
, m_model(new QStandardItemModel(m_listView))
|
||||
, m_itemDelegate(new DStyledItemDelegate(m_listView))
|
||||
, m_deviceInfo("")
|
||||
, m_lastPort(nullptr)
|
||||
, m_gsettings(Utils::ModuleSettingsPtr("sound", QByteArray(), this))
|
||||
@ -139,6 +139,7 @@ void SoundApplet::initUi()
|
||||
m_listView->setEditTriggers(DListView::NoEditTriggers);
|
||||
m_listView->setSelectionMode(QAbstractItemView::NoSelection);
|
||||
m_listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_listView->setBackgroundType(DStyledItemDelegate::NoBackground);
|
||||
m_listView->setItemRadius(0);
|
||||
m_listView->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
|
||||
m_listView->setFixedHeight(0);
|
||||
@ -178,6 +179,9 @@ void SoundApplet::initUi()
|
||||
deviceLayout->addWidget(m_deviceLabel, 0, Qt::AlignLeft);
|
||||
deviceLayout->addWidget(m_soundShow, 0, Qt::AlignRight);
|
||||
|
||||
BackgroundWidget *deviceWidget = new BackgroundWidget(this);
|
||||
deviceWidget->setLayout(deviceLayout);
|
||||
|
||||
// 音量滑动条
|
||||
QHBoxLayout *volumeCtrlLayout = new QHBoxLayout;
|
||||
volumeCtrlLayout->setSpacing(0);
|
||||
@ -187,13 +191,16 @@ void SoundApplet::initUi()
|
||||
volumeCtrlLayout->addWidget(m_volumeSlider);
|
||||
volumeCtrlLayout->addWidget(m_volumeIconMax);
|
||||
|
||||
BackgroundWidget *volumnWidget = new BackgroundWidget(this);
|
||||
volumnWidget->setLayout(volumeCtrlLayout);
|
||||
|
||||
m_centralLayout = new QVBoxLayout(this);
|
||||
m_centralLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_centralLayout->setMargin(0);
|
||||
m_centralLayout->setSpacing(0);
|
||||
m_centralLayout->addLayout(deviceLayout);
|
||||
m_centralLayout->addWidget(deviceWidget);
|
||||
m_centralLayout->addWidget(m_seperator);
|
||||
m_centralLayout->addLayout(volumeCtrlLayout);
|
||||
m_centralLayout->addWidget(volumnWidget);
|
||||
// 需要判断是否有声音端口
|
||||
m_centralLayout->addWidget(m_secondSeperator);
|
||||
|
||||
@ -210,7 +217,7 @@ void SoundApplet::initUi()
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_centralWidget->setAutoFillBackground(false);
|
||||
viewport()->setAutoFillBackground(false);
|
||||
m_listView->setItemDelegate(m_itemDelegate);
|
||||
m_listView->setItemDelegate(new DStyledItemDelegate(m_listView));
|
||||
|
||||
m_secondSeperator->setVisible(m_model->rowCount() > 1);
|
||||
|
||||
@ -396,23 +403,9 @@ void SoundApplet::refreshIcon()
|
||||
QString iconLeft = QString("audio-volume-%1-symbolic").arg(volumeString);
|
||||
QString iconRight = QString("audio-volume-high-symbolic");
|
||||
|
||||
QColor color;
|
||||
switch (DGuiApplicationHelper::instance()->themeType()) {
|
||||
case DGuiApplicationHelper::LightType:
|
||||
color = Qt::black;
|
||||
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) {
|
||||
iconLeft.append("-dark");
|
||||
iconRight.append("-dark");
|
||||
break;
|
||||
default:
|
||||
color = Qt::white;
|
||||
break;
|
||||
}
|
||||
|
||||
//主题改变时,同步修改item颜色
|
||||
for (int i = 0; i < m_model->rowCount(); i++) {
|
||||
auto item = m_model->item(i);
|
||||
item->setForeground(color);
|
||||
item->setBackground(Qt::transparent);
|
||||
}
|
||||
|
||||
const auto ratio = devicePixelRatioF();
|
||||
@ -473,8 +466,7 @@ void SoundApplet::addPort(const Port *port)
|
||||
DStandardItem *pi = new DStandardItem;
|
||||
QString deviceName = port->name() + "(" + port->cardName() + ")";
|
||||
pi->setText(deviceName);
|
||||
pi->setBackground(Qt::transparent);
|
||||
pi->setForeground(QBrush(Qt::black));
|
||||
pi->setTextColorRole(QPalette::BrightText);
|
||||
pi->setData(QVariant::fromValue<const Port *>(port), Qt::WhatsThisPropertyRole);
|
||||
|
||||
connect(port, &Port::nameChanged, this, [ = ](const QString &str) {
|
||||
@ -492,6 +484,7 @@ void SoundApplet::addPort(const Port *port)
|
||||
if (port->isActive()) {
|
||||
pi->setCheckState(Qt::CheckState::Checked);
|
||||
}
|
||||
|
||||
m_model->appendRow(pi);
|
||||
m_model->sort(0);
|
||||
m_secondSeperator->setVisible(m_model->rowCount() > 1);
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include <DIconButton>
|
||||
#include <DListView>
|
||||
#include <DApplicationHelper>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
@ -94,6 +95,29 @@ private:
|
||||
Direction m_direction;
|
||||
};
|
||||
|
||||
class BackgroundWidget : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit BackgroundWidget(QWidget *parent = nullptr)
|
||||
: QWidget(parent) {}
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setPen(Qt::NoPen);
|
||||
if (DApplicationHelper::instance()->themeType() == DApplicationHelper::LightType) {
|
||||
painter.setBrush(QColor(0, 0, 0, 0.03 * 255));
|
||||
} else {
|
||||
painter.setBrush(QColor(255, 255, 255, 0.03 * 255));
|
||||
}
|
||||
painter.drawRect(rect());
|
||||
|
||||
return QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class SoundApplet : public QScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -155,7 +179,6 @@ private:
|
||||
DBusSink *m_defSinkInter;
|
||||
DTK_WIDGET_NAMESPACE::DListView *m_listView;
|
||||
QStandardItemModel *m_model;
|
||||
DStyledItemDelegate *m_itemDelegate;
|
||||
QList<Port *> m_ports;
|
||||
QString m_deviceInfo;
|
||||
QPointer<Port> m_lastPort;//最后一个因为只有一个设备而被直接移除的设备
|
||||
|
Loading…
x
Reference in New Issue
Block a user