Skip to content

Commit 422bbc4

Browse files
committed
fix(view): fix schedule label misalignment in week/day view
Convert global screen coordinates to widget-relative coordinates using mapFromGlobal() for proper positioning. Use logical pixel offset to avoid mixing coordinate systems. Remove unused QDesktopWidget include. 修复周/日视图下日程标签位置错位的问题,通过mapFromGlobal 将全局坐标转为控件相对坐标,使用逻辑像素偏移量。 Log: 修复周/日视图日程标签位置错位 PMS: BUG-356301 Influence: 修复后周/日视图下日程标签在窗口最大化及不同DPI下正确显示在日程旁边。
1 parent bdf80b6 commit 422bbc4

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

src/calendar-client/src/customWidget/scheduleview.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
#include <QShortcut>
2222
#include <QVBoxLayout>
2323
#include <QApplication>
24-
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
25-
#include <QDesktopWidget>
26-
#endif
2724

2825
DGUI_USE_NAMESPACE
2926

@@ -539,23 +536,19 @@ void CScheduleView::slotScheduleShow(const bool isShow, const DSchedule::Ptr &ou
539536
CSchedulesColor gdColor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType(
540537
out->scheduleTypeID());
541538

542-
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
543-
QScreen *screen = QGuiApplication::primaryScreen();
544-
QRect screenGeometry = screen->geometry();
545-
#else
546-
QDesktopWidget *w = QApplication::desktop();
547-
QRect screenGeometry = w->screenGeometry();
548-
#endif
549539
m_ScheduleRemindWidget->setData(out, gdColor);
540+
// pos22: 全局屏幕坐标; rPos: 转换后的控件逻辑坐标
541+
const auto rPos = this->mapFromGlobal(pos22);
542+
const int offsetPx = 15; // 逻辑像素偏移,与 rPos 同一坐标系
550543

551-
if ((pos22.x() + m_ScheduleRemindWidget->width() + 15) > screenGeometry.width()) {
544+
if ((rPos.x() + m_ScheduleRemindWidget->width() + offsetPx) > this->window()->width()) {
552545
qCDebug(ClientLogger) << "Positioning widget to the right";
553546
m_ScheduleRemindWidget->setDirection(DArrowRectangle::ArrowRight);
554-
m_ScheduleRemindWidget->show(pos22.x() - 15, pos22.y());
547+
m_ScheduleRemindWidget->show(rPos.x() - offsetPx, rPos.y());
555548
} else {
556549
qCDebug(ClientLogger) << "Positioning widget to the left";
557550
m_ScheduleRemindWidget->setDirection(DArrowRectangle::ArrowLeft);
558-
m_ScheduleRemindWidget->show(pos22.x() + 15, pos22.y());
551+
m_ScheduleRemindWidget->show(rPos.x() + offsetPx, rPos.y());
559552
}
560553
} else {
561554
// qCDebug(ClientLogger) << "Hiding schedule widget";

0 commit comments

Comments
 (0)