mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
fix: 应用图标tips位置错误
因为之前修改图标点击范围的问题,在图标的外面加了一层布局,导致在计算tips位置的时候,多加了一个边距。 这里是以图标与父控件的相对坐标的迭代计算得到tips应该显示的位置,原来的图标范围与任务栏边距为0,当加了一层布局后, 还是完全以图标为原点迭代计算就不对了,这里应该根据任务栏的位置调整参与计算的图标相对于父控件的x,y坐标,再进行累加。 (这里图标的父控件与外层的控件之间的间距为0,如果后续调整边距,这里需要重新调整这个计算) Log: 修复任务栏应用图标预览窗口位置显示错误的问题。 Bug: https://pms.uniontech.com/zentao/bug-view-58703.html Change-Id: I0644a9df38b802d7a4d3a5374ed5eaabfd35885d
This commit is contained in:
parent
6929caf73a
commit
8d38378f54
@ -277,11 +277,6 @@ void DockItem::showHoverTips()
|
||||
if (PopupWindow->model())
|
||||
return;
|
||||
|
||||
// if not in geometry area
|
||||
const QRect r(topleftPoint(), size());
|
||||
if (!r.contains(QCursor::pos()))
|
||||
return;
|
||||
|
||||
QWidget *const content = popupTips();
|
||||
if (!content)
|
||||
return;
|
||||
@ -376,61 +371,47 @@ bool DockItem::checkAndResetTapHoldGestureState()
|
||||
const QPoint DockItem::popupMarkPoint()
|
||||
{
|
||||
QPoint p(topleftPoint());
|
||||
int margin = PLUGIN_MARGIN;
|
||||
if (itemType() == Plugins){
|
||||
PluginsItem *pluginItem = dynamic_cast<PluginsItem*>(this);
|
||||
if (nullptr != pluginItem){
|
||||
if (pluginItem->pluginName() == "datetime")
|
||||
margin = 0;
|
||||
}
|
||||
}
|
||||
const QRect r = rect();
|
||||
switch (DockPosition) {
|
||||
case Top: {
|
||||
if (itemType() == Plugins) {
|
||||
p += QPoint(r.width() / 2, r.height() + margin);
|
||||
} else {
|
||||
p += QPoint(r.width() / 2, r.height());
|
||||
}
|
||||
case Top:
|
||||
p += QPoint(r.width() / 2, r.height());
|
||||
break;
|
||||
}
|
||||
case Bottom: {
|
||||
if (itemType() == Plugins) {
|
||||
p += QPoint(r.width() / 2, 0 - margin);
|
||||
} else {
|
||||
p += QPoint(r.width() / 2, 0);
|
||||
}
|
||||
case Bottom:
|
||||
p += QPoint(r.width() / 2, 0);
|
||||
break;
|
||||
}
|
||||
case Left: {
|
||||
if (itemType() == Plugins) {
|
||||
p += QPoint(r.width() + margin, r.height() / 2);
|
||||
} else {
|
||||
p += QPoint(r.width(), r.height() / 2);
|
||||
}
|
||||
case Left:
|
||||
p += QPoint(r.width(), r.height() / 2);
|
||||
break;
|
||||
}
|
||||
case Right: {
|
||||
if (itemType() == Plugins) {
|
||||
p += QPoint(0 - margin, r.height() / 2);
|
||||
} else {
|
||||
p += QPoint(0, r.height() / 2);
|
||||
}
|
||||
case Right:
|
||||
p += QPoint(0, r.height() / 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
const QPoint DockItem::topleftPoint() const
|
||||
{
|
||||
QPoint p;
|
||||
const QWidget *w = this;
|
||||
do {
|
||||
QPoint p = this->pos();
|
||||
/* 由于点击范围的问题,在图标的外面加了一层布局,这个布局的边距需要考虑 */
|
||||
switch (DockPosition) {
|
||||
case Top:
|
||||
p.setY(p.y() * 2);
|
||||
break;
|
||||
case Bottom:
|
||||
p.setY(0);
|
||||
break;
|
||||
case Left:
|
||||
p.setX(p.x() * 2);
|
||||
break;
|
||||
case Right:
|
||||
p.setX(0);
|
||||
break;
|
||||
}
|
||||
const QWidget *w = qobject_cast<QWidget *>(this->parent());
|
||||
while (w) {
|
||||
p += w->pos();
|
||||
w = qobject_cast<QWidget *>(w->parent());
|
||||
} while (w);
|
||||
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -461,4 +442,3 @@ bool DockItem::isDragging()
|
||||
{
|
||||
return m_draging;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user