mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix: 修复插件部分图标模糊,以及界面高度不对带来的体验不友好等问题
蓝牙刷新图标模糊问题 声音界面图标模糊问题 声音界面相关 网络界面相关 Log: Change-Id: Idfb343a2d3dc9fa98c45955637c0157a3a9957e6
This commit is contained in:
parent
b891a5565e
commit
95aabc0a2f
@ -1,4 +1,5 @@
|
||||
#include "refreshbutton.h"
|
||||
#include "imageutil.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QPainter>
|
||||
@ -19,7 +20,7 @@ RefreshButton::RefreshButton(QWidget *parent)
|
||||
|
||||
void RefreshButton::setRotateIcon(QString path)
|
||||
{
|
||||
m_pixmap = QIcon(path).pixmap(size());
|
||||
m_pixmap = ImageUtil::loadSvg(path, ":/", qMin(width(), height()), devicePixelRatio());
|
||||
}
|
||||
|
||||
void RefreshButton::startRotate()
|
||||
@ -44,7 +45,7 @@ void RefreshButton::paintEvent(QPaintEvent *e)
|
||||
QPainter painter(this);
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
|
||||
|
||||
painter.translate(this->width() / 2, this->height() / 2);
|
||||
painter.rotate(m_rotateAngle);
|
||||
|
@ -88,7 +88,7 @@ AccessPointWidget::AccessPointWidget(QWidget *parent)
|
||||
infoLayout->addSpacing(10);
|
||||
infoLayout->addWidget(m_ssidBtn);
|
||||
infoLayout->addWidget(m_stateButton);
|
||||
infoLayout->addSpacing(3);
|
||||
infoLayout->addSpacing(10);
|
||||
infoLayout->setSpacing(0);
|
||||
|
||||
QVBoxLayout *centralLayout = new QVBoxLayout;
|
||||
|
@ -269,6 +269,10 @@ 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);
|
||||
|
||||
updateSelf();
|
||||
}
|
||||
|
||||
@ -1134,22 +1138,14 @@ void NetworkItem::updateView()
|
||||
if (m_switchWiredBtnState)
|
||||
itemCount += wiredDeviceCnt;
|
||||
|
||||
// 分割线 都有设备时才有
|
||||
// auto hasDevice = wirelessDeviceCnt && wiredDeviceCnt;
|
||||
// m_line->setVisible(hasDevice);
|
||||
|
||||
auto centralWidget = m_applet->widget();
|
||||
if (itemCount <= constDisplayItemCnt) {
|
||||
contentHeight += (itemCount - wiredDeviceCnt) * ITEM_HEIGHT;
|
||||
contentHeight += wiredDeviceCnt * ITEM_HEIGHT;
|
||||
centralWidget->setFixedHeight(contentHeight);
|
||||
m_applet->setFixedHeight(contentHeight);
|
||||
} else {
|
||||
contentHeight += (itemCount - wiredDeviceCnt) * ITEM_HEIGHT;
|
||||
contentHeight += wiredDeviceCnt * ITEM_HEIGHT;
|
||||
//加上分割线占用的高度,否则显示界面高度不够显示,会造成无线网络列表item最后一项比其它项的高度小
|
||||
centralWidget->setFixedHeight(contentHeight + SeparatorItemHeight * 3);
|
||||
m_applet->setFixedHeight(constDisplayItemCnt * ITEM_HEIGHT + SeparatorItemHeight * 3);
|
||||
centralWidget->setFixedHeight(centralWidget->sizeHint().height());
|
||||
m_applet->setFixedHeight(centralWidget->sizeHint().height());
|
||||
} else {//最大大小
|
||||
contentHeight += itemCount * ITEM_HEIGHT;
|
||||
centralWidget->setFixedHeight(centralWidget->sizeHint().height());
|
||||
m_applet->setFixedHeight(qMin(centralWidget->sizeHint().height(), 360));
|
||||
}
|
||||
|
||||
if (m_wirelessControlPanel->isVisible()) {
|
||||
|
@ -112,7 +112,7 @@ void Port::setCardId(const uint &cardId)
|
||||
SoundApplet::SoundApplet(QWidget *parent)
|
||||
: QScrollArea(parent)
|
||||
, m_centralWidget(new QWidget(this))
|
||||
, m_volumeIconMin(new DIconButton(this))
|
||||
, m_volumeIconMin(new QLabel(this))
|
||||
, m_volumeIconMax(new QLabel(this))
|
||||
, m_volumeSlider(new VolumeSlider(this))
|
||||
, m_soundShow(new QLabel(this))
|
||||
@ -129,6 +129,8 @@ SoundApplet::SoundApplet(QWidget *parent)
|
||||
, m_gsettings(Utils::ModuleSettingsPtr("sound", QByteArray(), this))
|
||||
{
|
||||
initUi();
|
||||
|
||||
m_volumeIconMin->installEventFilter(this);
|
||||
}
|
||||
|
||||
void SoundApplet::initUi()
|
||||
@ -152,14 +154,12 @@ void SoundApplet::initUi()
|
||||
verticalScrollBar()->setAccessibleName("volume-verticalscrollbar");
|
||||
|
||||
m_volumeIconMin->setFixedSize(ICON_SIZE, ICON_SIZE);
|
||||
m_volumeIconMin->setIconSize(QSize(ICON_SIZE, ICON_SIZE));
|
||||
m_volumeIconMin->setFlat(true);
|
||||
m_volumeIconMax->setFixedSize(ICON_SIZE, ICON_SIZE);
|
||||
|
||||
m_soundShow->setText(QString("%1%").arg(0));
|
||||
m_soundShow->setFixedHeight(TITLE_HEIGHT);
|
||||
m_soundShow->setForegroundRole(QPalette::BrightText);
|
||||
DFontSizeManager::instance()->bind(m_soundShow, DFontSizeManager::T4, QFont::Medium);
|
||||
DFontSizeManager::instance()->bind(m_soundShow, DFontSizeManager::T8, QFont::Medium);
|
||||
|
||||
m_deviceLabel->setText(tr("Device"));
|
||||
m_deviceLabel->setFixedHeight(TITLE_HEIGHT);
|
||||
@ -204,6 +204,7 @@ void SoundApplet::initUi()
|
||||
|
||||
setFixedWidth(WIDTH);
|
||||
setWidget(m_centralWidget);
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
setFrameShape(QFrame::NoFrame);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
@ -219,9 +220,6 @@ void SoundApplet::initUi()
|
||||
updateVolumeSliderStatus(m_gsettings->get(GSETTING_SOUND_OUTPUT_SLIDER).toString());
|
||||
}
|
||||
});
|
||||
connect(m_volumeIconMin, &DIconButton::clicked, this, [ = ] {
|
||||
m_defSinkInter->SetMuteQueued(!m_defSinkInter->mute());
|
||||
});
|
||||
connect(qApp, &QGuiApplication::fontChanged, this, &SoundApplet::updateListHeight);
|
||||
connect(m_volumeSlider, &VolumeSlider::valueChanged, this, &SoundApplet::volumeSliderValueChanged);
|
||||
connect(m_audioInter, &DBusAudio::DefaultSinkChanged, this, &SoundApplet::onDefaultSinkChanged);
|
||||
@ -409,20 +407,20 @@ void SoundApplet::refreshIcon()
|
||||
color = Qt::white;
|
||||
break;
|
||||
}
|
||||
// setControlBackground();
|
||||
|
||||
//主题改变时,同步修改item颜色
|
||||
for (int i = 0; i < m_model->rowCount(); i++) {
|
||||
auto item = m_model->item(i);
|
||||
item->setForeground(color);
|
||||
item->setBackground(Qt::transparent);
|
||||
}
|
||||
// setItemHoverColor();
|
||||
|
||||
const auto ratio = devicePixelRatioF();
|
||||
QPixmap ret = ImageUtil::loadSvg(iconRight, ":/", ICON_SIZE, ratio);
|
||||
m_volumeIconMax->setPixmap(ret);
|
||||
|
||||
ret = ImageUtil::loadSvg(iconLeft, ":/", ICON_SIZE, ratio);
|
||||
m_volumeIconMin->setIcon(ret);
|
||||
m_volumeIconMin->setPixmap(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -620,6 +618,14 @@ void SoundApplet::updateVolumeSliderStatus(const QString &status)
|
||||
m_volumeIconMax->setVisible(flag);
|
||||
}
|
||||
|
||||
bool SoundApplet::eventFilter(QObject *watcher, QEvent *event)
|
||||
{
|
||||
if (watcher == m_volumeIconMin && event->type() == QEvent::MouseButtonRelease) {
|
||||
m_defSinkInter->SetMuteQueued(!m_defSinkInter->mute());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SoundApplet::haldleDbusSignal(const QDBusMessage &msg)
|
||||
{
|
||||
Q_UNUSED(msg)
|
||||
@ -630,7 +636,7 @@ void SoundApplet::haldleDbusSignal(const QDBusMessage &msg)
|
||||
void SoundApplet::updateListHeight()
|
||||
{
|
||||
//设备数多于10个时显示滚动条,固定高度
|
||||
int count = m_model->rowCount();
|
||||
int count = m_model->rowCount() == 1 ? 0 : m_model->rowCount();
|
||||
|
||||
if (m_model->rowCount() > 10) {
|
||||
count = 10;
|
||||
@ -640,7 +646,7 @@ void SoundApplet::updateListHeight()
|
||||
}
|
||||
|
||||
int visualHeight = 0;
|
||||
for (int i = 1; i < count; i++)
|
||||
for (int i = 0; i < count; i++)
|
||||
visualHeight += m_listView->visualRect(m_model->index(i, 0)).height();
|
||||
|
||||
int listMargin = m_listView->contentsMargins().top() + m_listView->contentsMargins().bottom();
|
||||
@ -648,7 +654,7 @@ void SoundApplet::updateListHeight()
|
||||
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;
|
||||
int infoHeight = labelHeight + m_seperator->height() * 2 + m_volumeSlider->height();
|
||||
int margain = m_centralLayout->contentsMargins().top() + m_centralLayout->contentsMargins().bottom();
|
||||
//整个界面高度 = 显示声音设备列表高度 + 设备信息高度 + 边距
|
||||
int totalHeight = viewHeight + infoHeight + margain;
|
||||
|
@ -110,8 +110,6 @@ public:
|
||||
Port *findPort(const QString &portId, const uint &cardId) const;
|
||||
void setUnchecked(DStandardItem *pi);
|
||||
void initUi();
|
||||
// void setItemHoverColor();
|
||||
// void setControlBackground();
|
||||
|
||||
signals:
|
||||
void volumeChanged(const int value) const;
|
||||
@ -139,9 +137,12 @@ private:
|
||||
void removeDisabledDevice(QString portId, unsigned int cardId);
|
||||
void updateVolumeSliderStatus(const QString &status);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watcher, QEvent *event) override;
|
||||
|
||||
private:
|
||||
QWidget *m_centralWidget;
|
||||
DIconButton *m_volumeIconMin;
|
||||
QLabel *m_volumeIconMin;
|
||||
QLabel *m_volumeIconMax;
|
||||
VolumeSlider *m_volumeSlider;
|
||||
QLabel *m_soundShow;
|
||||
|
Loading…
x
Reference in New Issue
Block a user