Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Games
KSudoku
Commits
a6dd87c0
Commit
a6dd87c0
authored
Nov 28, 2007
by
Christian Ehrlicher
Browse files
Make sure the text has not the same color like the background color
svn path=/trunk/KDE/kdegames/ksudoku/; revision=742727
parent
608811c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/gui/gamevariants.cpp
View file @
a6dd87c0
...
...
@@ -139,12 +139,16 @@ QSize GameVariantDelegate::sizeHint(const QStyleOptionViewItem& option, const QM
void
GameVariantDelegate
::
paint
(
QPainter
*
painter
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
index
)
const
{
// show background
QColor
bkgColor
;
if
(
option
.
state
&
QStyle
::
State_Selected
)
{
painter
->
fillRect
(
option
.
rect
,
option
.
palette
.
color
(
QPalette
::
Highlight
));
bkgColor
=
option
.
palette
.
color
(
QPalette
::
Highlight
);
painter
->
fillRect
(
option
.
rect
,
bkgColor
);
}
else
if
(
index
.
row
()
%
2
)
{
painter
->
fillRect
(
option
.
rect
,
option
.
palette
.
color
(
QPalette
::
AlternateBase
));
bkgColor
=
option
.
palette
.
color
(
QPalette
::
AlternateBase
);
painter
->
fillRect
(
option
.
rect
,
bkgColor
);
}
else
{
painter
->
fillRect
(
option
.
rect
,
option
.
palette
.
color
(
QPalette
::
Base
));
bkgColor
=
option
.
palette
.
color
(
QPalette
::
Base
);
painter
->
fillRect
(
option
.
rect
,
bkgColor
);
}
QRect
contentRect
=
option
.
rect
.
adjusted
(
m_leftMargin
,
m_separatorPixels
,
-
m_rightMargin
,
-
m_separatorPixels
);
...
...
@@ -167,6 +171,16 @@ void GameVariantDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
titleFont
.
setPointSize
(
titleFont
.
pointSize
()
+
2
);
titleFont
.
setWeight
(
QFont
::
Bold
);
QPen
previousPen
(
painter
->
pen
());
// TODO: don't we have a function for 'color1 similar color2'
if
(
previousPen
.
color
()
==
bkgColor
)
{
QPen
p
(
previousPen
);
int
color
=
bkgColor
.
rgb
();
color
=
~
color
|
0xff000000
;
p
.
setColor
(
color
);
painter
->
setPen
(
p
);
}
QFont
previousFont
(
painter
->
font
());
painter
->
setFont
(
titleFont
);
QString
titleStr
=
painter
->
fontMetrics
().
elidedText
(
title
(
index
),
Qt
::
ElideRight
,
contentRect
.
width
());
...
...
@@ -177,6 +191,8 @@ void GameVariantDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
// Show Description
QString
descrStr
=
painter
->
fontMetrics
().
elidedText
(
description
(
index
),
Qt
::
ElideRight
,
contentRect
.
width
());
painter
->
drawText
(
contentRect
,
descrStr
);
painter
->
setPen
(
previousPen
);
}
QString
GameVariantDelegate
::
title
(
const
QModelIndex
&
index
)
const
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment