Cleanup
This commit is contained in:
		
					parent
					
						
							
								41be285e07
							
						
					
				
			
			
				commit
				
					
						64e16642ff
					
				
			
		
					 1 changed files with 11 additions and 12 deletions
				
			
		| 
						 | 
					@ -47,13 +47,7 @@ namespace Danbooru {
 | 
				
			||||||
                                                                    m_itemView(itemView)
 | 
					                                                                    m_itemView(itemView)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Get the sizes for the buttons
 | 
				
			||||||
        //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
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const int iconSize = KIconLoader::global()->currentSize(
 | 
					        const int iconSize = KIconLoader::global()->currentSize(
 | 
				
			||||||
            KIconLoader::Toolbar
 | 
					            KIconLoader::Toolbar
 | 
				
			||||||
| 
						 | 
					@ -119,6 +113,11 @@ namespace Danbooru {
 | 
				
			||||||
        // Scaling is unavoidable to keep things in the right dimension
 | 
					        // Scaling is unavoidable to keep things in the right dimension
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QPixmap scaled;
 | 
					        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;
 | 
					        int maxHeight = rect.height() - 3 * metrics.height() - 2 * MARGIN;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        scaled = pixmap.scaled(rect.width() - 2 * MARGIN,
 | 
					        scaled = pixmap.scaled(rect.width() - 2 * MARGIN,
 | 
				
			||||||
| 
						 | 
					@ -138,13 +137,14 @@ namespace Danbooru {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        painter->drawPixmap(pixRect, scaled);
 | 
					        painter->drawPixmap(pixRect, scaled);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Buttons
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        painter->save();
 | 
					        painter->save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Show buttons on mouseover
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (option.state & QStyle::State_MouseOver) {
 | 
					        if (option.state & QStyle::State_MouseOver) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Get the bottom coordinate for the buttons
 | 
					            // Get the bottom coordinate for the buttons
 | 
				
			||||||
 | 
					            // TODO: Perhaps add some transition?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            m_downloadButton->move(pixRect.topLeft());
 | 
					            m_downloadButton->move(pixRect.topLeft());
 | 
				
			||||||
            m_viewButton->move(pixRect.bottomLeft() - QPoint(
 | 
					            m_viewButton->move(pixRect.bottomLeft() - QPoint(
 | 
				
			||||||
| 
						 | 
					@ -160,7 +160,7 @@ namespace Danbooru {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        painter->restore();
 | 
					        painter->restore();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Text (resolution)
 | 
					        // Text
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        DanbooruPost* post = index.data().value<Danbooru::DanbooruPost*>();
 | 
					        DanbooruPost* post = index.data().value<Danbooru::DanbooruPost*>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -194,13 +194,12 @@ namespace Danbooru {
 | 
				
			||||||
                ratingString = i18n("Explicit");
 | 
					                ratingString = i18n("Explicit");
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            default:
 | 
					            default:
 | 
				
			||||||
                ratingString = i18nc("Unknown", "Unknown rating");
 | 
					                ratingString = i18nc("Unknown post rating", "Unknown");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        imageText += i18n("Rating: %1", ratingString);
 | 
					        imageText += i18n("Rating: %1", ratingString);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        painter->drawText(textRect, imageText);
 | 
					        painter->drawText(textRect, imageText);
 | 
				
			||||||
 | 
					 | 
				
			||||||
        painter->restore();
 | 
					        painter->restore();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue