summaryrefslogtreecommitdiff
authorwazlaf <wazlaf>2002-09-23 22:12:39 (UTC)
committer wazlaf <wazlaf>2002-09-23 22:12:39 (UTC)
commit074769a4adb816153e47d63087e9e326bd3a04bf (patch) (unidiff)
treecc69651d9e9e5901696a55d9523e343125780705
parente0b04701b3c9182ba22f56e329f98c57af4e1fe2 (diff)
downloadopie-074769a4adb816153e47d63087e9e326bd3a04bf.zip
opie-074769a4adb816153e47d63087e9e326bd3a04bf.tar.gz
opie-074769a4adb816153e47d63087e9e326bd3a04bf.tar.bz2
configuration dialog + color configurability throughout the program + popup menu on the channel person list
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchannel.cpp1
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp58
-rw-r--r--noncore/net/opieirc/ircchanneltab.h10
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp1
-rw-r--r--noncore/net/opieirc/ircmisc.cpp31
-rw-r--r--noncore/net/opieirc/ircmisc.h44
-rw-r--r--noncore/net/opieirc/ircperson.cpp1
-rw-r--r--noncore/net/opieirc/ircquerytab.cpp14
-rw-r--r--noncore/net/opieirc/ircquerytab.h1
-rw-r--r--noncore/net/opieirc/ircservereditor.cpp1
-rw-r--r--noncore/net/opieirc/ircserverlist.cpp3
-rw-r--r--noncore/net/opieirc/ircservertab.cpp43
-rw-r--r--noncore/net/opieirc/ircservertab.h11
-rw-r--r--noncore/net/opieirc/ircsettings.cpp71
-rw-r--r--noncore/net/opieirc/ircsettings.h46
-rw-r--r--noncore/net/opieirc/irctab.cpp9
-rw-r--r--noncore/net/opieirc/irctab.h10
-rw-r--r--noncore/net/opieirc/ircversion.h2
-rw-r--r--noncore/net/opieirc/mainwindow.cpp40
-rw-r--r--noncore/net/opieirc/mainwindow.h7
-rw-r--r--noncore/net/opieirc/opieirc.pro6
21 files changed, 357 insertions, 53 deletions
diff --git a/noncore/net/opieirc/ircchannel.cpp b/noncore/net/opieirc/ircchannel.cpp
index 9814a26..5c380e5 100644
--- a/noncore/net/opieirc/ircchannel.cpp
+++ b/noncore/net/opieirc/ircchannel.cpp
@@ -1,48 +1,47 @@
1#include "ircchannel.h" 1#include "ircchannel.h"
2#include <stdio.h>
3 2
4IRCChannel::IRCChannel(QString channelname) { 3IRCChannel::IRCChannel(QString channelname) {
5 m_hasPeople = FALSE; 4 m_hasPeople = FALSE;
6 m_channelname = channelname; 5 m_channelname = channelname;
7} 6}
8 7
9IRCChannel::~IRCChannel() { 8IRCChannel::~IRCChannel() {
10 /* We want this to get deleted */ 9 /* We want this to get deleted */
11 m_people.setAutoDelete(TRUE); 10 m_people.setAutoDelete(TRUE);
12} 11}
13 12
14QString IRCChannel::channelname() { 13QString IRCChannel::channelname() {
15 return m_channelname; 14 return m_channelname;
16} 15}
17 16
18bool IRCChannel::hasPeople() { 17bool IRCChannel::hasPeople() {
19 return m_hasPeople; 18 return m_hasPeople;
20} 19}
21 20
22void IRCChannel::setHasPeople(bool hasPeople) { 21void IRCChannel::setHasPeople(bool hasPeople) {
23 m_hasPeople = hasPeople; 22 m_hasPeople = hasPeople;
24} 23}
25 24
26void IRCChannel::addPerson(IRCChannelPerson *person) { 25void IRCChannel::addPerson(IRCChannelPerson *person) {
27 m_people.append(person); 26 m_people.append(person);
28} 27}
29 28
30void IRCChannel::removePerson(IRCChannelPerson *person) { 29void IRCChannel::removePerson(IRCChannelPerson *person) {
31 m_people.remove(person); 30 m_people.remove(person);
32} 31}
33 32
34QListIterator<IRCChannelPerson> IRCChannel::people() { 33QListIterator<IRCChannelPerson> IRCChannel::people() {
35 QListIterator<IRCChannelPerson> it(m_people); 34 QListIterator<IRCChannelPerson> it(m_people);
36 return it; 35 return it;
37} 36}
38 37
39IRCChannelPerson *IRCChannel::getPerson(QString nickname) { 38IRCChannelPerson *IRCChannel::getPerson(QString nickname) {
40 QListIterator<IRCChannelPerson> it(m_people); 39 QListIterator<IRCChannelPerson> it(m_people);
41 for (; it.current(); ++it) { 40 for (; it.current(); ++it) {
42 if (it.current()->person->nick() == nickname) { 41 if (it.current()->person->nick() == nickname) {
43 return it.current(); 42 return it.current();
44 } 43 }
45 } 44 }
46 return 0; 45 return 0;
47} 46}
48 47
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index 4675265..c1695db 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -1,94 +1,146 @@
1#include <qpe/qpeapplication.h>
2#include <qpe/resource.h>
3#include <qcursor.h>
1#include <qhbox.h> 4#include <qhbox.h>
2#include "ircchanneltab.h" 5#include "ircchanneltab.h"
3#include "ircservertab.h" 6#include "ircservertab.h"
4 7
5IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 8IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
6 m_mainWindow = mainWindow; 9 m_mainWindow = mainWindow;
7 m_parentTab = parentTab; 10 m_parentTab = parentTab;
8 m_channel = channel; 11 m_channel = channel;
9 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); 12 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>");
10 QHBox *hbox = new QHBox(this); 13 QHBox *hbox = new QHBox(this);
11 m_textview = new QTextView(hbox); 14 m_textview = new QTextView(hbox);
12 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 15 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
13 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 16 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
14 m_listVisible = TRUE; 17 m_listVisible = TRUE;
15 m_listButton = new QPushButton(">", m_textview); 18 m_listButton = new QPushButton(">", m_textview);
16 m_textview->setCornerWidget(m_listButton); 19 m_textview->setCornerWidget(m_listButton);
17 m_textview->setTextFormat(RichText); 20 m_textview->setTextFormat(RichText);
18 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); 21 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
19 m_list = new IRCChannelList(m_channel, hbox); 22 m_list = new IRCChannelList(m_channel, hbox);
20 m_list->update(); 23 m_list->update();
21 m_list->setMaximumWidth(LISTWIDTH); 24 m_list->setMaximumWidth(LISTWIDTH);
22 m_field = new QLineEdit(this); 25 m_field = new QLineEdit(this);
26 m_popup = new QPopupMenu(m_list);
27 /* Required so that embedded-style "right" clicks work */
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 &)));
30 /* Construct the popup menu */
31 QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
32 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu);
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()));
35 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
36 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
37
23 m_layout->add(hbox); 38 m_layout->add(hbox);
24 hbox->show(); 39 hbox->show();
25 m_layout->add(m_field); 40 m_layout->add(m_field);
26 m_field->setFocus(); 41 m_field->setFocus();
27 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 42 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
28 43 settingsChanged();
29} 44}
30 45
31void IRCChannelTab::appendText(QString text) { 46void IRCChannelTab::appendText(QString text) {
32 /* not using append because it creates layout problems */ 47 /* not using append because it creates layout problems */
33 m_textview->setText(m_textview->text() + text); 48 m_textview->setText(m_textview->text() + text);
34 m_textview->ensureVisible(0, m_textview->contentsHeight()); 49 m_textview->ensureVisible(0, m_textview->contentsHeight());
35} 50}
36 51
37IRCChannelTab::~IRCChannelTab() { 52IRCChannelTab::~IRCChannelTab() {
38 m_parentTab->removeChannelTab(this); 53 m_parentTab->removeChannelTab(this);
39} 54}
40 55
41void IRCChannelTab::processCommand() { 56void IRCChannelTab::processCommand() {
42 QString text = m_field->text(); 57 QString text = m_field->text();
43 if (text.length()>0) { 58 if (text.length()>0) {
44 if (session()->isSessionActive()) { 59 if (session()->isSessionActive()) {
45 if (text.startsWith("/") && !text.startsWith("//")) { 60 if (text.startsWith("/") && !text.startsWith("//")) {
46 /* Command mode */ 61 /* Command mode */
47 m_parentTab->executeCommand(this, text);; 62 m_parentTab->executeCommand(this, text);;
48 } else { 63 } else {
49 if (text.startsWith("//")) 64 if (text.startsWith("//"))
50 text = text.right(text.length()-1); 65 text = text.right(text.length()-1);
51 session()->sendMessage(m_channel, m_field->text()); 66 session()->sendMessage(m_channel, m_field->text());
52 appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+IRCOutput::toHTML(m_field->text())+"<br>"); 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>");
53 } 68 }
54 } else { 69 } else {
55 appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); 70 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
56 } 71 }
57 } 72 }
58 m_field->clear(); 73 m_field->clear();
59} 74}
60 75
76void IRCChannelTab::settingsChanged() {
77 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
78}
79
61void IRCChannelTab::toggleList() { 80void IRCChannelTab::toggleList() {
62 if (m_listVisible) { 81 if (m_listVisible) {
63 m_list->setMaximumWidth(0); 82 m_list->setMaximumWidth(0);
64 m_listButton->setText("<"); 83 m_listButton->setText("<");
65 } else { 84 } else {
66 m_list->setMaximumWidth(LISTWIDTH); 85 m_list->setMaximumWidth(LISTWIDTH);
67 m_listButton->setText(">"); 86 m_listButton->setText(">");
68 } 87 }
69 m_listVisible = !m_listVisible; 88 m_listVisible = !m_listVisible;
70} 89}
71 90
91void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) {
92 switch (mouse) {
93 case 1:
94 break;
95 case 2:
96 m_popup->popup(point);
97 break;
98 };
99}
100
101void IRCChannelTab::popupQuery() {
102 if (m_list->currentItem() != -1) {
103 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text());
104 if (person) {
105 IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
106 if (!tab) {
107 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent());
108 m_parentTab->addQueryTab(tab);
109 m_mainWindow->addTab(tab);
110 }
111 }
112 }
113}
114
115void IRCChannelTab::popupPing() {
116}
117
118void IRCChannelTab::popupVersion() {
119}
120
121void IRCChannelTab::popupWhois() {
122}
123
72QString IRCChannelTab::title() { 124QString IRCChannelTab::title() {
73 return m_channel->channelname(); 125 return m_channel->channelname();
74} 126}
75 127
76IRCSession *IRCChannelTab::session() { 128IRCSession *IRCChannelTab::session() {
77 return m_parentTab->session(); 129 return m_parentTab->session();
78} 130}
79 131
80void IRCChannelTab::remove() { 132void IRCChannelTab::remove() {
81 if (session()->isSessionActive()) { 133 if (session()->isSessionActive()) {
82 session()->part(m_channel); 134 session()->part(m_channel);
83 } else { 135 } else {
84 m_mainWindow->killTab(this); 136 m_mainWindow->killTab(this);
85 } 137 }
86} 138}
87 139
88IRCChannel *IRCChannelTab::channel() { 140IRCChannel *IRCChannelTab::channel() {
89 return m_channel; 141 return m_channel;
90} 142}
91 143
92IRCChannelList *IRCChannelTab::list() { 144IRCChannelList *IRCChannelTab::list() {
93 return m_list; 145 return m_list;
94} 146}
diff --git a/noncore/net/opieirc/ircchanneltab.h b/noncore/net/opieirc/ircchanneltab.h
index 2127c4d..971614b 100644
--- a/noncore/net/opieirc/ircchanneltab.h
+++ b/noncore/net/opieirc/ircchanneltab.h
@@ -1,60 +1,70 @@
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 __IRCCHANNELTAB_H 21#ifndef __IRCCHANNELTAB_H
22#define __IRCCHANNELTAB_H 22#define __IRCCHANNELTAB_H
23 23
24#include <qpopupmenu.h>
24#include <qpushbutton.h> 25#include <qpushbutton.h>
25#include "irctab.h" 26#include "irctab.h"
26#include "ircsession.h" 27#include "ircsession.h"
27#include "mainwindow.h" 28#include "mainwindow.h"
28#include "ircchannellist.h" 29#include "ircchannellist.h"
29 30
30#define LISTWIDTH 70 31#define LISTWIDTH 70
31 32
32class IRCServerTab; 33class IRCServerTab;
33class IRCChannelTab : public IRCTab { 34class IRCChannelTab : public IRCTab {
34 Q_OBJECT 35 Q_OBJECT
35public: 36public:
36 /* IRCTab implementation */ 37 /* IRCTab implementation */
37 IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); 38 IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
38 ~IRCChannelTab(); 39 ~IRCChannelTab();
39 QString title(); 40 QString title();
40 IRCSession *session(); 41 IRCSession *session();
41 IRCChannel *channel(); 42 IRCChannel *channel();
42 IRCChannelList *list(); 43 IRCChannelList *list();
43public: 44public:
44 void appendText(QString text); 45 void appendText(QString text);
45public slots: 46public slots:
46 void remove(); 47 void remove();
48 void settingsChanged();
49protected slots:
47 void processCommand(); 50 void processCommand();
48 void toggleList(); 51 void toggleList();
52 void mouseButtonPressed(int mouse, QListBoxItem *item, const QPoint &point);
53 /* Popup slots */
54 void popupQuery();
55 void popupPing();
56 void popupVersion();
57 void popupWhois();
49protected: 58protected:
50 IRCServerTab *m_parentTab; 59 IRCServerTab *m_parentTab;
51 IRCChannel *m_channel; 60 IRCChannel *m_channel;
52 IRCChannelList *m_list; 61 IRCChannelList *m_list;
53 QPushButton *m_listButton; 62 QPushButton *m_listButton;
54 MainWindow *m_mainWindow; 63 MainWindow *m_mainWindow;
55 QTextView *m_textview; 64 QTextView *m_textview;
56 QLineEdit *m_field; 65 QLineEdit *m_field;
66 QPopupMenu *m_popup;
57 bool m_listVisible; 67 bool m_listVisible;
58}; 68};
59 69
60#endif /* __IRCCHANNELTAB_H */ 70#endif /* __IRCCHANNELTAB_H */
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp
index 3063741..5c70753 100644
--- a/noncore/net/opieirc/ircmessageparser.cpp
+++ b/noncore/net/opieirc/ircmessageparser.cpp
@@ -1,52 +1,51 @@
1#include <qtextstream.h> 1#include <qtextstream.h>
2#include "ircmessageparser.h" 2#include "ircmessageparser.h"
3#include "ircversion.h" 3#include "ircversion.h"
4#include <stdio.h>
5 4
6/* Lookup table for literal commands */ 5/* Lookup table for literal commands */
7IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { 6IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
8 { "PING", FUNC(parseLiteralPing) }, 7 { "PING", FUNC(parseLiteralPing) },
9 { "NOTICE", FUNC(parseLiteralNotice) }, 8 { "NOTICE", FUNC(parseLiteralNotice) },
10 { "JOIN", FUNC(parseLiteralJoin) }, 9 { "JOIN", FUNC(parseLiteralJoin) },
11 { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, 10 { "PRIVMSG", FUNC(parseLiteralPrivMsg) },
12 { "NICK", FUNC(parseLiteralNick) }, 11 { "NICK", FUNC(parseLiteralNick) },
13 { "PART", FUNC(parseLiteralPart) }, 12 { "PART", FUNC(parseLiteralPart) },
14 { "QUIT", FUNC(parseLiteralQuit) }, 13 { "QUIT", FUNC(parseLiteralQuit) },
15 { "ERROR", FUNC(parseLiteralError) }, 14 { "ERROR", FUNC(parseLiteralError) },
16 { "ERROR:", FUNC(parseLiteralError) }, 15 { "ERROR:", FUNC(parseLiteralError) },
17 { "MODE", FUNC(parseLiteralMode) }, 16 { "MODE", FUNC(parseLiteralMode) },
18 { "KICK", FUNC(parseLiteralKick) }, 17 { "KICK", FUNC(parseLiteralKick) },
19 { 0 , 0 } 18 { 0 , 0 }
20}; 19};
21 20
22/* Lookup table for literal commands */ 21/* Lookup table for literal commands */
23IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { 22IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = {
24 { "PING", FUNC(parseCTCPPing) }, 23 { "PING", FUNC(parseCTCPPing) },
25 { "VERSION", FUNC(parseCTCPVersion) }, 24 { "VERSION", FUNC(parseCTCPVersion) },
26 { "ACTION", FUNC(parseCTCPAction) }, 25 { "ACTION", FUNC(parseCTCPAction) },
27 { 0 , 0 } 26 { 0 , 0 }
28}; 27};
29 28
30/* Lookup table for numerical commands */ 29/* Lookup table for numerical commands */
31IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { 30IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
32 { 1, FUNC(parseNumerical001) }, // RPL_WELCOME 31 { 1, FUNC(parseNumerical001) }, // RPL_WELCOME
33 { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST 32 { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST
34 { 3, FUNC(parseNumerical003) }, // RPL_CREATED 33 { 3, FUNC(parseNumerical003) }, // RPL_CREATED
35 { 4, FUNC(parseNumerical004) }, // RPL_MYINFO 34 { 4, FUNC(parseNumerical004) }, // RPL_MYINFO
36 { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL 35 { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL
37 { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT 36 { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT
38 { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS 37 { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS
39 { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME 38 { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME
40 { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY 39 { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY
41 { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES 40 { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES
42 { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART 41 { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART
43 { 372, FUNC(parseNumericalStats) }, // RPL_MOTD 42 { 372, FUNC(parseNumericalStats) }, // RPL_MOTD
44 { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD 43 { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD
45 { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 44 { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2
46 { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 45 { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3
47 { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK 46 { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK
48 { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK 47 { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK
49 { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND 48 { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND
50 { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE 49 { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE
51 { 0, 0 } 50 { 0, 0 }
52}; 51};
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp
new file mode 100644
index 0000000..f41a89a
--- a/dev/null
+++ b/noncore/net/opieirc/ircmisc.cpp
@@ -0,0 +1,31 @@
1#include <opie/colordialog.h>
2#include <qlayout.h>
3#include "ircmisc.h"
4
5IRCColorLabel::IRCColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QLabel(parent, name, f) {
6 m_color = color;
7 setAlignment(AlignVCenter | AlignCenter);
8 setFrameStyle(QFrame::StyledPanel);
9 setFrameShadow(QFrame::Sunken);
10 setBackgroundColor(m_color);
11}
12
13void IRCColorLabel::mousePressEvent(QMouseEvent *) {
14 m_color = OColorDialog::getColor(m_color);
15 setBackgroundColor(m_color);
16}
17
18QColor IRCColorLabel::color() {
19 return m_color;
20}
21
22IRCFramedColorLabel::IRCFramedColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) {
23 QVBoxLayout *layout = new QVBoxLayout(this, 10, 0);
24 m_label = new IRCColorLabel(color, this);
25 layout->addWidget(m_label);
26}
27
28QColor IRCFramedColorLabel::color() {
29 return m_label->color();
30}
31
diff --git a/noncore/net/opieirc/ircmisc.h b/noncore/net/opieirc/ircmisc.h
new file mode 100644
index 0000000..1ea04c8
--- a/dev/null
+++ b/noncore/net/opieirc/ircmisc.h
@@ -0,0 +1,44 @@
1/*
2 OpieIRC - An embedded IRC client
3 Copyright (C) 2002 Wenzel Jakob
4
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
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
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
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19*/
20
21#ifndef __IRCMISC_H
22#define __IRCMISC_H
23
24#include <qlabel.h>
25#include <qcolor.h>
26
27class IRCColorLabel : public QLabel {
28 public:
29 IRCColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
30 QColor color();
31 void mousePressEvent(QMouseEvent *event);
32 protected:
33 QColor m_color;
34};
35
36class IRCFramedColorLabel : public QWidget {
37 public:
38 IRCFramedColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
39 QColor color();
40 protected:
41 IRCColorLabel *m_label;
42};
43
44#endif /* __IRCMISC_H */
diff --git a/noncore/net/opieirc/ircperson.cpp b/noncore/net/opieirc/ircperson.cpp
index bd341f1..2f5b435 100644
--- a/noncore/net/opieirc/ircperson.cpp
+++ b/noncore/net/opieirc/ircperson.cpp
@@ -1,50 +1,49 @@
1#include "ircperson.h" 1#include "ircperson.h"
2#include <stdio.h>
3 2
4IRCPerson::IRCPerson() { 3IRCPerson::IRCPerson() {
5 m_nick = ""; 4 m_nick = "";
6 m_user = ""; 5 m_user = "";
7 m_host = ""; 6 m_host = "";
8} 7}
9 8
10IRCPerson::IRCPerson(const IRCPerson &person) { 9IRCPerson::IRCPerson(const IRCPerson &person) {
11 m_nick = person.m_nick; 10 m_nick = person.m_nick;
12 m_user = person.m_user; 11 m_user = person.m_user;
13 m_host = person.m_host; 12 m_host = person.m_host;
14} 13}
15 14
16IRCPerson::IRCPerson(QString mask) { 15IRCPerson::IRCPerson(QString mask) {
17 IRCPerson(); 16 IRCPerson();
18 fromMask(mask); 17 fromMask(mask);
19} 18}
20 19
21void IRCPerson::fromMask(QString mask) { 20void IRCPerson::fromMask(QString mask) {
22 int sep1 = mask.find("!"); 21 int sep1 = mask.find("!");
23 int sep2 = mask.find("@"); 22 int sep2 = mask.find("@");
24 23
25 m_nick = mask.left(sep1); 24 m_nick = mask.left(sep1);
26 m_user = mask.mid(sep1+1, sep2-sep1-1); 25 m_user = mask.mid(sep1+1, sep2-sep1-1);
27 m_host = mask.right(mask.length()-sep2-1); 26 m_host = mask.right(mask.length()-sep2-1);
28} 27}
29 28
30QString IRCPerson::toMask() { 29QString IRCPerson::toMask() {
31 return m_nick + "!" + m_user + "@" + m_host; 30 return m_nick + "!" + m_user + "@" + m_host;
32} 31}
33 32
34void IRCPerson::setNick(QString nick) { 33void IRCPerson::setNick(QString nick) {
35 m_nick = nick; 34 m_nick = nick;
36} 35}
37 36
38void IRCPerson::setUser(QString user) { 37void IRCPerson::setUser(QString user) {
39 m_user = user; 38 m_user = user;
40} 39}
41 40
42void IRCPerson::setHost(QString host) { 41void IRCPerson::setHost(QString host) {
43 m_host = host; 42 m_host = host;
44} 43}
45 44
46QString IRCPerson::nick() { 45QString IRCPerson::nick() {
47 return m_nick; 46 return m_nick;
48} 47}
49 48
50QString IRCPerson::user() { 49QString IRCPerson::user() {
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp
index 642cc5b..c6b8211 100644
--- a/noncore/net/opieirc/ircquerytab.cpp
+++ b/noncore/net/opieirc/ircquerytab.cpp
@@ -1,78 +1,82 @@
1#include <qhbox.h> 1#include <qhbox.h>
2#include "ircquerytab.h" 2#include "ircquerytab.h"
3#include "ircservertab.h" 3#include "ircservertab.h"
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 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} 28}
29 29
30IRCQueryTab::~IRCQueryTab() { 30IRCQueryTab::~IRCQueryTab() {
31 m_parentTab->removeQueryTab(this); 31 m_parentTab->removeQueryTab(this);
32 delete m_person; 32 delete m_person;
33} 33}
34 34
35void IRCQueryTab::processCommand() { 35void IRCQueryTab::processCommand() {
36 QString text = m_field->text(); 36 QString text = m_field->text();
37 if (text.length()>0) { 37 if (text.length()>0) {
38 if (session()->isSessionActive()) { 38 if (session()->isSessionActive()) {
39 if (text.startsWith("/") && !text.startsWith("//")) { 39 if (text.startsWith("/") && !text.startsWith("//")) {
40 /* Command mode */ 40 /* Command mode */
41 m_parentTab->executeCommand(this, text);; 41 m_parentTab->executeCommand(this, text);;
42 } else { 42 } else {
43 if (text.startsWith("//")) 43 if (text.startsWith("//"))
44 text = text.right(text.length()-1); 44 text = text.right(text.length()-1);
45 session()->sendMessage(m_person, m_field->text()); 45 session()->sendMessage(m_person, m_field->text());
46 appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+IRCOutput::toHTML(m_field->text())+"<br>"); 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 } 47 }
48 } else { 48 } else {
49 appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); 49 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
50 } 50 }
51 } 51 }
52 m_field->clear(); 52 m_field->clear();
53} 53}
54 54
55void IRCQueryTab::display(IRCOutput output) { 55void IRCQueryTab::display(IRCOutput output) {
56 if (output.type() == OUTPUT_QUERYPRIVMSG) { 56 if (output.type() == OUTPUT_QUERYPRIVMSG) {
57 appendText("&lt;<font color=\"#0000dd\">"+m_person->nick()+"</font>&gt; " + output.htmlMessage() + "<br>"); 57 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage() + "</font><br>");
58 } else if (output.type() == OUTPUT_QUERYACTION) { 58 } else if (output.type() == OUTPUT_QUERYACTION) {
59 appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "<br>"); 59 appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>");
60 } 60 }
61} 61}
62 62
63void IRCQueryTab::settingsChanged() {
64 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
65}
66
63QString IRCQueryTab::title() { 67QString IRCQueryTab::title() {
64 return m_person->nick(); 68 return m_person->nick();
65} 69}
66 70
67IRCSession *IRCQueryTab::session() { 71IRCSession *IRCQueryTab::session() {
68 return m_parentTab->session(); 72 return m_parentTab->session();
69} 73}
70 74
71void IRCQueryTab::remove() { 75void IRCQueryTab::remove() {
72 m_mainWindow->killTab(this); 76 m_mainWindow->killTab(this);
73} 77}
74 78
75IRCPerson *IRCQueryTab::person() { 79IRCPerson *IRCQueryTab::person() {
76 return m_person; 80 return m_person;
77} 81}
78 82
diff --git a/noncore/net/opieirc/ircquerytab.h b/noncore/net/opieirc/ircquerytab.h
index ea777f4..07fa57f 100644
--- a/noncore/net/opieirc/ircquerytab.h
+++ b/noncore/net/opieirc/ircquerytab.h
@@ -1,51 +1,52 @@
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 __IRCQUERYTAB_H 21#ifndef __IRCQUERYTAB_H
22#define __IRCQUERYTAB_H 22#define __IRCQUERYTAB_H
23 23
24#include "ircsession.h" 24#include "ircsession.h"
25#include "mainwindow.h" 25#include "mainwindow.h"
26 26
27class IRCServerTab; 27class IRCServerTab;
28class IRCQueryTab : public IRCTab { 28class IRCQueryTab : public IRCTab {
29 Q_OBJECT 29 Q_OBJECT
30public: 30public:
31 /* IRCTab implementation */ 31 /* IRCTab implementation */
32 IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); 32 IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
33 ~IRCQueryTab(); 33 ~IRCQueryTab();
34 QString title(); 34 QString title();
35 IRCSession *session(); 35 IRCSession *session();
36 IRCPerson *person(); 36 IRCPerson *person();
37 void appendText(QString text); 37 void appendText(QString text);
38public slots: 38public slots:
39 void remove(); 39 void remove();
40 void processCommand(); 40 void processCommand();
41 void display(IRCOutput output); 41 void display(IRCOutput output);
42 void settingsChanged();
42protected: 43protected:
43 bool m_close; 44 bool m_close;
44 MainWindow *m_mainWindow; 45 MainWindow *m_mainWindow;
45 IRCServerTab *m_parentTab; 46 IRCServerTab *m_parentTab;
46 IRCPerson *m_person; 47 IRCPerson *m_person;
47 QTextView *m_textview; 48 QTextView *m_textview;
48 QLineEdit *m_field; 49 QLineEdit *m_field;
49}; 50};
50 51
51#endif /* __IRCQUERYTAB_H */ 52#endif /* __IRCQUERYTAB_H */
diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp
index c3a444d..5e916ae 100644
--- a/noncore/net/opieirc/ircservereditor.cpp
+++ b/noncore/net/opieirc/ircservereditor.cpp
@@ -1,76 +1,77 @@
1#include <qmessagebox.h> 1#include <qmessagebox.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include "ircservereditor.h" 4#include "ircservereditor.h"
5 5
6IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) { 6IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) {
7 QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); 7 QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5);
8 QLabel *label = new QLabel(tr("Profile name :"), this); 8 QLabel *label = new QLabel(tr("Profile name :"), this);
9 m_name = new QLineEdit(server.name(), this); 9 m_name = new QLineEdit(server.name(), this);
10 layout->addWidget(label, 0, 0); 10 layout->addWidget(label, 0, 0);
11 layout->addWidget(m_name, 0, 1); 11 layout->addWidget(m_name, 0, 1);
12 label = new QLabel(tr("Hostname :"), this); 12 label = new QLabel(tr("Hostname :"), this);
13 m_hostname = new QLineEdit(server.hostname(), this); 13 m_hostname = new QLineEdit(server.hostname(), this);
14 layout->addWidget(label, 1, 0); 14 layout->addWidget(label, 1, 0);
15 layout->addWidget(m_hostname, 1, 1); 15 layout->addWidget(m_hostname, 1, 1);
16 label = new QLabel(tr("Port :"), this); 16 label = new QLabel(tr("Port :"), this);
17 m_port = new QLineEdit(QString::number(server.port()), this); 17 m_port = new QLineEdit(QString::number(server.port()), this);
18 layout->addWidget(label, 2, 0); 18 layout->addWidget(label, 2, 0);
19 layout->addWidget(m_port, 2, 1); 19 layout->addWidget(m_port, 2, 1);
20 label = new QLabel(tr("Nickname :"), this); 20 label = new QLabel(tr("Nickname :"), this);
21 m_nickname = new QLineEdit(server.nick(), this); 21 m_nickname = new QLineEdit(server.nick(), this);
22 layout->addWidget(label, 3, 0); 22 layout->addWidget(label, 3, 0);
23 layout->addWidget(m_nickname, 3, 1); 23 layout->addWidget(m_nickname, 3, 1);
24 label = new QLabel(tr("Realname :"), this); 24 label = new QLabel(tr("Realname :"), this);
25 m_realname = new QLineEdit(server.realname(), this); 25 m_realname = new QLineEdit(server.realname(), this);
26 layout->addWidget(label, 4, 0); 26 layout->addWidget(label, 4, 0);
27 layout->addWidget(m_realname, 4, 1); 27 layout->addWidget(m_realname, 4, 1);
28 label = new QLabel(tr("Password :"), this); 28 label = new QLabel(tr("Password :"), this);
29 m_password = new QLineEdit(server.password(), this); 29 m_password = new QLineEdit(server.password(), this);
30 layout->addWidget(label, 5, 0); 30 layout->addWidget(label, 5, 0);
31 layout->addWidget(m_password, 5, 1); 31 layout->addWidget(m_password, 5, 1);
32 label = new QLabel(tr("Channels :"), this); 32 label = new QLabel(tr("Channels :"), this);
33 m_channels = new QLineEdit(server.channels(), this); 33 m_channels = new QLineEdit(server.channels(), this);
34 layout->addWidget(label, 6, 0); 34 layout->addWidget(label, 6, 0);
35 layout->addWidget(m_channels, 6, 1); 35 layout->addWidget(m_channels, 6, 1);
36 setCaption(tr("Edit server information"));
36 showMaximized(); 37 showMaximized();
37} 38}
38 39
39 40
40void IRCServerEditor::accept() { 41void IRCServerEditor::accept() {
41 if (m_name->text().length()==0) 42 if (m_name->text().length()==0)
42 QMessageBox::critical(this, tr("Error"), tr("Profile name required")); 43 QMessageBox::critical(this, tr("Error"), tr("Profile name required"));
43 else if (m_hostname->text().length()==0) 44 else if (m_hostname->text().length()==0)
44 QMessageBox::critical(this, tr("Error"), tr("Host name required")); 45 QMessageBox::critical(this, tr("Error"), tr("Host name required"));
45 else if (m_port->text().toInt()<=0) 46 else if (m_port->text().toInt()<=0)
46 QMessageBox::critical(this, tr("Error"), tr("Port required")); 47 QMessageBox::critical(this, tr("Error"), tr("Port required"));
47 else if (m_nickname->text().length()==0) 48 else if (m_nickname->text().length()==0)
48 QMessageBox::critical(this, tr("Error"), tr("Nickname required")); 49 QMessageBox::critical(this, tr("Error"), tr("Nickname required"));
49 else if (m_realname->text().length()==0) 50 else if (m_realname->text().length()==0)
50 QMessageBox::critical(this, tr("Error"), tr("Realname required")); 51 QMessageBox::critical(this, tr("Error"), tr("Realname required"));
51 else { 52 else {
52 /* Now verify whether the channel list has a valid format */ 53 /* Now verify whether the channel list has a valid format */
53 QStringList channels = QStringList::split(QChar(','), m_channels->text()); 54 QStringList channels = QStringList::split(QChar(','), m_channels->text());
54 for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { 55 for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) {
55 QString channelName = (*it).stripWhiteSpace(); 56 QString channelName = (*it).stripWhiteSpace();
56 if (!channelName.startsWith("#")) { 57 if (!channelName.startsWith("#")) {
57 QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with '#'")); 58 QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with '#'"));
58 return; 59 return;
59 } 60 }
60 } 61 }
61 QDialog::accept(); 62 QDialog::accept();
62 } 63 }
63} 64}
64 65
65IRCServer IRCServerEditor::getServer() { 66IRCServer IRCServerEditor::getServer() {
66 IRCServer server; 67 IRCServer server;
67 server.setName(m_name->text()); 68 server.setName(m_name->text());
68 server.setHostname(m_hostname->text()); 69 server.setHostname(m_hostname->text());
69 server.setPort(m_port->text().toInt()); 70 server.setPort(m_port->text().toInt());
70 server.setNick(m_nickname->text()); 71 server.setNick(m_nickname->text());
71 server.setRealname(m_realname->text()); 72 server.setRealname(m_realname->text());
72 server.setUsername(m_nickname->text()); 73 server.setUsername(m_nickname->text());
73 server.setPassword(m_password->text()); 74 server.setPassword(m_password->text());
74 server.setChannels(m_channels->text()); 75 server.setChannels(m_channels->text());
75 return server; 76 return server;
76} 77}
diff --git a/noncore/net/opieirc/ircserverlist.cpp b/noncore/net/opieirc/ircserverlist.cpp
index e664ba1..3293591 100644
--- a/noncore/net/opieirc/ircserverlist.cpp
+++ b/noncore/net/opieirc/ircserverlist.cpp
@@ -1,133 +1,130 @@
1#include <stdio.h>
2#include <qlayout.h> 1#include <qlayout.h>
3#include <qlabel.h> 2#include <qlabel.h>
4#include <qhbox.h> 3#include <qhbox.h>
5#include <qpushbutton.h> 4#include <qpushbutton.h>
6#include "ircserverlist.h" 5#include "ircserverlist.h"
7#include "ircservereditor.h" 6#include "ircservereditor.h"
8#include <stdio.h>
9 7
10class IRCListBoxServer : public QListBoxText { 8class IRCListBoxServer : public QListBoxText {
11public: 9public:
12 IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) { 10 IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) {
13 m_server = server; 11 m_server = server;
14 } 12 }
15 13
16 IRCServer server() { 14 IRCServer server() {
17 return m_server; 15 return m_server;
18 } 16 }
19 17
20 void setServer(IRCServer server) { 18 void setServer(IRCServer server) {
21 m_server = server; 19 m_server = server;
22 setText(m_server.name()); 20 setText(m_server.name());
23 } 21 }
24protected: 22protected:
25 IRCServer m_server; 23 IRCServer m_server;
26}; 24};
27 25
28IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags f) : QDialog(parent, name, modal, f) { 26IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags f) : QDialog(parent, name, modal, f) {
29 QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); 27 QVBoxLayout *layout = new QVBoxLayout(this, 5, 5);
30 setCaption(tr("Serverlist Browser")); 28 setCaption(tr("Serverlist Browser"));
31 QLabel *label = new QLabel(tr("Please choose a server profile"), this); 29 QLabel *label = new QLabel(tr("Please choose a server profile"), this);
32 label->setAlignment(AlignHCenter); 30 label->setAlignment(AlignHCenter);
33 layout->addWidget(label); 31 layout->addWidget(label);
34 m_list = new QListBox(this); 32 m_list = new QListBox(this);
35 layout->addWidget(m_list); 33 layout->addWidget(m_list);
36 QHBox *buttons = new QHBox(this); 34 QHBox *buttons = new QHBox(this);
37 QPushButton *del = new QPushButton(tr("Delete"), buttons); 35 QPushButton *del = new QPushButton(tr("Delete"), buttons);
38 QPushButton *edit = new QPushButton(tr("Edit"), buttons); 36 QPushButton *edit = new QPushButton(tr("Edit"), buttons);
39 QPushButton *add = new QPushButton(tr("Add"), buttons); 37 QPushButton *add = new QPushButton(tr("Add"), buttons);
40 connect(del, SIGNAL(clicked()), this, SLOT(delServer())); 38 connect(del, SIGNAL(clicked()), this, SLOT(delServer()));
41 connect(edit, SIGNAL(clicked()), this, SLOT(editServer())); 39 connect(edit, SIGNAL(clicked()), this, SLOT(editServer()));
42 connect(add, SIGNAL(clicked()), this, SLOT(addServer())); 40 connect(add, SIGNAL(clicked()), this, SLOT(addServer()));
43 layout->addWidget(buttons); 41 layout->addWidget(buttons);
44 /* Load the configuration file */ 42 /* Load the configuration file */
45 m_config = new Config("OpieIRC"); 43 m_config = new Config("OpieIRC");
46 m_config->setGroup("OpieIRC"); 44 m_config->setGroup("OpieIRC");
47 int count = m_config->readNumEntry("ServerCount", 0); 45 int count = m_config->readNumEntry("ServerCount", 0);
48 if (count) { 46 if (count) {
49 for (int i=0; i<count; i++) { 47 for (int i=0; i<count; i++) {
50 m_config->setGroup("OpieIRC"); 48 m_config->setGroup("OpieIRC");
51 QString name = m_config->readEntry("Server"+QString::number(i)); 49 QString name = m_config->readEntry("Server"+QString::number(i));
52 if (name.length() > 0) { 50 if (name.length() > 0) {
53 IRCServer server; 51 IRCServer server;
54 m_config->setGroup(name); 52 m_config->setGroup(name);
55 server.setName(name); 53 server.setName(name);
56 server.setHostname(m_config->readEntry("Hostname")); 54 server.setHostname(m_config->readEntry("Hostname"));
57 server.setPort(m_config->readNumEntry("Port")); 55 server.setPort(m_config->readNumEntry("Port"));
58 server.setUsername(m_config->readEntry("Username")); 56 server.setUsername(m_config->readEntry("Username"));
59 server.setPassword(m_config->readEntry("Password")); 57 server.setPassword(m_config->readEntry("Password"));
60 server.setNick(m_config->readEntry("Nick")); 58 server.setNick(m_config->readEntry("Nick"));
61 server.setRealname(m_config->readEntry("Realname")); 59 server.setRealname(m_config->readEntry("Realname"));
62 server.setChannels(m_config->readEntry("Channels")); 60 server.setChannels(m_config->readEntry("Channels"));
63 m_list->insertItem(new IRCListBoxServer(server)); 61 m_list->insertItem(new IRCListBoxServer(server));
64 } 62 }
65 } 63 }
66 } 64 }
67 65
68 showMaximized(); 66 showMaximized();
69} 67}
70 68
71void IRCServerList::addServer() { 69void IRCServerList::addServer() {
72 IRCServer server; 70 IRCServer server;
73 IRCServerEditor editor(server, this, "ServerEditor", TRUE); 71 IRCServerEditor editor(server, this, "ServerEditor", TRUE);
74 if (editor.exec() == QDialog::Accepted) { 72 if (editor.exec() == QDialog::Accepted) {
75 server = editor.getServer(); 73 server = editor.getServer();
76 /* Gets deleted by QListBox, so this is ok */ 74 /* Gets deleted by QListBox, so this is ok */
77 m_list->insertItem(new IRCListBoxServer(server)); 75 m_list->insertItem(new IRCListBoxServer(server));
78 } 76 }
79} 77}
80 78
81void IRCServerList::delServer() { 79void IRCServerList::delServer() {
82 int index = m_list->currentItem(); 80 int index = m_list->currentItem();
83 if (index != -1) { 81 if (index != -1) {
84 m_list->removeItem(index); 82 m_list->removeItem(index);
85 } 83 }
86} 84}
87 85
88void IRCServerList::editServer() { 86void IRCServerList::editServer() {
89 int index = m_list->currentItem(); 87 int index = m_list->currentItem();
90 if (index != -1) { 88 if (index != -1) {
91 IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); 89 IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index);
92 IRCServer server = item->server(); 90 IRCServer server = item->server();
93 IRCServerEditor editor(server, this, "ServerEditor", TRUE); 91 IRCServerEditor editor(server, this, "ServerEditor", TRUE);
94 if (editor.exec() == QDialog::Accepted) { 92 if (editor.exec() == QDialog::Accepted) {
95 server = editor.getServer(); 93 server = editor.getServer();
96 item->setServer(server); 94 item->setServer(server);
97 } 95 }
98 } 96 }
99} 97}
100 98
101int IRCServerList::exec() { 99int IRCServerList::exec() {
102 int returncode = QDialog::exec(); 100 int returncode = QDialog::exec();
103 /* Now save the changes */ 101 /* Now save the changes */
104 m_config->setGroup("OpieIRC"); 102 m_config->setGroup("OpieIRC");
105 m_config->clearGroup();
106 m_config->writeEntry("ServerCount", QString::number(m_list->count())); 103 m_config->writeEntry("ServerCount", QString::number(m_list->count()));
107 for (unsigned int i=0; i<m_list->count(); i++) { 104 for (unsigned int i=0; i<m_list->count(); i++) {
108 IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); 105 IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server();
109 m_config->setGroup("OpieIRC"); 106 m_config->setGroup("OpieIRC");
110 m_config->writeEntry("Server"+QString::number(i), server.name()); 107 m_config->writeEntry("Server"+QString::number(i), server.name());
111 m_config->setGroup(server.name()); 108 m_config->setGroup(server.name());
112 m_config->writeEntry("Hostname", server.hostname()); 109 m_config->writeEntry("Hostname", server.hostname());
113 m_config->writeEntry("Port", QString::number(server.port())); 110 m_config->writeEntry("Port", QString::number(server.port()));
114 m_config->writeEntry("Username", server.username()); 111 m_config->writeEntry("Username", server.username());
115 m_config->writeEntry("Password", server.password()); 112 m_config->writeEntry("Password", server.password());
116 m_config->writeEntry("Nick", server.nick()); 113 m_config->writeEntry("Nick", server.nick());
117 m_config->writeEntry("Realname", server.realname()); 114 m_config->writeEntry("Realname", server.realname());
118 m_config->writeEntry("Channels", server.channels()); 115 m_config->writeEntry("Channels", server.channels());
119 } 116 }
120 return returncode; 117 return returncode;
121} 118}
122 119
123bool IRCServerList::hasServer() { 120bool IRCServerList::hasServer() {
124 return (m_list->currentItem() != -1); 121 return (m_list->currentItem() != -1);
125} 122}
126 123
127IRCServer IRCServerList::server() { 124IRCServer IRCServerList::server() {
128 return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server(); 125 return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server();
129} 126}
130 127
131IRCServerList::~IRCServerList() { 128IRCServerList::~IRCServerList() {
132 delete m_config; 129 delete m_config;
133} 130}
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index 8b8771f..4be60ef 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -1,243 +1,252 @@
1#include <stdio.h> 1#include <qpe/config.h>
2#include <qtextstream.h> 2#include <qtextstream.h>
3#include "ircservertab.h" 3#include "ircservertab.h"
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} 22}
22 23
23void IRCServerTab::appendText(QString text) { 24void IRCServerTab::appendText(QString text) {
24 /* not using append because it creates layout problems */ 25 /* not using append because it creates layout problems */
25 m_textview->setText(m_textview->text() + text); 26 m_textview->setText(m_textview->text() + text);
26 m_textview->ensureVisible(0, m_textview->contentsHeight()); 27 m_textview->ensureVisible(0, m_textview->contentsHeight());
27} 28}
28 29
29IRCServerTab::~IRCServerTab() { 30IRCServerTab::~IRCServerTab() {
30 delete m_session; 31 delete m_session;
31} 32}
32 33
33void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { 34void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
34 m_channelTabs.remove(tab); 35 m_channelTabs.remove(tab);
35} 36}
36 37
37void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { 38void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
38 m_queryTabs.remove(tab); 39 m_queryTabs.remove(tab);
39} 40}
40 41
42void IRCServerTab::addQueryTab(IRCQueryTab *tab) {
43 m_queryTabs.append(tab);
44}
45
41QString IRCServerTab::title() { 46QString IRCServerTab::title() {
42 return "Server"; 47 return "Server";
43} 48}
44 49
45IRCSession *IRCServerTab::session() { 50IRCSession *IRCServerTab::session() {
46 return m_session; 51 return m_session;
47} 52}
48 53
49IRCServer *IRCServerTab::server() { 54IRCServer *IRCServerTab::server() {
50 return &m_server; 55 return &m_server;
51} 56}
52 57
58void IRCServerTab::settingsChanged() {
59 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
60}
61
53void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 62void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
54 QTextIStream stream(&line); 63 QTextIStream stream(&line);
55 QString command; 64 QString command;
56 stream >> command; 65 stream >> command;
57 command = command.upper().right(command.length()-1); 66 command = command.upper().right(command.length()-1);
58 67
59 if (command == "JOIN") { 68 if (command == "JOIN") {
60 QString channel; 69 QString channel;
61 stream >> channel; 70 stream >> channel;
62 if (channel.length() > 0 && channel.startsWith("#")) { 71 if (channel.length() > 0 && channel.startsWith("#")) {
63 m_session->join(channel); 72 m_session->join(channel);
64 } else { 73 } else {
65 tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>"); 74 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>");
66 } 75 }
67 } else if (command == "ME") { 76 } else if (command == "ME") {
68 QString text = line.right(line.length()-4); 77 QString text = line.right(line.length()-4);
69 if (text.length() > 0) { 78 if (text.length() > 0) {
70 if (tab->isA("IRCChannelTab")) { 79 if (tab->isA("IRCChannelTab")) {
71 tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 80 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
72 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); 81 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text);
73 } else if (tab->isA("IRCQueryTab")) { 82 } else if (tab->isA("IRCQueryTab")) {
74 tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 83 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
75 m_session->sendAction(((IRCQueryTab *)tab)->person(), text); 84 m_session->sendAction(((IRCQueryTab *)tab)->person(), text);
76 } else { 85 } else {
77 tab->appendText("<font color=\"#ff0000\">Invalid tab for this command</font><br>"); 86 tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>");
78 } 87 }
79 } 88 }
80 } else if (command == "MSG") { 89 } else if (command == "MSG") {
81 QString nickname; 90 QString nickname;
82 stream >> nickname; 91 stream >> nickname;
83 if (nickname.length() > 0) { 92 if (nickname.length() > 0) {
84 if (line.length() > 6 + nickname.length()) { 93 if (line.length() > 6 + nickname.length()) {
85 QString text = line.right(line.length()-nickname.length()-6); 94 QString text = line.right(line.length()-nickname.length()-6);
86 IRCPerson person; 95 IRCPerson person;
87 person.setNick(nickname); 96 person.setNick(nickname);
88 tab->appendText("&gt;<font color=\"#0000dd\">"+IRCOutput::toHTML(nickname)+"</font>&lt; "+IRCOutput::toHTML(text)+"<br>"); 97 tab->appendText("<font color=\"" + m_textColor + "\">&gt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">&lt; "+IRCOutput::toHTML(text)+"</font><br>");
89 m_session->sendMessage(&person, text); 98 m_session->sendMessage(&person, text);
90 } 99 }
91 } 100 }
92 } else { 101 } else {
93 tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>"); 102 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>");
94 } 103 }
95} 104}
96 105
97void IRCServerTab::processCommand() { 106void IRCServerTab::processCommand() {
98 QString text = m_field->text(); 107 QString text = m_field->text();
99 if (text.startsWith("/") && !text.startsWith("//")) { 108 if (text.startsWith("/") && !text.startsWith("//")) {
100 /* Command mode */ 109 /* Command mode */
101 executeCommand(this, text); 110 executeCommand(this, text);
102 } 111 }
103 m_field->clear(); 112 m_field->clear();
104} 113}
105 114
106void IRCServerTab::doConnect() { 115void IRCServerTab::doConnect() {
107 m_session->beginSession(); 116 m_session->beginSession();
108} 117}
109 118
110void IRCServerTab::remove() { 119void IRCServerTab::remove() {
111 /* Close requested */ 120 /* Close requested */
112 if (m_session->isSessionActive()) { 121 if (m_session->isSessionActive()) {
113 /* While there is a running session */ 122 /* While there is a running session */
114 m_close = TRUE; 123 m_close = TRUE;
115 m_session->endSession(); 124 m_session->endSession();
116 } else { 125 } else {
117 /* Session has previously been closed */ 126 /* Session has previously been closed */
118 m_channelTabs.first(); 127 m_channelTabs.first();
119 while (m_channelTabs.current() != 0) { 128 while (m_channelTabs.current() != 0) {
120 m_mainWindow->killTab(m_channelTabs.current()); 129 m_mainWindow->killTab(m_channelTabs.current());
121 } 130 }
122 m_queryTabs.first(); 131 m_queryTabs.first();
123 while (m_queryTabs.current() != 0) { 132 while (m_queryTabs.current() != 0) {
124 m_mainWindow->killTab(m_queryTabs.current()); 133 m_mainWindow->killTab(m_queryTabs.current());
125 } 134 }
126 m_mainWindow->killTab(this); 135 m_mainWindow->killTab(this);
127 } 136 }
128} 137}
129 138
130IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { 139IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
131 QListIterator<IRCChannelTab> it(m_channelTabs); 140 QListIterator<IRCChannelTab> it(m_channelTabs);
132 141
133 for (; it.current(); ++it) { 142 for (; it.current(); ++it) {
134 if (it.current()->channel() == channel) 143 if (it.current()->channel() == channel)
135 return it.current(); 144 return it.current();
136 } 145 }
137 return 0; 146 return 0;
138} 147}
139 148
140IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { 149IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) {
141 QListIterator<IRCQueryTab> it(m_queryTabs); 150 QListIterator<IRCQueryTab> it(m_queryTabs);
142 151
143 for (; it.current(); ++it) { 152 for (; it.current(); ++it) {
144 if (it.current()->person()->nick() == person->nick()) 153 if (it.current()->person()->nick() == person->nick())
145 return it.current(); 154 return it.current();
146 } 155 }
147 return 0; 156 return 0;
148} 157}
149 158
150void IRCServerTab::display(IRCOutput output) { 159void IRCServerTab::display(IRCOutput output) {
151 160
152 /* All messages to be displayed inside the GUI get here */ 161 /* All messages to be displayed inside the GUI get here */
153 switch (output.type()) { 162 switch (output.type()) {
154 case OUTPUT_CONNCLOSE: 163 case OUTPUT_CONNCLOSE:
155 if (m_close) { 164 if (m_close) {
156 m_channelTabs.first(); 165 m_channelTabs.first();
157 while (m_channelTabs.current() != 0) { 166 while (m_channelTabs.current() != 0) {
158 m_mainWindow->killTab(m_channelTabs.current()); 167 m_mainWindow->killTab(m_channelTabs.current());
159 } 168 }
160 m_queryTabs.first(); 169 m_queryTabs.first();
161 while (m_queryTabs.current() != 0) { 170 while (m_queryTabs.current() != 0) {
162 m_mainWindow->killTab(m_queryTabs.current()); 171 m_mainWindow->killTab(m_queryTabs.current());
163 } 172 }
164 m_mainWindow->killTab(this); 173 m_mainWindow->killTab(this);
165 } else { 174 } else {
166 appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); 175 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>");
167 QListIterator<IRCChannelTab> it(m_channelTabs); 176 QListIterator<IRCChannelTab> it(m_channelTabs);
168 for (; it.current(); ++it) { 177 for (; it.current(); ++it) {
169 it.current()->appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); 178 it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>");
170 } 179 }
171 } 180 }
172 break; 181 break;
173 case OUTPUT_SELFJOIN: { 182 case OUTPUT_SELFJOIN: {
174 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); 183 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
175 m_channelTabs.append(channeltab); 184 m_channelTabs.append(channeltab);
176 m_mainWindow->addTab(channeltab); 185 m_mainWindow->addTab(channeltab);
177 } 186 }
178 break; 187 break;
179 case OUTPUT_CHANPRIVMSG: { 188 case OUTPUT_CHANPRIVMSG: {
180 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 189 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
181 channelTab->appendText("&lt;<font color=\"#0000dd\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font>&gt; "+output.htmlMessage()+"<br>"); 190 channelTab->appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage()+"</font><br>");
182 } 191 }
183 break; 192 break;
184 case OUTPUT_QUERYACTION: 193 case OUTPUT_QUERYACTION:
185 case OUTPUT_QUERYPRIVMSG: { 194 case OUTPUT_QUERYPRIVMSG: {
186 IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); 195 IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0));
187 if (!queryTab) { 196 if (!queryTab) {
188 queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); 197 queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
189 m_queryTabs.append(queryTab); 198 m_queryTabs.append(queryTab);
190 m_mainWindow->addTab(queryTab); 199 m_mainWindow->addTab(queryTab);
191 } 200 }
192 queryTab->display(output); 201 queryTab->display(output);
193 } 202 }
194 break; 203 break;
195 case OUTPUT_SELFPART: { 204 case OUTPUT_SELFPART: {
196 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 205 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
197 if (channelTab) 206 if (channelTab)
198 m_mainWindow->killTab(channelTab); 207 m_mainWindow->killTab(channelTab);
199 } 208 }
200 break; 209 break;
201 case OUTPUT_SELFKICK: { 210 case OUTPUT_SELFKICK: {
202 appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>"); 211 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
203 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 212 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
204 if (channelTab) 213 if (channelTab)
205 m_mainWindow->killTab(channelTab); 214 m_mainWindow->killTab(channelTab);
206 } 215 }
207 break; 216 break;
208 case OUTPUT_CHANACTION: { 217 case OUTPUT_CHANACTION: {
209 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 218 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
210 channelTab->appendText("<font color=\"#cc0000\">"+output.htmlMessage()+"</font><br>"); 219 channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>");
211 } 220 }
212 break; 221 break;
213 case OUTPUT_QUIT: { 222 case OUTPUT_QUIT: {
214 QString nick = ((IRCPerson *)output.getParam(0))->nick(); 223 QString nick = ((IRCPerson *)output.getParam(0))->nick();
215 QListIterator<IRCChannelTab> it(m_channelTabs); 224 QListIterator<IRCChannelTab> it(m_channelTabs);
216 for (; it.current(); ++it) { 225 for (; it.current(); ++it) {
217 if (it.current()->list()->hasPerson(nick)) { 226 if (it.current()->list()->hasPerson(nick)) {
218 it.current()->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>"); 227 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
219 it.current()->list()->update(); 228 it.current()->list()->update();
220 } 229 }
221 } 230 }
222 } 231 }
223 break; 232 break;
224 case OUTPUT_OTHERJOIN: 233 case OUTPUT_OTHERJOIN:
225 case OUTPUT_OTHERKICK: 234 case OUTPUT_OTHERKICK:
226 case OUTPUT_CHANPERSONMODE: 235 case OUTPUT_CHANPERSONMODE:
227 case OUTPUT_OTHERPART: { 236 case OUTPUT_OTHERPART: {
228 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 237 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
229 channelTab->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>"); 238 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
230 channelTab->list()->update(); 239 channelTab->list()->update();
231 } 240 }
232 break; 241 break;
233 case OUTPUT_CTCP: 242 case OUTPUT_CTCP:
234 appendText("<font color=\"#00bb00\">" + output.htmlMessage() + "</font><br>"); 243 appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>");
235 break; 244 break;
236 case OUTPUT_ERROR: 245 case OUTPUT_ERROR:
237 appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>"); 246 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
238 break; 247 break;
239 default: 248 default:
240 appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "</font><br>"); 249 appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>");
241 break; 250 break;
242 } 251 }
243} 252}
diff --git a/noncore/net/opieirc/ircservertab.h b/noncore/net/opieirc/ircservertab.h
index e439d84..698689a 100644
--- a/noncore/net/opieirc/ircservertab.h
+++ b/noncore/net/opieirc/ircservertab.h
@@ -1,70 +1,73 @@
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 __IRCSERVERTAB_H 21#ifndef __IRCSERVERTAB_H
22#define __IRCSERVERTAB_H 22#define __IRCSERVERTAB_H
23 23
24#include "irctab.h" 24#include "irctab.h"
25#include "ircsession.h" 25#include "ircsession.h"
26#include "mainwindow.h" 26#include "mainwindow.h"
27#include "ircchanneltab.h" 27#include "ircchanneltab.h"
28#include "ircquerytab.h" 28#include "ircquerytab.h"
29 29
30class IRCServerTab : public IRCTab { 30class IRCServerTab : public IRCTab {
31 Q_OBJECT 31 Q_OBJECT
32public: 32public:
33 /* IRCTab implementation */ 33 /* IRCTab implementation */
34 IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); 34 IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
35 ~IRCServerTab(); 35 ~IRCServerTab();
36 QString title(); 36 QString title();
37 IRCSession *session(); 37 IRCSession *session();
38 IRCServer *server(); 38 IRCServer *server();
39 39
40 /* Start the server session */ 40 /* Start the server session */
41 void doConnect(); 41 void doConnect();
42 /* Remove tabs from the internal tab lists */ 42 /* Remove tabs from the internal tab lists */
43 void removeChannelTab(IRCChannelTab *tab); 43 void removeChannelTab(IRCChannelTab *tab);
44 void removeQueryTab(IRCQueryTab *tab); 44 void removeQueryTab(IRCQueryTab *tab);
45 45 /* Return tabs from the internal tab lists */
46 /* Execute a user command such as /join */ 46 IRCChannelTab *getTabForChannel(IRCChannel *channel);
47 IRCQueryTab *getTabForQuery(IRCPerson *person);
48 /* Add tabs to the internal tab lists */
49 void addQueryTab(IRCQueryTab *tab);
50 /* Execute a user command such as /join, /msg etc */
47 void executeCommand(IRCTab *tab, QString line); 51 void executeCommand(IRCTab *tab, QString line);
48protected: 52protected:
49 void appendText(QString text); 53 void appendText(QString text);
50 IRCChannelTab *getTabForChannel(IRCChannel *channel);
51 IRCQueryTab *getTabForQuery(IRCPerson *person);
52public slots: 54public slots:
53 void remove(); 55 void remove();
54 void processCommand(); 56 void processCommand();
57 void settingsChanged();
55protected slots: 58protected slots:
56 void display(IRCOutput output); 59 void display(IRCOutput output);
57protected: 60protected:
58 bool m_close; 61 bool m_close;
59 IRCServer m_server; 62 IRCServer m_server;
60 IRCSession *m_session; 63 IRCSession *m_session;
61 MainWindow *m_mainWindow; 64 MainWindow *m_mainWindow;
62 QTextView *m_textview; 65 QTextView *m_textview;
63 QLineEdit *m_field; 66 QLineEdit *m_field;
64 /* Channel tabs associated with this server tab */ 67 /* Channel tabs associated with this server tab */
65 QList<IRCChannelTab> m_channelTabs; 68 QList<IRCChannelTab> m_channelTabs;
66 /* Query tabs associated with this server tab */ 69 /* Query tabs associated with this server tab */
67 QList<IRCQueryTab> m_queryTabs; 70 QList<IRCQueryTab> m_queryTabs;
68}; 71};
69 72
70#endif /* __IRCSERVERTAB_H */ 73#endif /* __IRCSERVERTAB_H */
diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp
new file mode 100644
index 0000000..d1fef67
--- a/dev/null
+++ b/noncore/net/opieirc/ircsettings.cpp
@@ -0,0 +1,71 @@
1#include <qlayout.h>
2#include "ircsettings.h"
3#include "irctab.h"
4#include "ircmisc.h"
5#include <stdio.h>
6
7IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags f) : QDialog(parent, name, modal, f) {
8 m_config = new Config("OpieIRC");
9 m_config->setGroup("OpieIRC");
10
11 setCaption("Settings");
12 QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 0);
13 QLabel *label = new QLabel(tr("Background color :"), this);
14 layout->addWidget(label, 0, 0);
15 m_background = new IRCFramedColorLabel(QColor(m_config->readEntry("BackgroundColor", "#FFFFFF")), this);
16 layout->addWidget(m_background, 0, 1);
17 label = new QLabel(tr("Normal text color :"), this);
18 layout->addWidget(label, 1, 0);
19 m_text = new IRCFramedColorLabel(m_config->readEntry("TextColor", "#000000"), this);
20 layout->addWidget(m_text, 1, 1);
21 label = new QLabel(tr("Error color :"), this);
22 layout->addWidget(label, 2, 0);
23 m_error = new IRCFramedColorLabel(m_config->readEntry("ErrorColor", "#FF0000"), this);
24 layout->addWidget(m_error, 2, 1);
25 label = new QLabel(tr("Text written by yourself :"), this);
26 layout->addWidget(label, 3, 0);
27 m_self = new IRCFramedColorLabel(m_config->readEntry("SelfColor", "#CC0000"), this);
28 layout->addWidget(m_self, 3, 1);
29 label = new QLabel(tr("Text written by others :"), this);
30 layout->addWidget(label, 4, 0);
31 m_other = new IRCFramedColorLabel(m_config->readEntry("OtherColor", "#0000BB"), this);
32 layout->addWidget(m_other, 4, 1);
33 label = new QLabel(tr("Text written by the server :"), this);
34 layout->addWidget(label, 5, 0);
35 m_server = new IRCFramedColorLabel(m_config->readEntry("ServerColor", "#0000FF"), this);
36 layout->addWidget(m_server, 5, 1);
37 label = new QLabel(tr("Notifications :"), this);
38 layout->addWidget(label, 6, 0);
39 m_notification = new IRCFramedColorLabel(m_config->readEntry("NotificationColor", "#AAE300"), this);
40 layout->addWidget(m_notification, 6, 1);
41 showMaximized();
42}
43
44QString IRCSettings::getColorString(QWidget *widget) {
45 QColor color = ((IRCFramedColorLabel *)widget)->color();
46 QString temp;
47 temp.sprintf("#%02x%02x%02x", color.red(), color.green(), color.blue());
48 return temp;
49}
50
51void IRCSettings::accept() {
52 IRCTab::m_backgroundColor = getColorString(m_background);
53 IRCTab::m_textColor = getColorString(m_text);
54 IRCTab::m_errorColor = getColorString(m_error);
55 IRCTab::m_selfColor = getColorString(m_self);
56 IRCTab::m_otherColor = getColorString(m_other);
57 IRCTab::m_serverColor = getColorString(m_server);
58 IRCTab::m_notificationColor = getColorString(m_notification);
59 m_config->writeEntry("BackgroundColor", getColorString(m_background));
60 m_config->writeEntry("TextColor", getColorString(m_text));
61 m_config->writeEntry("ErrorColor", getColorString(m_error));
62 m_config->writeEntry("SelfColor", getColorString(m_self));
63 m_config->writeEntry("OtherColor", getColorString(m_other));
64 m_config->writeEntry("ServerColor", getColorString(m_server));
65 m_config->writeEntry("NotificationColor", getColorString(m_notification));
66 QDialog::accept();
67}
68
69IRCSettings::~IRCSettings() {
70 delete m_config;
71}
diff --git a/noncore/net/opieirc/ircsettings.h b/noncore/net/opieirc/ircsettings.h
new file mode 100644
index 0000000..1d3aeb7
--- a/dev/null
+++ b/noncore/net/opieirc/ircsettings.h
@@ -0,0 +1,46 @@
1/*
2 OpieIRC - An embedded IRC client
3 Copyright (C) 2002 Wenzel Jakob
4
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
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
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
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19*/
20
21#ifndef __IRCSETTINGS_H
22#define __IRCSETTINGS_H
23
24#include <qpe/config.h>
25#include <qdialog.h>
26
27class IRCSettings : public QDialog {
28 Q_OBJECT
29public:
30 IRCSettings(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0);
31 QString getColorString(QWidget *widget);
32 ~IRCSettings();
33protected slots:
34 void accept();
35protected:
36 Config *m_config;
37 QWidget *m_background;
38 QWidget *m_text;
39 QWidget *m_error;
40 QWidget *m_self;
41 QWidget *m_server;
42 QWidget *m_other;
43 QWidget *m_notification;
44};
45
46#endif /* __IRCSETTINGS_H */
diff --git a/noncore/net/opieirc/irctab.cpp b/noncore/net/opieirc/irctab.cpp
index 653a5de..6b578d1 100644
--- a/noncore/net/opieirc/irctab.cpp
+++ b/noncore/net/opieirc/irctab.cpp
@@ -1,19 +1,28 @@
1#include <qpe/resource.h> 1#include <qpe/resource.h>
2#include <qpixmap.h> 2#include <qpixmap.h>
3#include <qpushbutton.h> 3#include <qpushbutton.h>
4#include "irctab.h" 4#include "irctab.h"
5 5
6QString IRCTab::m_errorColor;
7QString IRCTab::m_serverColor;
8QString IRCTab::m_textColor;
9QString IRCTab::m_backgroundColor;
10QString IRCTab::m_selfColor;
11QString IRCTab::m_otherColor;
12QString IRCTab::m_notificationColor;
13
14
6IRCTab::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) {
7 m_layout = new QVBoxLayout(this); 16 m_layout = new QVBoxLayout(this);
8 QHBoxLayout *descLayout = new QHBoxLayout(m_layout); 17 QHBoxLayout *descLayout = new QHBoxLayout(m_layout);
9 descLayout->setMargin(5); 18 descLayout->setMargin(5);
10 m_description = new QLabel(tr("Missing description"), this); 19 m_description = new QLabel(tr("Missing description"), this);
11 descLayout->addWidget(m_description); 20 descLayout->addWidget(m_description);
12 descLayout->setStretchFactor(m_description, 5); 21 descLayout->setStretchFactor(m_description, 5);
13 QPushButton *close = new QPushButton(this); 22 QPushButton *close = new QPushButton(this);
14 close->setPixmap(Resource::loadPixmap("close")); 23 close->setPixmap(Resource::loadPixmap("close"));
15 connect(close, SIGNAL(clicked()), this, SLOT(remove())); 24 connect(close, SIGNAL(clicked()), this, SLOT(remove()));
16 descLayout->addWidget(close); 25 descLayout->addWidget(close);
17 descLayout->setStretchFactor(m_description, 1); 26 descLayout->setStretchFactor(m_description, 1);
18} 27}
19 28
diff --git a/noncore/net/opieirc/irctab.h b/noncore/net/opieirc/irctab.h
index 0ce9777..248ea13 100644
--- a/noncore/net/opieirc/irctab.h
+++ b/noncore/net/opieirc/irctab.h
@@ -1,48 +1,58 @@
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 __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 virtual QString title() = 0; 38 virtual QString title() = 0;
39 virtual IRCSession *session() = 0; 39 virtual IRCSession *session() = 0;
40 virtual void appendText(QString text) = 0; 40 virtual void appendText(QString text) = 0;
41public slots: 41public slots:
42 virtual void remove() = 0; 42 virtual void remove() = 0;
43 virtual void settingsChanged() = 0;
43protected: 44protected:
44 QLabel *m_description; 45 QLabel *m_description;
45 QVBoxLayout *m_layout; 46 QVBoxLayout *m_layout;
47public:
48 /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */
49 static QString m_errorColor;
50 static QString m_serverColor;
51 static QString m_textColor;
52 static QString m_backgroundColor;
53 static QString m_selfColor;
54 static QString m_otherColor;
55 static QString m_notificationColor;
46}; 56};
47 57
48#endif /* __IRCTAB_H */ 58#endif /* __IRCTAB_H */
diff --git a/noncore/net/opieirc/ircversion.h b/noncore/net/opieirc/ircversion.h
index f8510e6..f0f196e 100644
--- a/noncore/net/opieirc/ircversion.h
+++ b/noncore/net/opieirc/ircversion.h
@@ -1,27 +1,27 @@
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 __IRCVERSION_H 21#ifndef __IRCVERSION_H
22#define __IRCVERSION_H 22#define __IRCVERSION_H
23 23
24#define APP_VERSION "OpieIRC 0.2" 24#define APP_VERSION "OpieIRC 0.3"
25#define APP_COPYSTR "(c) 2002 by Wenzel Jakob" 25#define APP_COPYSTR "(c) 2002 by Wenzel Jakob"
26 26
27#endif /* __IRCVERSION_H */ 27#endif /* __IRCVERSION_H */
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp
index af4ce78..d78e5ab 100644
--- a/noncore/net/opieirc/mainwindow.cpp
+++ b/noncore/net/opieirc/mainwindow.cpp
@@ -1,55 +1,71 @@
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 10
10MainWindow::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) {
11 setCaption(tr("IRC Client")); 12 setCaption(tr("IRC Client"));
12 m_tabWidget = new QTabWidget(this); 13 m_tabWidget = new QTabWidget(this);
13 connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(tabSelected(QWidget *)));
14 setCentralWidget(m_tabWidget); 14 setCentralWidget(m_tabWidget);
15 setToolBarsMovable(FALSE); 15 setToolBarsMovable(FALSE);
16 QPEMenuBar *menuBar = new QPEMenuBar(this); 16 QPEMenuBar *menuBar = new QPEMenuBar(this);
17 QPopupMenu *irc = new QPopupMenu(this); 17 QPopupMenu *irc = new QPopupMenu(this);
18 menuBar->insertItem(tr("IRC"), irc); 18 menuBar->insertItem(tr("IRC"), irc);
19 QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); 19 QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0);
20 connect(a, SIGNAL(activated()), this, SLOT(newConnection())); 20 connect(a, SIGNAL(activated()), this, SLOT(newConnection()));
21 a->addTo(irc); 21 a->addTo(irc);
22 a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0);
23 connect(a, SIGNAL(activated()), this, SLOT(settings()));
24 a->addTo(irc);
25 loadSettings();
22} 26}
23 27
24void MainWindow::tabSelected(QWidget *) { 28void MainWindow::loadSettings() {
25} 29 Config config("OpieIRC");
26 30 config.setGroup("OpieIRC");
27void MainWindow::closeTab() { 31 IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF");
28 /* Does not directly close the tab but triggers an action 32 IRCTab::m_textColor = config.readEntry("TextColor", "#000000");
29 which at some point will close the tab using a callback */ 33 IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000");
30 IRCTab *tab = (IRCTab *)m_tabWidget->currentPage(); 34 IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000");
31 if (tab) { 35 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB");
32 tab->remove(); 36 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF");
33 } 37 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300");
34} 38}
35 39
36void MainWindow::addTab(IRCTab *tab) { 40void MainWindow::addTab(IRCTab *tab) {
37 m_tabWidget->addTab(tab, tab->title()); 41 m_tabWidget->addTab(tab, tab->title());
38 m_tabWidget->showPage(tab); 42 m_tabWidget->showPage(tab);
39 tabSelected(tab); 43 m_tabs.append(tab);
40} 44}
41 45
42void MainWindow::killTab(IRCTab *tab) { 46void MainWindow::killTab(IRCTab *tab) {
43 m_tabWidget->removePage(tab); 47 m_tabWidget->removePage(tab);
48 m_tabs.remove(tab);
44 /* there might be nicer ways to do this .. */ 49 /* there might be nicer ways to do this .. */
45 delete tab; 50 delete tab;
46} 51}
47 52
48void MainWindow::newConnection() { 53void MainWindow::newConnection() {
49 IRCServerList list(this, "ServerList", TRUE); 54 IRCServerList list(this, "ServerList", TRUE);
50 if (list.exec() == QDialog::Accepted && list.hasServer()) { 55 if (list.exec() == QDialog::Accepted && list.hasServer()) {
51 IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); 56 IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget);
52 addTab(serverTab); 57 addTab(serverTab);
53 serverTab->doConnect(); 58 serverTab->doConnect();
54 } 59 }
55} 60}
61
62void MainWindow::settings() {
63 IRCSettings settings(this, "Settings", TRUE);
64 if (settings.exec() == QDialog::Accepted) {
65 QListIterator<IRCTab> it(m_tabs);
66 for (; it.current(); ++it) {
67 /* Inform all tabs about the new settings */
68 it.current()->settingsChanged();
69 }
70 }
71}
diff --git a/noncore/net/opieirc/mainwindow.h b/noncore/net/opieirc/mainwindow.h
index dcb782f..d057178 100644
--- a/noncore/net/opieirc/mainwindow.h
+++ b/noncore/net/opieirc/mainwindow.h
@@ -1,45 +1,48 @@
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 __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 <qtabwidget.h> 27#include <qtabwidget.h>
27#include "mainwindow.h" 28#include "mainwindow.h"
28#include "irctab.h" 29#include "irctab.h"
29 30
30class MainWindow : public QMainWindow { 31class MainWindow : public QMainWindow {
31 Q_OBJECT 32 Q_OBJECT
32public: 33public:
33 MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); 34 MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
34 35
35 void addTab(IRCTab *tab); 36 void addTab(IRCTab *tab);
36 void killTab(IRCTab *tab); 37 void killTab(IRCTab *tab);
37protected slots: 38protected slots:
38 void newConnection(); 39 void newConnection();
39 void closeTab(); 40 void settings();
40 void tabSelected(QWidget *widget); 41protected:
42 void loadSettings();
41protected: 43protected:
42 QTabWidget *m_tabWidget; 44 QTabWidget *m_tabWidget;
45 QList<IRCTab> m_tabs;
43}; 46};
44 47
45#endif /* __MAINWINDOW_H */ 48#endif /* __MAINWINDOW_H */
diff --git a/noncore/net/opieirc/opieirc.pro b/noncore/net/opieirc/opieirc.pro
index 0e188e4..37742f5 100644
--- a/noncore/net/opieirc/opieirc.pro
+++ b/noncore/net/opieirc/opieirc.pro
@@ -1,24 +1,24 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin 3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS = ircchannel.h ircconnection.h \ 4 HEADERS = ircchannel.h ircconnection.h \
5 ircmessage.h \ 5 ircmessage.h \
6 ircmessageparser.h ircoutput.h \ 6 ircmessageparser.h ircoutput.h \
7 ircperson.h ircserver.h ircsession.h \ 7 ircperson.h ircserver.h ircsession.h \
8 mainwindow.h irctab.h ircservertab.h \ 8 mainwindow.h irctab.h ircservertab.h \
9 ircchanneltab.h ircchannellist.h \ 9 ircchanneltab.h ircchannellist.h \
10 ircserverlist.h ircservereditor.h \ 10 ircserverlist.h ircservereditor.h \
11 ircquerytab.h 11 ircquerytab.h ircsettings.h ircmisc.h
12 SOURCES = ircchannel.cpp ircconnection.cpp \ 12 SOURCES = ircchannel.cpp ircconnection.cpp \
13 ircmessage.cpp \ 13 ircmessage.cpp \
14 ircmessageparser.cpp ircoutput.cpp \ 14 ircmessageparser.cpp ircoutput.cpp \
15 ircperson.cpp ircserver.cpp \ 15 ircperson.cpp ircserver.cpp \
16 ircsession.cpp main.cpp mainwindow.cpp \ 16 ircsession.cpp main.cpp mainwindow.cpp \
17 irctab.cpp ircservertab.cpp \ 17 irctab.cpp ircservertab.cpp \
18 ircchanneltab.cpp ircchannellist.cpp \ 18 ircchanneltab.cpp ircchannellist.cpp \
19 ircserverlist.cpp ircservereditor.cpp \ 19 ircserverlist.cpp ircservereditor.cpp \
20 ircquerytab.cpp 20 ircquerytab.cpp ircsettings.cpp ircmisc.cpp
21INCLUDEPATH += $(OPIEDIR)/include 21INCLUDEPATH += $(OPIEDIR)/include
22 DEPENDPATH+= $(OPIEDIR)/include 22 DEPENDPATH+= $(OPIEDIR)/include
23LIBS += -lqpe 23LIBS += -lqpe -lopie
24 24