mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 00:26:39 +00:00 
			
		
		
		
	Draw the frame around rect in ColorEditor and ColorPickerDelegate
This commit is contained in:
		
							parent
							
								
									eb5180ba86
								
							
						
					
					
						commit
						caeba1b887
					
				
					 3 changed files with 10 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -31,6 +31,8 @@ void CSVWidget::ColorEditor::paintEvent(QPaintEvent *event)
 | 
			
		|||
                      qRound(buttonRect.height() / 2.0));
 | 
			
		||||
    QPainter painter(this);
 | 
			
		||||
    painter.fillRect(coloredRect, mColor);
 | 
			
		||||
    painter.setPen(Qt::black);
 | 
			
		||||
    painter.drawRect(coloredRect);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QColor CSVWidget::ColorEditor::color() const
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,16 +15,15 @@ void CSVWorld::ColorPickerDelegate::paint(QPainter *painter,
 | 
			
		|||
                                          const QStyleOptionViewItem &option,
 | 
			
		||||
                                          const QModelIndex &index) const
 | 
			
		||||
{
 | 
			
		||||
    QRect coloredRect = getColoredRect(option);
 | 
			
		||||
    QRect coloredRect(qRound(option.rect.x() + option.rect.width() / 4.0),
 | 
			
		||||
                      qRound(option.rect.y() + option.rect.height() / 4.0),
 | 
			
		||||
                      qRound(option.rect.width() / 2.0),
 | 
			
		||||
                      qRound(option.rect.height() / 2.0));
 | 
			
		||||
    painter->save();
 | 
			
		||||
    painter->fillRect(coloredRect, index.data().value<QColor>());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QRect CSVWorld::ColorPickerDelegate::getColoredRect(const QStyleOptionViewItem &option) const
 | 
			
		||||
{
 | 
			
		||||
    return QRect(qRound(option.rect.x() + option.rect.width() / 4.0),
 | 
			
		||||
                 qRound(option.rect.y() + option.rect.height() / 4.0),
 | 
			
		||||
                 qRound(option.rect.width() / 2.0),
 | 
			
		||||
                 qRound(option.rect.height() / 2.0));
 | 
			
		||||
    painter->setPen(Qt::black);
 | 
			
		||||
    painter->drawRect(coloredRect);
 | 
			
		||||
    painter->restore();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CSVWorld::CommandDelegate *CSVWorld::ColorPickerDelegateFactory::makeDelegate(CSMWorld::CommandDispatcher *dispatcher, 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,8 +14,6 @@ namespace CSVWorld
 | 
			
		|||
{
 | 
			
		||||
    class ColorPickerDelegate : public CommandDelegate
 | 
			
		||||
    {
 | 
			
		||||
            QRect getColoredRect(const QStyleOptionViewItem &option) const;
 | 
			
		||||
 | 
			
		||||
        public:
 | 
			
		||||
            ColorPickerDelegate(CSMWorld::CommandDispatcher *dispatcher, 
 | 
			
		||||
                                CSMDoc::Document& document, 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue