aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Vladimir Panteleev2018-12-02 20:06:26 +0000
committerGravatar Benjamin Staneck2019-01-16 21:40:14 +0100
commit2c9ba26432856b65883aa6dea98f73009f20bb3a (patch)
tree0f3f2296cc285d3d68e0ba619c7f5bafd6154abd /src
parentKviOptions.h: Add getMircColor (diff)
downloadKVIrc-2c9ba26432856b65883aa6dea98f73009f20bb3a.tar.gz
KVIrc-2c9ba26432856b65883aa6dea98f73009f20bb3a.tar.bz2
KVIrc-2c9ba26432856b65883aa6dea98f73009f20bb3a.zip
Replace KVI_OPTION_MIRCCOLOR usage with getMircColor
- Replace occurrences in IRC-related views, and message type references - Don't replace occurrences dealing with the color picker or the configurable low (0-15) colors - Also replace hard-coded references to the maximum color index (15/16) with KVI_EXTCOLOR_MAX
Diffstat (limited to 'src')
-rw-r--r--src/kvirc/kernel/KviHtmlGenerator.cpp12
-rw-r--r--src/kvirc/ui/KviInputEditor.cpp8
-rw-r--r--src/kvirc/ui/KviIrcView.cpp19
-rw-r--r--src/kvirc/ui/KviThemedComboBox.cpp4
-rw-r--r--src/kvirc/ui/KviThemedLabel.cpp2
-rw-r--r--src/kvirc/ui/KviThemedLineEdit.cpp2
-rw-r--r--src/kvirc/ui/KviThemedTreeWidget.cpp2
-rw-r--r--src/kvirc/ui/KviTopicWidget.cpp8
-rw-r--r--src/modules/options/OptionsWidget_message.cpp16
-rw-r--r--src/modules/url/libkviurl.cpp8
10 files changed, 41 insertions, 40 deletions
diff --git a/src/kvirc/kernel/KviHtmlGenerator.cpp b/src/kvirc/kernel/KviHtmlGenerator.cpp
index 673af7d1d..0dd94895a 100644
--- a/src/kvirc/kernel/KviHtmlGenerator.cpp
+++ b/src/kvirc/kernel/KviHtmlGenerator.cpp
@@ -96,9 +96,9 @@ namespace KviHtmlGenerator
{
szResult.append("<span style=\"color:");
if(uCurFore == Background) // this is the result of reverse
- szResult.append(KVI_OPTION_MIRCCOLOR(KviControlCodes::White).name());
+ szResult.append(getMircColor(KviControlCodes::White).name());
else
- szResult.append(KVI_OPTION_MIRCCOLOR(uCurFore).name());
+ szResult.append(getMircColor(uCurFore).name());
bOpened = true;
}
@@ -114,9 +114,9 @@ namespace KviHtmlGenerator
szResult.append(";background-color:");
}
if(uCurBack == Foreground) // this is the result of reverse
- szResult.append(KVI_OPTION_MIRCCOLOR(KviControlCodes::Black).name());
+ szResult.append(getMircColor(KviControlCodes::Black).name());
else
- szResult.append(KVI_OPTION_MIRCCOLOR(uCurBack).name());
+ szResult.append(getMircColor(uCurBack).name());
}
if(bCurUnderline)
@@ -293,7 +293,7 @@ namespace KviHtmlGenerator
if(uCurBack != Background)
{
szResult.append("\" style=\"background-color:");
- szResult.append(KVI_OPTION_MIRCCOLOR(uCurBack).name());
+ szResult.append(getMircColor(uCurBack).name());
}
szResult.append("\" />");
}
@@ -335,7 +335,7 @@ namespace KviHtmlGenerator
if(uCurBack != Background)
{
szResult.append("\" style=\"background-color:");
- szResult.append(KVI_OPTION_MIRCCOLOR(uCurBack).name());
+ szResult.append(getMircColor(uCurBack).name());
}
szResult.append("\" />");
}
diff --git a/src/kvirc/ui/KviInputEditor.cpp b/src/kvirc/ui/KviInputEditor.cpp
index 1584dba31..482d81ec0 100644
--- a/src/kvirc/ui/KviInputEditor.cpp
+++ b/src/kvirc/ui/KviInputEditor.cpp
@@ -897,17 +897,17 @@ void KviInputEditor::drawContents(QPainter * p)
{
if(pBlock->uForeground == KVI_INPUT_DEF_FORE)
p->setPen(bIsSelected ? KVI_OPTION_COLOR(KviOption_colorInputSelectionForeground) : KVI_OPTION_COLOR(KviOption_colorInputForeground));
- else if(pBlock->uForeground >= 16)
+ else if(pBlock->uForeground > KVI_EXTCOLOR_MAX)
p->setPen(KVI_OPTION_COLOR(KviOption_colorInputBackground));
else
- p->setPen(KVI_OPTION_MIRCCOLOR(pBlock->uForeground));
+ p->setPen(getMircColor(pBlock->uForeground));
if(pBlock->uBackground != KVI_INPUT_DEF_BACK)
{
- if(pBlock->uBackground >= 16)
+ if(pBlock->uBackground > KVI_EXTCOLOR_MAX)
p->fillRect(QRectF(fCurX, iTop, pBlock->fWidth, iBottom - iTop), KVI_OPTION_COLOR(KviOption_colorInputForeground));
else
- p->fillRect(QRectF(fCurX, iTop, pBlock->fWidth, iBottom - iTop), KVI_OPTION_MIRCCOLOR(pBlock->uBackground));
+ p->fillRect(QRectF(fCurX, iTop, pBlock->fWidth, iBottom - iTop), getMircColor(pBlock->uBackground));
}
diff --git a/src/kvirc/ui/KviIrcView.cpp b/src/kvirc/ui/KviIrcView.cpp
index 7f1e628ac..7b52722a9 100644
--- a/src/kvirc/ui/KviIrcView.cpp
+++ b/src/kvirc/ui/KviIrcView.cpp
@@ -1311,9 +1311,9 @@ void KviIrcView::paintEvent(QPaintEvent * p)
//
#define SET_PEN(_color, _custom) \
- if(((unsigned char)_color) < 16) \
+ if(((unsigned char)_color) <= KVI_EXTCOLOR_MAX) \
{ \
- pa.setPen(KVI_OPTION_MIRCCOLOR((unsigned char)_color)); \
+ pa.setPen(getMircColor((unsigned char)_color)); \
} \
else \
{ \
@@ -1358,7 +1358,7 @@ void KviIrcView::paintEvent(QPaintEvent * p)
int theWdth = _text_width; \
if(theWdth < 0) \
theWdth = width() - (curLeftCoord + KVI_IRCVIEW_HORIZONTAL_BORDER + scrollbarWidth); \
- pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_SELECT).back())); \
+ pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing, getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_SELECT).back())); \
} \
pPenFont.setStyle(curItalic ^ (normalFontStyle != QFont::StyleNormal) ? QFont::StyleItalic : QFont::StyleNormal); \
if (m_bUseRealBold) \
@@ -1376,7 +1376,7 @@ void KviIrcView::paintEvent(QPaintEvent * p)
int theWdth = _text_width; \
if(theWdth < 0) \
theWdth = width() - (curLeftCoord + KVI_IRCVIEW_HORIZONTAL_BORDER + scrollbarWidth); \
- pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing, KVI_OPTION_MIRCCOLOR((unsigned char)curBack)); \
+ pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing, getMircColor((unsigned char)curBack)); \
} \
pPenFont.setStyle(curItalic ^ (normalFontStyle != QFont::StyleNormal) ? QFont::StyleItalic : QFont::StyleNormal); \
if (m_bUseRealBold) \
@@ -1447,7 +1447,8 @@ void KviIrcView::paintEvent(QPaintEvent * p)
int theWdth = block->block_width;
if(theWdth < 0)
theWdth = width() - (curLeftCoord + KVI_IRCVIEW_HORIZONTAL_BORDER + scrollbarWidth);
- pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_SELECT).back()));
+ pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing,
+ getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_SELECT).back()));
goto no_selection_paint;
}
break;
@@ -1484,9 +1485,9 @@ void KviIrcView::paintEvent(QPaintEvent * p)
wdth = widgetWidth - (curLeftCoord + KVI_IRCVIEW_HORIZONTAL_BORDER);
int imageYPos = curBottomCoord - m_iRelativePixmapY;
// Set the mask if needed
- if(curBack != KviControlCodes::Transparent && curBack < 16)
+ if(curBack != KviControlCodes::Transparent && curBack <= KVI_EXTCOLOR_MAX)
{
- pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, wdth, m_iFontLineSpacing, KVI_OPTION_MIRCCOLOR((unsigned char)curBack));
+ pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, wdth, m_iFontLineSpacing, getMircColor((unsigned char)curBack));
}
QString tmpQ;
tmpQ.setUtf16(block->pChunk->szSmileId, kvi_wstrlen(block->pChunk->szSmileId));
@@ -1521,9 +1522,9 @@ void KviIrcView::paintEvent(QPaintEvent * p)
SET_PEN(curFore, block->pChunk ? block->pChunk->customFore : QColor());
- if(curBack != KviControlCodes::Transparent && curBack < 16)
+ if(curBack != KviControlCodes::Transparent && curBack <= KVI_EXTCOLOR_MAX)
{
- pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, wdth, m_iFontLineSpacing, KVI_OPTION_MIRCCOLOR((unsigned char)curBack));
+ pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, wdth, m_iFontLineSpacing, getMircColor((unsigned char)curBack));
}
bool bBold = curBold || curLink;
diff --git a/src/kvirc/ui/KviThemedComboBox.cpp b/src/kvirc/ui/KviThemedComboBox.cpp
index e9a97112b..de724e226 100644
--- a/src/kvirc/ui/KviThemedComboBox.cpp
+++ b/src/kvirc/ui/KviThemedComboBox.cpp
@@ -75,14 +75,14 @@ void KviThemedComboBox::applyOptions()
QPalette pal = palette();
pal.setBrush(QPalette::Base, bIsTrasparent ? Qt::transparent : KVI_OPTION_COLOR(KviOption_colorLabelBackground));
//qcombobox forces QPalette::Text as its forecolor
- pal.setBrush(QPalette::Text, bIsTrasparent ? KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()) : KVI_OPTION_COLOR(KviOption_colorLabelForeground));
+ pal.setBrush(QPalette::Text, bIsTrasparent ? getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()) : KVI_OPTION_COLOR(KviOption_colorLabelForeground));
setPalette(pal);
#if 0
} else {
//QString szStyle = QString("QComboBox { background: %1; color: %2; font-family: %3; font-size: %4pt; font-weight: %5; font-style: %6;}")
QString szStyle = QString("QComboBox { background: %1; color: %2; font-family: %3; font-size: %4pt; font-weight: %5; font-style: %6;}")
.arg(bIsTrasparent ? "transparent" : KVI_OPTION_COLOR(KviOption_colorLabelBackground).name())
- .arg(bIsTrasparent ? KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name())
+ .arg(bIsTrasparent ? getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name())
.arg(KVI_OPTION_FONT(KviOption_fontLabel).family())
.arg(KVI_OPTION_FONT(KviOption_fontLabel).pointSize())
.arg(KVI_OPTION_FONT(KviOption_fontLabel).weight() == QFont::Bold ? "bold" : "normal")
diff --git a/src/kvirc/ui/KviThemedLabel.cpp b/src/kvirc/ui/KviThemedLabel.cpp
index ffded12f8..b8359536d 100644
--- a/src/kvirc/ui/KviThemedLabel.cpp
+++ b/src/kvirc/ui/KviThemedLabel.cpp
@@ -63,7 +63,7 @@ void KviThemedLabel::applyOptions()
QString szStyle = QString("QLabel { background: %1; background-clip: content; color: %2; font-family: %3; font-size: %4pt; font-weight: %5; font-style: %6;}")
.arg(bIsTrasparent ? "transparent" : KVI_OPTION_COLOR(KviOption_colorLabelBackground).name())
- .arg(bIsTrasparent ? KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name())
+ .arg(bIsTrasparent ? getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name())
.arg(KVI_OPTION_FONT(KviOption_fontLabel).family())
.arg(KVI_OPTION_FONT(KviOption_fontLabel).pointSize())
.arg(KVI_OPTION_FONT(KviOption_fontLabel).weight() == QFont::Bold ? "bold" : "normal")
diff --git a/src/kvirc/ui/KviThemedLineEdit.cpp b/src/kvirc/ui/KviThemedLineEdit.cpp
index 21bcad156..f41d4bf8b 100644
--- a/src/kvirc/ui/KviThemedLineEdit.cpp
+++ b/src/kvirc/ui/KviThemedLineEdit.cpp
@@ -73,7 +73,7 @@ void KviThemedLineEdit::applyOptions()
#endif
QString szStyle = QString("QLineEdit { background: %1; color: %2; font-family: %3; font-size: %4pt; font-weight: %5; font-style: %6; margin: 1px; }")
.arg(bIsTrasparent ? "transparent" : KVI_OPTION_COLOR(KviOption_colorLabelBackground).name())
- .arg(bIsTrasparent ? KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name())
+ .arg(bIsTrasparent ? getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name())
.arg(KVI_OPTION_FONT(KviOption_fontLabel).family())
.arg(KVI_OPTION_FONT(KviOption_fontLabel).pointSize())
.arg(KVI_OPTION_FONT(KviOption_fontLabel).weight() == QFont::Bold ? "bold" : "normal")
diff --git a/src/kvirc/ui/KviThemedTreeWidget.cpp b/src/kvirc/ui/KviThemedTreeWidget.cpp
index 29e850964..5677964d6 100644
--- a/src/kvirc/ui/KviThemedTreeWidget.cpp
+++ b/src/kvirc/ui/KviThemedTreeWidget.cpp
@@ -57,7 +57,7 @@ void KviThemedTreeWidget::applyOptions()
QString szStyle = QString("QTreeWidget { background: %1; background-clip: content; color: %2; font-family: %3; font-size: %4pt; font-weight: %5; font-style: %6;}")
.arg(bIsTrasparent ? "transparent" : KVI_OPTION_COLOR(KviOption_colorLabelBackground).name())
- .arg(bIsTrasparent ? KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name())
+ .arg(bIsTrasparent ? getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name())
.arg(KVI_OPTION_FONT(KviOption_fontLabel).family())
.arg(KVI_OPTION_FONT(KviOption_fontLabel).pointSize())
.arg(KVI_OPTION_FONT(KviOption_fontLabel).weight() == QFont::Bold ? "bold" : "normal")
diff --git a/src/kvirc/ui/KviTopicWidget.cpp b/src/kvirc/ui/KviTopicWidget.cpp
index e753c0106..de5b56373 100644
--- a/src/kvirc/ui/KviTopicWidget.cpp
+++ b/src/kvirc/ui/KviTopicWidget.cpp
@@ -229,15 +229,15 @@ void KviTopicWidget::paintColoredText(QPainter * p, QString text, const QPalette
}
else
{
- if(curFore > 16)
+ if(curFore > KVI_EXTCOLOR_MAX)
p->setPen(cg.background().color());
else
- p->setPen(KVI_OPTION_MIRCCOLOR(curFore));
+ p->setPen(getMircColor(curFore));
}
if(curBack != KVI_LABEL_DEF_BACK)
{
- if(curBack > 16)
+ if(curBack > KVI_EXTCOLOR_MAX)
{
p->fillRect(curX, rect.y() + 2, wdth, rect.height() - 4,
cg.text());
@@ -245,7 +245,7 @@ void KviTopicWidget::paintColoredText(QPainter * p, QString text, const QPalette
else
{
p->fillRect(curX, rect.y() + 2, wdth, rect.height() - 4,
- KVI_OPTION_MIRCCOLOR(curBack));
+ getMircColor(curBack));
}
}
diff --git a/src/modules/options/OptionsWidget_message.cpp b/src/modules/options/OptionsWidget_message.cpp
index 47ff68796..2755bedfe 100644
--- a/src/modules/options/OptionsWidget_message.cpp
+++ b/src/modules/options/OptionsWidget_message.cpp
@@ -279,15 +279,15 @@ void MessageListWidgetItemDelegate::paint(QPainter * p, const QStyleOptionViewIt
p->drawPixmap(pt, *(g_pIconManager->getSmallIcon(it->msgType()->pixId())));
pt.setX(pt.x() + 18);
// draw the background
- if(it->msgType()->back() < 16)
+ if(it->msgType()->back() <= KVI_EXTCOLOR_MAX)
{
- QColor bColor = KVI_OPTION_MIRCCOLOR(it->msgType()->back());
+ QColor bColor = getMircColor(it->msgType()->back());
p->fillRect(pt.x(), pt.y(), opt.rect.width() - pt.x(), opt.rect.height(), bColor);
}
unsigned char ucFore = it->msgType()->fore();
- if(ucFore > 15)
+ if(ucFore > KVI_EXTCOLOR_MAX)
ucFore = 0;
- p->setPen(QPen(KVI_OPTION_MIRCCOLOR(ucFore)));
+ p->setPen(QPen(getMircColor(ucFore)));
pt.setX(pt.x() + 2);
p->drawText(pt.x(), pt.y(), opt.rect.width() - pt.x(), opt.rect.height(), Qt::AlignLeft | Qt::AlignVCenter, szText);
@@ -312,14 +312,14 @@ MessageColorListWidgetItem::MessageColorListWidgetItem(KviTalListWidget * b, int
{
m_iClrIdx = idx;
- if((idx < 0) || (idx > 15))
+ if((idx < 0) || (idx > KVI_EXTCOLOR_MAX))
{
setText(__tr2qs_ctx("Transparent", "options"));
setBackground(listWidget()->isEnabled() ? Qt::transparent : Qt::gray);
}
else
{
- setBackground(QColor(KVI_OPTION_MIRCCOLOR(m_iClrIdx)));
+ setBackground(QColor(getMircColor(m_iClrIdx)));
setText(" ");
}
}
@@ -336,9 +336,9 @@ void MessageColorListWidgetItemDelegate::paint(QPainter * p, const QStyleOptionV
const KviTalListWidget * lb = (const KviTalListWidget *)parent();
MessageColorListWidgetItem * it = static_cast<MessageColorListWidgetItem *>(index.internalPointer());
- if((it->clrIdx() >= 0) && (it->clrIdx() <= 15))
+ if((it->clrIdx() >= 0) && (it->clrIdx() <= KVI_EXTCOLOR_MAX))
{
- clr = KVI_OPTION_MIRCCOLOR(it->clrIdx());
+ clr = getMircColor(it->clrIdx());
}
else
{
diff --git a/src/modules/url/libkviurl.cpp b/src/modules/url/libkviurl.cpp
index 81144088b..a10d5171c 100644
--- a/src/modules/url/libkviurl.cpp
+++ b/src/modules/url/libkviurl.cpp
@@ -288,10 +288,10 @@ void UrlDialog::addUrl(QString url, QString window, QString count, QString times
UrlItem->setText(2, count);
UrlItem->setText(3, timestamp);
- UrlItem->setForeground(0, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_URL).fore()));
- UrlItem->setForeground(1, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()));
- UrlItem->setForeground(2, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()));
- UrlItem->setForeground(3, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()));
+ UrlItem->setForeground(0, getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_URL).fore()));
+ UrlItem->setForeground(1, getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()));
+ UrlItem->setForeground(2, getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()));
+ UrlItem->setForeground(3, getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()));
m_pUrlList->resizeColumnToContents(0);
m_pUrlList->resizeColumnToContents(3);