Changeset 763 for trunk/src/gui/image/qicon.cpp
- Timestamp:
- Jul 29, 2010, 3:37:35 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/image/qicon.cpp
r651 r763 139 139 140 140 // 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) 141 static QPixmapIconEngineEntry *bestSizeMatch( const QSize &size, QPixmapIconEngineEntry *pa, QPixmapIconEngineEntry *pb) 150 142 { 151 143 int s = area(size); … … 160 152 } 161 153 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) 167 156 res = qMin(a,b); 168 }169 157 else 158 res = qMax(a,b); 170 159 if (res == a) 171 160 return pa; … … 311 300 return actualSize; 312 301 313 if ( actualSize.width() > size.width() || actualSize.height() > size.height())302 if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height())) 314 303 actualSize.scale(size, Qt::KeepAspectRatio); 315 304 return actualSize;
Note:
See TracChangeset
for help on using the changeset viewer.