mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
fix: plugin back button not support hiDPI
Closed: https://github.com/linuxdeepin/developer-center/issues/3748
This commit is contained in:
parent
6102475daf
commit
e8fc0b7735
@ -20,7 +20,7 @@ DGUI_USE_NAMESPACE
|
||||
PluginChildPage::PluginChildPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_headerWidget(new QWidget(this))
|
||||
, m_back(new QPushButton(m_headerWidget))
|
||||
, m_back(new DIconButton(QStyle::SP_ArrowBack, this))
|
||||
, m_title(new QLabel(m_headerWidget))
|
||||
, m_container(new QWidget(this))
|
||||
, m_topWidget(nullptr)
|
||||
@ -59,8 +59,6 @@ void PluginChildPage::setTitle(const QString &text)
|
||||
|
||||
void PluginChildPage::initUi()
|
||||
{
|
||||
m_back->setIcon(backPixmap());
|
||||
m_back->setFixedWidth(24);
|
||||
m_back->setFlat(true);
|
||||
m_title->setAlignment(Qt::AlignCenter);
|
||||
QHBoxLayout *headerLayout = new QHBoxLayout(m_headerWidget);
|
||||
@ -99,33 +97,3 @@ void PluginChildPage::resetHeight()
|
||||
m_container->setFixedHeight(m.top() + m.bottom() + (m_topWidget ? m_topWidget->height() : 0));
|
||||
setFixedHeight(m_headerWidget->height() + m_container->height());
|
||||
}
|
||||
|
||||
QPixmap PluginChildPage::backPixmap() const
|
||||
{
|
||||
QPixmap pixmap(16, 16);
|
||||
pixmap.fill(Qt::transparent);
|
||||
|
||||
// 设置背景色
|
||||
QColor backColor;
|
||||
if (DGuiApplicationHelper::ColorType::DarkType == DGuiApplicationHelper::instance()->themeType()) {
|
||||
backColor = Qt::black;
|
||||
backColor.setAlphaF(0.05);
|
||||
} else {
|
||||
backColor = Qt::white;
|
||||
backColor.setAlphaF(0.2);
|
||||
}
|
||||
QPainter painter(&pixmap);
|
||||
painter.setRenderHints(QPainter::SmoothPixmapTransform | QPainter::Antialiasing);
|
||||
painter.setPen(Qt::NoPen);
|
||||
QPainterPath path;
|
||||
path.addEllipse(pixmap.rect());
|
||||
painter.fillPath(path, backColor);
|
||||
QSize arrowSize(10, 10);
|
||||
QPixmap arrowPixmap = DStyle::standardIcon(style(), DStyle::SP_ArrowLeave).pixmap(arrowSize);
|
||||
// 让其居中显示
|
||||
QSize backSize = pixmap.size();
|
||||
painter.drawPixmap((backSize.width() - arrowSize.width()) / 2, (backSize.height() - arrowSize.height()) / 2,
|
||||
arrowSize.width(), arrowSize.height(), arrowPixmap);
|
||||
painter.end();
|
||||
return pixmap;
|
||||
}
|
||||
|
@ -7,11 +7,14 @@
|
||||
#define PLUGINCHILDPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <DIconButton>
|
||||
|
||||
class QPushButton;
|
||||
class QLabel;
|
||||
class QVBoxLayout;
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
class PluginChildPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -32,11 +35,10 @@ private:
|
||||
void initUi();
|
||||
void initConnection();
|
||||
void resetHeight();
|
||||
QPixmap backPixmap() const;
|
||||
|
||||
private:
|
||||
QWidget *m_headerWidget;
|
||||
QPushButton *m_back;
|
||||
DIconButton *m_back;
|
||||
QLabel *m_title;
|
||||
QWidget *m_container;
|
||||
QWidget *m_topWidget;
|
||||
|
Loading…
x
Reference in New Issue
Block a user