summaryrefslogtreecommitdiff
Side-by-side diff
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,8 +1,7 @@
#include "ircchannel.h"
-#include <stdio.h>
IRCChannel::IRCChannel(QString channelname) {
m_hasPeople = FALSE;
m_channelname = channelname;
}
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,6 +1,9 @@
+#include <qpe/qpeapplication.h>
+#include <qpe/resource.h>
+#include <qcursor.h>
#include <qhbox.h>
#include "ircchanneltab.h"
#include "ircservertab.h"
IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
m_mainWindow = mainWindow;
@@ -17,18 +20,30 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
m_textview->setTextFormat(RichText);
connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
m_list = new IRCChannelList(m_channel, hbox);
m_list->update();
m_list->setMaximumWidth(LISTWIDTH);
m_field = new QLineEdit(this);
+ m_popup = new QPopupMenu(m_list);
+ /* Required so that embedded-style "right" clicks work */
+ QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold);
+ connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &)));
+ /* Construct the popup menu */
+ QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
+ m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu);
+ m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery()));
+ ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing()));
+ ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
+ ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
+
m_layout->add(hbox);
hbox->show();
m_layout->add(m_field);
m_field->setFocus();
connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
-
+ settingsChanged();
}
void IRCChannelTab::appendText(QString text) {
/* not using append because it creates layout problems */
m_textview->setText(m_textview->text() + text);
m_textview->ensureVisible(0, m_textview->contentsHeight());
@@ -46,32 +61,69 @@ void IRCChannelTab::processCommand() {
/* Command mode */
m_parentTab->executeCommand(this, text);;
} else {
if (text.startsWith("//"))
text = text.right(text.length()-1);
session()->sendMessage(m_channel, m_field->text());
- appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+IRCOutput::toHTML(m_field->text())+"<br>");
+ 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>");
}
} else {
- appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>");
+ appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
}
}
m_field->clear();
}
+void IRCChannelTab::settingsChanged() {
+ m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
+}
+
void IRCChannelTab::toggleList() {
if (m_listVisible) {
m_list->setMaximumWidth(0);
m_listButton->setText("<");
} else {
m_list->setMaximumWidth(LISTWIDTH);
m_listButton->setText(">");
}
m_listVisible = !m_listVisible;
}
+void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) {
+ switch (mouse) {
+ case 1:
+ break;
+ case 2:
+ m_popup->popup(point);
+ break;
+ };
+}
+
+void IRCChannelTab::popupQuery() {
+ if (m_list->currentItem() != -1) {
+ IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text());
+ if (person) {
+ IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
+ if (!tab) {
+ tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent());
+ m_parentTab->addQueryTab(tab);
+ m_mainWindow->addTab(tab);
+ }
+ }
+ }
+}
+
+void IRCChannelTab::popupPing() {
+}
+
+void IRCChannelTab::popupVersion() {
+}
+
+void IRCChannelTab::popupWhois() {
+}
+
QString IRCChannelTab::title() {
return m_channel->channelname();
}
IRCSession *IRCChannelTab::session() {
return m_parentTab->session();
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
@@ -18,12 +18,13 @@
*/
#ifndef __IRCCHANNELTAB_H
#define __IRCCHANNELTAB_H
+#include <qpopupmenu.h>
#include <qpushbutton.h>
#include "irctab.h"
#include "ircsession.h"
#include "mainwindow.h"
#include "ircchannellist.h"
@@ -41,20 +42,29 @@ public:
IRCChannel *channel();
IRCChannelList *list();
public:
void appendText(QString text);
public slots:
void remove();
+ void settingsChanged();
+protected slots:
void processCommand();
void toggleList();
+ void mouseButtonPressed(int mouse, QListBoxItem *item, const QPoint &point);
+ /* Popup slots */
+ void popupQuery();
+ void popupPing();
+ void popupVersion();
+ void popupWhois();
protected:
IRCServerTab *m_parentTab;
IRCChannel *m_channel;
IRCChannelList *m_list;
QPushButton *m_listButton;
MainWindow *m_mainWindow;
QTextView *m_textview;
QLineEdit *m_field;
+ QPopupMenu *m_popup;
bool m_listVisible;
};
#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,10 +1,9 @@
#include <qtextstream.h>
#include "ircmessageparser.h"
#include "ircversion.h"
-#include <stdio.h>
/* Lookup table for literal commands */
IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
{ "PING", FUNC(parseLiteralPing) },
{ "NOTICE", FUNC(parseLiteralNotice) },
{ "JOIN", FUNC(parseLiteralJoin) },
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 @@
+#include <opie/colordialog.h>
+#include <qlayout.h>
+#include "ircmisc.h"
+
+IRCColorLabel::IRCColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QLabel(parent, name, f) {
+ m_color = color;
+ setAlignment(AlignVCenter | AlignCenter);
+ setFrameStyle(QFrame::StyledPanel);
+ setFrameShadow(QFrame::Sunken);
+ setBackgroundColor(m_color);
+}
+
+void IRCColorLabel::mousePressEvent(QMouseEvent *) {
+ m_color = OColorDialog::getColor(m_color);
+ setBackgroundColor(m_color);
+}
+
+QColor IRCColorLabel::color() {
+ return m_color;
+}
+
+IRCFramedColorLabel::IRCFramedColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) {
+ QVBoxLayout *layout = new QVBoxLayout(this, 10, 0);
+ m_label = new IRCColorLabel(color, this);
+ layout->addWidget(m_label);
+}
+
+QColor IRCFramedColorLabel::color() {
+ return m_label->color();
+}
+
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 @@
+/*
+ OpieIRC - An embedded IRC client
+ Copyright (C) 2002 Wenzel Jakob
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#ifndef __IRCMISC_H
+#define __IRCMISC_H
+
+#include <qlabel.h>
+#include <qcolor.h>
+
+class IRCColorLabel : public QLabel {
+ public:
+ IRCColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
+ QColor color();
+ void mousePressEvent(QMouseEvent *event);
+ protected:
+ QColor m_color;
+};
+
+class IRCFramedColorLabel : public QWidget {
+ public:
+ IRCFramedColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
+ QColor color();
+ protected:
+ IRCColorLabel *m_label;
+};
+
+#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,8 +1,7 @@
#include "ircperson.h"
-#include <stdio.h>
IRCPerson::IRCPerson() {
m_nick = "";
m_user = "";
m_host = "";
}
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
@@ -15,13 +15,13 @@ IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow
m_field = new QLineEdit(this);
m_layout->add(hbox);
hbox->show();
m_layout->add(m_field);
m_field->setFocus();
connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
-
+ settingsChanged();
}
void IRCQueryTab::appendText(QString text) {
/* not using append because it creates layout problems */
m_textview->setText(m_textview->text() + text);
m_textview->ensureVisible(0, m_textview->contentsHeight());
@@ -40,29 +40,33 @@ void IRCQueryTab::processCommand() {
/* Command mode */
m_parentTab->executeCommand(this, text);;
} else {
if (text.startsWith("//"))
text = text.right(text.length()-1);
session()->sendMessage(m_person, m_field->text());
- appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+IRCOutput::toHTML(m_field->text())+"<br>");
+ 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>");
}
} else {
- appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>");
+ appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
}
}
m_field->clear();
}
void IRCQueryTab::display(IRCOutput output) {
if (output.type() == OUTPUT_QUERYPRIVMSG) {
- appendText("&lt;<font color=\"#0000dd\">"+m_person->nick()+"</font>&gt; " + output.htmlMessage() + "<br>");
+ appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage() + "</font><br>");
} else if (output.type() == OUTPUT_QUERYACTION) {
- appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "<br>");
+ appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>");
}
}
+void IRCQueryTab::settingsChanged() {
+ m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
+}
+
QString IRCQueryTab::title() {
return m_person->nick();
}
IRCSession *IRCQueryTab::session() {
return m_parentTab->session();
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
@@ -36,12 +36,13 @@ public:
IRCPerson *person();
void appendText(QString text);
public slots:
void remove();
void processCommand();
void display(IRCOutput output);
+ void settingsChanged();
protected:
bool m_close;
MainWindow *m_mainWindow;
IRCServerTab *m_parentTab;
IRCPerson *m_person;
QTextView *m_textview;
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
@@ -30,12 +30,13 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char*
layout->addWidget(label, 5, 0);
layout->addWidget(m_password, 5, 1);
label = new QLabel(tr("Channels :"), this);
m_channels = new QLineEdit(server.channels(), this);
layout->addWidget(label, 6, 0);
layout->addWidget(m_channels, 6, 1);
+ setCaption(tr("Edit server information"));
showMaximized();
}
void IRCServerEditor::accept() {
if (m_name->text().length()==0)
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,14 +1,12 @@
-#include <stdio.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qhbox.h>
#include <qpushbutton.h>
#include "ircserverlist.h"
#include "ircservereditor.h"
-#include <stdio.h>
class IRCListBoxServer : public QListBoxText {
public:
IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) {
m_server = server;
}
@@ -99,13 +97,12 @@ void IRCServerList::editServer() {
}
int IRCServerList::exec() {
int returncode = QDialog::exec();
/* Now save the changes */
m_config->setGroup("OpieIRC");
- m_config->clearGroup();
m_config->writeEntry("ServerCount", QString::number(m_list->count()));
for (unsigned int i=0; i<m_list->count(); i++) {
IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server();
m_config->setGroup("OpieIRC");
m_config->writeEntry("Server"+QString::number(i), server.name());
m_config->setGroup(server.name());
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,7 +1,7 @@
-#include <stdio.h>
+#include <qpe/config.h>
#include <qtextstream.h>
#include "ircservertab.h"
IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
m_server = server;
m_session = new IRCSession(&m_server);
@@ -15,12 +15,13 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa
m_layout->add(m_textview);
m_field = new QLineEdit(this);
m_layout->add(m_field);
connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
m_field->setFocus();
connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
+ settingsChanged();
}
void IRCServerTab::appendText(QString text) {
/* not using append because it creates layout problems */
m_textview->setText(m_textview->text() + text);
m_textview->ensureVisible(0, m_textview->contentsHeight());
@@ -35,65 +36,73 @@ void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
}
void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
m_queryTabs.remove(tab);
}
+void IRCServerTab::addQueryTab(IRCQueryTab *tab) {
+ m_queryTabs.append(tab);
+}
+
QString IRCServerTab::title() {
return "Server";
}
IRCSession *IRCServerTab::session() {
return m_session;
}
IRCServer *IRCServerTab::server() {
return &m_server;
}
+void IRCServerTab::settingsChanged() {
+ m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
+}
+
void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
QTextIStream stream(&line);
QString command;
stream >> command;
command = command.upper().right(command.length()-1);
if (command == "JOIN") {
QString channel;
stream >> channel;
if (channel.length() > 0 && channel.startsWith("#")) {
m_session->join(channel);
} else {
- tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>");
+ tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>");
}
} else if (command == "ME") {
QString text = line.right(line.length()-4);
if (text.length() > 0) {
if (tab->isA("IRCChannelTab")) {
- tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
+ tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
m_session->sendAction(((IRCChannelTab *)tab)->channel(), text);
} else if (tab->isA("IRCQueryTab")) {
- tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
+ tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
m_session->sendAction(((IRCQueryTab *)tab)->person(), text);
} else {
- tab->appendText("<font color=\"#ff0000\">Invalid tab for this command</font><br>");
+ tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>");
}
}
} else if (command == "MSG") {
QString nickname;
stream >> nickname;
if (nickname.length() > 0) {
if (line.length() > 6 + nickname.length()) {
QString text = line.right(line.length()-nickname.length()-6);
IRCPerson person;
person.setNick(nickname);
- tab->appendText("&gt;<font color=\"#0000dd\">"+IRCOutput::toHTML(nickname)+"</font>&lt; "+IRCOutput::toHTML(text)+"<br>");
+ 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>");
m_session->sendMessage(&person, text);
}
}
} else {
- tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>");
+ tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>");
}
}
void IRCServerTab::processCommand() {
QString text = m_field->text();
if (text.startsWith("/") && !text.startsWith("//")) {
@@ -160,28 +169,28 @@ void IRCServerTab::display(IRCOutput output) {
m_queryTabs.first();
while (m_queryTabs.current() != 0) {
m_mainWindow->killTab(m_queryTabs.current());
}
m_mainWindow->killTab(this);
} else {
- appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>");
+ appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>");
QListIterator<IRCChannelTab> it(m_channelTabs);
for (; it.current(); ++it) {
- it.current()->appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>");
+ it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>");
}
}
break;
case OUTPUT_SELFJOIN: {
IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
m_channelTabs.append(channeltab);
m_mainWindow->addTab(channeltab);
}
break;
case OUTPUT_CHANPRIVMSG: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
- channelTab->appendText("&lt;<font color=\"#0000dd\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font>&gt; "+output.htmlMessage()+"<br>");
+ 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>");
}
break;
case OUTPUT_QUERYACTION:
case OUTPUT_QUERYPRIVMSG: {
IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0));
if (!queryTab) {
@@ -196,48 +205,48 @@ void IRCServerTab::display(IRCOutput output) {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
if (channelTab)
m_mainWindow->killTab(channelTab);
}
break;
case OUTPUT_SELFKICK: {
- appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>");
+ appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
if (channelTab)
m_mainWindow->killTab(channelTab);
}
break;
case OUTPUT_CHANACTION: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
- channelTab->appendText("<font color=\"#cc0000\">"+output.htmlMessage()+"</font><br>");
+ channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>");
}
break;
case OUTPUT_QUIT: {
QString nick = ((IRCPerson *)output.getParam(0))->nick();
QListIterator<IRCChannelTab> it(m_channelTabs);
for (; it.current(); ++it) {
if (it.current()->list()->hasPerson(nick)) {
- it.current()->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>");
+ it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
it.current()->list()->update();
}
}
}
break;
case OUTPUT_OTHERJOIN:
case OUTPUT_OTHERKICK:
case OUTPUT_CHANPERSONMODE:
case OUTPUT_OTHERPART: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
- channelTab->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>");
+ channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
channelTab->list()->update();
}
break;
case OUTPUT_CTCP:
- appendText("<font color=\"#00bb00\">" + output.htmlMessage() + "</font><br>");
+ appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>");
break;
case OUTPUT_ERROR:
- appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>");
+ appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
break;
default:
- appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "</font><br>");
+ appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>");
break;
}
}
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
@@ -39,22 +39,25 @@ public:
/* Start the server session */
void doConnect();
/* Remove tabs from the internal tab lists */
void removeChannelTab(IRCChannelTab *tab);
void removeQueryTab(IRCQueryTab *tab);
-
- /* Execute a user command such as /join */
+ /* Return tabs from the internal tab lists */
+ IRCChannelTab *getTabForChannel(IRCChannel *channel);
+ IRCQueryTab *getTabForQuery(IRCPerson *person);
+ /* Add tabs to the internal tab lists */
+ void addQueryTab(IRCQueryTab *tab);
+ /* Execute a user command such as /join, /msg etc */
void executeCommand(IRCTab *tab, QString line);
protected:
void appendText(QString text);
- IRCChannelTab *getTabForChannel(IRCChannel *channel);
- IRCQueryTab *getTabForQuery(IRCPerson *person);
public slots:
void remove();
void processCommand();
+ void settingsChanged();
protected slots:
void display(IRCOutput output);
protected:
bool m_close;
IRCServer m_server;
IRCSession *m_session;
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 @@
+#include <qlayout.h>
+#include "ircsettings.h"
+#include "irctab.h"
+#include "ircmisc.h"
+#include <stdio.h>
+
+IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags f) : QDialog(parent, name, modal, f) {
+ m_config = new Config("OpieIRC");
+ m_config->setGroup("OpieIRC");
+
+ setCaption("Settings");
+ QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 0);
+ QLabel *label = new QLabel(tr("Background color :"), this);
+ layout->addWidget(label, 0, 0);
+ m_background = new IRCFramedColorLabel(QColor(m_config->readEntry("BackgroundColor", "#FFFFFF")), this);
+ layout->addWidget(m_background, 0, 1);
+ label = new QLabel(tr("Normal text color :"), this);
+ layout->addWidget(label, 1, 0);
+ m_text = new IRCFramedColorLabel(m_config->readEntry("TextColor", "#000000"), this);
+ layout->addWidget(m_text, 1, 1);
+ label = new QLabel(tr("Error color :"), this);
+ layout->addWidget(label, 2, 0);
+ m_error = new IRCFramedColorLabel(m_config->readEntry("ErrorColor", "#FF0000"), this);
+ layout->addWidget(m_error, 2, 1);
+ label = new QLabel(tr("Text written by yourself :"), this);
+ layout->addWidget(label, 3, 0);
+ m_self = new IRCFramedColorLabel(m_config->readEntry("SelfColor", "#CC0000"), this);
+ layout->addWidget(m_self, 3, 1);
+ label = new QLabel(tr("Text written by others :"), this);
+ layout->addWidget(label, 4, 0);
+ m_other = new IRCFramedColorLabel(m_config->readEntry("OtherColor", "#0000BB"), this);
+ layout->addWidget(m_other, 4, 1);
+ label = new QLabel(tr("Text written by the server :"), this);
+ layout->addWidget(label, 5, 0);
+ m_server = new IRCFramedColorLabel(m_config->readEntry("ServerColor", "#0000FF"), this);
+ layout->addWidget(m_server, 5, 1);
+ label = new QLabel(tr("Notifications :"), this);
+ layout->addWidget(label, 6, 0);
+ m_notification = new IRCFramedColorLabel(m_config->readEntry("NotificationColor", "#AAE300"), this);
+ layout->addWidget(m_notification, 6, 1);
+ showMaximized();
+}
+
+QString IRCSettings::getColorString(QWidget *widget) {
+ QColor color = ((IRCFramedColorLabel *)widget)->color();
+ QString temp;
+ temp.sprintf("#%02x%02x%02x", color.red(), color.green(), color.blue());
+ return temp;
+}
+
+void IRCSettings::accept() {
+ IRCTab::m_backgroundColor = getColorString(m_background);
+ IRCTab::m_textColor = getColorString(m_text);
+ IRCTab::m_errorColor = getColorString(m_error);
+ IRCTab::m_selfColor = getColorString(m_self);
+ IRCTab::m_otherColor = getColorString(m_other);
+ IRCTab::m_serverColor = getColorString(m_server);
+ IRCTab::m_notificationColor = getColorString(m_notification);
+ m_config->writeEntry("BackgroundColor", getColorString(m_background));
+ m_config->writeEntry("TextColor", getColorString(m_text));
+ m_config->writeEntry("ErrorColor", getColorString(m_error));
+ m_config->writeEntry("SelfColor", getColorString(m_self));
+ m_config->writeEntry("OtherColor", getColorString(m_other));
+ m_config->writeEntry("ServerColor", getColorString(m_server));
+ m_config->writeEntry("NotificationColor", getColorString(m_notification));
+ QDialog::accept();
+}
+
+IRCSettings::~IRCSettings() {
+ delete m_config;
+}
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 @@
+/*
+ OpieIRC - An embedded IRC client
+ Copyright (C) 2002 Wenzel Jakob
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#ifndef __IRCSETTINGS_H
+#define __IRCSETTINGS_H
+
+#include <qpe/config.h>
+#include <qdialog.h>
+
+class IRCSettings : public QDialog {
+ Q_OBJECT
+public:
+ IRCSettings(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0);
+ QString getColorString(QWidget *widget);
+ ~IRCSettings();
+protected slots:
+ void accept();
+protected:
+ Config *m_config;
+ QWidget *m_background;
+ QWidget *m_text;
+ QWidget *m_error;
+ QWidget *m_self;
+ QWidget *m_server;
+ QWidget *m_other;
+ QWidget *m_notification;
+};
+
+#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,11 +1,20 @@
#include <qpe/resource.h>
#include <qpixmap.h>
#include <qpushbutton.h>
#include "irctab.h"
+QString IRCTab::m_errorColor;
+QString IRCTab::m_serverColor;
+QString IRCTab::m_textColor;
+QString IRCTab::m_backgroundColor;
+QString IRCTab::m_selfColor;
+QString IRCTab::m_otherColor;
+QString IRCTab::m_notificationColor;
+
+
IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) {
m_layout = new QVBoxLayout(this);
QHBoxLayout *descLayout = new QHBoxLayout(m_layout);
descLayout->setMargin(5);
m_description = new QLabel(tr("Missing description"), this);
descLayout->addWidget(m_description);
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
@@ -37,12 +37,22 @@ public:
IRCTab(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
virtual QString title() = 0;
virtual IRCSession *session() = 0;
virtual void appendText(QString text) = 0;
public slots:
virtual void remove() = 0;
+ virtual void settingsChanged() = 0;
protected:
QLabel *m_description;
QVBoxLayout *m_layout;
+public:
+ /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */
+ static QString m_errorColor;
+ static QString m_serverColor;
+ static QString m_textColor;
+ static QString m_backgroundColor;
+ static QString m_selfColor;
+ static QString m_otherColor;
+ static QString m_notificationColor;
};
#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
@@ -18,10 +18,10 @@
*/
#ifndef __IRCVERSION_H
#define __IRCVERSION_H
-#define APP_VERSION "OpieIRC 0.2"
+#define APP_VERSION "OpieIRC 0.3"
#define APP_COPYSTR "(c) 2002 by Wenzel Jakob"
#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
@@ -3,53 +3,69 @@
#include <qpe/config.h>
#include <qpopupmenu.h>
#include "mainwindow.h"
#include "ircservertab.h"
#include "ircserverlist.h"
+#include "ircsettings.h"
MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) {
setCaption(tr("IRC Client"));
m_tabWidget = new QTabWidget(this);
- connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(tabSelected(QWidget *)));
setCentralWidget(m_tabWidget);
setToolBarsMovable(FALSE);
QPEMenuBar *menuBar = new QPEMenuBar(this);
QPopupMenu *irc = new QPopupMenu(this);
menuBar->insertItem(tr("IRC"), irc);
QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0);
connect(a, SIGNAL(activated()), this, SLOT(newConnection()));
a->addTo(irc);
+ a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0);
+ connect(a, SIGNAL(activated()), this, SLOT(settings()));
+ a->addTo(irc);
+ loadSettings();
}
-void MainWindow::tabSelected(QWidget *) {
-}
-
-void MainWindow::closeTab() {
- /* Does not directly close the tab but triggers an action
- which at some point will close the tab using a callback */
- IRCTab *tab = (IRCTab *)m_tabWidget->currentPage();
- if (tab) {
- tab->remove();
- }
+void MainWindow::loadSettings() {
+ Config config("OpieIRC");
+ config.setGroup("OpieIRC");
+ IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF");
+ IRCTab::m_textColor = config.readEntry("TextColor", "#000000");
+ IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000");
+ IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000");
+ IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB");
+ IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF");
+ IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300");
}
void MainWindow::addTab(IRCTab *tab) {
m_tabWidget->addTab(tab, tab->title());
m_tabWidget->showPage(tab);
- tabSelected(tab);
+ m_tabs.append(tab);
}
void MainWindow::killTab(IRCTab *tab) {
m_tabWidget->removePage(tab);
+ m_tabs.remove(tab);
/* there might be nicer ways to do this .. */
delete tab;
}
void MainWindow::newConnection() {
IRCServerList list(this, "ServerList", TRUE);
if (list.exec() == QDialog::Accepted && list.hasServer()) {
IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget);
addTab(serverTab);
serverTab->doConnect();
}
}
+
+void MainWindow::settings() {
+ IRCSettings settings(this, "Settings", TRUE);
+ if (settings.exec() == QDialog::Accepted) {
+ QListIterator<IRCTab> it(m_tabs);
+ for (; it.current(); ++it) {
+ /* Inform all tabs about the new settings */
+ it.current()->settingsChanged();
+ }
+ }
+}
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
@@ -20,12 +20,13 @@
#ifndef __MAINWINDOW_H
#define __MAINWINDOW_H
#include <qmainwindow.h>
#include <qaction.h>
+#include <qlist.h>
#include <qtabwidget.h>
#include "mainwindow.h"
#include "irctab.h"
class MainWindow : public QMainWindow {
Q_OBJECT
@@ -33,13 +34,15 @@ public:
MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
void addTab(IRCTab *tab);
void killTab(IRCTab *tab);
protected slots:
void newConnection();
- void closeTab();
- void tabSelected(QWidget *widget);
+ void settings();
+protected:
+ void loadSettings();
protected:
QTabWidget *m_tabWidget;
+ QList<IRCTab> m_tabs;
};
#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
@@ -5,20 +5,20 @@ HEADERS = ircchannel.h ircconnection.h \
ircmessage.h \
ircmessageparser.h ircoutput.h \
ircperson.h ircserver.h ircsession.h \
mainwindow.h irctab.h ircservertab.h \
ircchanneltab.h ircchannellist.h \
ircserverlist.h ircservereditor.h \
- ircquerytab.h
+ ircquerytab.h ircsettings.h ircmisc.h
SOURCES = ircchannel.cpp ircconnection.cpp \
ircmessage.cpp \
ircmessageparser.cpp ircoutput.cpp \
ircperson.cpp ircserver.cpp \
ircsession.cpp main.cpp mainwindow.cpp \
irctab.cpp ircservertab.cpp \
ircchanneltab.cpp ircchannellist.cpp \
ircserverlist.cpp ircservereditor.cpp \
- ircquerytab.cpp
+ ircquerytab.cpp ircsettings.cpp ircmisc.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe
+LIBS += -lqpe -lopie