Changeset 261 for trunk/src/gui/image/qicon.cpp
- Timestamp:
- Oct 28, 2009, 8:20:57 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/image/qicon.cpp
r2 r261 188 188 189 189 // returns the smallest of the two that is still larger than or equal to size. 190 static QPixmapIconEngineEntry *bestSizeMatch( const QSize &size, QPixmapIconEngineEntry *pa, QPixmapIconEngineEntry *pb) 190 191 // According to the QIcon documentation, actualSize() and pixmap() may return 192 // icons that are smaller than the requested size but never larger. If we only 193 // have a larger icon, the engine will smooth scale it to the requested size. 194 // Given that, we should prefer the largerst pixmap that is smaller or equal to 195 // the requested size (i.e. the most close one from the group of smaller 196 // pixmaps), and if there are no such pixmaps, we return the smallest one 197 // from the larger group. This function just does that. 198 static QPixmapIconEngineEntry *bestSizeMatch(const QSize &size, QPixmapIconEngineEntry *pa, QPixmapIconEngineEntry *pb) 191 199 { 192 200 int s = area(size); … … 201 209 } 202 210 int b = area(pb->size); 203 int res = a; 204 if (qMin(a,b) >= s) 211 212 // prefer the largest among smaller 213 int res = qMax(a,b); 214 if (res > s) { 215 // fallback to the smallest among larger 205 216 res = qMin(a,b); 206 else207 res = qMax(a,b); 217 218 208 219 if (res == a) 209 220 return pa; … … 347 358 return actualSize; 348 359 349 if ( !actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))360 if ()) 350 361 actualSize.scale(size, Qt::KeepAspectRatio); 351 362 return actualSize;
Note:
See TracChangeset
for help on using the changeset viewer.