forked from teamnwah/openmw-tes3coop
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));
|
qRound(buttonRect.height() / 2.0));
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.fillRect(coloredRect, mColor);
|
painter.fillRect(coloredRect, mColor);
|
||||||
|
painter.setPen(Qt::black);
|
||||||
|
painter.drawRect(coloredRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor CSVWidget::ColorEditor::color() const
|
QColor CSVWidget::ColorEditor::color() const
|
||||||
|
|
|
@ -15,16 +15,15 @@ void CSVWorld::ColorPickerDelegate::paint(QPainter *painter,
|
||||||
const QStyleOptionViewItem &option,
|
const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) const
|
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>());
|
painter->fillRect(coloredRect, index.data().value<QColor>());
|
||||||
}
|
painter->setPen(Qt::black);
|
||||||
|
painter->drawRect(coloredRect);
|
||||||
QRect CSVWorld::ColorPickerDelegate::getColoredRect(const QStyleOptionViewItem &option) const
|
painter->restore();
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::CommandDelegate *CSVWorld::ColorPickerDelegateFactory::makeDelegate(CSMWorld::CommandDispatcher *dispatcher,
|
CSVWorld::CommandDelegate *CSVWorld::ColorPickerDelegateFactory::makeDelegate(CSMWorld::CommandDispatcher *dispatcher,
|
||||||
|
|
|
@ -14,8 +14,6 @@ namespace CSVWorld
|
||||||
{
|
{
|
||||||
class ColorPickerDelegate : public CommandDelegate
|
class ColorPickerDelegate : public CommandDelegate
|
||||||
{
|
{
|
||||||
QRect getColoredRect(const QStyleOptionViewItem &option) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ColorPickerDelegate(CSMWorld::CommandDispatcher *dispatcher,
|
ColorPickerDelegate(CSMWorld::CommandDispatcher *dispatcher,
|
||||||
CSMDoc::Document& document,
|
CSMDoc::Document& document,
|
||||||
|
|
Loading…
Reference in a new issue