Ignore:
Timestamp:
Jul 29, 2010, 3:37:35 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Reverter r261 as it breaks cross-platform compatibility with applications not providing consistent icon sizes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/image/qicon.cpp

    r651 r763  
    139139
    140140// returns the smallest of the two that is still larger than or equal to size.
    141 
    142 // According to the QIcon documentation, actualSize() and pixmap() may return
    143 // icons that are smaller than the requested size but never larger. If we only
    144 // have a larger icon, the engine will smooth scale it to the requested size.
    145 // Given that, we should prefer the largerst pixmap that is smaller or equal to
    146 // the requested size (i.e. the most close one from the group of smaller
    147 // pixmaps), and if there are no such pixmaps, we return the smallest one
    148 // from the larger group. This function just does that.
    149 static QPixmapIconEngineEntry *bestSizeMatch(const QSize &size, QPixmapIconEngineEntry *pa, QPixmapIconEngineEntry *pb)
     141static QPixmapIconEngineEntry *bestSizeMatch( const QSize &size, QPixmapIconEngineEntry *pa, QPixmapIconEngineEntry *pb)
    150142{
    151143    int s = area(size);
     
    160152    }
    161153    int b = area(pb->size);
    162 
    163     // prefer the largest among smaller
    164     int res = qMax(a,b);
    165     if (res > s) {
    166         // fallback to the smallest among larger
     154    int res = a;
     155    if (qMin(a,b) >= s)
    167156        res = qMin(a,b);
    168     }
    169 
     157    else
     158        res = qMax(a,b);
    170159    if (res == a)
    171160        return pa;
     
    311300        return actualSize;
    312301
    313     if (actualSize.width() > size.width() || actualSize.height() > size.height())
     302    if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
    314303        actualSize.scale(size, Qt::KeepAspectRatio);
    315304    return actualSize;
Note: See TracChangeset for help on using the changeset viewer.