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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //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<Danbooru::DanbooruPost*>();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue