mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 16:44:39 +03:00
Color property reafctored
This commit is contained in:
parent
dd94689f41
commit
1caf4a8e2d
@ -28,11 +28,14 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrcoloreditor.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QColorDialog>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
#include <QStyle>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
@ -94,18 +97,23 @@ void ColorEditor::slotClicked()
|
||||
emit(editingFinished());
|
||||
}
|
||||
|
||||
|
||||
void ColorIndicator::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
QStyle* style = QApplication::style();
|
||||
painter.save();
|
||||
painter.setBrush(m_color);
|
||||
painter.setPen(Qt::transparent);
|
||||
QRect rect = event->rect().adjusted(3,3,-4,-4);
|
||||
rect.setWidth(rect.height());
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
// painter.drawEllipse(rect);
|
||||
painter.drawRoundedRect(rect,2,2);
|
||||
QColor penColor = isColorDark(m_color) ? Qt::transparent : Qt::darkGray;
|
||||
|
||||
painter.setPen(penColor);
|
||||
int border = (event->rect().height() - style->pixelMetric(QStyle::PM_IndicatorWidth))/2;
|
||||
|
||||
QRect rect(event->rect().x()+border, event->rect().y()+border,
|
||||
style->pixelMetric(QStyle::PM_IndicatorWidth),
|
||||
style->pixelMetric(QStyle::PM_IndicatorWidth));// = option.rect.adjusted(4,4,-4,-6);
|
||||
|
||||
painter.drawRect(rect);
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,10 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrcolorpropitem.h"
|
||||
#include "lrglobal.h"
|
||||
#include "editors/lrcoloreditor.h"
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createColorPropItem(
|
||||
@ -58,24 +60,20 @@ bool ColorPropItem::paint(QPainter *painter, const StyleOptionViewItem &option,
|
||||
{
|
||||
if (index.column()==1){
|
||||
painter->save();
|
||||
|
||||
QStyle* style = option.widget ? option.widget->style() : QApplication::style();
|
||||
QPen pen;
|
||||
|
||||
// if (option.state & QStyle::State_Selected){
|
||||
// pen.setWidth(1);
|
||||
// pen.setColor(option.palette.brightText().color());
|
||||
// }else {
|
||||
// pen.setColor(Qt::darkGray);
|
||||
// }
|
||||
|
||||
pen.setColor(Qt::transparent);
|
||||
QColor penColor = isColorDark(propertyValue().value<QColor>()) ? Qt::transparent : Qt::darkGray;
|
||||
pen.setColor(penColor);
|
||||
painter->setPen(pen);
|
||||
|
||||
painter->setBrush(propertyValue().value<QColor>());
|
||||
QRect rect = option.rect.adjusted(4,4,-4,-6);
|
||||
rect.setWidth(rect.height());
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->drawRoundedRect(rect,2,2);
|
||||
// painter->drawEllipse(rect);
|
||||
int border = (option.rect.height() - style->pixelMetric(QStyle::PM_IndicatorWidth))/2;
|
||||
|
||||
QRect rect(option.rect.x()+border,option.rect.y()+border,
|
||||
style->pixelMetric(QStyle::PM_IndicatorWidth),
|
||||
style->pixelMetric(QStyle::PM_IndicatorWidth));
|
||||
painter->drawRect(rect);
|
||||
|
||||
painter->restore();
|
||||
return true;
|
||||
} else return false;
|
||||
|
Loading…
Reference in New Issue
Block a user