Force custom colors within usable range

We previously allowed fully white and yellow colors as the
base color for our interface. This does not work with our
icons or other interface elements. Instead I now constrain
the selectable colors within a certain range of saturation
and brightness. This still leaves the user in control but
will prevent the common case where the user selects an
overly saturated color from the color picker and ends up
with an unusable or extremely ugly panel.
This commit is contained in:
Jens Bache-Wiig
2010-03-03 11:02:13 +01:00
parent 5bba68aa25
commit 93dbb3a5fc
5 changed files with 17 additions and 4 deletions

View File

@@ -95,6 +95,7 @@ QColor StyleHelper::panelTextColor(bool lightColored)
}
QColor StyleHelper::m_baseColor(0x666666);
QColor StyleHelper::m_requestedBaseColor(0x666666);
QColor StyleHelper::baseColor(bool lightColored)
{
@@ -136,8 +137,18 @@ QColor StyleHelper::borderColor(bool lightColored)
return result;
}
void StyleHelper::setBaseColor(const QColor &color)
// We try to ensure that the actual color used are within
// reasonalbe bounds while generating the actual baseColor
// from the users request.
void StyleHelper::setBaseColor(const QColor &newcolor)
{
m_requestedBaseColor = newcolor;
QColor color;
color.setHsv(newcolor.hue(),
newcolor.saturation() * 0.7,
64 + newcolor.value() / 3);
if (color.isValid() && color != m_baseColor) {
m_baseColor = color;
foreach (QWidget *w, QApplication::topLevelWidgets())