summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (show 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.h28
-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, 96 insertions, 3 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) {
/* not using append because it creates layout problems */
m_textview->setText(m_textview->text() + text);
m_textview->ensureVisible(0, m_textview->contentsHeight());
+ emit changed(this);
}
IRCChannelTab::~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 @@
#include <opie/colordialog.h>
#include <qlayout.h>
+#include <stdio.h>
#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);
+}
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,10 +21,16 @@
#ifndef __IRCMISC_H
#define __IRCMISC_H
+#include <qtabwidget.h>
+#include <qtabbar.h>
#include <qlabel.h>
#include <qcolor.h>
+#include <qvector.h>
+
+/* IRCFramedColorLabel is used to display a color */
class IRCColorLabel : public QLabel {
+ Q_OBJECT
public:
IRCColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
QColor color();
@@ -34,6 +40,7 @@ class IRCColorLabel : public QLabel {
};
class IRCFramedColorLabel : public QWidget {
+ Q_OBJECT
public:
IRCFramedColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
QColor color();
@@ -41,4 +48,25 @@ class IRCFramedColorLabel : public QWidget {
IRCColorLabel *m_label;
};
+/* Custom colored QTabWidget */
+
+class IRCTabWidget : public QTabWidget {
+ Q_OBJECT
+public:
+ IRCTabWidget(QWidget *parent = 0, const char *name = 0);
+ void setTabColor(int index, const QColor *color);
+};
+
+class IRCTabBar : public QTabBar {
+ Q_OBJECT
+public:
+ IRCTabBar(QWidget *parent = 0, const char *name = 0);
+ void setTabColor(int index, const QColor *color);
+protected:
+ void paintLabel(QPainter*, const QRect&, QTab*, bool) const;
+ int insertTab(QTab *, int index = -1);
+protected:
+ QVector<QColor> m_colors;
+};
+
#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) {
/* not using append because it creates layout problems */
m_textview->setText(m_textview->text() + text);
m_textview->ensureVisible(0, m_textview->contentsHeight());
+ emit changed(this);
}
IRCQueryTab::~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) {
/* not using append because it creates layout problems */
m_textview->setText(m_textview->text() + text);
m_textview->ensureVisible(0, m_textview->contentsHeight());
+ emit changed(this);
}
IRCServerTab::~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
descLayout->setStretchFactor(m_description, 1);
}
+
+void IRCTab::setID(int id) {
+ m_id = id;
+}
+
+int IRCTab::id() {
+ return m_id;
+}
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 {
Q_OBJECT
public:
IRCTab(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
+ void setID(int id);
+ int id();
virtual QString title() = 0;
virtual IRCSession *session() = 0;
virtual void appendText(QString text) = 0;
+signals:
+ void changed(IRCTab *);
public slots:
virtual void remove() = 0;
virtual void settingsChanged() = 0;
protected:
QLabel *m_description;
QVBoxLayout *m_layout;
+ int m_id;
public:
/* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */
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 @@
MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) {
setCaption(tr("IRC Client"));
- m_tabWidget = new QTabWidget(this);
+ m_tabWidget = new IRCTabWidget(this);
+ connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(selected(QWidget *)));
setCentralWidget(m_tabWidget);
setToolBarsMovable(FALSE);
QPEMenuBar *menuBar = new QPEMenuBar(this);
@@ -37,12 +38,23 @@ void MainWindow::loadSettings() {
IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300");
}
+void MainWindow::selected(QWidget *) {
+ m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), &black);
+}
+
void MainWindow::addTab(IRCTab *tab) {
+ connect(tab, SIGNAL(changed(IRCTab *)), this, SLOT(changeEvent(IRCTab *)));
m_tabWidget->addTab(tab, tab->title());
m_tabWidget->showPage(tab);
+ tab->setID(m_tabWidget->currentPageIndex());
m_tabs.append(tab);
}
+void MainWindow::changeEvent(IRCTab *tab) {
+ if (tab->id() != m_tabWidget->currentPageIndex())
+ m_tabWidget->setTabColor(tab->id(), &blue);
+}
+
void MainWindow::killTab(IRCTab *tab) {
m_tabWidget->removePage(tab);
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 @@
#include <qmainwindow.h>
#include <qaction.h>
#include <qlist.h>
-#include <qtabwidget.h>
#include "mainwindow.h"
+#include "ircmisc.h"
#include "irctab.h"
class MainWindow : public QMainWindow {
@@ -38,10 +38,12 @@ public:
protected slots:
void newConnection();
void settings();
+ void selected(QWidget *);
+ void changeEvent(IRCTab *);
protected:
void loadSettings();
protected:
- QTabWidget *m_tabWidget;
+ IRCTabWidget *m_tabWidget;
QList<IRCTab> m_tabs;
};