mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
refactor: close button name of preview
make a distinction between the name of buttons both of 2d and 3d mode Change-Id: I2b8c744bcc920707b74f9f98859851cc0399a461
This commit is contained in:
parent
6417a6255c
commit
5a6942d90c
@ -56,14 +56,14 @@ AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
|
||||
, m_wid(wid)
|
||||
, m_title(new TipsWidget)
|
||||
, m_waitLeaveTimer(new QTimer(this))
|
||||
, m_closeBtn(new DImageButton)
|
||||
, m_closeBtn2D(new DImageButton)
|
||||
, m_wmHelper(DWindowManagerHelper::instance())
|
||||
{
|
||||
m_closeBtn->setFixedSize(24, 24);
|
||||
m_closeBtn->setNormalPic(":/icons/resources/close_round_normal.svg");
|
||||
m_closeBtn->setHoverPic(":/icons/resources/close_round_hover.svg");
|
||||
m_closeBtn->setPressPic(":/icons/resources/close_round_press.svg");
|
||||
m_closeBtn->setVisible(false);
|
||||
m_closeBtn2D->setFixedSize(24, 24);
|
||||
m_closeBtn2D->setNormalPic(":/icons/resources/close_round_normal.svg");
|
||||
m_closeBtn2D->setHoverPic(":/icons/resources/close_round_hover.svg");
|
||||
m_closeBtn2D->setPressPic(":/icons/resources/close_round_press.svg");
|
||||
m_closeBtn2D->setVisible(false);
|
||||
m_title->setObjectName("AppSnapshotTitle");
|
||||
|
||||
m_waitLeaveTimer->setInterval(200);
|
||||
@ -71,17 +71,17 @@ AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
|
||||
|
||||
QHBoxLayout *centralLayout = new QHBoxLayout;
|
||||
centralLayout->addWidget(m_title);
|
||||
centralLayout->addWidget(m_closeBtn);
|
||||
centralLayout->addWidget(m_closeBtn2D);
|
||||
centralLayout->setSpacing(5);
|
||||
centralLayout->setMargin(0);
|
||||
|
||||
centralLayout->setAlignment(m_closeBtn, Qt::AlignRight);
|
||||
centralLayout->setAlignment(m_closeBtn2D, Qt::AlignRight);
|
||||
|
||||
setLayout(centralLayout);
|
||||
setAcceptDrops(true);
|
||||
resize(SNAP_WIDTH, SNAP_HEIGHT);
|
||||
|
||||
connect(m_closeBtn, &DImageButton::clicked, this, &AppSnapshot::closeWindow, Qt::QueuedConnection);
|
||||
connect(m_closeBtn2D, &DImageButton::clicked, this, &AppSnapshot::closeWindow, Qt::QueuedConnection);
|
||||
connect(m_wmHelper, &DWindowManagerHelper::hasCompositeChanged, this, &AppSnapshot::compositeChanged, Qt::QueuedConnection);
|
||||
connect(m_waitLeaveTimer, &QTimer::timeout, this, [=] {
|
||||
emit entered(wid);
|
||||
@ -205,7 +205,7 @@ void AppSnapshot::enterEvent(QEvent *e)
|
||||
QWidget::enterEvent(e);
|
||||
|
||||
if (!m_wmHelper->hasComposite()) {
|
||||
m_closeBtn->setVisible(true);
|
||||
m_closeBtn2D->setVisible(true);
|
||||
}
|
||||
else {
|
||||
m_waitLeaveTimer->start();
|
||||
@ -218,7 +218,7 @@ void AppSnapshot::leaveEvent(QEvent *e)
|
||||
{
|
||||
QWidget::leaveEvent(e);
|
||||
|
||||
m_closeBtn->setVisible(false);
|
||||
m_closeBtn2D->setVisible(false);
|
||||
m_waitLeaveTimer->stop();
|
||||
|
||||
update();
|
||||
|
@ -89,7 +89,7 @@ private:
|
||||
|
||||
TipsWidget *m_title;
|
||||
QTimer *m_waitLeaveTimer;
|
||||
DImageButton *m_closeBtn;
|
||||
DImageButton *m_closeBtn2D;
|
||||
DWindowManagerHelper *m_wmHelper;
|
||||
};
|
||||
|
||||
|
@ -29,23 +29,23 @@
|
||||
FloatingPreview::FloatingPreview(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
|
||||
m_closeBtn(new DImageButton)
|
||||
m_closeBtn3D(new DImageButton)
|
||||
{
|
||||
m_closeBtn->setFixedSize(24, 24);
|
||||
m_closeBtn->setNormalPic(":/icons/resources/close_round_normal.svg");
|
||||
m_closeBtn->setHoverPic(":/icons/resources/close_round_hover.svg");
|
||||
m_closeBtn->setPressPic(":/icons/resources/close_round_press.svg");
|
||||
m_closeBtn3D->setFixedSize(24, 24);
|
||||
m_closeBtn3D->setNormalPic(":/icons/resources/close_round_normal.svg");
|
||||
m_closeBtn3D->setHoverPic(":/icons/resources/close_round_hover.svg");
|
||||
m_closeBtn3D->setPressPic(":/icons/resources/close_round_press.svg");
|
||||
|
||||
QVBoxLayout *centralLayout = new QVBoxLayout;
|
||||
centralLayout->addWidget(m_closeBtn);
|
||||
centralLayout->setAlignment(m_closeBtn, Qt::AlignRight | Qt::AlignTop);
|
||||
centralLayout->addWidget(m_closeBtn3D);
|
||||
centralLayout->setAlignment(m_closeBtn3D, Qt::AlignRight | Qt::AlignTop);
|
||||
centralLayout->setMargin(0);
|
||||
centralLayout->setSpacing(0);
|
||||
|
||||
setLayout(centralLayout);
|
||||
setFixedSize(SNAP_WIDTH, SNAP_HEIGHT);
|
||||
|
||||
connect(m_closeBtn, &DImageButton::clicked, this, &FloatingPreview::onCloseBtnClicked);
|
||||
connect(m_closeBtn3D, &DImageButton::clicked, this, &FloatingPreview::onCloseBtnClicked);
|
||||
}
|
||||
|
||||
WId FloatingPreview::trackedWid() const
|
||||
@ -66,7 +66,7 @@ void FloatingPreview::trackWindow(AppSnapshot * const snap)
|
||||
m_tracked->removeEventFilter(this);
|
||||
snap->installEventFilter(this);
|
||||
m_tracked = snap;
|
||||
m_closeBtn->setVisible(m_tracked->closeAble());
|
||||
m_closeBtn3D->setVisible(m_tracked->closeAble());
|
||||
|
||||
const QRect r = rect();
|
||||
const QRect sr = snap->geometry();
|
||||
|
@ -58,7 +58,7 @@ private slots:
|
||||
private:
|
||||
QPointer<AppSnapshot> m_tracked;
|
||||
|
||||
DImageButton *m_closeBtn;
|
||||
DImageButton *m_closeBtn3D;
|
||||
};
|
||||
|
||||
#endif // FLOATINGPREVIEW_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user