mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 03:12:56 +00:00
QColor cleanup
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
30897c3c09
commit
775c5e0f3d
3 changed files with 8 additions and 38 deletions
|
@ -52,7 +52,7 @@
|
|||
# include "qx11info_x11.h"
|
||||
# include "qt_x11_p.h"
|
||||
|
||||
static bool allowX11ColorNames = false;
|
||||
static bool qAllowX11ColorNames = false;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -550,7 +550,7 @@ bool QColor::setNamedColor(const QString &name)
|
|||
|
||||
#ifndef QT_NO_COLORNAMES
|
||||
QRgb rgb;
|
||||
if (qt_get_named_rgb(name.toLatin1(), &rgb)) {
|
||||
if (qt_get_named_rgb(name.toLower().toLatin1(), &rgb)) {
|
||||
setRgba(rgb);
|
||||
return true;
|
||||
} else
|
||||
|
@ -2393,7 +2393,7 @@ QColor::operator QVariant() const
|
|||
*/
|
||||
bool QColor::allowX11ColorNames()
|
||||
{
|
||||
return ::allowX11ColorNames;
|
||||
return qAllowX11ColorNames;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -2407,7 +2407,7 @@ bool QColor::allowX11ColorNames()
|
|||
*/
|
||||
void QColor::setAllowX11ColorNames(bool enabled)
|
||||
{
|
||||
::allowX11ColorNames = enabled;
|
||||
qAllowX11ColorNames = enabled;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -268,10 +268,9 @@ inline bool operator<(const char *name, const RGBData &data)
|
|||
inline bool operator<(const RGBData &data, const char *name)
|
||||
{ return qstrcmp(data.name, name) < 0; }
|
||||
|
||||
static bool get_named_rgb(const char *name_no_space, QRgb *rgb)
|
||||
bool qt_get_named_rgb(const char *name, QRgb* rgb)
|
||||
{
|
||||
QByteArray name = QByteArray::fromRawData(name_no_space, qstrlen(name_no_space)).toLower();
|
||||
const RGBData *r = qBinaryFind(rgbTbl, rgbTbl + rgbTblSize, name.constData());
|
||||
const RGBData *r = qBinaryFind(rgbTbl, rgbTbl + rgbTblSize, name);
|
||||
if (r != rgbTbl + rgbTblSize) {
|
||||
*rgb = r->value;
|
||||
return true;
|
||||
|
@ -279,36 +278,12 @@ static bool get_named_rgb(const char *name_no_space, QRgb *rgb)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool qt_get_named_rgb(const char *name, QRgb* rgb)
|
||||
{
|
||||
int len = int(strlen(name));
|
||||
if(len > 255)
|
||||
return false;
|
||||
char name_no_space[256];
|
||||
int pos = 0;
|
||||
for(int i = 0; i < len; i++) {
|
||||
if(name[i] != '\t' && name[i] != ' ')
|
||||
name_no_space[pos++] = name[i];
|
||||
}
|
||||
name_no_space[pos] = 0;
|
||||
|
||||
return get_named_rgb(name_no_space, rgb);
|
||||
}
|
||||
|
||||
uint qt_get_rgb_val(const char *name)
|
||||
{
|
||||
QRgb r = 0;
|
||||
qt_get_named_rgb(name,&r);
|
||||
return r;
|
||||
}
|
||||
|
||||
QStringList qt_get_colornames()
|
||||
{
|
||||
int i = 0;
|
||||
static QStringList lst;
|
||||
if (lst.isEmpty()) {
|
||||
for (i = 0; i < rgbTblSize; i++)
|
||||
lst << QLatin1String(rgbTbl[i].name);
|
||||
for (int i = 0; i < rgbTblSize; i++)
|
||||
lst << QString::fromLatin1(rgbTbl[i].name);
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
@ -320,10 +295,6 @@ bool qt_get_named_rgb(const char *, QRgb*)
|
|||
return false;
|
||||
}
|
||||
|
||||
uint qt_get_rgb_val(const char *)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
QStringList qt_get_colornames()
|
||||
{
|
||||
return QStringList();
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
uint qt_get_rgb_val(const char *name);
|
||||
bool qt_get_named_rgb(const char *, QRgb*);
|
||||
bool qt_get_hex_rgb(const char *, QRgb *);
|
||||
QStringList qt_get_colornames();
|
||||
|
|
Loading…
Add table
Reference in a new issue