summaryrefslogtreecommitdiff
authorwazlaf <wazlaf>2002-09-23 22:12:39 (UTC)
committer wazlaf <wazlaf>2002-09-23 22:12:39 (UTC)
commit074769a4adb816153e47d63087e9e326bd3a04bf (patch) (side-by-side diff)
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,6 +1,5 @@
#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,4 +1,7 @@
+#include <qpe/qpeapplication.h>
+#include <qpe/resource.h>
+#include <qcursor.h>
#include <qhbox.h>
#include "ircchanneltab.h"
#include "ircservertab.h"
@@ -19,14 +22,26 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
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 */
@@ -48,17 +63,21 @@ void IRCChannelTab::processCommand() {
} 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("<");
@@ -68,8 +87,41 @@ void IRCChannelTab::toggleList() {
}
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();
}
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
@@ -20,8 +20,9 @@
#ifndef __IRCCHANNELTAB_H
#define __IRCCHANNELTAB_H
+#include <qpopupmenu.h>
#include <qpushbutton.h>
#include "irctab.h"
#include "ircsession.h"
#include "mainwindow.h"
@@ -43,18 +44,27 @@ public:
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,8 +1,7 @@
#include <qtextstream.h>
#include "ircmessageparser.h"
#include "ircversion.h"
-#include <stdio.h>
/* Lookup table for literal commands */
IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
{ "PING", FUNC(parseLiteralPing) },
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,6 +1,5 @@
#include "ircperson.h"
-#include <stdio.h>
IRCPerson::IRCPerson() {
m_nick = "";
m_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
@@ -17,9 +17,9 @@ IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow
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 */
@@ -42,25 +42,29 @@ void IRCQueryTab::processCommand() {
} 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();
}
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
@@ -38,8 +38,9 @@ public:
public slots:
void remove();
void processCommand();
void display(IRCOutput output);
+ void settingsChanged();
protected:
bool m_close;
MainWindow *m_mainWindow;
IRCServerTab *m_parentTab;
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
@@ -32,8 +32,9 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char*
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();
}
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,12 +1,10 @@
-#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()) {
@@ -101,9 +99,8 @@ 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");
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,5 +1,5 @@
-#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) {
@@ -17,8 +17,9 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa
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 */
@@ -37,8 +38,12 @@ 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";
}
@@ -49,8 +54,12 @@ IRCSession *IRCServerTab::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;
@@ -61,21 +70,21 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
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;
@@ -84,14 +93,14 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
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() {
@@ -162,12 +171,12 @@ void IRCServerTab::display(IRCOutput output) {
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: {
@@ -177,9 +186,9 @@ void IRCServerTab::display(IRCOutput output) {
}
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: {
@@ -198,25 +207,25 @@ void IRCServerTab::display(IRCOutput output) {
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();
}
}
}
@@ -225,19 +234,19 @@ void IRCServerTab::display(IRCOutput output) {
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
@@ -41,18 +41,21 @@ public:
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;
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
@@ -2,8 +2,17 @@
#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);
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
@@ -39,10 +39,20 @@ public:
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
@@ -20,8 +20,8 @@
#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
@@ -5,43 +5,48 @@
#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;
}
@@ -52,4 +57,15 @@ void MainWindow::newConnection() {
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
@@ -22,8 +22,9 @@
#define __MAINWINDOW_H
#include <qmainwindow.h>
#include <qaction.h>
+#include <qlist.h>
#include <qtabwidget.h>
#include "mainwindow.h"
#include "irctab.h"
@@ -35,11 +36,13 @@ public:
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
@@ -7,18 +7,18 @@ HEADERS = ircchannel.h ircconnection.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