Commit 5bc0b561 authored by Kurt Hindenburg's avatar Kurt Hindenburg

Remove class ColorEntry which was actually just a QColor wrapper

For now typedef ColorEntry to a QColor
parent 341e84dc
......@@ -34,53 +34,7 @@ namespace Konsole
* A color palette is an array of 16 ColorEntry instances which map
* system color indexes (from 0 to 15) into actual colors.
*/
class ColorEntry
{
public:
/**
* Constructs a new color palette entry.
*
* @param c The color value for this entry.
*/
explicit ColorEntry(QColor c)
: color(c) {}
/**
* Constructs a new color palette entry using black color.
*/
ColorEntry() : color(QColor(0x00, 0x00, 0x00)) {}
/**
* Sets the color of this color to those of @p rhs.
*/
void operator=(const ColorEntry& rhs) {
color = rhs.color;
}
/** The color value of this entry for display. */
QColor color;
/**
* Compares two color entries and returns true if they represent the same
* color.
*/
friend bool operator == (const ColorEntry& a, const ColorEntry& b);
/**
* Compares two color entries and returns true if they represent different
* color.
*/
friend bool operator != (const ColorEntry& a, const ColorEntry& b);
};
inline bool operator == (const ColorEntry& a, const ColorEntry& b)
{
return a.color == b.color;
}
inline bool operator != (const ColorEntry& a, const ColorEntry& b)
{
return !operator==(a, b);
}
typedef QColor ColorEntry;
// Attributed Character Representations ///////////////////////////////
......@@ -236,11 +190,11 @@ inline const QColor color256(quint8 u, const ColorEntry* base)
{
// 0.. 16: system colors
if (u < 8) {
return base[u + 2].color;
return base[u + 2];
}
u -= 8;
if (u < 8) {
return base[u + 2 + BASE_COLORS].color;
return base[u + 2 + BASE_COLORS];
}
u -= 8;
......@@ -262,9 +216,9 @@ inline QColor CharacterColor::color(const ColorEntry* base) const
{
switch (_colorSpace) {
case COLOR_SPACE_DEFAULT:
return base[_u + 0 + (_v * BASE_COLORS)].color;
return base[_u + 0 + (_v * BASE_COLORS)];
case COLOR_SPACE_SYSTEM:
return base[_u + 2 + (_v * BASE_COLORS)].color;
return base[_u + 2 + (_v * BASE_COLORS)];
case COLOR_SPACE_256:
return color256(_u, base);
case COLOR_SPACE_RGB:
......
......@@ -261,7 +261,7 @@ ColorEntry ColorScheme::colorEntry(int index , uint randomSeed) const
valueDifference = dist(randomEngine) - range.value / 2;
}
QColor& color = entry.color;
QColor& color = entry;
int newHue = qAbs((color.hue() + hueDifference) % MAX_HUE);
int newValue = qMin(qAbs(color.value() + valueDifference) , 255);
......@@ -317,11 +317,11 @@ const ColorEntry* ColorScheme::colorTable() const
}
QColor ColorScheme::foregroundColor() const
{
return colorTable()[FGCOLOR_INDEX].color;
return colorTable()[FGCOLOR_INDEX];
}
QColor ColorScheme::backgroundColor() const
{
return colorTable()[BGCOLOR_INDEX].color;
return colorTable()[BGCOLOR_INDEX];
}
bool ColorScheme::hasDarkBackground() const
{
......@@ -364,7 +364,7 @@ void ColorScheme::readColorEntry(const KConfig& config , int index)
ColorEntry entry;
entry.color = configGroup.readEntry("Color", QColor());
entry = configGroup.readEntry("Color", QColor());
setColorTableEntry(index , entry);
......@@ -395,7 +395,7 @@ void ColorScheme::writeColorEntry(KConfig& config , int index) const
const ColorEntry& entry = colorTable()[index];
configGroup.writeEntry("Color", entry.color);
configGroup.writeEntry("Color", entry);
// Remove unused keys
if (configGroup.hasKey("Transparent")) {
......
......@@ -172,7 +172,7 @@ void ColorSchemeEditor::editColorItem(QTableWidgetItem* item)
}
ColorEntry entry(_colors->colorEntry(colorSchemeRow));
entry.color = color;
entry = color;
_colors->setColorTableEntry(colorSchemeRow, entry);
emit colorsChanged(_colors);
......@@ -268,17 +268,17 @@ void ColorSchemeEditor::setupColorTable(const ColorScheme* colors)
nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
auto colorItem = new QTableWidgetItem();
colorItem->setBackground(table[row].color);
colorItem->setBackground(table[row]);
colorItem->setFlags(colorItem->flags() & ~Qt::ItemIsEditable & ~Qt::ItemIsSelectable);
colorItem->setToolTip(i18nc("@info:tooltip", "Click to choose color"));
auto colorItemIntense = new QTableWidgetItem();
colorItemIntense->setBackground(table[COLOR_TABLE_ROW_LENGTH + row].color);
colorItemIntense->setBackground(table[COLOR_TABLE_ROW_LENGTH + row]);
colorItemIntense->setFlags(colorItem->flags() & ~Qt::ItemIsEditable & ~Qt::ItemIsSelectable);
colorItemIntense->setToolTip(i18nc("@info:tooltip", "Click to choose intense color"));
auto colorItemFaint = new QTableWidgetItem();
colorItemFaint->setBackground(table[2*COLOR_TABLE_ROW_LENGTH + row].color);
colorItemFaint->setBackground(table[2*COLOR_TABLE_ROW_LENGTH + row]);
colorItemFaint->setFlags(colorItem->flags() & ~Qt::ItemIsEditable & ~Qt::ItemIsSelectable);
colorItemFaint->setToolTip(i18nc("@info:tooltip", "Click to choose Faint color"));
......
......@@ -133,7 +133,7 @@ const ColorEntry* TerminalDisplay::colorTable() const
}
void TerminalDisplay::setBackgroundColor(const QColor& color)
{
_colorTable[DEFAULT_BACK_COLOR].color = color;
_colorTable[DEFAULT_BACK_COLOR] = color;
QPalette p = palette();
p.setColor(backgroundRole(), color);
......@@ -151,7 +151,7 @@ QColor TerminalDisplay::getBackgroundColor() const
}
void TerminalDisplay::setForegroundColor(const QColor& color)
{
_colorTable[DEFAULT_FORE_COLOR].color = color;
_colorTable[DEFAULT_FORE_COLOR] = color;
update();
}
......@@ -160,7 +160,7 @@ void TerminalDisplay::setColorTable(const ColorEntry table[])
for (int i = 0; i < TABLE_COLORS; i++)
_colorTable[i] = table[i];
setBackgroundColor(_colorTable[DEFAULT_BACK_COLOR].color);
setBackgroundColor(_colorTable[DEFAULT_BACK_COLOR]);
}
/* ------------------------------------------------------------------------- */
......@@ -3011,8 +3011,8 @@ void TerminalDisplay::drawInputMethodPreeditString(QPainter& painter , const QRe
const QPoint cursorPos = cursorPosition();
bool invertColors = false;
const QColor background = _colorTable[DEFAULT_BACK_COLOR].color;
const QColor foreground = _colorTable[DEFAULT_FORE_COLOR].color;
const QColor background = _colorTable[DEFAULT_BACK_COLOR];
const QColor foreground = _colorTable[DEFAULT_FORE_COLOR];
const Character* style = &_image[loc(cursorPos.x(), cursorPos.y())];
drawBackground(painter, rect, background, true);
......
......@@ -98,8 +98,8 @@ void CharacterColorTest::testColorEntry()
// Test ColorEntry()
ColorEntry defaultColorEntry = ColorEntry();
QCOMPARE(defaultColorEntry != green, true);
QCOMPARE(defaultColorEntry == black, true);
QCOMPARE(defaultColorEntry != black, false);
QCOMPARE(defaultColorEntry != black, true);
QCOMPARE(defaultColorEntry.isValid(), false);
}
......@@ -114,8 +114,8 @@ void CharacterColorTest::testColorSpaceDefault_data()
QTest::addColumn<int>("colorValue");
QTest::addColumn<QColor>("expected");
QTest::newRow("color 0") << 0 << DefaultColorTable[0].color;
QTest::newRow("color 1") << 1 << DefaultColorTable[1].color;
QTest::newRow("color 0") << 0 << DefaultColorTable[0];
QTest::newRow("color 1") << 1 << DefaultColorTable[1];
}
void CharacterColorTest::testColorSpaceDefault()
......@@ -134,9 +134,9 @@ void CharacterColorTest::testColorSpaceSystem_data()
QTest::addColumn<int>("colorValue");
QTest::addColumn<QColor>("expected");
QTest::newRow("color 0") << 0 << DefaultColorTable[2 + 0].color;
QTest::newRow("color 1") << 1 << DefaultColorTable[2 + 1].color;
QTest::newRow("color 7") << 7 << DefaultColorTable[2 + 7].color;
QTest::newRow("color 0") << 0 << DefaultColorTable[2 + 0];
QTest::newRow("color 1") << 1 << DefaultColorTable[2 + 1];
QTest::newRow("color 7") << 7 << DefaultColorTable[2 + 7];
}
void CharacterColorTest::testColorSpaceSystem()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment