forked from qt-creator/qt-creator
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:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user