diff --git a/src/model/danboorupostdelegate.cpp b/src/model/danboorupostdelegate.cpp index 6a9ee28..ac6e1da 100644 --- a/src/model/danboorupostdelegate.cpp +++ b/src/model/danboorupostdelegate.cpp @@ -47,13 +47,7 @@ namespace Danbooru { m_itemView(itemView) { - - //FIXME: Copied directly from Gwenview without understanding - - #define pm(x) itemView->style()->pixelMetric(QStyle::x) - m_margin = pm(PM_ToolBarItemMargin); - m_spacing = pm(PM_ToolBarItemSpacing); - #undef pm + // Get the sizes for the buttons const int iconSize = KIconLoader::global()->currentSize( KIconLoader::Toolbar @@ -119,6 +113,11 @@ namespace Danbooru { // Scaling is unavoidable to keep things in the right dimension QPixmap scaled; + + // Reserve enough space for the pixmap + the 3 lines of text: + // this prevents issues with images that have height > width + // (like in yande.re which keeps a lot of scans) + int maxHeight = rect.height() - 3 * metrics.height() - 2 * MARGIN; scaled = pixmap.scaled(rect.width() - 2 * MARGIN, @@ -138,13 +137,14 @@ namespace Danbooru { painter->drawPixmap(pixRect, scaled); - // Buttons - painter->save(); + // Show buttons on mouseover + if (option.state & QStyle::State_MouseOver) { // Get the bottom coordinate for the buttons + // TODO: Perhaps add some transition? m_downloadButton->move(pixRect.topLeft()); m_viewButton->move(pixRect.bottomLeft() - QPoint( @@ -160,7 +160,7 @@ namespace Danbooru { painter->restore(); - // Text (resolution) + // Text DanbooruPost* post = index.data().value(); @@ -194,13 +194,12 @@ namespace Danbooru { ratingString = i18n("Explicit"); break; default: - ratingString = i18nc("Unknown", "Unknown rating"); + ratingString = i18nc("Unknown post rating", "Unknown"); } imageText += i18n("Rating: %1", ratingString); painter->drawText(textRect, imageText); - painter->restore(); }