QPixmap XCursorImage::createIcon () const { QPixmap pixmap; int iconSize = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize); int cursorSize = nominalCursorSize(iconSize); QSize size = QSize(iconSize, iconSize); QImage img = image(cursorSize); if (!img.isNull()) { // Scale the image if it's larger than the preferred icon size if (img.width() > size.width() || img.height() > size.height()) img = img.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation); pixmap = QPixmap::fromImage(img); } return pixmap; }
QPixmap XCursorThemeData::createIcon () const { int iconSize = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize); int cursorSize = nominalCursorSize(iconSize); QSize size = QSize(iconSize, iconSize); QPixmap pixmap; QImage image = loadImage(sample(), cursorSize); if (image.isNull() && sample() != "left_ptr") image = loadImage("left_ptr", cursorSize); if (!image.isNull()) { // Scale the image if it's larger than the preferred icon size if (image.width() > size.width() || image.height() > size.height()) image = image.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation); pixmap = QPixmap::fromImage(image); } return pixmap; }
QPixmap CursorTheme::createIcon() const { int iconSize = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize); int cursorSize = nominalCursorSize(iconSize); QSize size = QSize(iconSize, iconSize); QPixmap pixmap = createIcon(cursorSize); if (!pixmap.isNull()) { // Scale the pixmap if it's larger than the preferred icon size if (pixmap.width() > size.width() || pixmap.height() > size.height()) pixmap = pixmap.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation); } return pixmap; }