Disabled fix color of chat messages for Qt 4.5 and lower because of missing methods on QColor.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5592 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-09-24 11:32:11 +00:00
parent 16f07f766c
commit 91710adfac
3 changed files with 13 additions and 2 deletions

View File

@ -88,6 +88,11 @@ ChatPage::ChatPage(QWidget * parent, Qt::WFlags flags)
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
#if QT_VERSION < 0x040600
ui.minimumContrastLabel->hide();
ui.minimumContrast->hide();
#endif
/* Hide platform specific features */
#ifdef Q_WS_WIN

View File

@ -98,7 +98,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_40">
<item>
<widget class="QLabel" name="label40">
<widget class="QLabel" name="minimumContrastLabel">
<property name="text">
<string>Minimum text contrast</string>
</property>

View File

@ -451,6 +451,12 @@ static qreal getContrastRatio(qreal lum1, qreal lum2)
*/
static void findBestColor(QString &val, qreal bglum, qreal desiredContrast)
{
#if QT_VERSION < 0x040600
// missing methods on class QColor
Q_UNUSED(val);
Q_UNUSED(bglum);
Q_UNUSED(desiredContrast);
#else
// Change text color to get a good contrast with the background
QColor c(val);
qreal lum = ::getRelativeLuminance(c);
@ -466,7 +472,6 @@ static void findBestColor(QString &val, qreal bglum, qreal desiredContrast)
// So we enforce desired contrast when the bg is dark.
if (!searchDown || ::getContrastRatio(lum, bglum) < desiredContrast) {
// Bisection search of the correct "lightness" to get the desired contrast
qreal minl = searchDown ? 0.0 : bglum;
qreal maxl = searchDown ? bglum : 1.0;
@ -485,6 +490,7 @@ static void findBestColor(QString &val, qreal bglum, qreal desiredContrast)
c.setHslF(c.hslHueF(), c.hslSaturationF(), minl);
val = c.name();
}
#endif // QT_VERSION < 0x040600
}
static void optimizeHtml(QDomDocument& doc, QDomElement& currentElement, unsigned int flag, qreal bglum, qreal desiredContrast)