fix: 关闭按钮不使用水平布局方式显示,通过计算位置在右侧显示

关闭按钮和应用程序标题使用的水平布局显示,当鼠标进入提示窗口时,显示关闭按钮,应用标题会向左缩放,造成文字偏左,因此关闭按钮不使用水平布局显示,
当需要显示关闭按钮时,实时计算按钮位置,在右侧显示

Log: 修复2D模式下,鼠标hover在预览信息上,文字会移动到信息边框的最左边问题
Bug: https://pms.uniontech.com/zentao/bug-view-41363.html
Change-Id: I6d6fe44c021639813b7ec73b648a82203ff10551
Reviewed-on: http://gerrit.uniontech.com/c/dde-dock/+/1343
Tested-by: lizhongming <lizhongming@uniontech.com>
Reviewed-by: lizhongming <lizhongming@uniontech.com>
Reviewed-by: niecheng <niecheng@uniontech.com>
This commit is contained in:
chenjun 2020-08-05 18:11:56 +08:00
parent 9486e1380d
commit aa0f599124

View File

@ -74,12 +74,8 @@ AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
QHBoxLayout *centralLayout = new QHBoxLayout;
centralLayout->addWidget(m_title);
centralLayout->addWidget(m_closeBtn2D);
centralLayout->setSpacing(5);
centralLayout->setMargin(0);
centralLayout->setAlignment(m_closeBtn2D, Qt::AlignRight);
setLayout(centralLayout);
setAcceptDrops(true);
resize(SNAP_WIDTH, SNAP_HEIGHT);
@ -202,6 +198,7 @@ void AppSnapshot::enterEvent(QEvent *e)
QWidget::enterEvent(e);
if (!m_wmHelper->hasComposite()) {
m_closeBtn2D->move(width() - m_closeBtn2D->width() - 5, (height() - m_closeBtn2D->height()) / 2);
m_closeBtn2D->setVisible(true);
} else {
emit entered(wid());