summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp1
-rw-r--r--noncore/net/opieirc/ircmisc.cpp35
-rw-r--r--noncore/net/opieirc/ircmisc.h50
-rw-r--r--noncore/net/opieirc/ircquerytab.cpp1
-rw-r--r--noncore/net/opieirc/ircservertab.cpp1
-rw-r--r--noncore/net/opieirc/irctab.cpp8
-rw-r--r--noncore/net/opieirc/irctab.h5
-rw-r--r--noncore/net/opieirc/mainwindow.cpp14
-rw-r--r--noncore/net/opieirc/mainwindow.h6
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
@@ -47,6 +47,7 @@ void IRCChannelTab::appendText(QString text) {
47 /* not using append because it creates layout problems */ 47 /* not using append because it creates layout problems */
48 m_textview->setText(m_textview->text() + text); 48 m_textview->setText(m_textview->text() + text);
49 m_textview->ensureVisible(0, m_textview->contentsHeight()); 49 m_textview->ensureVisible(0, m_textview->contentsHeight());
50 emit changed(this);
50} 51}
51 52
52IRCChannelTab::~IRCChannelTab() { 53IRCChannelTab::~IRCChannelTab() {
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 @@
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
5IRCColorLabel::IRCColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QLabel(parent, name, f) { 6IRCColorLabel::IRCColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QLabel(parent, name, f) {
@@ -29,3 +30,37 @@ QColor IRCFramedColorLabel::color() {
29 return m_label->color(); 30 return m_label->color();
30} 31}
31 32
33IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) {
34}
35
36int 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
46void IRCTabBar::setTabColor(int index, const QColor *color) {
47 m_colors.insert(index, color);
48 update();
49}
50
51void 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
60IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) {
61 setTabBar(new IRCTabBar(this, "tab control"));
62}
63
64void 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
@@ -21,24 +21,52 @@
21#ifndef __IRCMISC_H 21#ifndef __IRCMISC_H
22#define __IRCMISC_H 22#define __IRCMISC_H
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
27class IRCColorLabel : public QLabel { 32class IRCColorLabel : public QLabel {
28 public: 33 Q_OBJECT
29 IRCColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); 34public:
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; 38protected:
39 QColor m_color;
34}; 40};
35 41
36class IRCFramedColorLabel : public QWidget { 42class IRCFramedColorLabel : public QWidget {
37 public: 43 Q_OBJECT
38 IRCFramedColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); 44public:
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; 47protected:
48 IRCColorLabel *m_label;
49};
50
51/* Custom colored QTabWidget */
52
53class IRCTabWidget : public QTabWidget {
54 Q_OBJECT
55public:
56 IRCTabWidget(QWidget *parent = 0, const char *name = 0);
57 void setTabColor(int index, const QColor *color);
58};
59
60class IRCTabBar : public QTabBar {
61 Q_OBJECT
62public:
63 IRCTabBar(QWidget *parent = 0, const char *name = 0);
64 void setTabColor(int index, const QColor *color);
65protected:
66 void paintLabel(QPainter*, const QRect&, QTab*, bool) const;
67 int insertTab(QTab *, int index = -1);
68protected:
69 QVector<QColor> m_colors;
42}; 70};
43 71
44#endif /* __IRCMISC_H */ 72#endif /* __IRCMISC_H */
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
@@ -25,6 +25,7 @@ void IRCQueryTab::appendText(QString text) {
25 /* not using append because it creates layout problems */ 25 /* not using append because it creates layout problems */
26 m_textview->setText(m_textview->text() + text); 26 m_textview->setText(m_textview->text() + text);
27 m_textview->ensureVisible(0, m_textview->contentsHeight()); 27 m_textview->ensureVisible(0, m_textview->contentsHeight());
28 emit changed(this);
28} 29}
29 30
30IRCQueryTab::~IRCQueryTab() { 31IRCQueryTab::~IRCQueryTab() {
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
@@ -25,6 +25,7 @@ void IRCServerTab::appendText(QString text) {
25 /* not using append because it creates layout problems */ 25 /* not using append because it creates layout problems */
26 m_textview->setText(m_textview->text() + text); 26 m_textview->setText(m_textview->text() + text);
27 m_textview->ensureVisible(0, m_textview->contentsHeight()); 27 m_textview->ensureVisible(0, m_textview->contentsHeight());
28 emit changed(this);
28} 29}
29 30
30IRCServerTab::~IRCServerTab() { 31IRCServerTab::~IRCServerTab() {
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
@@ -26,3 +26,11 @@ IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, na
26 descLayout->setStretchFactor(m_description, 1); 26 descLayout->setStretchFactor(m_description, 1);
27} 27}
28 28
29
30void IRCTab::setID(int id) {
31 m_id = id;
32}
33
34int 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
@@ -35,15 +35,20 @@ class IRCTab : public QWidget {
35 Q_OBJECT 35 Q_OBJECT
36public: 36public:
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;
39 virtual IRCSession *session() = 0; 41 virtual IRCSession *session() = 0;
40 virtual void appendText(QString text) = 0; 42 virtual void appendText(QString text) = 0;
43signals:
44 void changed(IRCTab *);
41public slots: 45public slots:
42 virtual void remove() = 0; 46 virtual void remove() = 0;
43 virtual void settingsChanged() = 0; 47 virtual void settingsChanged() = 0;
44protected: 48protected:
45 QLabel *m_description; 49 QLabel *m_description;
46 QVBoxLayout *m_layout; 50 QVBoxLayout *m_layout;
51 int m_id;
47public: 52public:
48 /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */ 53 /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */
49 static QString m_errorColor; 54 static QString m_errorColor;
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
@@ -10,7 +10,8 @@
10 10
11MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) { 11MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) {
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);
15 setToolBarsMovable(FALSE); 16 setToolBarsMovable(FALSE);
16 QPEMenuBar *menuBar = new QPEMenuBar(this); 17 QPEMenuBar *menuBar = new QPEMenuBar(this);
@@ -37,12 +38,23 @@ void MainWindow::loadSettings() {
37 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); 38 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300");
38} 39}
39 40
41void MainWindow::selected(QWidget *) {
42 m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), &black);
43}
44
40void MainWindow::addTab(IRCTab *tab) { 45void 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);
44} 51}
45 52
53void MainWindow::changeEvent(IRCTab *tab) {
54 if (tab->id() != m_tabWidget->currentPageIndex())
55 m_tabWidget->setTabColor(tab->id(), &blue);
56}
57
46void MainWindow::killTab(IRCTab *tab) { 58void MainWindow::killTab(IRCTab *tab) {
47 m_tabWidget->removePage(tab); 59 m_tabWidget->removePage(tab);
48 m_tabs.remove(tab); 60 m_tabs.remove(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
@@ -24,8 +24,8 @@
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include <qaction.h> 25#include <qaction.h>
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"
30 30
31class MainWindow : public QMainWindow { 31class MainWindow : public QMainWindow {
@@ -38,10 +38,12 @@ public:
38protected slots: 38protected slots:
39 void newConnection(); 39 void newConnection();
40 void settings(); 40 void settings();
41 void selected(QWidget *);
42 void changeEvent(IRCTab *);
41protected: 43protected:
42 void loadSettings(); 44 void loadSettings();
43protected: 45protected:
44 QTabWidget *m_tabWidget; 46 IRCTabWidget *m_tabWidget;
45 QList<IRCTab> m_tabs; 47 QList<IRCTab> m_tabs;
46}; 48};
47 49