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