Changeset View
Changeset View
Standalone View
Standalone View
src/icon.cpp
Show First 20 Lines • Show All 433 Lines • ▼ Show 20 Line(s) | |||||
434 | } | 434 | } | ||
435 | 435 | | |||
436 | QImage Icon::findIcon(const QSize &size) | 436 | QImage Icon::findIcon(const QSize &size) | ||
437 | { | 437 | { | ||
438 | QImage img; | 438 | QImage img; | ||
439 | QString iconSource = m_source.toString(); | 439 | QString iconSource = m_source.toString(); | ||
440 | 440 | | |||
441 | if (iconSource.startsWith(QLatin1String("image://"))) { | 441 | if (iconSource.startsWith(QLatin1String("image://"))) { | ||
442 | const auto multiplier = QCoreApplication::instance()->testAttribute(Qt::AA_UseHighDpiPixmaps) ? (window() ? window()->devicePixelRatio() : qGuiApp->devicePixelRatio()) : 1; | ||||
442 | QUrl iconUrl(iconSource); | 443 | QUrl iconUrl(iconSource); | ||
443 | QString iconProviderId = iconUrl.host(); | 444 | QString iconProviderId = iconUrl.host(); | ||
444 | QString iconId = iconUrl.path(); | 445 | QString iconId = iconUrl.path(); | ||
445 | 446 | | |||
446 | // QRC paths are not correctly handled by .path() | 447 | // QRC paths are not correctly handled by .path() | ||
447 | if (iconId.size() >=2 && iconId.startsWith(QLatin1String("/:"))) { | 448 | if (iconId.size() >=2 && iconId.startsWith(QLatin1String("/:"))) { | ||
448 | iconId.remove(0, 1); | 449 | iconId.remove(0, 1); | ||
449 | } | 450 | } | ||
450 | 451 | | |||
451 | QSize actualSize; | 452 | QSize actualSize; | ||
452 | QQuickImageProvider* imageProvider = dynamic_cast<QQuickImageProvider*>( | 453 | QQuickImageProvider* imageProvider = dynamic_cast<QQuickImageProvider*>( | ||
453 | qmlEngine(this)->imageProvider(iconProviderId)); | 454 | qmlEngine(this)->imageProvider(iconProviderId)); | ||
454 | if (!imageProvider) | 455 | if (!imageProvider) | ||
455 | return img; | 456 | return img; | ||
456 | switch(imageProvider->imageType()){ | 457 | switch(imageProvider->imageType()){ | ||
457 | case QQmlImageProviderBase::Image: | 458 | case QQmlImageProviderBase::Image: | ||
458 | img = imageProvider->requestImage(iconId, &actualSize, size); | 459 | img = imageProvider->requestImage(iconId, &actualSize, size * multiplier); | ||
459 | break; | 460 | break; | ||
460 | case QQmlImageProviderBase::Pixmap: | 461 | case QQmlImageProviderBase::Pixmap: | ||
461 | img = imageProvider->requestPixmap(iconId, &actualSize, size).toImage(); | 462 | img = imageProvider->requestPixmap(iconId, &actualSize, size * multiplier).toImage(); | ||
462 | break; | 463 | break; | ||
463 | case QQmlImageProviderBase::Texture: | 464 | case QQmlImageProviderBase::Texture: | ||
464 | case QQmlImageProviderBase::Invalid: | 465 | case QQmlImageProviderBase::Invalid: | ||
465 | case QQmlImageProviderBase::ImageResponse: | 466 | case QQmlImageProviderBase::ImageResponse: | ||
466 | //will have to investigate this more | 467 | //will have to investigate this more | ||
467 | break; | 468 | break; | ||
468 | } | 469 | } | ||
469 | } else if(iconSource.startsWith(QLatin1String("http://")) || iconSource.startsWith(QLatin1String("https://"))) { | 470 | } else if(iconSource.startsWith(QLatin1String("http://")) || iconSource.startsWith(QLatin1String("https://"))) { | ||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |