@@ -52,7 +52,7 @@ static constexpr Qt::SortOrder DEFAULT_SORT_ORDER = Qt::AscendingOrder;
5252static constexpr std::array<int , GameListModel::Column_Count> DEFAULT_COLUMN_WIDTHS = {{
5353 55 , // type
5454 85 , // code
55- 95 , // favorite
55+ 55 , // favorite
5656 -1 , // title
5757 -1 , // file title
5858 75 , // crc
@@ -139,8 +139,8 @@ namespace
139139 static constexpr int STAR_MARGIN = 4 ;
140140
141141 GameListIconStyleDelegate (QWidget* parent, const GameListModel* model)
142- : QStyledItemDelegate(parent)
143- , m_model(model)
142+ : QStyledItemDelegate(parent)
143+ , m_model(model)
144144 {
145145 }
146146 ~GameListIconStyleDelegate () = default ;
@@ -169,7 +169,7 @@ namespace
169169 // Determine starting location of icon (Qt uses top-left origin).
170170 const int icon_width = static_cast <int >(static_cast <qreal>(icon.width ()) / icon.devicePixelRatio ());
171171 const int icon_height = static_cast <int >(static_cast <qreal>(icon.height ()) / icon.devicePixelRatio ());
172- const QPoint icon_top_left = QPoint ((rect.width () - icon_width) / 2 , (rect.height () - icon_height) / 2 );
172+ const QPoint icon_top_left = rect. topLeft () + QPoint ((rect.width () - icon_width) / 2 , (rect.height () - icon_height) / 2 );
173173
174174 // Change palette if the item is selected.
175175 if (option.state & QStyle::State_Selected)
@@ -195,20 +195,23 @@ namespace
195195 QPixmapCache::insert (key, highlighted_icon);
196196 }
197197
198- painter->drawPixmap (rect. topLeft () + icon_top_left, highlighted_icon);
198+ painter->drawPixmap (icon_top_left, highlighted_icon);
199199 }
200200 else
201201 {
202- painter->drawPixmap (rect. topLeft () + icon_top_left, icon);
202+ painter->drawPixmap (icon_top_left, icon);
203203 }
204204
205205 // Draw star overlay on bottom-right corner if game is favorited.
206206 const bool is_favorite = (index.column () == GameListModel::Column_Cover) &&
207207 index.data (GameListModel::NeedsFavoriteBadgeRole).toBool ();
208208 if (is_favorite)
209209 {
210- const QPoint star_pos = rect.bottomRight () - QPoint (STAR_SIZE + STAR_MARGIN, STAR_SIZE + STAR_MARGIN);
211- painter->drawPixmap (star_pos, m_model->getFavoritePixmap ());
210+ const QPixmap& star = m_model->getFavoritePixmap ();
211+ const QPoint icon_bottom_right = icon_top_left + QPoint (icon_width, icon_height);
212+ const QSizeF size = star.deviceIndependentSize ();
213+ const QPoint star_pos = icon_bottom_right - QPoint (size.width () + STAR_MARGIN, size.height () + STAR_MARGIN);
214+ painter->drawPixmap (star_pos, star);
212215 }
213216
214217 // Restore the old clip path.
0 commit comments