author | wazlaf <wazlaf> | 2002-09-23 22:12:39 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-09-23 22:12:39 (UTC) |
commit | 074769a4adb816153e47d63087e9e326bd3a04bf (patch) (unidiff) | |
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,8 +1,7 @@ | |||
1 | #include "ircchannel.h" | 1 | #include "ircchannel.h" |
2 | #include <stdio.h> | ||
3 | 2 | ||
4 | IRCChannel::IRCChannel(QString channelname) { | 3 | IRCChannel::IRCChannel(QString channelname) { |
5 | m_hasPeople = FALSE; | 4 | m_hasPeople = FALSE; |
6 | m_channelname = channelname; | 5 | m_channelname = channelname; |
7 | } | 6 | } |
8 | 7 | ||
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp index 4675265..c1695db 100644 --- a/noncore/net/opieirc/ircchanneltab.cpp +++ b/noncore/net/opieirc/ircchanneltab.cpp | |||
@@ -1,6 +1,9 @@ | |||
1 | #include <qpe/qpeapplication.h> | ||
2 | #include <qpe/resource.h> | ||
3 | #include <qcursor.h> | ||
1 | #include <qhbox.h> | 4 | #include <qhbox.h> |
2 | #include "ircchanneltab.h" | 5 | #include "ircchanneltab.h" |
3 | #include "ircservertab.h" | 6 | #include "ircservertab.h" |
4 | 7 | ||
5 | IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 8 | IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
6 | m_mainWindow = mainWindow; | 9 | m_mainWindow = mainWindow; |
@@ -17,18 +20,30 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW | |||
17 | m_textview->setTextFormat(RichText); | 20 | m_textview->setTextFormat(RichText); |
18 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); | 21 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); |
19 | m_list = new IRCChannelList(m_channel, hbox); | 22 | m_list = new IRCChannelList(m_channel, hbox); |
20 | m_list->update(); | 23 | m_list->update(); |
21 | m_list->setMaximumWidth(LISTWIDTH); | 24 | m_list->setMaximumWidth(LISTWIDTH); |
22 | m_field = new QLineEdit(this); | 25 | m_field = new QLineEdit(this); |
26 | m_popup = new QPopupMenu(m_list); | ||
27 | /* Required so that embedded-style "right" clicks work */ | ||
28 | QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); | ||
29 | connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &))); | ||
30 | /* Construct the popup menu */ | ||
31 | QPopupMenu *ctcpMenu = new QPopupMenu(m_list); | ||
32 | m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); | ||
33 | m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); | ||
34 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); | ||
35 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); | ||
36 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); | ||
37 | |||
23 | m_layout->add(hbox); | 38 | m_layout->add(hbox); |
24 | hbox->show(); | 39 | hbox->show(); |
25 | m_layout->add(m_field); | 40 | m_layout->add(m_field); |
26 | m_field->setFocus(); | 41 | m_field->setFocus(); |
27 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 42 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
28 | 43 | settingsChanged(); | |
29 | } | 44 | } |
30 | 45 | ||
31 | void IRCChannelTab::appendText(QString text) { | 46 | void IRCChannelTab::appendText(QString text) { |
32 | /* not using append because it creates layout problems */ | 47 | /* not using append because it creates layout problems */ |
33 | m_textview->setText(m_textview->text() + text); | 48 | m_textview->setText(m_textview->text() + text); |
34 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 49 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
@@ -46,32 +61,69 @@ void IRCChannelTab::processCommand() { | |||
46 | /* Command mode */ | 61 | /* Command mode */ |
47 | m_parentTab->executeCommand(this, text);; | 62 | m_parentTab->executeCommand(this, text);; |
48 | } else { | 63 | } else { |
49 | if (text.startsWith("//")) | 64 | if (text.startsWith("//")) |
50 | text = text.right(text.length()-1); | 65 | text = text.right(text.length()-1); |
51 | session()->sendMessage(m_channel, m_field->text()); | 66 | session()->sendMessage(m_channel, m_field->text()); |
52 | appendText("<<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>> "+IRCOutput::toHTML(m_field->text())+"<br>"); | 67 | 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>"); |
53 | } | 68 | } |
54 | } else { | 69 | } else { |
55 | appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); | 70 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); |
56 | } | 71 | } |
57 | } | 72 | } |
58 | m_field->clear(); | 73 | m_field->clear(); |
59 | } | 74 | } |
60 | 75 | ||
76 | void IRCChannelTab::settingsChanged() { | ||
77 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | ||
78 | } | ||
79 | |||
61 | void IRCChannelTab::toggleList() { | 80 | void IRCChannelTab::toggleList() { |
62 | if (m_listVisible) { | 81 | if (m_listVisible) { |
63 | m_list->setMaximumWidth(0); | 82 | m_list->setMaximumWidth(0); |
64 | m_listButton->setText("<"); | 83 | m_listButton->setText("<"); |
65 | } else { | 84 | } else { |
66 | m_list->setMaximumWidth(LISTWIDTH); | 85 | m_list->setMaximumWidth(LISTWIDTH); |
67 | m_listButton->setText(">"); | 86 | m_listButton->setText(">"); |
68 | } | 87 | } |
69 | m_listVisible = !m_listVisible; | 88 | m_listVisible = !m_listVisible; |
70 | } | 89 | } |
71 | 90 | ||
91 | void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { | ||
92 | switch (mouse) { | ||
93 | case 1: | ||
94 | break; | ||
95 | case 2: | ||
96 | m_popup->popup(point); | ||
97 | break; | ||
98 | }; | ||
99 | } | ||
100 | |||
101 | void IRCChannelTab::popupQuery() { | ||
102 | if (m_list->currentItem() != -1) { | ||
103 | IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); | ||
104 | if (person) { | ||
105 | IRCQueryTab *tab = m_parentTab->getTabForQuery(person); | ||
106 | if (!tab) { | ||
107 | tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); | ||
108 | m_parentTab->addQueryTab(tab); | ||
109 | m_mainWindow->addTab(tab); | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | |||
115 | void IRCChannelTab::popupPing() { | ||
116 | } | ||
117 | |||
118 | void IRCChannelTab::popupVersion() { | ||
119 | } | ||
120 | |||
121 | void IRCChannelTab::popupWhois() { | ||
122 | } | ||
123 | |||
72 | QString IRCChannelTab::title() { | 124 | QString IRCChannelTab::title() { |
73 | return m_channel->channelname(); | 125 | return m_channel->channelname(); |
74 | } | 126 | } |
75 | 127 | ||
76 | IRCSession *IRCChannelTab::session() { | 128 | IRCSession *IRCChannelTab::session() { |
77 | return m_parentTab->session(); | 129 | return m_parentTab->session(); |
diff --git a/noncore/net/opieirc/ircchanneltab.h b/noncore/net/opieirc/ircchanneltab.h index 2127c4d..971614b 100644 --- a/noncore/net/opieirc/ircchanneltab.h +++ b/noncore/net/opieirc/ircchanneltab.h | |||
@@ -18,12 +18,13 @@ | |||
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __IRCCHANNELTAB_H | 21 | #ifndef __IRCCHANNELTAB_H |
22 | #define __IRCCHANNELTAB_H | 22 | #define __IRCCHANNELTAB_H |
23 | 23 | ||
24 | #include <qpopupmenu.h> | ||
24 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
25 | #include "irctab.h" | 26 | #include "irctab.h" |
26 | #include "ircsession.h" | 27 | #include "ircsession.h" |
27 | #include "mainwindow.h" | 28 | #include "mainwindow.h" |
28 | #include "ircchannellist.h" | 29 | #include "ircchannellist.h" |
29 | 30 | ||
@@ -41,20 +42,29 @@ public: | |||
41 | IRCChannel *channel(); | 42 | IRCChannel *channel(); |
42 | IRCChannelList *list(); | 43 | IRCChannelList *list(); |
43 | public: | 44 | public: |
44 | void appendText(QString text); | 45 | void appendText(QString text); |
45 | public slots: | 46 | public slots: |
46 | void remove(); | 47 | void remove(); |
48 | void settingsChanged(); | ||
49 | protected slots: | ||
47 | void processCommand(); | 50 | void processCommand(); |
48 | void toggleList(); | 51 | void toggleList(); |
52 | void mouseButtonPressed(int mouse, QListBoxItem *item, const QPoint &point); | ||
53 | /* Popup slots */ | ||
54 | void popupQuery(); | ||
55 | void popupPing(); | ||
56 | void popupVersion(); | ||
57 | void popupWhois(); | ||
49 | protected: | 58 | protected: |
50 | IRCServerTab *m_parentTab; | 59 | IRCServerTab *m_parentTab; |
51 | IRCChannel *m_channel; | 60 | IRCChannel *m_channel; |
52 | IRCChannelList *m_list; | 61 | IRCChannelList *m_list; |
53 | QPushButton *m_listButton; | 62 | QPushButton *m_listButton; |
54 | MainWindow *m_mainWindow; | 63 | MainWindow *m_mainWindow; |
55 | QTextView *m_textview; | 64 | QTextView *m_textview; |
56 | QLineEdit *m_field; | 65 | QLineEdit *m_field; |
66 | QPopupMenu *m_popup; | ||
57 | bool m_listVisible; | 67 | bool m_listVisible; |
58 | }; | 68 | }; |
59 | 69 | ||
60 | #endif /* __IRCCHANNELTAB_H */ | 70 | #endif /* __IRCCHANNELTAB_H */ |
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index 3063741..5c70753 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -1,10 +1,9 @@ | |||
1 | #include <qtextstream.h> | 1 | #include <qtextstream.h> |
2 | #include "ircmessageparser.h" | 2 | #include "ircmessageparser.h" |
3 | #include "ircversion.h" | 3 | #include "ircversion.h" |
4 | #include <stdio.h> | ||
5 | 4 | ||
6 | /* Lookup table for literal commands */ | 5 | /* Lookup table for literal commands */ |
7 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { | 6 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { |
8 | { "PING", FUNC(parseLiteralPing) }, | 7 | { "PING", FUNC(parseLiteralPing) }, |
9 | { "NOTICE", FUNC(parseLiteralNotice) }, | 8 | { "NOTICE", FUNC(parseLiteralNotice) }, |
10 | { "JOIN", FUNC(parseLiteralJoin) }, | 9 | { "JOIN", FUNC(parseLiteralJoin) }, |
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp new file mode 100644 index 0000000..f41a89a --- a/dev/null +++ b/noncore/net/opieirc/ircmisc.cpp | |||
@@ -0,0 +1,31 @@ | |||
1 | #include <opie/colordialog.h> | ||
2 | #include <qlayout.h> | ||
3 | #include "ircmisc.h" | ||
4 | |||
5 | IRCColorLabel::IRCColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QLabel(parent, name, f) { | ||
6 | m_color = color; | ||
7 | setAlignment(AlignVCenter | AlignCenter); | ||
8 | setFrameStyle(QFrame::StyledPanel); | ||
9 | setFrameShadow(QFrame::Sunken); | ||
10 | setBackgroundColor(m_color); | ||
11 | } | ||
12 | |||
13 | void IRCColorLabel::mousePressEvent(QMouseEvent *) { | ||
14 | m_color = OColorDialog::getColor(m_color); | ||
15 | setBackgroundColor(m_color); | ||
16 | } | ||
17 | |||
18 | QColor IRCColorLabel::color() { | ||
19 | return m_color; | ||
20 | } | ||
21 | |||
22 | IRCFramedColorLabel::IRCFramedColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { | ||
23 | QVBoxLayout *layout = new QVBoxLayout(this, 10, 0); | ||
24 | m_label = new IRCColorLabel(color, this); | ||
25 | layout->addWidget(m_label); | ||
26 | } | ||
27 | |||
28 | QColor IRCFramedColorLabel::color() { | ||
29 | return m_label->color(); | ||
30 | } | ||
31 | |||
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 @@ | |||
1 | /* | ||
2 | OpieIRC - An embedded IRC client | ||
3 | Copyright (C) 2002 Wenzel Jakob | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | |||
19 | */ | ||
20 | |||
21 | #ifndef __IRCMISC_H | ||
22 | #define __IRCMISC_H | ||
23 | |||
24 | #include <qlabel.h> | ||
25 | #include <qcolor.h> | ||
26 | |||
27 | class IRCColorLabel : public QLabel { | ||
28 | public: | ||
29 | IRCColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | ||
30 | QColor color(); | ||
31 | void mousePressEvent(QMouseEvent *event); | ||
32 | protected: | ||
33 | QColor m_color; | ||
34 | }; | ||
35 | |||
36 | class IRCFramedColorLabel : public QWidget { | ||
37 | public: | ||
38 | IRCFramedColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | ||
39 | QColor color(); | ||
40 | protected: | ||
41 | IRCColorLabel *m_label; | ||
42 | }; | ||
43 | |||
44 | #endif /* __IRCMISC_H */ | ||
diff --git a/noncore/net/opieirc/ircperson.cpp b/noncore/net/opieirc/ircperson.cpp index bd341f1..2f5b435 100644 --- a/noncore/net/opieirc/ircperson.cpp +++ b/noncore/net/opieirc/ircperson.cpp | |||
@@ -1,8 +1,7 @@ | |||
1 | #include "ircperson.h" | 1 | #include "ircperson.h" |
2 | #include <stdio.h> | ||
3 | 2 | ||
4 | IRCPerson::IRCPerson() { | 3 | IRCPerson::IRCPerson() { |
5 | m_nick = ""; | 4 | m_nick = ""; |
6 | m_user = ""; | 5 | m_user = ""; |
7 | m_host = ""; | 6 | m_host = ""; |
8 | } | 7 | } |
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp index 642cc5b..c6b8211 100644 --- a/noncore/net/opieirc/ircquerytab.cpp +++ b/noncore/net/opieirc/ircquerytab.cpp | |||
@@ -15,13 +15,13 @@ IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow | |||
15 | m_field = new QLineEdit(this); | 15 | m_field = new QLineEdit(this); |
16 | m_layout->add(hbox); | 16 | m_layout->add(hbox); |
17 | hbox->show(); | 17 | hbox->show(); |
18 | m_layout->add(m_field); | 18 | m_layout->add(m_field); |
19 | m_field->setFocus(); | 19 | m_field->setFocus(); |
20 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 20 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
21 | 21 | settingsChanged(); | |
22 | } | 22 | } |
23 | 23 | ||
24 | void IRCQueryTab::appendText(QString text) { | 24 | void IRCQueryTab::appendText(QString text) { |
25 | /* not using append because it creates layout problems */ | 25 | /* not using append because it creates layout problems */ |
26 | m_textview->setText(m_textview->text() + text); | 26 | m_textview->setText(m_textview->text() + text); |
27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
@@ -40,29 +40,33 @@ void IRCQueryTab::processCommand() { | |||
40 | /* Command mode */ | 40 | /* Command mode */ |
41 | m_parentTab->executeCommand(this, text);; | 41 | m_parentTab->executeCommand(this, text);; |
42 | } else { | 42 | } else { |
43 | if (text.startsWith("//")) | 43 | if (text.startsWith("//")) |
44 | text = text.right(text.length()-1); | 44 | text = text.right(text.length()-1); |
45 | session()->sendMessage(m_person, m_field->text()); | 45 | session()->sendMessage(m_person, m_field->text()); |
46 | appendText("<<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>> "+IRCOutput::toHTML(m_field->text())+"<br>"); | 46 | 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>"); |
47 | } | 47 | } |
48 | } else { | 48 | } else { |
49 | appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); | 49 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); |
50 | } | 50 | } |
51 | } | 51 | } |
52 | m_field->clear(); | 52 | m_field->clear(); |
53 | } | 53 | } |
54 | 54 | ||
55 | void IRCQueryTab::display(IRCOutput output) { | 55 | void IRCQueryTab::display(IRCOutput output) { |
56 | if (output.type() == OUTPUT_QUERYPRIVMSG) { | 56 | if (output.type() == OUTPUT_QUERYPRIVMSG) { |
57 | appendText("<<font color=\"#0000dd\">"+m_person->nick()+"</font>> " + output.htmlMessage() + "<br>"); | 57 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage() + "</font><br>"); |
58 | } else if (output.type() == OUTPUT_QUERYACTION) { | 58 | } else if (output.type() == OUTPUT_QUERYACTION) { |
59 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "<br>"); | 59 | appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>"); |
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | void IRCQueryTab::settingsChanged() { | ||
64 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | ||
65 | } | ||
66 | |||
63 | QString IRCQueryTab::title() { | 67 | QString IRCQueryTab::title() { |
64 | return m_person->nick(); | 68 | return m_person->nick(); |
65 | } | 69 | } |
66 | 70 | ||
67 | IRCSession *IRCQueryTab::session() { | 71 | IRCSession *IRCQueryTab::session() { |
68 | return m_parentTab->session(); | 72 | return m_parentTab->session(); |
diff --git a/noncore/net/opieirc/ircquerytab.h b/noncore/net/opieirc/ircquerytab.h index ea777f4..07fa57f 100644 --- a/noncore/net/opieirc/ircquerytab.h +++ b/noncore/net/opieirc/ircquerytab.h | |||
@@ -36,12 +36,13 @@ public: | |||
36 | IRCPerson *person(); | 36 | IRCPerson *person(); |
37 | void appendText(QString text); | 37 | void appendText(QString text); |
38 | public slots: | 38 | public slots: |
39 | void remove(); | 39 | void remove(); |
40 | void processCommand(); | 40 | void processCommand(); |
41 | void display(IRCOutput output); | 41 | void display(IRCOutput output); |
42 | void settingsChanged(); | ||
42 | protected: | 43 | protected: |
43 | bool m_close; | 44 | bool m_close; |
44 | MainWindow *m_mainWindow; | 45 | MainWindow *m_mainWindow; |
45 | IRCServerTab *m_parentTab; | 46 | IRCServerTab *m_parentTab; |
46 | IRCPerson *m_person; | 47 | IRCPerson *m_person; |
47 | QTextView *m_textview; | 48 | QTextView *m_textview; |
diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp index c3a444d..5e916ae 100644 --- a/noncore/net/opieirc/ircservereditor.cpp +++ b/noncore/net/opieirc/ircservereditor.cpp | |||
@@ -30,12 +30,13 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* | |||
30 | layout->addWidget(label, 5, 0); | 30 | layout->addWidget(label, 5, 0); |
31 | layout->addWidget(m_password, 5, 1); | 31 | layout->addWidget(m_password, 5, 1); |
32 | label = new QLabel(tr("Channels :"), this); | 32 | label = new QLabel(tr("Channels :"), this); |
33 | m_channels = new QLineEdit(server.channels(), this); | 33 | m_channels = new QLineEdit(server.channels(), this); |
34 | layout->addWidget(label, 6, 0); | 34 | layout->addWidget(label, 6, 0); |
35 | layout->addWidget(m_channels, 6, 1); | 35 | layout->addWidget(m_channels, 6, 1); |
36 | setCaption(tr("Edit server information")); | ||
36 | showMaximized(); | 37 | showMaximized(); |
37 | } | 38 | } |
38 | 39 | ||
39 | 40 | ||
40 | void IRCServerEditor::accept() { | 41 | void IRCServerEditor::accept() { |
41 | if (m_name->text().length()==0) | 42 | if (m_name->text().length()==0) |
diff --git a/noncore/net/opieirc/ircserverlist.cpp b/noncore/net/opieirc/ircserverlist.cpp index e664ba1..3293591 100644 --- a/noncore/net/opieirc/ircserverlist.cpp +++ b/noncore/net/opieirc/ircserverlist.cpp | |||
@@ -1,14 +1,12 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <qlayout.h> | 1 | #include <qlayout.h> |
3 | #include <qlabel.h> | 2 | #include <qlabel.h> |
4 | #include <qhbox.h> | 3 | #include <qhbox.h> |
5 | #include <qpushbutton.h> | 4 | #include <qpushbutton.h> |
6 | #include "ircserverlist.h" | 5 | #include "ircserverlist.h" |
7 | #include "ircservereditor.h" | 6 | #include "ircservereditor.h" |
8 | #include <stdio.h> | ||
9 | 7 | ||
10 | class IRCListBoxServer : public QListBoxText { | 8 | class IRCListBoxServer : public QListBoxText { |
11 | public: | 9 | public: |
12 | IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) { | 10 | IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) { |
13 | m_server = server; | 11 | m_server = server; |
14 | } | 12 | } |
@@ -99,13 +97,12 @@ void IRCServerList::editServer() { | |||
99 | } | 97 | } |
100 | 98 | ||
101 | int IRCServerList::exec() { | 99 | int IRCServerList::exec() { |
102 | int returncode = QDialog::exec(); | 100 | int returncode = QDialog::exec(); |
103 | /* Now save the changes */ | 101 | /* Now save the changes */ |
104 | m_config->setGroup("OpieIRC"); | 102 | m_config->setGroup("OpieIRC"); |
105 | m_config->clearGroup(); | ||
106 | m_config->writeEntry("ServerCount", QString::number(m_list->count())); | 103 | m_config->writeEntry("ServerCount", QString::number(m_list->count())); |
107 | for (unsigned int i=0; i<m_list->count(); i++) { | 104 | for (unsigned int i=0; i<m_list->count(); i++) { |
108 | IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); | 105 | IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); |
109 | m_config->setGroup("OpieIRC"); | 106 | m_config->setGroup("OpieIRC"); |
110 | m_config->writeEntry("Server"+QString::number(i), server.name()); | 107 | m_config->writeEntry("Server"+QString::number(i), server.name()); |
111 | m_config->setGroup(server.name()); | 108 | m_config->setGroup(server.name()); |
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 8b8771f..4be60ef 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -1,7 +1,7 @@ | |||
1 | #include <stdio.h> | 1 | #include <qpe/config.h> |
2 | #include <qtextstream.h> | 2 | #include <qtextstream.h> |
3 | #include "ircservertab.h" | 3 | #include "ircservertab.h" |
4 | 4 | ||
5 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 5 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
6 | m_server = server; | 6 | m_server = server; |
7 | m_session = new IRCSession(&m_server); | 7 | m_session = new IRCSession(&m_server); |
@@ -15,12 +15,13 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa | |||
15 | m_layout->add(m_textview); | 15 | m_layout->add(m_textview); |
16 | m_field = new QLineEdit(this); | 16 | m_field = new QLineEdit(this); |
17 | m_layout->add(m_field); | 17 | m_layout->add(m_field); |
18 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 18 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
19 | m_field->setFocus(); | 19 | m_field->setFocus(); |
20 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); | 20 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); |
21 | settingsChanged(); | ||
21 | } | 22 | } |
22 | 23 | ||
23 | void IRCServerTab::appendText(QString text) { | 24 | void IRCServerTab::appendText(QString text) { |
24 | /* not using append because it creates layout problems */ | 25 | /* not using append because it creates layout problems */ |
25 | m_textview->setText(m_textview->text() + text); | 26 | m_textview->setText(m_textview->text() + text); |
26 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
@@ -35,65 +36,73 @@ void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { | |||
35 | } | 36 | } |
36 | 37 | ||
37 | void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { | 38 | void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { |
38 | m_queryTabs.remove(tab); | 39 | m_queryTabs.remove(tab); |
39 | } | 40 | } |
40 | 41 | ||
42 | void IRCServerTab::addQueryTab(IRCQueryTab *tab) { | ||
43 | m_queryTabs.append(tab); | ||
44 | } | ||
45 | |||
41 | QString IRCServerTab::title() { | 46 | QString IRCServerTab::title() { |
42 | return "Server"; | 47 | return "Server"; |
43 | } | 48 | } |
44 | 49 | ||
45 | IRCSession *IRCServerTab::session() { | 50 | IRCSession *IRCServerTab::session() { |
46 | return m_session; | 51 | return m_session; |
47 | } | 52 | } |
48 | 53 | ||
49 | IRCServer *IRCServerTab::server() { | 54 | IRCServer *IRCServerTab::server() { |
50 | return &m_server; | 55 | return &m_server; |
51 | } | 56 | } |
52 | 57 | ||
58 | void IRCServerTab::settingsChanged() { | ||
59 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | ||
60 | } | ||
61 | |||
53 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { | 62 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { |
54 | QTextIStream stream(&line); | 63 | QTextIStream stream(&line); |
55 | QString command; | 64 | QString command; |
56 | stream >> command; | 65 | stream >> command; |
57 | command = command.upper().right(command.length()-1); | 66 | command = command.upper().right(command.length()-1); |
58 | 67 | ||
59 | if (command == "JOIN") { | 68 | if (command == "JOIN") { |
60 | QString channel; | 69 | QString channel; |
61 | stream >> channel; | 70 | stream >> channel; |
62 | if (channel.length() > 0 && channel.startsWith("#")) { | 71 | if (channel.length() > 0 && channel.startsWith("#")) { |
63 | m_session->join(channel); | 72 | m_session->join(channel); |
64 | } else { | 73 | } else { |
65 | tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>"); | 74 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); |
66 | } | 75 | } |
67 | } else if (command == "ME") { | 76 | } else if (command == "ME") { |
68 | QString text = line.right(line.length()-4); | 77 | QString text = line.right(line.length()-4); |
69 | if (text.length() > 0) { | 78 | if (text.length() > 0) { |
70 | if (tab->isA("IRCChannelTab")) { | 79 | if (tab->isA("IRCChannelTab")) { |
71 | tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); | 80 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); |
72 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); | 81 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); |
73 | } else if (tab->isA("IRCQueryTab")) { | 82 | } else if (tab->isA("IRCQueryTab")) { |
74 | tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); | 83 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); |
75 | m_session->sendAction(((IRCQueryTab *)tab)->person(), text); | 84 | m_session->sendAction(((IRCQueryTab *)tab)->person(), text); |
76 | } else { | 85 | } else { |
77 | tab->appendText("<font color=\"#ff0000\">Invalid tab for this command</font><br>"); | 86 | tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); |
78 | } | 87 | } |
79 | } | 88 | } |
80 | } else if (command == "MSG") { | 89 | } else if (command == "MSG") { |
81 | QString nickname; | 90 | QString nickname; |
82 | stream >> nickname; | 91 | stream >> nickname; |
83 | if (nickname.length() > 0) { | 92 | if (nickname.length() > 0) { |
84 | if (line.length() > 6 + nickname.length()) { | 93 | if (line.length() > 6 + nickname.length()) { |
85 | QString text = line.right(line.length()-nickname.length()-6); | 94 | QString text = line.right(line.length()-nickname.length()-6); |
86 | IRCPerson person; | 95 | IRCPerson person; |
87 | person.setNick(nickname); | 96 | person.setNick(nickname); |
88 | tab->appendText("><font color=\"#0000dd\">"+IRCOutput::toHTML(nickname)+"</font>< "+IRCOutput::toHTML(text)+"<br>"); | 97 | tab->appendText("<font color=\"" + m_textColor + "\">></font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">< "+IRCOutput::toHTML(text)+"</font><br>"); |
89 | m_session->sendMessage(&person, text); | 98 | m_session->sendMessage(&person, text); |
90 | } | 99 | } |
91 | } | 100 | } |
92 | } else { | 101 | } else { |
93 | tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>"); | 102 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); |
94 | } | 103 | } |
95 | } | 104 | } |
96 | 105 | ||
97 | void IRCServerTab::processCommand() { | 106 | void IRCServerTab::processCommand() { |
98 | QString text = m_field->text(); | 107 | QString text = m_field->text(); |
99 | if (text.startsWith("/") && !text.startsWith("//")) { | 108 | if (text.startsWith("/") && !text.startsWith("//")) { |
@@ -160,28 +169,28 @@ void IRCServerTab::display(IRCOutput output) { | |||
160 | m_queryTabs.first(); | 169 | m_queryTabs.first(); |
161 | while (m_queryTabs.current() != 0) { | 170 | while (m_queryTabs.current() != 0) { |
162 | m_mainWindow->killTab(m_queryTabs.current()); | 171 | m_mainWindow->killTab(m_queryTabs.current()); |
163 | } | 172 | } |
164 | m_mainWindow->killTab(this); | 173 | m_mainWindow->killTab(this); |
165 | } else { | 174 | } else { |
166 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); | 175 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); |
167 | QListIterator<IRCChannelTab> it(m_channelTabs); | 176 | QListIterator<IRCChannelTab> it(m_channelTabs); |
168 | for (; it.current(); ++it) { | 177 | for (; it.current(); ++it) { |
169 | it.current()->appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); | 178 | it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); |
170 | } | 179 | } |
171 | } | 180 | } |
172 | break; | 181 | break; |
173 | case OUTPUT_SELFJOIN: { | 182 | case OUTPUT_SELFJOIN: { |
174 | IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); | 183 | IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); |
175 | m_channelTabs.append(channeltab); | 184 | m_channelTabs.append(channeltab); |
176 | m_mainWindow->addTab(channeltab); | 185 | m_mainWindow->addTab(channeltab); |
177 | } | 186 | } |
178 | break; | 187 | break; |
179 | case OUTPUT_CHANPRIVMSG: { | 188 | case OUTPUT_CHANPRIVMSG: { |
180 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 189 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
181 | channelTab->appendText("<<font color=\"#0000dd\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font>> "+output.htmlMessage()+"<br>"); | 190 | 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>"); |
182 | } | 191 | } |
183 | break; | 192 | break; |
184 | case OUTPUT_QUERYACTION: | 193 | case OUTPUT_QUERYACTION: |
185 | case OUTPUT_QUERYPRIVMSG: { | 194 | case OUTPUT_QUERYPRIVMSG: { |
186 | IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); | 195 | IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); |
187 | if (!queryTab) { | 196 | if (!queryTab) { |
@@ -196,48 +205,48 @@ void IRCServerTab::display(IRCOutput output) { | |||
196 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 205 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
197 | if (channelTab) | 206 | if (channelTab) |
198 | m_mainWindow->killTab(channelTab); | 207 | m_mainWindow->killTab(channelTab); |
199 | } | 208 | } |
200 | break; | 209 | break; |
201 | case OUTPUT_SELFKICK: { | 210 | case OUTPUT_SELFKICK: { |
202 | appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>"); | 211 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); |
203 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 212 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
204 | if (channelTab) | 213 | if (channelTab) |
205 | m_mainWindow->killTab(channelTab); | 214 | m_mainWindow->killTab(channelTab); |
206 | } | 215 | } |
207 | break; | 216 | break; |
208 | case OUTPUT_CHANACTION: { | 217 | case OUTPUT_CHANACTION: { |
209 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 218 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
210 | channelTab->appendText("<font color=\"#cc0000\">"+output.htmlMessage()+"</font><br>"); | 219 | channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); |
211 | } | 220 | } |
212 | break; | 221 | break; |
213 | case OUTPUT_QUIT: { | 222 | case OUTPUT_QUIT: { |
214 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); | 223 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); |
215 | QListIterator<IRCChannelTab> it(m_channelTabs); | 224 | QListIterator<IRCChannelTab> it(m_channelTabs); |
216 | for (; it.current(); ++it) { | 225 | for (; it.current(); ++it) { |
217 | if (it.current()->list()->hasPerson(nick)) { | 226 | if (it.current()->list()->hasPerson(nick)) { |
218 | it.current()->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>"); | 227 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
219 | it.current()->list()->update(); | 228 | it.current()->list()->update(); |
220 | } | 229 | } |
221 | } | 230 | } |
222 | } | 231 | } |
223 | break; | 232 | break; |
224 | case OUTPUT_OTHERJOIN: | 233 | case OUTPUT_OTHERJOIN: |
225 | case OUTPUT_OTHERKICK: | 234 | case OUTPUT_OTHERKICK: |
226 | case OUTPUT_CHANPERSONMODE: | 235 | case OUTPUT_CHANPERSONMODE: |
227 | case OUTPUT_OTHERPART: { | 236 | case OUTPUT_OTHERPART: { |
228 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 237 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
229 | channelTab->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>"); | 238 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
230 | channelTab->list()->update(); | 239 | channelTab->list()->update(); |
231 | } | 240 | } |
232 | break; | 241 | break; |
233 | case OUTPUT_CTCP: | 242 | case OUTPUT_CTCP: |
234 | appendText("<font color=\"#00bb00\">" + output.htmlMessage() + "</font><br>"); | 243 | appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); |
235 | break; | 244 | break; |
236 | case OUTPUT_ERROR: | 245 | case OUTPUT_ERROR: |
237 | appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>"); | 246 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); |
238 | break; | 247 | break; |
239 | default: | 248 | default: |
240 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "</font><br>"); | 249 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); |
241 | break; | 250 | break; |
242 | } | 251 | } |
243 | } | 252 | } |
diff --git a/noncore/net/opieirc/ircservertab.h b/noncore/net/opieirc/ircservertab.h index e439d84..698689a 100644 --- a/noncore/net/opieirc/ircservertab.h +++ b/noncore/net/opieirc/ircservertab.h | |||
@@ -39,22 +39,25 @@ public: | |||
39 | 39 | ||
40 | /* Start the server session */ | 40 | /* Start the server session */ |
41 | void doConnect(); | 41 | void doConnect(); |
42 | /* Remove tabs from the internal tab lists */ | 42 | /* Remove tabs from the internal tab lists */ |
43 | void removeChannelTab(IRCChannelTab *tab); | 43 | void removeChannelTab(IRCChannelTab *tab); |
44 | void removeQueryTab(IRCQueryTab *tab); | 44 | void removeQueryTab(IRCQueryTab *tab); |
45 | 45 | /* Return tabs from the internal tab lists */ | |
46 | /* Execute a user command such as /join */ | 46 | IRCChannelTab *getTabForChannel(IRCChannel *channel); |
47 | IRCQueryTab *getTabForQuery(IRCPerson *person); | ||
48 | /* Add tabs to the internal tab lists */ | ||
49 | void addQueryTab(IRCQueryTab *tab); | ||
50 | /* Execute a user command such as /join, /msg etc */ | ||
47 | void executeCommand(IRCTab *tab, QString line); | 51 | void executeCommand(IRCTab *tab, QString line); |
48 | protected: | 52 | protected: |
49 | void appendText(QString text); | 53 | void appendText(QString text); |
50 | IRCChannelTab *getTabForChannel(IRCChannel *channel); | ||
51 | IRCQueryTab *getTabForQuery(IRCPerson *person); | ||
52 | public slots: | 54 | public slots: |
53 | void remove(); | 55 | void remove(); |
54 | void processCommand(); | 56 | void processCommand(); |
57 | void settingsChanged(); | ||
55 | protected slots: | 58 | protected slots: |
56 | void display(IRCOutput output); | 59 | void display(IRCOutput output); |
57 | protected: | 60 | protected: |
58 | bool m_close; | 61 | bool m_close; |
59 | IRCServer m_server; | 62 | IRCServer m_server; |
60 | IRCSession *m_session; | 63 | IRCSession *m_session; |
diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp new file mode 100644 index 0000000..d1fef67 --- a/dev/null +++ b/noncore/net/opieirc/ircsettings.cpp | |||
@@ -0,0 +1,71 @@ | |||
1 | #include <qlayout.h> | ||
2 | #include "ircsettings.h" | ||
3 | #include "irctab.h" | ||
4 | #include "ircmisc.h" | ||
5 | #include <stdio.h> | ||
6 | |||
7 | IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags f) : QDialog(parent, name, modal, f) { | ||
8 | m_config = new Config("OpieIRC"); | ||
9 | m_config->setGroup("OpieIRC"); | ||
10 | |||
11 | setCaption("Settings"); | ||
12 | QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 0); | ||
13 | QLabel *label = new QLabel(tr("Background color :"), this); | ||
14 | layout->addWidget(label, 0, 0); | ||
15 | m_background = new IRCFramedColorLabel(QColor(m_config->readEntry("BackgroundColor", "#FFFFFF")), this); | ||
16 | layout->addWidget(m_background, 0, 1); | ||
17 | label = new QLabel(tr("Normal text color :"), this); | ||
18 | layout->addWidget(label, 1, 0); | ||
19 | m_text = new IRCFramedColorLabel(m_config->readEntry("TextColor", "#000000"), this); | ||
20 | layout->addWidget(m_text, 1, 1); | ||
21 | label = new QLabel(tr("Error color :"), this); | ||
22 | layout->addWidget(label, 2, 0); | ||
23 | m_error = new IRCFramedColorLabel(m_config->readEntry("ErrorColor", "#FF0000"), this); | ||
24 | layout->addWidget(m_error, 2, 1); | ||
25 | label = new QLabel(tr("Text written by yourself :"), this); | ||
26 | layout->addWidget(label, 3, 0); | ||
27 | m_self = new IRCFramedColorLabel(m_config->readEntry("SelfColor", "#CC0000"), this); | ||
28 | layout->addWidget(m_self, 3, 1); | ||
29 | label = new QLabel(tr("Text written by others :"), this); | ||
30 | layout->addWidget(label, 4, 0); | ||
31 | m_other = new IRCFramedColorLabel(m_config->readEntry("OtherColor", "#0000BB"), this); | ||
32 | layout->addWidget(m_other, 4, 1); | ||
33 | label = new QLabel(tr("Text written by the server :"), this); | ||
34 | layout->addWidget(label, 5, 0); | ||
35 | m_server = new IRCFramedColorLabel(m_config->readEntry("ServerColor", "#0000FF"), this); | ||
36 | layout->addWidget(m_server, 5, 1); | ||
37 | label = new QLabel(tr("Notifications :"), this); | ||
38 | layout->addWidget(label, 6, 0); | ||
39 | m_notification = new IRCFramedColorLabel(m_config->readEntry("NotificationColor", "#AAE300"), this); | ||
40 | layout->addWidget(m_notification, 6, 1); | ||
41 | showMaximized(); | ||
42 | } | ||
43 | |||
44 | QString IRCSettings::getColorString(QWidget *widget) { | ||
45 | QColor color = ((IRCFramedColorLabel *)widget)->color(); | ||
46 | QString temp; | ||
47 | temp.sprintf("#%02x%02x%02x", color.red(), color.green(), color.blue()); | ||
48 | return temp; | ||
49 | } | ||
50 | |||
51 | void IRCSettings::accept() { | ||
52 | IRCTab::m_backgroundColor = getColorString(m_background); | ||
53 | IRCTab::m_textColor = getColorString(m_text); | ||
54 | IRCTab::m_errorColor = getColorString(m_error); | ||
55 | IRCTab::m_selfColor = getColorString(m_self); | ||
56 | IRCTab::m_otherColor = getColorString(m_other); | ||
57 | IRCTab::m_serverColor = getColorString(m_server); | ||
58 | IRCTab::m_notificationColor = getColorString(m_notification); | ||
59 | m_config->writeEntry("BackgroundColor", getColorString(m_background)); | ||
60 | m_config->writeEntry("TextColor", getColorString(m_text)); | ||
61 | m_config->writeEntry("ErrorColor", getColorString(m_error)); | ||
62 | m_config->writeEntry("SelfColor", getColorString(m_self)); | ||
63 | m_config->writeEntry("OtherColor", getColorString(m_other)); | ||
64 | m_config->writeEntry("ServerColor", getColorString(m_server)); | ||
65 | m_config->writeEntry("NotificationColor", getColorString(m_notification)); | ||
66 | QDialog::accept(); | ||
67 | } | ||
68 | |||
69 | IRCSettings::~IRCSettings() { | ||
70 | delete m_config; | ||
71 | } | ||
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 @@ | |||
1 | /* | ||
2 | OpieIRC - An embedded IRC client | ||
3 | Copyright (C) 2002 Wenzel Jakob | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | |||
19 | */ | ||
20 | |||
21 | #ifndef __IRCSETTINGS_H | ||
22 | #define __IRCSETTINGS_H | ||
23 | |||
24 | #include <qpe/config.h> | ||
25 | #include <qdialog.h> | ||
26 | |||
27 | class IRCSettings : public QDialog { | ||
28 | Q_OBJECT | ||
29 | public: | ||
30 | IRCSettings(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); | ||
31 | QString getColorString(QWidget *widget); | ||
32 | ~IRCSettings(); | ||
33 | protected slots: | ||
34 | void accept(); | ||
35 | protected: | ||
36 | Config *m_config; | ||
37 | QWidget *m_background; | ||
38 | QWidget *m_text; | ||
39 | QWidget *m_error; | ||
40 | QWidget *m_self; | ||
41 | QWidget *m_server; | ||
42 | QWidget *m_other; | ||
43 | QWidget *m_notification; | ||
44 | }; | ||
45 | |||
46 | #endif /* __IRCSETTINGS_H */ | ||
diff --git a/noncore/net/opieirc/irctab.cpp b/noncore/net/opieirc/irctab.cpp index 653a5de..6b578d1 100644 --- a/noncore/net/opieirc/irctab.cpp +++ b/noncore/net/opieirc/irctab.cpp | |||
@@ -1,11 +1,20 @@ | |||
1 | #include <qpe/resource.h> | 1 | #include <qpe/resource.h> |
2 | #include <qpixmap.h> | 2 | #include <qpixmap.h> |
3 | #include <qpushbutton.h> | 3 | #include <qpushbutton.h> |
4 | #include "irctab.h" | 4 | #include "irctab.h" |
5 | 5 | ||
6 | QString IRCTab::m_errorColor; | ||
7 | QString IRCTab::m_serverColor; | ||
8 | QString IRCTab::m_textColor; | ||
9 | QString IRCTab::m_backgroundColor; | ||
10 | QString IRCTab::m_selfColor; | ||
11 | QString IRCTab::m_otherColor; | ||
12 | QString IRCTab::m_notificationColor; | ||
13 | |||
14 | |||
6 | IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { | 15 | IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { |
7 | m_layout = new QVBoxLayout(this); | 16 | m_layout = new QVBoxLayout(this); |
8 | QHBoxLayout *descLayout = new QHBoxLayout(m_layout); | 17 | QHBoxLayout *descLayout = new QHBoxLayout(m_layout); |
9 | descLayout->setMargin(5); | 18 | descLayout->setMargin(5); |
10 | m_description = new QLabel(tr("Missing description"), this); | 19 | m_description = new QLabel(tr("Missing description"), this); |
11 | descLayout->addWidget(m_description); | 20 | descLayout->addWidget(m_description); |
diff --git a/noncore/net/opieirc/irctab.h b/noncore/net/opieirc/irctab.h index 0ce9777..248ea13 100644 --- a/noncore/net/opieirc/irctab.h +++ b/noncore/net/opieirc/irctab.h | |||
@@ -37,12 +37,22 @@ public: | |||
37 | IRCTab(QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 37 | IRCTab(QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
38 | virtual QString title() = 0; | 38 | virtual QString title() = 0; |
39 | virtual IRCSession *session() = 0; | 39 | virtual IRCSession *session() = 0; |
40 | virtual void appendText(QString text) = 0; | 40 | virtual void appendText(QString text) = 0; |
41 | public slots: | 41 | public slots: |
42 | virtual void remove() = 0; | 42 | virtual void remove() = 0; |
43 | virtual void settingsChanged() = 0; | ||
43 | protected: | 44 | protected: |
44 | QLabel *m_description; | 45 | QLabel *m_description; |
45 | QVBoxLayout *m_layout; | 46 | QVBoxLayout *m_layout; |
47 | public: | ||
48 | /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */ | ||
49 | static QString m_errorColor; | ||
50 | static QString m_serverColor; | ||
51 | static QString m_textColor; | ||
52 | static QString m_backgroundColor; | ||
53 | static QString m_selfColor; | ||
54 | static QString m_otherColor; | ||
55 | static QString m_notificationColor; | ||
46 | }; | 56 | }; |
47 | 57 | ||
48 | #endif /* __IRCTAB_H */ | 58 | #endif /* __IRCTAB_H */ |
diff --git a/noncore/net/opieirc/ircversion.h b/noncore/net/opieirc/ircversion.h index f8510e6..f0f196e 100644 --- a/noncore/net/opieirc/ircversion.h +++ b/noncore/net/opieirc/ircversion.h | |||
@@ -18,10 +18,10 @@ | |||
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __IRCVERSION_H | 21 | #ifndef __IRCVERSION_H |
22 | #define __IRCVERSION_H | 22 | #define __IRCVERSION_H |
23 | 23 | ||
24 | #define APP_VERSION "OpieIRC 0.2" | 24 | #define APP_VERSION "OpieIRC 0.3" |
25 | #define APP_COPYSTR "(c) 2002 by Wenzel Jakob" | 25 | #define APP_COPYSTR "(c) 2002 by Wenzel Jakob" |
26 | 26 | ||
27 | #endif /* __IRCVERSION_H */ | 27 | #endif /* __IRCVERSION_H */ |
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp index af4ce78..d78e5ab 100644 --- a/noncore/net/opieirc/mainwindow.cpp +++ b/noncore/net/opieirc/mainwindow.cpp | |||
@@ -3,53 +3,69 @@ | |||
3 | #include <qpe/config.h> | 3 | #include <qpe/config.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | 5 | ||
6 | #include "mainwindow.h" | 6 | #include "mainwindow.h" |
7 | #include "ircservertab.h" | 7 | #include "ircservertab.h" |
8 | #include "ircserverlist.h" | 8 | #include "ircserverlist.h" |
9 | #include "ircsettings.h" | ||
9 | 10 | ||
10 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) { | 11 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) { |
11 | setCaption(tr("IRC Client")); | 12 | setCaption(tr("IRC Client")); |
12 | m_tabWidget = new QTabWidget(this); | 13 | m_tabWidget = new QTabWidget(this); |
13 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(tabSelected(QWidget *))); | ||
14 | setCentralWidget(m_tabWidget); | 14 | setCentralWidget(m_tabWidget); |
15 | setToolBarsMovable(FALSE); | 15 | setToolBarsMovable(FALSE); |
16 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 16 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
17 | QPopupMenu *irc = new QPopupMenu(this); | 17 | QPopupMenu *irc = new QPopupMenu(this); |
18 | menuBar->insertItem(tr("IRC"), irc); | 18 | menuBar->insertItem(tr("IRC"), irc); |
19 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); | 19 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); |
20 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); | 20 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); |
21 | a->addTo(irc); | 21 | a->addTo(irc); |
22 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); | ||
23 | connect(a, SIGNAL(activated()), this, SLOT(settings())); | ||
24 | a->addTo(irc); | ||
25 | loadSettings(); | ||
22 | } | 26 | } |
23 | 27 | ||
24 | void MainWindow::tabSelected(QWidget *) { | 28 | void MainWindow::loadSettings() { |
25 | } | 29 | Config config("OpieIRC"); |
26 | 30 | config.setGroup("OpieIRC"); | |
27 | void MainWindow::closeTab() { | 31 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); |
28 | /* Does not directly close the tab but triggers an action | 32 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); |
29 | which at some point will close the tab using a callback */ | 33 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); |
30 | IRCTab *tab = (IRCTab *)m_tabWidget->currentPage(); | 34 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); |
31 | if (tab) { | 35 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); |
32 | tab->remove(); | 36 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); |
33 | } | 37 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); |
34 | } | 38 | } |
35 | 39 | ||
36 | void MainWindow::addTab(IRCTab *tab) { | 40 | void MainWindow::addTab(IRCTab *tab) { |
37 | m_tabWidget->addTab(tab, tab->title()); | 41 | m_tabWidget->addTab(tab, tab->title()); |
38 | m_tabWidget->showPage(tab); | 42 | m_tabWidget->showPage(tab); |
39 | tabSelected(tab); | 43 | m_tabs.append(tab); |
40 | } | 44 | } |
41 | 45 | ||
42 | void MainWindow::killTab(IRCTab *tab) { | 46 | void MainWindow::killTab(IRCTab *tab) { |
43 | m_tabWidget->removePage(tab); | 47 | m_tabWidget->removePage(tab); |
48 | m_tabs.remove(tab); | ||
44 | /* there might be nicer ways to do this .. */ | 49 | /* there might be nicer ways to do this .. */ |
45 | delete tab; | 50 | delete tab; |
46 | } | 51 | } |
47 | 52 | ||
48 | void MainWindow::newConnection() { | 53 | void MainWindow::newConnection() { |
49 | IRCServerList list(this, "ServerList", TRUE); | 54 | IRCServerList list(this, "ServerList", TRUE); |
50 | if (list.exec() == QDialog::Accepted && list.hasServer()) { | 55 | if (list.exec() == QDialog::Accepted && list.hasServer()) { |
51 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); | 56 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); |
52 | addTab(serverTab); | 57 | addTab(serverTab); |
53 | serverTab->doConnect(); | 58 | serverTab->doConnect(); |
54 | } | 59 | } |
55 | } | 60 | } |
61 | |||
62 | void MainWindow::settings() { | ||
63 | IRCSettings settings(this, "Settings", TRUE); | ||
64 | if (settings.exec() == QDialog::Accepted) { | ||
65 | QListIterator<IRCTab> it(m_tabs); | ||
66 | for (; it.current(); ++it) { | ||
67 | /* Inform all tabs about the new settings */ | ||
68 | it.current()->settingsChanged(); | ||
69 | } | ||
70 | } | ||
71 | } | ||
diff --git a/noncore/net/opieirc/mainwindow.h b/noncore/net/opieirc/mainwindow.h index dcb782f..d057178 100644 --- a/noncore/net/opieirc/mainwindow.h +++ b/noncore/net/opieirc/mainwindow.h | |||
@@ -20,12 +20,13 @@ | |||
20 | 20 | ||
21 | #ifndef __MAINWINDOW_H | 21 | #ifndef __MAINWINDOW_H |
22 | #define __MAINWINDOW_H | 22 | #define __MAINWINDOW_H |
23 | 23 | ||
24 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
25 | #include <qaction.h> | 25 | #include <qaction.h> |
26 | #include <qlist.h> | ||
26 | #include <qtabwidget.h> | 27 | #include <qtabwidget.h> |
27 | #include "mainwindow.h" | 28 | #include "mainwindow.h" |
28 | #include "irctab.h" | 29 | #include "irctab.h" |
29 | 30 | ||
30 | class MainWindow : public QMainWindow { | 31 | class MainWindow : public QMainWindow { |
31 | Q_OBJECT | 32 | Q_OBJECT |
@@ -33,13 +34,15 @@ public: | |||
33 | MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 34 | MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
34 | 35 | ||
35 | void addTab(IRCTab *tab); | 36 | void addTab(IRCTab *tab); |
36 | void killTab(IRCTab *tab); | 37 | void killTab(IRCTab *tab); |
37 | protected slots: | 38 | protected slots: |
38 | void newConnection(); | 39 | void newConnection(); |
39 | void closeTab(); | 40 | void settings(); |
40 | void tabSelected(QWidget *widget); | 41 | protected: |
42 | void loadSettings(); | ||
41 | protected: | 43 | protected: |
42 | QTabWidget *m_tabWidget; | 44 | QTabWidget *m_tabWidget; |
45 | QList<IRCTab> m_tabs; | ||
43 | }; | 46 | }; |
44 | 47 | ||
45 | #endif /* __MAINWINDOW_H */ | 48 | #endif /* __MAINWINDOW_H */ |
diff --git a/noncore/net/opieirc/opieirc.pro b/noncore/net/opieirc/opieirc.pro index 0e188e4..37742f5 100644 --- a/noncore/net/opieirc/opieirc.pro +++ b/noncore/net/opieirc/opieirc.pro | |||
@@ -5,20 +5,20 @@ HEADERS = ircchannel.h ircconnection.h \ | |||
5 | ircmessage.h \ | 5 | ircmessage.h \ |
6 | ircmessageparser.h ircoutput.h \ | 6 | ircmessageparser.h ircoutput.h \ |
7 | ircperson.h ircserver.h ircsession.h \ | 7 | ircperson.h ircserver.h ircsession.h \ |
8 | mainwindow.h irctab.h ircservertab.h \ | 8 | mainwindow.h irctab.h ircservertab.h \ |
9 | ircchanneltab.h ircchannellist.h \ | 9 | ircchanneltab.h ircchannellist.h \ |
10 | ircserverlist.h ircservereditor.h \ | 10 | ircserverlist.h ircservereditor.h \ |
11 | ircquerytab.h | 11 | ircquerytab.h ircsettings.h ircmisc.h |
12 | SOURCES = ircchannel.cpp ircconnection.cpp \ | 12 | SOURCES = ircchannel.cpp ircconnection.cpp \ |
13 | ircmessage.cpp \ | 13 | ircmessage.cpp \ |
14 | ircmessageparser.cpp ircoutput.cpp \ | 14 | ircmessageparser.cpp ircoutput.cpp \ |
15 | ircperson.cpp ircserver.cpp \ | 15 | ircperson.cpp ircserver.cpp \ |
16 | ircsession.cpp main.cpp mainwindow.cpp \ | 16 | ircsession.cpp main.cpp mainwindow.cpp \ |
17 | irctab.cpp ircservertab.cpp \ | 17 | irctab.cpp ircservertab.cpp \ |
18 | ircchanneltab.cpp ircchannellist.cpp \ | 18 | ircchanneltab.cpp ircchannellist.cpp \ |
19 | ircserverlist.cpp ircservereditor.cpp \ | 19 | ircserverlist.cpp ircservereditor.cpp \ |
20 | ircquerytab.cpp | 20 | ircquerytab.cpp ircsettings.cpp ircmisc.cpp |
21 | INCLUDEPATH += $(OPIEDIR)/include | 21 | INCLUDEPATH += $(OPIEDIR)/include |
22 | DEPENDPATH+= $(OPIEDIR)/include | 22 | DEPENDPATH+= $(OPIEDIR)/include |
23 | LIBS += -lqpe | 23 | LIBS += -lqpe -lopie |
24 | 24 | ||