-rw-r--r-- | noncore/net/opieirc/ircchanneltab.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmisc.cpp | 35 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmisc.h | 50 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/irctab.cpp | 8 | ||||
-rw-r--r-- | noncore/net/opieirc/irctab.h | 5 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 14 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.h | 6 |
9 files changed, 107 insertions, 14 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp index c1695db..ddd6cf1 100644 --- a/noncore/net/opieirc/ircchanneltab.cpp +++ b/noncore/net/opieirc/ircchanneltab.cpp | |||
@@ -49,2 +49,3 @@ void IRCChannelTab::appendText(QString text) { | |||
49 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 49 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
50 | emit changed(this); | ||
50 | } | 51 | } |
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 | |||
@@ -2,2 +2,3 @@ | |||
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <stdio.h> | ||
3 | #include "ircmisc.h" | 4 | #include "ircmisc.h" |
@@ -31 +32,35 @@ QColor IRCFramedColorLabel::color() { | |||
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 | } | ||
diff --git a/noncore/net/opieirc/ircmisc.h b/noncore/net/opieirc/ircmisc.h index 1ea04c8..4df6ce0 100644 --- a/noncore/net/opieirc/ircmisc.h +++ b/noncore/net/opieirc/ircmisc.h | |||
@@ -23,12 +23,18 @@ | |||
23 | 23 | ||
24 | #include <qtabwidget.h> | ||
25 | #include <qtabbar.h> | ||
24 | #include <qlabel.h> | 26 | #include <qlabel.h> |
25 | #include <qcolor.h> | 27 | #include <qcolor.h> |
28 | #include <qvector.h> | ||
29 | |||
30 | /* IRCFramedColorLabel is used to display a color */ | ||
26 | 31 | ||
27 | class IRCColorLabel : public QLabel { | 32 | class IRCColorLabel : public QLabel { |
28 | public: | 33 | Q_OBJECT |
29 | IRCColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 34 | public: |
30 | QColor color(); | 35 | IRCColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
31 | void mousePressEvent(QMouseEvent *event); | 36 | QColor color(); |
32 | protected: | 37 | void mousePressEvent(QMouseEvent *event); |
33 | QColor m_color; | 38 | protected: |
39 | QColor m_color; | ||
34 | }; | 40 | }; |
@@ -36,7 +42,29 @@ class IRCColorLabel : public QLabel { | |||
36 | class IRCFramedColorLabel : public QWidget { | 42 | class IRCFramedColorLabel : public QWidget { |
37 | public: | 43 | Q_OBJECT |
38 | IRCFramedColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 44 | public: |
39 | QColor color(); | 45 | IRCFramedColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
40 | protected: | 46 | QColor color(); |
41 | IRCColorLabel *m_label; | 47 | protected: |
48 | IRCColorLabel *m_label; | ||
49 | }; | ||
50 | |||
51 | /* Custom colored QTabWidget */ | ||
52 | |||
53 | class IRCTabWidget : public QTabWidget { | ||
54 | Q_OBJECT | ||
55 | public: | ||
56 | IRCTabWidget(QWidget *parent = 0, const char *name = 0); | ||
57 | void setTabColor(int index, const QColor *color); | ||
58 | }; | ||
59 | |||
60 | class IRCTabBar : public QTabBar { | ||
61 | Q_OBJECT | ||
62 | public: | ||
63 | IRCTabBar(QWidget *parent = 0, const char *name = 0); | ||
64 | void setTabColor(int index, const QColor *color); | ||
65 | protected: | ||
66 | void paintLabel(QPainter*, const QRect&, QTab*, bool) const; | ||
67 | int insertTab(QTab *, int index = -1); | ||
68 | protected: | ||
69 | QVector<QColor> m_colors; | ||
42 | }; | 70 | }; |
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp index c6b8211..b946174 100644 --- a/noncore/net/opieirc/ircquerytab.cpp +++ b/noncore/net/opieirc/ircquerytab.cpp | |||
@@ -27,2 +27,3 @@ void IRCQueryTab::appendText(QString text) { | |||
27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
28 | emit changed(this); | ||
28 | } | 29 | } |
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index d16c05f..4ed5364 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -27,2 +27,3 @@ void IRCServerTab::appendText(QString text) { | |||
27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
28 | emit changed(this); | ||
28 | } | 29 | } |
diff --git a/noncore/net/opieirc/irctab.cpp b/noncore/net/opieirc/irctab.cpp index 6b578d1..a4dd7e2 100644 --- a/noncore/net/opieirc/irctab.cpp +++ b/noncore/net/opieirc/irctab.cpp | |||
@@ -28 +28,9 @@ IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, na | |||
28 | 28 | ||
29 | |||
30 | void IRCTab::setID(int id) { | ||
31 | m_id = id; | ||
32 | } | ||
33 | |||
34 | int IRCTab::id() { | ||
35 | return m_id; | ||
36 | } | ||
diff --git a/noncore/net/opieirc/irctab.h b/noncore/net/opieirc/irctab.h index 248ea13..e3a1857 100644 --- a/noncore/net/opieirc/irctab.h +++ b/noncore/net/opieirc/irctab.h | |||
@@ -37,2 +37,4 @@ public: | |||
37 | IRCTab(QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 37 | IRCTab(QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
38 | void setID(int id); | ||
39 | int id(); | ||
38 | virtual QString title() = 0; | 40 | virtual QString title() = 0; |
@@ -40,2 +42,4 @@ public: | |||
40 | virtual void appendText(QString text) = 0; | 42 | virtual void appendText(QString text) = 0; |
43 | signals: | ||
44 | void changed(IRCTab *); | ||
41 | public slots: | 45 | public slots: |
@@ -46,2 +50,3 @@ protected: | |||
46 | QVBoxLayout *m_layout; | 50 | QVBoxLayout *m_layout; |
51 | int m_id; | ||
47 | public: | 52 | public: |
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp index d78e5ab..fe59c3b 100644 --- a/noncore/net/opieirc/mainwindow.cpp +++ b/noncore/net/opieirc/mainwindow.cpp | |||
@@ -12,3 +12,4 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindo | |||
12 | setCaption(tr("IRC Client")); | 12 | setCaption(tr("IRC Client")); |
13 | m_tabWidget = new QTabWidget(this); | 13 | m_tabWidget = new IRCTabWidget(this); |
14 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(selected(QWidget *))); | ||
14 | setCentralWidget(m_tabWidget); | 15 | setCentralWidget(m_tabWidget); |
@@ -39,5 +40,11 @@ void MainWindow::loadSettings() { | |||
39 | 40 | ||
41 | void MainWindow::selected(QWidget *) { | ||
42 | m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), &black); | ||
43 | } | ||
44 | |||
40 | void MainWindow::addTab(IRCTab *tab) { | 45 | void MainWindow::addTab(IRCTab *tab) { |
46 | connect(tab, SIGNAL(changed(IRCTab *)), this, SLOT(changeEvent(IRCTab *))); | ||
41 | m_tabWidget->addTab(tab, tab->title()); | 47 | m_tabWidget->addTab(tab, tab->title()); |
42 | m_tabWidget->showPage(tab); | 48 | m_tabWidget->showPage(tab); |
49 | tab->setID(m_tabWidget->currentPageIndex()); | ||
43 | m_tabs.append(tab); | 50 | m_tabs.append(tab); |
@@ -45,2 +52,7 @@ void MainWindow::addTab(IRCTab *tab) { | |||
45 | 52 | ||
53 | void MainWindow::changeEvent(IRCTab *tab) { | ||
54 | if (tab->id() != m_tabWidget->currentPageIndex()) | ||
55 | m_tabWidget->setTabColor(tab->id(), &blue); | ||
56 | } | ||
57 | |||
46 | void MainWindow::killTab(IRCTab *tab) { | 58 | void MainWindow::killTab(IRCTab *tab) { |
diff --git a/noncore/net/opieirc/mainwindow.h b/noncore/net/opieirc/mainwindow.h index d057178..9946f10 100644 --- a/noncore/net/opieirc/mainwindow.h +++ b/noncore/net/opieirc/mainwindow.h | |||
@@ -26,4 +26,4 @@ | |||
26 | #include <qlist.h> | 26 | #include <qlist.h> |
27 | #include <qtabwidget.h> | ||
28 | #include "mainwindow.h" | 27 | #include "mainwindow.h" |
28 | #include "ircmisc.h" | ||
29 | #include "irctab.h" | 29 | #include "irctab.h" |
@@ -40,2 +40,4 @@ protected slots: | |||
40 | void settings(); | 40 | void settings(); |
41 | void selected(QWidget *); | ||
42 | void changeEvent(IRCTab *); | ||
41 | protected: | 43 | protected: |
@@ -43,3 +45,3 @@ protected: | |||
43 | protected: | 45 | protected: |
44 | QTabWidget *m_tabWidget; | 46 | IRCTabWidget *m_tabWidget; |
45 | QList<IRCTab> m_tabs; | 47 | QList<IRCTab> m_tabs; |