author | wazlaf <wazlaf> | 2002-09-23 22:12:39 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-09-23 22:12:39 (UTC) |
commit | 074769a4adb816153e47d63087e9e326bd3a04bf (patch) (side-by-side diff) | |
tree | cc69651d9e9e5901696a55d9523e343125780705 | |
parent | e0b04701b3c9182ba22f56e329f98c57af4e1fe2 (diff) | |
download | opie-074769a4adb816153e47d63087e9e326bd3a04bf.zip opie-074769a4adb816153e47d63087e9e326bd3a04bf.tar.gz opie-074769a4adb816153e47d63087e9e326bd3a04bf.tar.bz2 |
configuration dialog + color configurability throughout the program + popup menu on the channel person list
-rw-r--r-- | noncore/net/opieirc/ircchannel.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchanneltab.cpp | 58 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchanneltab.h | 10 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmisc.cpp | 31 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmisc.h | 44 | ||||
-rw-r--r-- | noncore/net/opieirc/ircperson.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.cpp | 14 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.h | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservereditor.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserverlist.cpp | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 43 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.h | 11 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsettings.cpp | 71 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsettings.h | 46 | ||||
-rw-r--r-- | noncore/net/opieirc/irctab.cpp | 9 | ||||
-rw-r--r-- | noncore/net/opieirc/irctab.h | 10 | ||||
-rw-r--r-- | noncore/net/opieirc/ircversion.h | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 40 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.h | 7 | ||||
-rw-r--r-- | noncore/net/opieirc/opieirc.pro | 6 |
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 @@ #include "ircchannel.h" -#include <stdio.h> IRCChannel::IRCChannel(QString channelname) { m_hasPeople = FALSE; m_channelname = channelname; } IRCChannel::~IRCChannel() { /* We want this to get deleted */ m_people.setAutoDelete(TRUE); } QString IRCChannel::channelname() { return m_channelname; } bool IRCChannel::hasPeople() { return m_hasPeople; } void IRCChannel::setHasPeople(bool hasPeople) { m_hasPeople = hasPeople; } void IRCChannel::addPerson(IRCChannelPerson *person) { m_people.append(person); } void IRCChannel::removePerson(IRCChannelPerson *person) { m_people.remove(person); } QListIterator<IRCChannelPerson> IRCChannel::people() { QListIterator<IRCChannelPerson> it(m_people); return it; } IRCChannelPerson *IRCChannel::getPerson(QString nickname) { QListIterator<IRCChannelPerson> it(m_people); for (; it.current(); ++it) { if (it.current()->person->nick() == nickname) { return it.current(); } } return 0; } 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 @@ +#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; m_parentTab = parentTab; m_channel = channel; m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); QHBox *hbox = new QHBox(this); m_textview = new QTextView(hbox); m_textview->setHScrollBarMode(QScrollView::AlwaysOff); m_textview->setVScrollBarMode(QScrollView::AlwaysOn); m_listVisible = TRUE; m_listButton = new QPushButton(">", m_textview); m_textview->setCornerWidget(m_listButton); 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()); } IRCChannelTab::~IRCChannelTab() { m_parentTab->removeChannelTab(this); } void IRCChannelTab::processCommand() { QString text = m_field->text(); if (text.length()>0) { if (session()->isSessionActive()) { if (text.startsWith("/") && !text.startsWith("//")) { /* 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("<<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>> "+IRCOutput::toHTML(m_field->text())+"<br>"); + appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">> "+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(); } void IRCChannelTab::remove() { if (session()->isSessionActive()) { session()->part(m_channel); } else { m_mainWindow->killTab(this); } } IRCChannel *IRCChannelTab::channel() { return m_channel; } IRCChannelList *IRCChannelTab::list() { return m_list; } 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 @@ /* 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 __IRCCHANNELTAB_H #define __IRCCHANNELTAB_H +#include <qpopupmenu.h> #include <qpushbutton.h> #include "irctab.h" #include "ircsession.h" #include "mainwindow.h" #include "ircchannellist.h" #define LISTWIDTH 70 class IRCServerTab; class IRCChannelTab : public IRCTab { Q_OBJECT public: /* IRCTab implementation */ IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); ~IRCChannelTab(); QString title(); IRCSession *session(); 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,132 +1,131 @@ #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) }, { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, { "NICK", FUNC(parseLiteralNick) }, { "PART", FUNC(parseLiteralPart) }, { "QUIT", FUNC(parseLiteralQuit) }, { "ERROR", FUNC(parseLiteralError) }, { "ERROR:", FUNC(parseLiteralError) }, { "MODE", FUNC(parseLiteralMode) }, { "KICK", FUNC(parseLiteralKick) }, { 0 , 0 } }; /* Lookup table for literal commands */ IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { { "PING", FUNC(parseCTCPPing) }, { "VERSION", FUNC(parseCTCPVersion) }, { "ACTION", FUNC(parseCTCPAction) }, { 0 , 0 } }; /* Lookup table for numerical commands */ IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { { 1, FUNC(parseNumerical001) }, // RPL_WELCOME { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST { 3, FUNC(parseNumerical003) }, // RPL_CREATED { 4, FUNC(parseNumerical004) }, // RPL_MYINFO { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART { 372, FUNC(parseNumericalStats) }, // RPL_MOTD { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE { 0, 0 } }; IRCMessageParser::IRCMessageParser(IRCSession *session) { m_session = session; } void IRCMessageParser::parse(IRCMessage *message) { /* Find out what kind of message we have here and call the appropriate handler using the parser tables. If no handler can be found, print out an error message */ if (message->isNumerical()) { for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { (this->*(numericalParserProcTable[i].proc))(message); return; } } emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command : ")+QString::number(message->commandNumber()))); } else if (message->isCTCP()) { for (int i=0; ctcpParserProcTable[i].commandName; i++) { if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { (this->*(ctcpParserProcTable[i].proc))(message); return; } } emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command : ")+message->ctcpCommand())); } else { for (int i=0; literalParserProcTable[i].commandName; i++) { if (message->command() == literalParserProcTable[i].commandName) { (this->*(literalParserProcTable[i].proc))(message); return; } } emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command())); } } void IRCMessageParser::nullFunc(IRCMessage *) { /* Do nothing */ } void IRCMessageParser::parseLiteralPing(IRCMessage *message) { m_session->m_connection->sendLine("PONG " + message->allParameters()); } void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); } void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { QString channelName = message->param(0); IRCPerson mask(message->prefix()); IRCChannel *channel = m_session->getChannel(channelName); if (!channel) { /* We joined */ if (mask.nick() == m_session->m_server->nick()) { channel = new IRCChannel(channelName); m_session->addChannel(channel); } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); } } else { /* Someone else joined */ if (mask.nick() != m_session->m_server->nick()) { if (!channel->getPerson(mask.nick())) { IRCChannelPerson *chanperson = new IRCChannelPerson(); IRCPerson *person = m_session->getPerson(mask.nick()); if (!person) { person = new IRCPerson(message->prefix()); m_session->addPerson(person); } chanperson->flags = 0; chanperson->person = person; channel->addPerson(chanperson); IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName); output.addParam(channel); output.addParam(chanperson); emit outputReady(output); } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); } } else { 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,56 +1,55 @@ #include "ircperson.h" -#include <stdio.h> IRCPerson::IRCPerson() { m_nick = ""; m_user = ""; m_host = ""; } IRCPerson::IRCPerson(const IRCPerson &person) { m_nick = person.m_nick; m_user = person.m_user; m_host = person.m_host; } IRCPerson::IRCPerson(QString mask) { IRCPerson(); fromMask(mask); } void IRCPerson::fromMask(QString mask) { int sep1 = mask.find("!"); int sep2 = mask.find("@"); m_nick = mask.left(sep1); m_user = mask.mid(sep1+1, sep2-sep1-1); m_host = mask.right(mask.length()-sep2-1); } QString IRCPerson::toMask() { return m_nick + "!" + m_user + "@" + m_host; } void IRCPerson::setNick(QString nick) { m_nick = nick; } void IRCPerson::setUser(QString user) { m_user = user; } void IRCPerson::setHost(QString host) { m_host = host; } QString IRCPerson::nick() { return m_nick; } QString IRCPerson::user() { return m_user; } QString IRCPerson::host() { return 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 @@ -1,78 +1,82 @@ #include <qhbox.h> #include "ircquerytab.h" #include "ircservertab.h" IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { m_mainWindow = mainWindow; m_parentTab = parentTab; m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */ m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>"); QHBox *hbox = new QHBox(this); m_textview = new QTextView(hbox); m_textview->setHScrollBarMode(QScrollView::AlwaysOff); m_textview->setVScrollBarMode(QScrollView::AlwaysOn); m_textview->setTextFormat(RichText); 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()); } IRCQueryTab::~IRCQueryTab() { m_parentTab->removeQueryTab(this); delete m_person; } void IRCQueryTab::processCommand() { QString text = m_field->text(); if (text.length()>0) { if (session()->isSessionActive()) { if (text.startsWith("/") && !text.startsWith("//")) { /* 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("<<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>> "+IRCOutput::toHTML(m_field->text())+"<br>"); + appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">> "+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("<<font color=\"#0000dd\">"+m_person->nick()+"</font>> " + output.htmlMessage() + "<br>"); + appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">> " + 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(); } void IRCQueryTab::remove() { m_mainWindow->killTab(this); } IRCPerson *IRCQueryTab::person() { return m_person; } 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 @@ /* 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 __IRCQUERYTAB_H #define __IRCQUERYTAB_H #include "ircsession.h" #include "mainwindow.h" class IRCServerTab; class IRCQueryTab : public IRCTab { Q_OBJECT public: /* IRCTab implementation */ IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); ~IRCQueryTab(); QString title(); IRCSession *session(); 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; QLineEdit *m_field; }; #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 @@ #include <qmessagebox.h> #include <qlayout.h> #include <qlabel.h> #include "ircservereditor.h" IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) { QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); QLabel *label = new QLabel(tr("Profile name :"), this); m_name = new QLineEdit(server.name(), this); layout->addWidget(label, 0, 0); layout->addWidget(m_name, 0, 1); label = new QLabel(tr("Hostname :"), this); m_hostname = new QLineEdit(server.hostname(), this); layout->addWidget(label, 1, 0); layout->addWidget(m_hostname, 1, 1); label = new QLabel(tr("Port :"), this); m_port = new QLineEdit(QString::number(server.port()), this); layout->addWidget(label, 2, 0); layout->addWidget(m_port, 2, 1); label = new QLabel(tr("Nickname :"), this); m_nickname = new QLineEdit(server.nick(), this); layout->addWidget(label, 3, 0); layout->addWidget(m_nickname, 3, 1); label = new QLabel(tr("Realname :"), this); m_realname = new QLineEdit(server.realname(), this); layout->addWidget(label, 4, 0); layout->addWidget(m_realname, 4, 1); label = new QLabel(tr("Password :"), this); m_password = new QLineEdit(server.password(), this); 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) QMessageBox::critical(this, tr("Error"), tr("Profile name required")); else if (m_hostname->text().length()==0) QMessageBox::critical(this, tr("Error"), tr("Host name required")); else if (m_port->text().toInt()<=0) QMessageBox::critical(this, tr("Error"), tr("Port required")); else if (m_nickname->text().length()==0) QMessageBox::critical(this, tr("Error"), tr("Nickname required")); else if (m_realname->text().length()==0) QMessageBox::critical(this, tr("Error"), tr("Realname required")); else { /* Now verify whether the channel list has a valid format */ QStringList channels = QStringList::split(QChar(','), m_channels->text()); for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { QString channelName = (*it).stripWhiteSpace(); if (!channelName.startsWith("#")) { QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with '#'")); return; } } QDialog::accept(); } } IRCServer IRCServerEditor::getServer() { IRCServer server; server.setName(m_name->text()); server.setHostname(m_hostname->text()); server.setPort(m_port->text().toInt()); server.setNick(m_nickname->text()); server.setRealname(m_realname->text()); server.setUsername(m_nickname->text()); server.setPassword(m_password->text()); server.setChannels(m_channels->text()); return server; } 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 @@ -#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; } IRCServer server() { return m_server; } void setServer(IRCServer server) { m_server = server; setText(m_server.name()); } protected: IRCServer m_server; }; IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags f) : QDialog(parent, name, modal, f) { QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); setCaption(tr("Serverlist Browser")); QLabel *label = new QLabel(tr("Please choose a server profile"), this); label->setAlignment(AlignHCenter); layout->addWidget(label); m_list = new QListBox(this); layout->addWidget(m_list); QHBox *buttons = new QHBox(this); QPushButton *del = new QPushButton(tr("Delete"), buttons); QPushButton *edit = new QPushButton(tr("Edit"), buttons); QPushButton *add = new QPushButton(tr("Add"), buttons); connect(del, SIGNAL(clicked()), this, SLOT(delServer())); connect(edit, SIGNAL(clicked()), this, SLOT(editServer())); connect(add, SIGNAL(clicked()), this, SLOT(addServer())); layout->addWidget(buttons); /* Load the configuration file */ m_config = new Config("OpieIRC"); m_config->setGroup("OpieIRC"); int count = m_config->readNumEntry("ServerCount", 0); if (count) { for (int i=0; i<count; i++) { m_config->setGroup("OpieIRC"); QString name = m_config->readEntry("Server"+QString::number(i)); if (name.length() > 0) { IRCServer server; m_config->setGroup(name); server.setName(name); server.setHostname(m_config->readEntry("Hostname")); server.setPort(m_config->readNumEntry("Port")); server.setUsername(m_config->readEntry("Username")); server.setPassword(m_config->readEntry("Password")); server.setNick(m_config->readEntry("Nick")); server.setRealname(m_config->readEntry("Realname")); server.setChannels(m_config->readEntry("Channels")); m_list->insertItem(new IRCListBoxServer(server)); } } } showMaximized(); } void IRCServerList::addServer() { IRCServer server; IRCServerEditor editor(server, this, "ServerEditor", TRUE); if (editor.exec() == QDialog::Accepted) { server = editor.getServer(); /* Gets deleted by QListBox, so this is ok */ m_list->insertItem(new IRCListBoxServer(server)); } } void IRCServerList::delServer() { int index = m_list->currentItem(); if (index != -1) { m_list->removeItem(index); } } void IRCServerList::editServer() { int index = m_list->currentItem(); if (index != -1) { IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); IRCServer server = item->server(); IRCServerEditor editor(server, this, "ServerEditor", TRUE); if (editor.exec() == QDialog::Accepted) { server = editor.getServer(); item->setServer(server); } } } 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()); m_config->writeEntry("Hostname", server.hostname()); m_config->writeEntry("Port", QString::number(server.port())); m_config->writeEntry("Username", server.username()); m_config->writeEntry("Password", server.password()); m_config->writeEntry("Nick", server.nick()); m_config->writeEntry("Realname", server.realname()); m_config->writeEntry("Channels", server.channels()); } return returncode; } bool IRCServerList::hasServer() { return (m_list->currentItem() != -1); } IRCServer IRCServerList::server() { return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server(); } IRCServerList::~IRCServerList() { delete m_config; } 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 @@ -#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); m_mainWindow = mainWindow; m_close = FALSE; m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); m_textview = new QTextView(this); m_textview->setHScrollBarMode(QScrollView::AlwaysOff); m_textview->setVScrollBarMode(QScrollView::AlwaysOn); m_textview->setTextFormat(RichText); 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()); } IRCServerTab::~IRCServerTab() { delete m_session; } void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { m_channelTabs.remove(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("><font color=\"#0000dd\">"+IRCOutput::toHTML(nickname)+"</font>< "+IRCOutput::toHTML(text)+"<br>"); + tab->appendText("<font color=\"" + m_textColor + "\">></font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">< "+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("//")) { /* Command mode */ executeCommand(this, text); } m_field->clear(); } void IRCServerTab::doConnect() { m_session->beginSession(); } void IRCServerTab::remove() { /* Close requested */ if (m_session->isSessionActive()) { /* While there is a running session */ m_close = TRUE; m_session->endSession(); } else { /* Session has previously been closed */ m_channelTabs.first(); while (m_channelTabs.current() != 0) { m_mainWindow->killTab(m_channelTabs.current()); } m_queryTabs.first(); while (m_queryTabs.current() != 0) { m_mainWindow->killTab(m_queryTabs.current()); } m_mainWindow->killTab(this); } } IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { QListIterator<IRCChannelTab> it(m_channelTabs); for (; it.current(); ++it) { if (it.current()->channel() == channel) return it.current(); } return 0; } IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { QListIterator<IRCQueryTab> it(m_queryTabs); for (; it.current(); ++it) { if (it.current()->person()->nick() == person->nick()) return it.current(); } return 0; } void IRCServerTab::display(IRCOutput output) { /* All messages to be displayed inside the GUI get here */ switch (output.type()) { case OUTPUT_CONNCLOSE: if (m_close) { m_channelTabs.first(); while (m_channelTabs.current() != 0) { m_mainWindow->killTab(m_channelTabs.current()); } 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("<<font color=\"#0000dd\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font>> "+output.htmlMessage()+"<br>"); + channelTab->appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage()+"</font><br>"); } break; case OUTPUT_QUERYACTION: case OUTPUT_QUERYPRIVMSG: { IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); if (!queryTab) { queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); m_queryTabs.append(queryTab); m_mainWindow->addTab(queryTab); } queryTab->display(output); } break; case OUTPUT_SELFPART: { 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 @@ -1,70 +1,73 @@ /* 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 __IRCSERVERTAB_H #define __IRCSERVERTAB_H #include "irctab.h" #include "ircsession.h" #include "mainwindow.h" #include "ircchanneltab.h" #include "ircquerytab.h" class IRCServerTab : public IRCTab { Q_OBJECT public: /* IRCTab implementation */ IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); ~IRCServerTab(); QString title(); IRCSession *session(); IRCServer *server(); /* 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; MainWindow *m_mainWindow; QTextView *m_textview; QLineEdit *m_field; /* Channel tabs associated with this server tab */ QList<IRCChannelTab> m_channelTabs; /* Query tabs associated with this server tab */ QList<IRCQueryTab> m_queryTabs; }; #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 @@ +#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,19 +1,28 @@ #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); descLayout->setStretchFactor(m_description, 5); QPushButton *close = new QPushButton(this); close->setPixmap(Resource::loadPixmap("close")); connect(close, SIGNAL(clicked()), this, SLOT(remove())); descLayout->addWidget(close); descLayout->setStretchFactor(m_description, 1); } 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 @@ /* 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 __IRCTAB_H #define __IRCTAB_H #include <qwidget.h> #include <qtextview.h> #include <qlineedit.h> #include <qlabel.h> #include <qlayout.h> #include "ircsession.h" /* This is the base class for any tabs which need to be integrated into the main GUI tab widget */ class IRCTab : public QWidget { Q_OBJECT 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 @@ -1,27 +1,27 @@ /* 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 __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 @@ -1,55 +1,71 @@ #include <qpe/qpemenubar.h> #include <qpe/resource.h> #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 @@ -1,45 +1,48 @@ /* 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 __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 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 @@ -1,24 +1,24 @@ TEMPLATE = app CONFIG = qt warn_on release DESTDIR = $(OPIEDIR)/bin 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 |