|
21 | 21 | #include <QShortcut> |
22 | 22 | #include <QVBoxLayout> |
23 | 23 | #include <QApplication> |
24 | | -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) |
25 | | -#include <QDesktopWidget> |
26 | | -#endif |
27 | 24 |
|
28 | 25 | DGUI_USE_NAMESPACE |
29 | 26 |
|
@@ -539,23 +536,19 @@ void CScheduleView::slotScheduleShow(const bool isShow, const DSchedule::Ptr &ou |
539 | 536 | CSchedulesColor gdColor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType( |
540 | 537 | out->scheduleTypeID()); |
541 | 538 |
|
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 |
549 | 539 | m_ScheduleRemindWidget->setData(out, gdColor); |
| 540 | + // pos22: 全局屏幕坐标; rPos: 转换后的控件逻辑坐标 |
| 541 | + const auto rPos = this->mapFromGlobal(pos22); |
| 542 | + const int offsetPx = 15; // 逻辑像素偏移,与 rPos 同一坐标系 |
550 | 543 |
|
551 | | - if ((pos22.x() + m_ScheduleRemindWidget->width() + 15) > screenGeometry.width()) { |
| 544 | + if ((rPos.x() + m_ScheduleRemindWidget->width() + offsetPx) > this->window()->width()) { |
552 | 545 | qCDebug(ClientLogger) << "Positioning widget to the right"; |
553 | 546 | m_ScheduleRemindWidget->setDirection(DArrowRectangle::ArrowRight); |
554 | | - m_ScheduleRemindWidget->show(pos22.x() - 15, pos22.y()); |
| 547 | + m_ScheduleRemindWidget->show(rPos.x() - offsetPx, rPos.y()); |
555 | 548 | } else { |
556 | 549 | qCDebug(ClientLogger) << "Positioning widget to the left"; |
557 | 550 | m_ScheduleRemindWidget->setDirection(DArrowRectangle::ArrowLeft); |
558 | | - m_ScheduleRemindWidget->show(pos22.x() + 15, pos22.y()); |
| 551 | + m_ScheduleRemindWidget->show(rPos.x() + offsetPx, rPos.y()); |
559 | 552 | } |
560 | 553 | } else { |
561 | 554 | // qCDebug(ClientLogger) << "Hiding schedule widget"; |
|
0 commit comments