Skip to content

Commit

Permalink
feat: support Qt 6.8
Browse files Browse the repository at this point in the history
support qt 6.8

Log:
  • Loading branch information
justforlxz committed Oct 14, 2024
1 parent 87fd9f3 commit 05c746c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/widgets/dlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,32 @@ void DLabel::paintEvent(QPaintEvent *event)
if (d->scaledcontents) {
QSize scaledSize = cr.size() * devicePixelRatioF();
if (!d->scaledpixmap || d->scaledpixmap->size() != scaledSize) {
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
if (!d->cachedimage)
#endif
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 2)
d->cachedimage = new QImage(d->pixmap->toImage());
delete d->scaledpixmap;
#else
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
d->cachedimage = QImage(d->pixmap->toImage());
#endif
d->scaledpixmap.reset();
#endif
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
QImage scaledImage =
d->cachedimage->scaled(scaledSize,
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
#else
d->scaledpixmap = d->pixmap->scaled(scaledSize,
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
#endif
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 2)
d->scaledpixmap = new QPixmap(QPixmap::fromImage(scaledImage));
#else
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
d->scaledpixmap = QPixmap(QPixmap::fromImage(scaledImage));
#endif
#endif
d->scaledpixmap->setDevicePixelRatio(devicePixelRatioF());
}
Expand Down
8 changes: 4 additions & 4 deletions src/widgets/dsimplelistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,10 +955,10 @@ void DSimpleListView::mouseMoveEvent(QMouseEvent *mouseEvent)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
auto point = QPoint{mouseEvent->x() - columnRenderX, d->renderOffset + mouseEvent->y() - hoverItemIndex * d->rowHeight};
#else
auto point = QPoint{mouseEvent->position().x() - columnRenderX,
auto point = QPointF{mouseEvent->position().x() - columnRenderX,
d->renderOffset + mouseEvent->position().y() - hoverItemIndex * d->rowHeight};
#endif
mouseHoverChanged(d->mouseHoverItem, item, columnCounter,point);
mouseHoverChanged(d->mouseHoverItem, item, columnCounter,point.toPoint());
d->mouseHoverItem = item;

if (d->lastHoverItem == NULL || !item->sameAs(d->lastHoverItem) || columnCounter != d->lastHoverColumnIndex) {
Expand Down Expand Up @@ -1235,10 +1235,10 @@ void DSimpleListView::mouseReleaseEvent(QMouseEvent *mouseEvent)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
auto point = QPoint{mouseEvent->x() - columnRenderX, d->renderOffset + mouseEvent->y() - releaseItemIndex * d->rowHeight};
#else
auto point = QPoint{mouseEvent->position().x() - columnRenderX,
auto point = QPointF{mouseEvent->position().x() - columnRenderX,
d->renderOffset + mouseEvent->position().y() - releaseItemIndex * d->rowHeight};
#endif
mouseReleaseChanged((*d->renderItems)[releaseItemIndex], columnCounter, point);
mouseReleaseChanged((*d->renderItems)[releaseItemIndex], columnCounter, point.toPoint());
}
}

Expand Down

0 comments on commit 05c746c

Please sign in to comment.