-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,4 +1,3 @@ #include "ircchannel.h" -#include <stdio.h> IRCChannel::IRCChannel(QString 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,2 +1,5 @@ +#include <qpe/qpeapplication.h> +#include <qpe/resource.h> +#include <qcursor.h> #include <qhbox.h> #include "ircchanneltab.h" @@ -21,4 +24,16 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW 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(); @@ -26,5 +41,5 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW m_field->setFocus(); connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); - + settingsChanged(); } @@ -50,8 +65,8 @@ void IRCChannelTab::processCommand() { 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>"); } } @@ -59,4 +74,8 @@ void IRCChannelTab::processCommand() { } +void IRCChannelTab::settingsChanged() { + m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); +} + void IRCChannelTab::toggleList() { if (m_listVisible) { @@ -70,4 +89,37 @@ void IRCChannelTab::toggleList() { } +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 @@ -22,4 +22,5 @@ #define __IRCCHANNELTAB_H +#include <qpopupmenu.h> #include <qpushbutton.h> #include "irctab.h" @@ -45,6 +46,14 @@ public: 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; @@ -55,4 +64,5 @@ protected: QTextView *m_textview; QLineEdit *m_field; + QPopupMenu *m_popup; bool m_listVisible; }; 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 @@ -2,5 +2,4 @@ #include "ircmessageparser.h" #include "ircversion.h" -#include <stdio.h> /* Lookup table for literal commands */ 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,4 +1,3 @@ #include "ircperson.h" -#include <stdio.h> IRCPerson::IRCPerson() { 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 @@ -19,5 +19,5 @@ IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow m_field->setFocus(); connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); - + settingsChanged(); } @@ -44,8 +44,8 @@ void IRCQueryTab::processCommand() { 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>"); } } @@ -55,10 +55,14 @@ void IRCQueryTab::processCommand() { 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(); 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 @@ -40,4 +40,5 @@ public slots: void processCommand(); void display(IRCOutput output); + void settingsChanged(); protected: bool m_close; 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 @@ -34,4 +34,5 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* 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,3 +1,2 @@ -#include <stdio.h> #include <qlayout.h> #include <qlabel.h> @@ -6,5 +5,4 @@ #include "ircserverlist.h" #include "ircservereditor.h" -#include <stdio.h> class IRCListBoxServer : public QListBoxText { @@ -103,5 +101,4 @@ int IRCServerList::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++) { 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,3 +1,3 @@ -#include <stdio.h> +#include <qpe/config.h> #include <qtextstream.h> #include "ircservertab.h" @@ -19,4 +19,5 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa m_field->setFocus(); connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); + settingsChanged(); } @@ -39,4 +40,8 @@ void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { } +void IRCServerTab::addQueryTab(IRCQueryTab *tab) { + m_queryTabs.append(tab); +} + QString IRCServerTab::title() { return "Server"; @@ -51,4 +56,8 @@ IRCServer *IRCServerTab::server() { } +void IRCServerTab::settingsChanged() { + m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); +} + void IRCServerTab::executeCommand(IRCTab *tab, QString line) { QTextIStream stream(&line); @@ -63,5 +72,5 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 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") { @@ -69,11 +78,11 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 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>"); } } @@ -86,10 +95,10 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 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>"); } } @@ -164,8 +173,8 @@ void IRCServerTab::display(IRCOutput output) { 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>"); } } @@ -179,5 +188,5 @@ void IRCServerTab::display(IRCOutput output) { 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; @@ -200,5 +209,5 @@ void IRCServerTab::display(IRCOutput output) { 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) @@ -208,5 +217,5 @@ void IRCServerTab::display(IRCOutput output) { 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; @@ -216,5 +225,5 @@ void IRCServerTab::display(IRCOutput output) { 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(); } @@ -227,16 +236,16 @@ void IRCServerTab::display(IRCOutput output) { 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 @@ -43,14 +43,17 @@ public: 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); 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 @@ -4,4 +4,13 @@ #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); 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 @@ -41,7 +41,17 @@ public: 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; }; 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 @@ -22,5 +22,5 @@ #define __IRCVERSION_H -#define APP_VERSION "OpieIRC 0.2" +#define APP_VERSION "OpieIRC 0.3" #define APP_COPYSTR "(c) 2002 by Wenzel Jakob" 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 @@ -7,9 +7,9 @@ #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); @@ -20,16 +20,20 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindo 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"); } @@ -37,9 +41,10 @@ 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; @@ -54,2 +59,13 @@ void MainWindow::newConnection() { } } + +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 @@ -24,4 +24,5 @@ #include <qmainwindow.h> #include <qaction.h> +#include <qlist.h> #include <qtabwidget.h> #include "mainwindow.h" @@ -37,8 +38,10 @@ public: protected slots: void newConnection(); - void closeTab(); - void tabSelected(QWidget *widget); + void settings(); +protected: + void loadSettings(); protected: QTabWidget *m_tabWidget; + QList<IRCTab> m_tabs; }; 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 @@ -9,5 +9,5 @@ HEADERS = ircchannel.h ircconnection.h \ ircchanneltab.h ircchannellist.h \ ircserverlist.h ircservereditor.h \ - ircquerytab.h + ircquerytab.h ircsettings.h ircmisc.h SOURCES = ircchannel.cpp ircconnection.cpp \ ircmessage.cpp \ @@ -18,7 +18,7 @@ SOURCES = ircchannel.cpp ircconnection.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 |