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 /noncore | |
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,3 +1,2 @@ #include "ircchannel.h" -#include <stdio.h> 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 +1,4 @@ +#include <qpe/qpeapplication.h> +#include <qpe/resource.h> +#include <qcursor.h> #include <qhbox.h> @@ -22,2 +25,14 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW 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); @@ -27,3 +42,3 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); - + settingsChanged(); } @@ -51,6 +66,6 @@ void IRCChannelTab::processCommand() { 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>"); } @@ -60,2 +75,6 @@ void IRCChannelTab::processCommand() { +void IRCChannelTab::settingsChanged() { + m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); +} + void IRCChannelTab::toggleList() { @@ -71,2 +90,35 @@ 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() { 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 @@ -23,2 +23,3 @@ +#include <qpopupmenu.h> #include <qpushbutton.h> @@ -46,4 +47,12 @@ 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: @@ -56,2 +65,3 @@ protected: 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 @@ -3,3 +3,2 @@ #include "ircversion.h" -#include <stdio.h> 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,3 +1,2 @@ #include "ircperson.h" -#include <stdio.h> 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 @@ -20,3 +20,3 @@ IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); - + settingsChanged(); } @@ -45,6 +45,6 @@ void IRCQueryTab::processCommand() { 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>"); } @@ -56,6 +56,10 @@ 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 + "\"/>"); } 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 @@ -41,2 +41,3 @@ public slots: void display(IRCOutput output); + void settingsChanged(); protected: 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 @@ -35,2 +35,3 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* 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,2 +1 @@ -#include <stdio.h> #include <qlayout.h> @@ -7,3 +6,2 @@ #include "ircservereditor.h" -#include <stdio.h> @@ -104,3 +102,2 @@ int IRCServerList::exec() { m_config->setGroup("OpieIRC"); - m_config->clearGroup(); m_config->writeEntry("ServerCount", QString::number(m_list->count())); 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,2 +1,2 @@ -#include <stdio.h> +#include <qpe/config.h> #include <qtextstream.h> @@ -20,2 +20,3 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); + settingsChanged(); } @@ -40,2 +41,6 @@ void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { +void IRCServerTab::addQueryTab(IRCQueryTab *tab) { + m_queryTabs.append(tab); +} + QString IRCServerTab::title() { @@ -52,2 +57,6 @@ IRCServer *IRCServerTab::server() { +void IRCServerTab::settingsChanged() { + m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); +} + void IRCServerTab::executeCommand(IRCTab *tab, QString line) { @@ -64,3 +73,3 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { } else { - tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>"); + tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); } @@ -70,9 +79,9 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 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>"); } @@ -87,3 +96,3 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 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); @@ -92,3 +101,3 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { } else { - tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>"); + tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); } @@ -165,6 +174,6 @@ void IRCServerTab::display(IRCOutput output) { } 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>"); } @@ -180,3 +189,3 @@ void IRCServerTab::display(IRCOutput output) { 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>"); } @@ -201,3 +210,3 @@ void IRCServerTab::display(IRCOutput output) { 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)); @@ -209,3 +218,3 @@ void IRCServerTab::display(IRCOutput output) { 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>"); } @@ -217,3 +226,3 @@ void IRCServerTab::display(IRCOutput output) { 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(); @@ -228,3 +237,3 @@ void IRCServerTab::display(IRCOutput output) { 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(); @@ -233,9 +242,9 @@ void IRCServerTab::display(IRCOutput output) { 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 @@ -44,4 +44,8 @@ public: 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); @@ -49,4 +53,2 @@ protected: void appendText(QString text); - IRCChannelTab *getTabForChannel(IRCChannel *channel); - IRCQueryTab *getTabForQuery(IRCPerson *person); public slots: @@ -54,2 +56,3 @@ public slots: void processCommand(); + void settingsChanged(); protected slots: 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 @@ -5,2 +5,11 @@ +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) { 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 @@ -42,2 +42,3 @@ public slots: virtual void remove() = 0; + virtual void settingsChanged() = 0; protected: @@ -45,2 +46,11 @@ protected: 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 @@ -23,3 +23,3 @@ -#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 @@ -8,2 +8,3 @@ #include "ircserverlist.h" +#include "ircsettings.h" @@ -12,3 +13,2 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindo m_tabWidget = new QTabWidget(this); - connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(tabSelected(QWidget *))); setCentralWidget(m_tabWidget); @@ -21,14 +21,18 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindo 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"); } @@ -38,3 +42,3 @@ void MainWindow::addTab(IRCTab *tab) { m_tabWidget->showPage(tab); - tabSelected(tab); + m_tabs.append(tab); } @@ -43,2 +47,3 @@ void MainWindow::killTab(IRCTab *tab) { m_tabWidget->removePage(tab); + m_tabs.remove(tab); /* there might be nicer ways to do this .. */ @@ -55 +60,12 @@ 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 @@ -25,2 +25,3 @@ #include <qaction.h> +#include <qlist.h> #include <qtabwidget.h> @@ -38,6 +39,8 @@ 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 @@ -10,3 +10,3 @@ HEADERS = ircchannel.h ircconnection.h \ ircserverlist.h ircservereditor.h \ - ircquerytab.h + ircquerytab.h ircsettings.h ircmisc.h SOURCES = ircchannel.cpp ircconnection.cpp \ @@ -19,6 +19,6 @@ SOURCES = ircchannel.cpp ircconnection.cpp \ ircserverlist.cpp ircservereditor.cpp \ - ircquerytab.cpp + ircquerytab.cpp ircsettings.cpp ircmisc.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe +LIBS += -lqpe -lopie |