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
@@ -26,48 +26,49 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
26 m_popup = new QPopupMenu(m_list); 26 m_popup = new QPopupMenu(m_list);
27 /* Required so that embedded-style "right" clicks work */ 27 /* Required so that embedded-style "right" clicks work */
28 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); 28 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold);
29 connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &))); 29 connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &)));
30 /* Construct the popup menu */ 30 /* Construct the popup menu */
31 QPopupMenu *ctcpMenu = new QPopupMenu(m_list); 31 QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
32 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); 32 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu);
33 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); 33 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery()));
34 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); 34 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing()));
35 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); 35 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
36 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); 36 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
37 37
38 m_layout->add(hbox); 38 m_layout->add(hbox);
39 hbox->show(); 39 hbox->show();
40 m_layout->add(m_field); 40 m_layout->add(m_field);
41 m_field->setFocus(); 41 m_field->setFocus();
42 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 42 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
43 settingsChanged(); 43 settingsChanged();
44} 44}
45 45
46void IRCChannelTab::appendText(QString text) { 46void 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() {
53 m_parentTab->removeChannelTab(this); 54 m_parentTab->removeChannelTab(this);
54} 55}
55 56
56void IRCChannelTab::processCommand() { 57void IRCChannelTab::processCommand() {
57 QString text = m_field->text(); 58 QString text = m_field->text();
58 if (text.length()>0) { 59 if (text.length()>0) {
59 if (session()->isSessionActive()) { 60 if (session()->isSessionActive()) {
60 if (text.startsWith("/") && !text.startsWith("//")) { 61 if (text.startsWith("/") && !text.startsWith("//")) {
61 /* Command mode */ 62 /* Command mode */
62 m_parentTab->executeCommand(this, text);; 63 m_parentTab->executeCommand(this, text);;
63 } else { 64 } else {
64 if (text.startsWith("//")) 65 if (text.startsWith("//"))
65 text = text.right(text.length()-1); 66 text = text.right(text.length()-1);
66 session()->sendMessage(m_channel, m_field->text()); 67 session()->sendMessage(m_channel, m_field->text());
67 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>"); 68 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>");
68 } 69 }
69 } else { 70 } else {
70 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); 71 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
71 } 72 }
72 } 73 }
73 m_field->clear(); 74 m_field->clear();
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,31 +1,66 @@
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) {
6 m_color = color; 7 m_color = color;
7 setAlignment(AlignVCenter | AlignCenter); 8 setAlignment(AlignVCenter | AlignCenter);
8 setFrameStyle(QFrame::StyledPanel); 9 setFrameStyle(QFrame::StyledPanel);
9 setFrameShadow(QFrame::Sunken); 10 setFrameShadow(QFrame::Sunken);
10 setBackgroundColor(m_color); 11 setBackgroundColor(m_color);
11} 12}
12 13
13void IRCColorLabel::mousePressEvent(QMouseEvent *) { 14void IRCColorLabel::mousePressEvent(QMouseEvent *) {
14 m_color = OColorDialog::getColor(m_color); 15 m_color = OColorDialog::getColor(m_color);
15 setBackgroundColor(m_color); 16 setBackgroundColor(m_color);
16} 17}
17 18
18QColor IRCColorLabel::color() { 19QColor IRCColorLabel::color() {
19 return m_color; 20 return m_color;
20} 21}
21 22
22IRCFramedColorLabel::IRCFramedColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { 23IRCFramedColorLabel::IRCFramedColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) {
23 QVBoxLayout *layout = new QVBoxLayout(this, 10, 0); 24 QVBoxLayout *layout = new QVBoxLayout(this, 10, 0);
24 m_label = new IRCColorLabel(color, this); 25 m_label = new IRCColorLabel(color, this);
25 layout->addWidget(m_label); 26 layout->addWidget(m_label);
26} 27}
27 28
28QColor IRCFramedColorLabel::color() { 29QColor 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
@@ -1,44 +1,72 @@
1/* 1/*
2 OpieIRC - An embedded IRC client 2 OpieIRC - An embedded IRC client
3 Copyright (C) 2002 Wenzel Jakob 3 Copyright (C) 2002 Wenzel Jakob
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18
19*/ 19*/
20 20
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
@@ -4,48 +4,49 @@
4 4
5IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 5IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
6 m_mainWindow = mainWindow; 6 m_mainWindow = mainWindow;
7 m_parentTab = parentTab; 7 m_parentTab = parentTab;
8 m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */ 8 m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */
9 m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>"); 9 m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>");
10 QHBox *hbox = new QHBox(this); 10 QHBox *hbox = new QHBox(this);
11 m_textview = new QTextView(hbox); 11 m_textview = new QTextView(hbox);
12 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 12 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
13 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 13 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
14 m_textview->setTextFormat(RichText); 14 m_textview->setTextFormat(RichText);
15 m_field = new QLineEdit(this); 15 m_field = new QLineEdit(this);
16 m_layout->add(hbox); 16 m_layout->add(hbox);
17 hbox->show(); 17 hbox->show();
18 m_layout->add(m_field); 18 m_layout->add(m_field);
19 m_field->setFocus(); 19 m_field->setFocus();
20 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 20 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
21 settingsChanged(); 21 settingsChanged();
22} 22}
23 23
24void IRCQueryTab::appendText(QString text) { 24void 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() {
31 m_parentTab->removeQueryTab(this); 32 m_parentTab->removeQueryTab(this);
32 delete m_person; 33 delete m_person;
33} 34}
34 35
35void IRCQueryTab::processCommand() { 36void IRCQueryTab::processCommand() {
36 QString text = m_field->text(); 37 QString text = m_field->text();
37 if (text.length()>0) { 38 if (text.length()>0) {
38 if (session()->isSessionActive()) { 39 if (session()->isSessionActive()) {
39 if (text.startsWith("/") && !text.startsWith("//")) { 40 if (text.startsWith("/") && !text.startsWith("//")) {
40 /* Command mode */ 41 /* Command mode */
41 m_parentTab->executeCommand(this, text);; 42 m_parentTab->executeCommand(this, text);;
42 } else { 43 } else {
43 if (text.startsWith("//")) 44 if (text.startsWith("//"))
44 text = text.right(text.length()-1); 45 text = text.right(text.length()-1);
45 session()->sendMessage(m_person, m_field->text()); 46 session()->sendMessage(m_person, m_field->text());
46 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>"); 47 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>");
47 } 48 }
48 } else { 49 } else {
49 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); 50 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
50 } 51 }
51 } 52 }
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
@@ -4,48 +4,49 @@
4 4
5IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 5IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
6 m_server = server; 6 m_server = server;
7 m_session = new IRCSession(&m_server); 7 m_session = new IRCSession(&m_server);
8 m_mainWindow = mainWindow; 8 m_mainWindow = mainWindow;
9 m_close = FALSE; 9 m_close = FALSE;
10 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); 10 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
11 m_textview = new QTextView(this); 11 m_textview = new QTextView(this);
12 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 12 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
13 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 13 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
14 m_textview->setTextFormat(RichText); 14 m_textview->setTextFormat(RichText);
15 m_layout->add(m_textview); 15 m_layout->add(m_textview);
16 m_field = new QLineEdit(this); 16 m_field = new QLineEdit(this);
17 m_layout->add(m_field); 17 m_layout->add(m_field);
18 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 18 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
19 m_field->setFocus(); 19 m_field->setFocus();
20 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); 20 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
21 settingsChanged(); 21 settingsChanged();
22} 22}
23 23
24void IRCServerTab::appendText(QString text) { 24void 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() {
31 delete m_session; 32 delete m_session;
32} 33}
33 34
34void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { 35void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
35 m_channelTabs.remove(tab); 36 m_channelTabs.remove(tab);
36} 37}
37 38
38void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { 39void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
39 m_queryTabs.remove(tab); 40 m_queryTabs.remove(tab);
40} 41}
41 42
42void IRCServerTab::addQueryTab(IRCQueryTab *tab) { 43void IRCServerTab::addQueryTab(IRCQueryTab *tab) {
43 m_queryTabs.append(tab); 44 m_queryTabs.append(tab);
44} 45}
45 46
46QString IRCServerTab::title() { 47QString IRCServerTab::title() {
47 return "Server"; 48 return "Server";
48} 49}
49 50
50IRCSession *IRCServerTab::session() { 51IRCSession *IRCServerTab::session() {
51 return m_session; 52 return m_session;
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
@@ -5,24 +5,32 @@
5 5
6QString IRCTab::m_errorColor; 6QString IRCTab::m_errorColor;
7QString IRCTab::m_serverColor; 7QString IRCTab::m_serverColor;
8QString IRCTab::m_textColor; 8QString IRCTab::m_textColor;
9QString IRCTab::m_backgroundColor; 9QString IRCTab::m_backgroundColor;
10QString IRCTab::m_selfColor; 10QString IRCTab::m_selfColor;
11QString IRCTab::m_otherColor; 11QString IRCTab::m_otherColor;
12QString IRCTab::m_notificationColor; 12QString IRCTab::m_notificationColor;
13 13
14 14
15IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { 15IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) {
16 m_layout = new QVBoxLayout(this); 16 m_layout = new QVBoxLayout(this);
17 QHBoxLayout *descLayout = new QHBoxLayout(m_layout); 17 QHBoxLayout *descLayout = new QHBoxLayout(m_layout);
18 descLayout->setMargin(5); 18 descLayout->setMargin(5);
19 m_description = new QLabel(tr("Missing description"), this); 19 m_description = new QLabel(tr("Missing description"), this);
20 descLayout->addWidget(m_description); 20 descLayout->addWidget(m_description);
21 descLayout->setStretchFactor(m_description, 5); 21 descLayout->setStretchFactor(m_description, 5);
22 QPushButton *close = new QPushButton(this); 22 QPushButton *close = new QPushButton(this);
23 close->setPixmap(Resource::loadPixmap("close")); 23 close->setPixmap(Resource::loadPixmap("close"));
24 connect(close, SIGNAL(clicked()), this, SLOT(remove())); 24 connect(close, SIGNAL(clicked()), this, SLOT(remove()));
25 descLayout->addWidget(close); 25 descLayout->addWidget(close);
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
@@ -14,45 +14,50 @@
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18
19*/ 19*/
20 20
21#ifndef __IRCTAB_H 21#ifndef __IRCTAB_H
22#define __IRCTAB_H 22#define __IRCTAB_H
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qtextview.h> 25#include <qtextview.h>
26#include <qlineedit.h> 26#include <qlineedit.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include "ircsession.h" 29#include "ircsession.h"
30 30
31/* This is the base class for any tabs which need to be integrated into 31/* This is the base class for any tabs which need to be integrated into
32 the main GUI tab widget */ 32 the main GUI tab widget */
33 33
34class IRCTab : public QWidget { 34class 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;
50 static QString m_serverColor; 55 static QString m_serverColor;
51 static QString m_textColor; 56 static QString m_textColor;
52 static QString m_backgroundColor; 57 static QString m_backgroundColor;
53 static QString m_selfColor; 58 static QString m_selfColor;
54 static QString m_otherColor; 59 static QString m_otherColor;
55 static QString m_notificationColor; 60 static QString m_notificationColor;
56}; 61};
57 62
58#endif /* __IRCTAB_H */ 63#endif /* __IRCTAB_H */
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
@@ -1,69 +1,81 @@
1#include <qpe/qpemenubar.h> 1#include <qpe/qpemenubar.h>
2#include <qpe/resource.h> 2#include <qpe/resource.h>
3#include <qpe/config.h> 3#include <qpe/config.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5 5
6#include "mainwindow.h" 6#include "mainwindow.h"
7#include "ircservertab.h" 7#include "ircservertab.h"
8#include "ircserverlist.h" 8#include "ircserverlist.h"
9#include "ircsettings.h" 9#include "ircsettings.h"
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);
17 QPopupMenu *irc = new QPopupMenu(this); 18 QPopupMenu *irc = new QPopupMenu(this);
18 menuBar->insertItem(tr("IRC"), irc); 19 menuBar->insertItem(tr("IRC"), irc);
19 QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); 20 QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0);
20 connect(a, SIGNAL(activated()), this, SLOT(newConnection())); 21 connect(a, SIGNAL(activated()), this, SLOT(newConnection()));
21 a->addTo(irc); 22 a->addTo(irc);
22 a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); 23 a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0);
23 connect(a, SIGNAL(activated()), this, SLOT(settings())); 24 connect(a, SIGNAL(activated()), this, SLOT(settings()));
24 a->addTo(irc); 25 a->addTo(irc);
25 loadSettings(); 26 loadSettings();
26} 27}
27 28
28void MainWindow::loadSettings() { 29void MainWindow::loadSettings() {
29 Config config("OpieIRC"); 30 Config config("OpieIRC");
30 config.setGroup("OpieIRC"); 31 config.setGroup("OpieIRC");
31 IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); 32 IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF");
32 IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); 33 IRCTab::m_textColor = config.readEntry("TextColor", "#000000");
33 IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); 34 IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000");
34 IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); 35 IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000");
35 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); 36 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB");
36 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); 37 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF");
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);
49 /* there might be nicer ways to do this .. */ 61 /* there might be nicer ways to do this .. */
50 delete tab; 62 delete tab;
51} 63}
52 64
53void MainWindow::newConnection() { 65void MainWindow::newConnection() {
54 IRCServerList list(this, "ServerList", TRUE); 66 IRCServerList list(this, "ServerList", TRUE);
55 if (list.exec() == QDialog::Accepted && list.hasServer()) { 67 if (list.exec() == QDialog::Accepted && list.hasServer()) {
56 IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); 68 IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget);
57 addTab(serverTab); 69 addTab(serverTab);
58 serverTab->doConnect(); 70 serverTab->doConnect();
59 } 71 }
60} 72}
61 73
62void MainWindow::settings() { 74void MainWindow::settings() {
63 IRCSettings settings(this, "Settings", TRUE); 75 IRCSettings settings(this, "Settings", TRUE);
64 if (settings.exec() == QDialog::Accepted) { 76 if (settings.exec() == QDialog::Accepted) {
65 QListIterator<IRCTab> it(m_tabs); 77 QListIterator<IRCTab> it(m_tabs);
66 for (; it.current(); ++it) { 78 for (; it.current(); ++it) {
67 /* Inform all tabs about the new settings */ 79 /* Inform all tabs about the new settings */
68 it.current()->settingsChanged(); 80 it.current()->settingsChanged();
69 } 81 }
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
@@ -3,46 +3,48 @@
3 Copyright (C) 2002 Wenzel Jakob 3 Copyright (C) 2002 Wenzel Jakob
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18
19*/ 19*/
20 20
21#ifndef __MAINWINDOW_H 21#ifndef __MAINWINDOW_H
22#define __MAINWINDOW_H 22#define __MAINWINDOW_H
23 23
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 {
32 Q_OBJECT 32 Q_OBJECT
33public: 33public:
34 MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); 34 MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
35 35
36 void addTab(IRCTab *tab); 36 void addTab(IRCTab *tab);
37 void killTab(IRCTab *tab); 37 void killTab(IRCTab *tab);
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
48#endif /* __MAINWINDOW_H */ 50#endif /* __MAINWINDOW_H */