Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 1b73ff9

Browse files
committed
Restore cosmetic pens & try to fix underdrawing
This improves the "under"-drawing a lot (at least on my retina).
1 parent 50d3063 commit 1b73ff9

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

src/libDiffViews/Views/Seq/SeqViewDelta.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,20 @@ namespace DiffViews
4545
{
4646
SeqViewInfo* i = info();
4747

48+
QPen pen(i->clrSeparator);
49+
pen.setWidth(0);
50+
4851
QFontMetricsF fm( i->mFixed );
4952
QLinearGradient grad( 0., 0., 0., height() );
5053

5154
grad.setColorAt( 0., i->clrDeltaFirst );
5255
grad.setColorAt( 1., i->clrDeltaSecond );
5356
p->setBrush( grad );
54-
p->setPen( i->clrSeparator );
57+
p->setPen(pen);
5558
p->drawRect( 10, 0, width() - 20, height() );
5659

57-
p->setPen( i->clrText );
60+
pen.setColor(i->clrText);
61+
p->setPen(pen);
5862
p->setFont( i->mFixed );
5963
qreal top = - fm.leading() / 2.;
6064

src/libDiffViews/Views/Seq/SeqViewDiffStat.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ namespace DiffViews
7070
{
7171
SeqViewInfo* ifo = info();
7272

73+
QPen pen(ifo->clrText);
74+
pen.setWidth(0);
75+
7376
p->setFont( ifo->mVariable );
74-
p->setPen( ifo->clrText );
77+
p->setPen(pen);
7578
p->drawText( QRectF( 5, 0, mTextWidth, height() ),
7679
Qt::AlignVCenter | Qt::AlignLeft, mPathName );
7780

@@ -93,7 +96,8 @@ namespace DiffViews
9396
p->fillRect( r, ifo->clrRemoved );
9497
}
9598

96-
p->setPen( ifo->clrSeparator );
99+
pen.setColor(ifo->clrSeparator);
100+
p->setPen(pen);
97101
p->drawLine( QPointF( 0, height() ), QPointF( width(), height() ) );
98102
}
99103

src/libDiffViews/Views/Seq/SeqViewHunk.cpp

+20-13
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,17 @@ namespace DiffViews
4242
void SeqViewHunkHeader::paint( QPainter* p, const QStyleOptionGraphicsItem*, QWidget* )
4343
{
4444
SeqViewInfo* i = info();
45+
QPen pen(i->clrSeparator);
46+
pen.setWidth(0);
47+
4548
QFontMetricsF fm( i->mFixed );
4649

47-
p->setPen( i->clrSeparator );
50+
p->setPen(pen);
4851
p->setBrush( i->clrDeltaFirst );
4952
p->drawRect( 10., 0., width() - 20., height() );
5053

51-
p->setPen( i->clrText );
54+
pen.setColor(i->clrText);
55+
p->setPen(pen);
5256
p->setFont( i->mFixed );
5357
p->drawText( QRectF( 12, 1 - fm.leading() / 2., width() - 24, height() - 2 ),
5458
Qt::AlignLeft | Qt::AlignTop | Qt::TextWrapAnywhere, mText );
@@ -150,30 +154,31 @@ namespace DiffViews
150154
SeqViewInfo* ifo = info();
151155

152156
QFontMetricsF fm( ifo->mFixed );
157+
QRectF outline(10, 0, width() - 20, height());
153158
QRectF r = fm.boundingRect( QLatin1String( "X" ) );
154159
qreal lh = r.height() + 1;
155-
qreal top = 1.;
156-
157-
p->setPen( ifo->clrSeparator );
158-
p->setBrush( ifo->clrDeltaFirst );
159-
p->drawRect( 10, 0, width() - 20, height() - 1 );
160+
qreal top = 0;
160161

161162
qreal left = 12 + mSpaceLeft + mSpaceRight + 6;
162163
qreal wide = width() - 12 - left;
163164

165+
p->fillRect(outline, ifo->clrDeltaFirst);
164166
p->setFont( ifo->mFixed );
165167

168+
QPen pen(ifo->clrText);
169+
pen.setWidth(0);
170+
p->setPen(pen);
171+
166172
for( int i = 0; i < mLines.count(); ++i )
167173
{
168174
if( !mLines[ i ].rightNr )
169175
{
170-
p->fillRect( QRectF( 11, top, width() - 21, lh ), ifo->clrRemoved );
176+
p->fillRect( QRectF( 10, top, width() - 20, lh ), ifo->clrRemoved );
171177
}
172178
else if( !mLines[ i ].leftNr )
173179
{
174-
p->fillRect( QRectF( 11, top, width() - 21, lh ), ifo->clrAdded );
180+
p->fillRect( QRectF( 10, top, width() - 20, lh ), ifo->clrAdded );
175181
}
176-
p->setPen( ifo->clrText );
177182

178183
qreal top2 = top - fm.leading() / 2.;
179184
if( mLines[ i ].leftNr )
@@ -197,12 +202,14 @@ namespace DiffViews
197202
top += lh;
198203
}
199204

200-
p->setPen( ifo->clrSeparator );
205+
pen.setColor(ifo->clrSeparator);
206+
p->setPen(pen);
207+
p->drawRect(outline);
201208
p->drawLine( 12 + mSpaceLeft + 1, 0,
202-
12 + mSpaceLeft + 1, height() - 1 );
209+
12 + mSpaceLeft + 1, height() );
203210

204211
p->drawLine( 12 + mSpaceLeft + mSpaceRight + 2, 0,
205-
12 + mSpaceLeft + mSpaceRight + 2, height() - 1 );
212+
12 + mSpaceLeft + mSpaceRight + 2, height() );
206213
}
207214

208215
}

0 commit comments

Comments
 (0)