From a999acbcd1b8bc1715f2ad2dda6acedf423b89ea Mon Sep 17 00:00:00 2001 From: wazlaf Date: Mon, 30 Sep 2002 08:07:05 +0000 Subject: tabs now change their color when actions occur --- (limited to 'noncore/net/opieirc/ircmisc.cpp') diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp index f41a89a..dd7292c 100644 --- a/noncore/net/opieirc/ircmisc.cpp +++ b/noncore/net/opieirc/ircmisc.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "ircmisc.h" IRCColorLabel::IRCColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QLabel(parent, name, f) { @@ -29,3 +30,37 @@ QColor IRCFramedColorLabel::color() { return m_label->color(); } +IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { +} + +int IRCTabBar::insertTab(QTab *tab, int index = -1) { + if (m_colors.size() == (unsigned int)count()) + m_colors.resize(m_colors.size() * 2 + 1); + if (index == -1) + m_colors.insert(count(), &black); + else + m_colors.insert(index, &black); + return QTabBar::insertTab(tab, index); +} + +void IRCTabBar::setTabColor(int index, const QColor *color) { + m_colors.insert(index, color); + update(); +} + +void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const { + QRect r = br; + QTabBar::paintLabel(p, br, t, focus); + if (t->id == currentTab()) + r.setBottom(r.bottom() - style().defaultFrameWidth()); + p->setPen(*m_colors.at(t->id)); + p->drawText(r, AlignCenter | ShowPrefix, t->label); +} + +IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) { + setTabBar(new IRCTabBar(this, "tab control")); +} + +void IRCTabWidget::setTabColor(int index, const QColor *color) { + ((IRCTabBar *)tabBar())->setTabColor(index, color); +} -- cgit v0.9.0.2