Diffstat (limited to 'noncore/net/opieirc/ircmisc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircmisc.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
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,8 +1,9 @@ | |||
1 | #include <opie/colordialog.h> | 1 | #include <opie/colordialog.h> |
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <stdio.h> | ||
3 | #include "ircmisc.h" | 4 | #include "ircmisc.h" |
4 | 5 | ||
5 | IRCColorLabel::IRCColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QLabel(parent, name, f) { | 6 | IRCColorLabel::IRCColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QLabel(parent, name, f) { |
6 | m_color = color; | 7 | m_color = color; |
7 | setAlignment(AlignVCenter | AlignCenter); | 8 | setAlignment(AlignVCenter | AlignCenter); |
8 | setFrameStyle(QFrame::StyledPanel); | 9 | setFrameStyle(QFrame::StyledPanel); |
@@ -26,6 +27,40 @@ IRCFramedColorLabel::IRCFramedColorLabel(QColor color, QWidget *parent, const ch | |||
26 | } | 27 | } |
27 | 28 | ||
28 | QColor IRCFramedColorLabel::color() { | 29 | QColor IRCFramedColorLabel::color() { |
29 | return m_label->color(); | 30 | return m_label->color(); |
30 | } | 31 | } |
31 | 32 | ||
33 | IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { | ||
34 | } | ||
35 | |||
36 | int IRCTabBar::insertTab(QTab *tab, int index = -1) { | ||
37 | if (m_colors.size() == (unsigned int)count()) | ||
38 | m_colors.resize(m_colors.size() * 2 + 1); | ||
39 | if (index == -1) | ||
40 | m_colors.insert(count(), &black); | ||
41 | else | ||
42 | m_colors.insert(index, &black); | ||
43 | return QTabBar::insertTab(tab, index); | ||
44 | } | ||
45 | |||
46 | void IRCTabBar::setTabColor(int index, const QColor *color) { | ||
47 | m_colors.insert(index, color); | ||
48 | update(); | ||
49 | } | ||
50 | |||
51 | void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const { | ||
52 | QRect r = br; | ||
53 | QTabBar::paintLabel(p, br, t, focus); | ||
54 | if (t->id == currentTab()) | ||
55 | r.setBottom(r.bottom() - style().defaultFrameWidth()); | ||
56 | p->setPen(*m_colors.at(t->id)); | ||
57 | p->drawText(r, AlignCenter | ShowPrefix, t->label); | ||
58 | } | ||
59 | |||
60 | IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) { | ||
61 | setTabBar(new IRCTabBar(this, "tab control")); | ||
62 | } | ||
63 | |||
64 | void IRCTabWidget::setTabColor(int index, const QColor *color) { | ||
65 | ((IRCTabBar *)tabBar())->setTabColor(index, color); | ||
66 | } | ||