mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +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)
|
PluginChildPage::PluginChildPage(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_headerWidget(new QWidget(this))
|
, 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_title(new QLabel(m_headerWidget))
|
||||||
, m_container(new QWidget(this))
|
, m_container(new QWidget(this))
|
||||||
, m_topWidget(nullptr)
|
, m_topWidget(nullptr)
|
||||||
@ -59,8 +59,6 @@ void PluginChildPage::setTitle(const QString &text)
|
|||||||
|
|
||||||
void PluginChildPage::initUi()
|
void PluginChildPage::initUi()
|
||||||
{
|
{
|
||||||
m_back->setIcon(backPixmap());
|
|
||||||
m_back->setFixedWidth(24);
|
|
||||||
m_back->setFlat(true);
|
m_back->setFlat(true);
|
||||||
m_title->setAlignment(Qt::AlignCenter);
|
m_title->setAlignment(Qt::AlignCenter);
|
||||||
QHBoxLayout *headerLayout = new QHBoxLayout(m_headerWidget);
|
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));
|
m_container->setFixedHeight(m.top() + m.bottom() + (m_topWidget ? m_topWidget->height() : 0));
|
||||||
setFixedHeight(m_headerWidget->height() + m_container->height());
|
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
|
#define PLUGINCHILDPAGE_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <DIconButton>
|
||||||
|
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
|
|
||||||
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
class PluginChildPage : public QWidget
|
class PluginChildPage : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -32,11 +35,10 @@ private:
|
|||||||
void initUi();
|
void initUi();
|
||||||
void initConnection();
|
void initConnection();
|
||||||
void resetHeight();
|
void resetHeight();
|
||||||
QPixmap backPixmap() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_headerWidget;
|
QWidget *m_headerWidget;
|
||||||
QPushButton *m_back;
|
DIconButton *m_back;
|
||||||
QLabel *m_title;
|
QLabel *m_title;
|
||||||
QWidget *m_container;
|
QWidget *m_container;
|
||||||
QWidget *m_topWidget;
|
QWidget *m_topWidget;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user