-rw-r--r-- | noncore/net/opieirc/.cvsignore | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchanneltab.cpp | 22 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchanneltab.h | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 34 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmisc.cpp | 5 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmisc.h | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.cpp | 9 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserverlist.cpp | 9 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserverlist.h | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 25 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsettings.cpp | 18 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsettings.h | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/irctab.cpp | 16 | ||||
-rw-r--r-- | noncore/net/opieirc/irctab.h | 4 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 32 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.h | 7 |
16 files changed, 155 insertions, 39 deletions
diff --git a/noncore/net/opieirc/.cvsignore b/noncore/net/opieirc/.cvsignore index d5423d6..0ccbade 100644 --- a/noncore/net/opieirc/.cvsignore +++ b/noncore/net/opieirc/.cvsignore | |||
@@ -1,4 +1,5 @@ | |||
1 | Makefile | 1 | Makefile |
2 | Makefile.in | 2 | Makefile.in |
3 | moc_*.cpp | 3 | moc_*.cpp |
4 | .moc \ No newline at end of file | 4 | .moc |
5 | *.gch \ No newline at end of file | ||
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp index b6e3954..7610058 100644 --- a/noncore/net/opieirc/ircchanneltab.cpp +++ b/noncore/net/opieirc/ircchanneltab.cpp | |||
@@ -1,181 +1,189 @@ | |||
1 | #include <qpe/resource.h> | 1 | #include <qpe/resource.h> |
2 | #include <qwhatsthis.h> | 2 | #include <qwhatsthis.h> |
3 | #include <qhbox.h> | 3 | #include <qhbox.h> |
4 | #include "ircchanneltab.h" | 4 | #include "ircchanneltab.h" |
5 | #include "ircservertab.h" | 5 | #include "ircservertab.h" |
6 | 6 | ||
7 | IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 7 | IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
8 | m_mainWindow = mainWindow; | 8 | m_mainWindow = mainWindow; |
9 | m_parentTab = parentTab; | 9 | m_parentTab = parentTab; |
10 | m_channel = channel; | 10 | m_channel = channel; |
11 | m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); | 11 | m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); |
12 | QHBox *hbox = new QHBox(this); | 12 | QHBox *hbox = new QHBox(this); |
13 | m_textview = new QTextView(hbox); | 13 | m_textview = new QTextView(hbox); |
14 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 14 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
15 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 15 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
16 | m_listVisible = TRUE; | 16 | m_listVisible = TRUE; |
17 | m_listButton = new QPushButton(">", m_textview); | 17 | m_listButton = new QPushButton(">", m_textview); |
18 | m_listButton->setFlat( true ); | ||
18 | m_textview->setCornerWidget(m_listButton); | 19 | m_textview->setCornerWidget(m_listButton); |
19 | m_textview->setTextFormat(RichText); | 20 | m_textview->setTextFormat(RichText); |
20 | QWhatsThis::add(m_textview, tr("Channel discussion")); | 21 | QWhatsThis::add(m_textview, tr("Channel discussion")); |
21 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); | 22 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); |
22 | m_list = new IRCChannelList(m_channel, hbox); | 23 | m_list = new IRCChannelList(m_channel, hbox); |
23 | m_list->update(); | 24 | m_list->update(); |
24 | m_list->setMaximumWidth(LISTWIDTH); | 25 | m_list->setMaximumWidth(LISTWIDTH); |
25 | m_field = new IRCHistoryLineEdit(this); | 26 | m_field = new IRCHistoryLineEdit(this); |
26 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); | 27 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); |
27 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); | 28 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); |
28 | connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab())); | 29 | connect(m_field, SIGNAL(closeTab()), this, SLOT(remove())); |
29 | connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); | 30 | connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); |
30 | 31 | ||
31 | QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); | 32 | QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); |
32 | m_popup = new QPopupMenu(m_list); | 33 | m_popup = new QPopupMenu(m_list); |
33 | m_lines = 0; | 34 | m_lines = 0; |
34 | /* Required so that embedded-style "right" clicks work */ | 35 | /* Required so that embedded-style "right" clicks work */ |
35 | QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); | 36 | QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); |
36 | connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); | 37 | connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); |
37 | /* Construct the popup menu */ | 38 | /* Construct the popup menu */ |
38 | QPopupMenu *ctcpMenu = new QPopupMenu(m_list); | 39 | QPopupMenu *ctcpMenu = new QPopupMenu(m_list); |
39 | m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); | ||
40 | m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); | 40 | m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); |
41 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); | 41 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); |
42 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); | 42 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); |
43 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); | 43 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); |
44 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); | 44 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); |
45 | m_layout->add(hbox); | 45 | m_layout->add(hbox); |
46 | hbox->show(); | 46 | hbox->show(); |
47 | m_layout->add(m_field); | 47 | m_layout->add(m_field); |
48 | m_field->setFocus(); | 48 | m_field->setFocus(); |
49 | m_field->setActiveWindow(); | 49 | m_field->setActiveWindow(); |
50 | 50 | ||
51 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 51 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
52 | connect(m_list, SIGNAL(doubleClicked ( QListBoxItem * ) ), this, SLOT(popupQuery( QListBoxItem * ) )); | ||
52 | settingsChanged(); | 53 | settingsChanged(); |
53 | } | 54 | } |
54 | 55 | ||
55 | void IRCChannelTab::scrolling(){ | 56 | void IRCChannelTab::scrolling(){ |
56 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 57 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
57 | } | 58 | } |
58 | 59 | ||
59 | void IRCChannelTab::appendText(QString text) { | 60 | void IRCChannelTab::appendText(QString text) { |
60 | /* not using append because it creates layout problems */ | 61 | /* not using append because it creates layout problems */ |
61 | QString txt = m_textview->text() + text + "\n"; | 62 | QString txt = m_textview->text() + IRCTab::appendTimestamp( text ); |
62 | if (m_maxLines > 0 && m_lines >= m_maxLines) { | 63 | if (m_maxLines > 0 && m_lines >= m_maxLines) { |
63 | int firstBreak = txt.find('\n'); | 64 | int firstBreak = txt.find('\n'); |
64 | if (firstBreak != -1) { | 65 | if (firstBreak != -1) { |
65 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); | 66 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); |
66 | } | 67 | } |
67 | } else { | 68 | } else { |
68 | m_lines++; | 69 | m_lines++; |
69 | } | 70 | } |
70 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 71 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
71 | m_textview->setText(txt); | 72 | m_textview->setText(txt); |
72 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 73 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
73 | 74 | ||
74 | int p1, p2; | 75 | int p1, p2; |
75 | if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) { | 76 | if ( text.contains( IRCMessageParser::tr("Received a CTCP PING from ") ) ) |
77 | emit ping( title() ); | ||
78 | else if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) { | ||
76 | int col = text.findRev("color", -1, false); | 79 | int col = text.findRev("color", -1, false); |
77 | if ( col < p2 ) | 80 | if ( col < p2 ) |
78 | emit ping( title() ); | 81 | emit ping( title() ); |
79 | 82 | ||
80 | } | 83 | } |
81 | 84 | ||
82 | emit changed(this); | 85 | emit changed(this); |
83 | } | 86 | } |
84 | 87 | ||
85 | IRCChannelTab::~IRCChannelTab() { | 88 | IRCChannelTab::~IRCChannelTab() { |
86 | m_parentTab->removeChannelTab(this); | 89 | m_parentTab->removeChannelTab(this); |
87 | } | 90 | } |
88 | 91 | ||
89 | void IRCChannelTab::processCommand() { | 92 | void IRCChannelTab::processCommand() { |
90 | QString text = m_field->text(); | 93 | QString text = m_field->text(); |
91 | if (text.length()>0) { | 94 | if (text.length()>0) { |
92 | if (session()->isSessionActive()) { | 95 | if (session()->isSessionActive()) { |
93 | if (text.startsWith("/") && !text.startsWith("//")) { | 96 | if (text.startsWith("/") && !text.startsWith("//")) { |
94 | /* Command mode */ | 97 | /* Command mode */ |
95 | m_parentTab->executeCommand(this, text);; | 98 | m_parentTab->executeCommand(this, text);; |
96 | } else { | 99 | } else { |
97 | if (text.startsWith("//")) | 100 | if (text.startsWith("//")) |
98 | text = text.right(text.length()-1); | 101 | text = text.right(text.length()-1); |
99 | session()->sendMessage(m_channel, m_field->text()); | 102 | session()->sendMessage(m_channel, m_field->text()); |
100 | 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>"); | 103 | 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>"); |
101 | } | 104 | } |
102 | } else { | 105 | } else { |
103 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); | 106 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); |
104 | } | 107 | } |
105 | } | 108 | } |
106 | m_field->clear(); | 109 | m_field->clear(); |
107 | } | 110 | } |
108 | 111 | ||
109 | void IRCChannelTab::settingsChanged() { | 112 | void IRCChannelTab::settingsChanged() { |
110 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | 113 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); |
111 | m_lines = 0; | 114 | m_lines = 0; |
112 | } | 115 | } |
113 | 116 | ||
114 | void IRCChannelTab::toggleList() { | 117 | void IRCChannelTab::toggleList() { |
115 | if (m_listVisible) { | 118 | if (m_listVisible) { |
116 | m_list->setMaximumWidth(0); | 119 | m_list->setMaximumWidth(0); |
117 | m_listButton->setText("<"); | 120 | m_listButton->setText("<"); |
118 | } else { | 121 | } else { |
119 | m_list->setMaximumWidth(LISTWIDTH); | 122 | m_list->setMaximumWidth(LISTWIDTH); |
120 | m_listButton->setText(">"); | 123 | m_listButton->setText(">"); |
121 | } | 124 | } |
122 | m_listVisible = !m_listVisible; | 125 | m_listVisible = !m_listVisible; |
123 | } | 126 | } |
124 | 127 | ||
125 | void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { | 128 | void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { |
126 | switch (mouse) { | 129 | switch (mouse) { |
127 | case 1: | 130 | case 1: |
128 | break; | 131 | break; |
129 | case 2: | 132 | case 2: |
130 | m_popup->popup(point); | 133 | m_popup->popup(point); |
131 | break; | 134 | break; |
132 | }; | 135 | }; |
133 | } | 136 | } |
134 | 137 | ||
135 | void IRCChannelTab::popupQuery() { | 138 | void IRCChannelTab::popupQuery( QListBoxItem *item) { |
136 | if (m_list->currentItem() != -1) { | 139 | if (item) { |
137 | IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); | 140 | IRCPerson *person = session()->getPerson(item->text()); |
138 | if (person) { | 141 | if (person) { |
139 | IRCQueryTab *tab = m_parentTab->getTabForQuery(person); | 142 | IRCQueryTab *tab = m_parentTab->getTabForQuery(person); |
140 | if (!tab) { | 143 | if (!tab) { |
141 | tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); | 144 | tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); |
142 | m_parentTab->addQueryTab(tab); | 145 | m_parentTab->addQueryTab(tab); |
143 | m_mainWindow->addTab(tab); | 146 | m_mainWindow->addTab(tab); |
144 | } | 147 | } |
145 | } | 148 | } |
146 | } | 149 | } |
147 | } | 150 | } |
148 | 151 | ||
152 | void IRCChannelTab::popupQuery() { | ||
153 | if ( m_list->currentItem() != -1 ) | ||
154 | popupQuery( m_list->item(m_list->currentItem())); | ||
155 | } | ||
156 | |||
149 | void IRCChannelTab::popupPing() { | 157 | void IRCChannelTab::popupPing() { |
150 | //HAHA, no wonder these don't work | 158 | //HAHA, no wonder these don't work |
151 | } | 159 | } |
152 | 160 | ||
153 | void IRCChannelTab::popupVersion() { | 161 | void IRCChannelTab::popupVersion() { |
154 | } | 162 | } |
155 | 163 | ||
156 | void IRCChannelTab::popupWhois() { | 164 | void IRCChannelTab::popupWhois() { |
157 | } | 165 | } |
158 | 166 | ||
159 | QString IRCChannelTab::title() { | 167 | QString IRCChannelTab::title() { |
160 | return m_channel->channelname(); | 168 | return m_channel->channelname(); |
161 | } | 169 | } |
162 | 170 | ||
163 | IRCSession *IRCChannelTab::session() { | 171 | IRCSession *IRCChannelTab::session() { |
164 | return m_parentTab->session(); | 172 | return m_parentTab->session(); |
165 | } | 173 | } |
166 | 174 | ||
167 | void IRCChannelTab::remove() { | 175 | void IRCChannelTab::remove() { |
168 | if (session()->isSessionActive()) { | 176 | if (session()->isSessionActive()) { |
169 | session()->part(m_channel); | 177 | session()->part(m_channel); |
170 | } else { | 178 | } else { |
171 | m_mainWindow->killTab(this); | 179 | m_mainWindow->killTab(this); |
172 | } | 180 | } |
173 | } | 181 | } |
174 | 182 | ||
175 | IRCChannel *IRCChannelTab::channel() { | 183 | IRCChannel *IRCChannelTab::channel() { |
176 | return m_channel; | 184 | return m_channel; |
177 | } | 185 | } |
178 | 186 | ||
179 | IRCChannelList *IRCChannelTab::list() { | 187 | IRCChannelList *IRCChannelTab::list() { |
180 | return m_list; | 188 | return m_list; |
181 | } | 189 | } |
diff --git a/noncore/net/opieirc/ircchanneltab.h b/noncore/net/opieirc/ircchanneltab.h index 001c96d..70b212c 100644 --- a/noncore/net/opieirc/ircchanneltab.h +++ b/noncore/net/opieirc/ircchanneltab.h | |||
@@ -1,73 +1,75 @@ | |||
1 | /* | 1 | /* |
2 | OpieIRC - An embedded IRC client | 2 | OpieIRC - An embedded IRC client |
3 | Copyright (C) 2002 Wenzel Jakob | 3 | Copyright (C) 2002 Wenzel Jakob |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 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 | 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 | 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
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 <qpopupmenu.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include "irctab.h" | 26 | #include "irctab.h" |
27 | #include "ircsession.h" | 27 | #include "ircsession.h" |
28 | #include "ircmisc.h" | 28 | #include "ircmisc.h" |
29 | #include "mainwindow.h" | 29 | #include "mainwindow.h" |
30 | #include "ircchannellist.h" | 30 | #include "ircchannellist.h" |
31 | 31 | ||
32 | #define LISTWIDTH 70 | 32 | #define LISTWIDTH 70 |
33 | 33 | ||
34 | class IRCServerTab; | 34 | class IRCServerTab; |
35 | class IRCChannelTab : public IRCTab { | 35 | class IRCChannelTab : public IRCTab { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | /* IRCTab implementation */ | 38 | /* IRCTab implementation */ |
39 | IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 39 | IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
40 | ~IRCChannelTab(); | 40 | ~IRCChannelTab(); |
41 | QString title(); | 41 | QString title(); |
42 | IRCSession *session(); | 42 | IRCSession *session(); |
43 | IRCChannel *channel(); | 43 | IRCChannel *channel(); |
44 | IRCChannelList *list(); | 44 | IRCChannelList *list(); |
45 | public: | 45 | public: |
46 | void appendText(QString text); | 46 | void appendText(QString text); |
47 | public slots: | 47 | public slots: |
48 | void remove(); | 48 | void remove(); |
49 | void settingsChanged(); | 49 | void settingsChanged(); |
50 | void scrolling(); | 50 | void scrolling(); |
51 | protected slots: | 51 | protected slots: |
52 | void processCommand(); | 52 | void processCommand(); |
53 | void toggleList(); | 53 | void toggleList(); |
54 | void mouseButtonPressed(int mouse, QListBoxItem *item, const QPoint &point); | 54 | void mouseButtonPressed(int mouse, QListBoxItem *item, const QPoint &point); |
55 | /* Popup slots */ | 55 | /* Popup slots */ |
56 | void popupQuery(QListBoxItem*); | ||
56 | void popupQuery(); | 57 | void popupQuery(); |
58 | |||
57 | void popupPing(); | 59 | void popupPing(); |
58 | void popupVersion(); | 60 | void popupVersion(); |
59 | void popupWhois(); | 61 | void popupWhois(); |
60 | protected: | 62 | protected: |
61 | IRCServerTab *m_parentTab; | 63 | IRCServerTab *m_parentTab; |
62 | IRCChannel *m_channel; | 64 | IRCChannel *m_channel; |
63 | IRCChannelList *m_list; | 65 | IRCChannelList *m_list; |
64 | QPushButton *m_listButton; | 66 | QPushButton *m_listButton; |
65 | MainWindow *m_mainWindow; | 67 | MainWindow *m_mainWindow; |
66 | QTextView *m_textview; | 68 | QTextView *m_textview; |
67 | IRCHistoryLineEdit *m_field; | 69 | IRCHistoryLineEdit *m_field; |
68 | QPopupMenu *m_popup; | 70 | QPopupMenu *m_popup; |
69 | bool m_listVisible; | 71 | bool m_listVisible; |
70 | int m_lines; | 72 | int m_lines; |
71 | }; | 73 | }; |
72 | 74 | ||
73 | #endif /* __IRCCHANNELTAB_H */ | 75 | #endif /* __IRCCHANNELTAB_H */ |
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index 90280d7..ecc7e9a 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -222,128 +222,162 @@ void IRCMessageParser::parseLiteralNick(IRCMessage *message) { | |||
222 | //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); | 222 | //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); |
223 | 223 | ||
224 | /* new code starts here -- this removes the person from all channels */ | 224 | /* new code starts here -- this removes the person from all channels */ |
225 | QList<IRCChannel> channels; | 225 | QList<IRCChannel> channels; |
226 | m_session->getChannelsByPerson(person, channels); | 226 | m_session->getChannelsByPerson(person, channels); |
227 | QListIterator<IRCChannel> it(channels); | 227 | QListIterator<IRCChannel> it(channels); |
228 | for (;it.current(); ++it) { | 228 | for (;it.current(); ++it) { |
229 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); | 229 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); |
230 | it.current()->removePerson(chanperson); | 230 | it.current()->removePerson(chanperson); |
231 | chanperson->person->setNick(message->param(0)); | 231 | chanperson->person->setNick(message->param(0)); |
232 | it.current()->addPerson(chanperson); | 232 | it.current()->addPerson(chanperson); |
233 | IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); | 233 | IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); |
234 | output.addParam(person); | 234 | output.addParam(person); |
235 | emit outputReady(output); | 235 | emit outputReady(output); |
236 | } | 236 | } |
237 | /* new code ends here */ | 237 | /* new code ends here */ |
238 | } else { | 238 | } else { |
239 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); | 239 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | } | 242 | } |
243 | 243 | ||
244 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { | 244 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { |
245 | IRCPerson mask(message->prefix()); | 245 | IRCPerson mask(message->prefix()); |
246 | IRCPerson *person = m_session->getPerson(mask.nick()); | 246 | IRCPerson *person = m_session->getPerson(mask.nick()); |
247 | if (person) { | 247 | if (person) { |
248 | QList<IRCChannel> channels; | 248 | QList<IRCChannel> channels; |
249 | m_session->getChannelsByPerson(person, channels); | 249 | m_session->getChannelsByPerson(person, channels); |
250 | QListIterator<IRCChannel> it(channels); | 250 | QListIterator<IRCChannel> it(channels); |
251 | for (;it.current(); ++it) { | 251 | for (;it.current(); ++it) { |
252 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); | 252 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); |
253 | it.current()->removePerson(chanperson); | 253 | it.current()->removePerson(chanperson); |
254 | delete chanperson; | 254 | delete chanperson; |
255 | } | 255 | } |
256 | m_session->removePerson(person); | 256 | m_session->removePerson(person); |
257 | IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) )); | 257 | IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) )); |
258 | output.addParam(person); | 258 | output.addParam(person); |
259 | emit outputReady(output); | 259 | emit outputReady(output); |
260 | delete person; | 260 | delete person; |
261 | } else { | 261 | } else { |
262 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); | 262 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { | 266 | void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { |
267 | IRCPerson mask(message->prefix()); | 267 | IRCPerson mask(message->prefix()); |
268 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 268 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
269 | if (channel) { | 269 | if (channel) { |
270 | IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); | 270 | IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); |
271 | output.addParam(channel); | 271 | output.addParam(channel); |
272 | emit outputReady(output); | 272 | emit outputReady(output); |
273 | } else { | 273 | } else { |
274 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); | 274 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { | 278 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { |
279 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); | 279 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); |
280 | } | 280 | } |
281 | 281 | ||
282 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { | 282 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { |
283 | IRCPerson mask(message->prefix()); | 283 | IRCPerson mask(message->prefix()); |
284 | m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); | 284 | m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); |
285 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); | 285 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); |
286 | |||
287 | //IRCPerson mask(message->prefix()); | ||
288 | QString dest = message->ctcpDestination(); | ||
289 | if (dest.startsWith("#")) { | ||
290 | IRCChannel *channel = m_session->getChannel(dest.lower()); | ||
291 | if (channel) { | ||
292 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | ||
293 | if (person) { | ||
294 | IRCOutput output(OUTPUT_CHANACTION, tr("Received a CTCP PING from ")+ mask.nick()) ; | ||
295 | output.addParam(channel); | ||
296 | output.addParam(person); | ||
297 | emit outputReady(output); | ||
298 | } else { | ||
299 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown person - Desynchronized?"))); | ||
300 | } | ||
301 | } else { | ||
302 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown channel - Desynchronized?"))); | ||
303 | } | ||
304 | } else { | ||
305 | if (message->ctcpDestination() == m_session->m_server->nick()) { | ||
306 | IRCPerson *person = m_session->getPerson(mask.nick()); | ||
307 | if (!person) { | ||
308 | /* Person not yet known, create and add to the current session */ | ||
309 | person = new IRCPerson(message->prefix()); | ||
310 | m_session->addPerson(person); | ||
311 | } | ||
312 | IRCOutput output(OUTPUT_QUERYACTION, tr("Received a CTCP PING from ")+ mask.nick() ); | ||
313 | output.addParam(person); | ||
314 | emit outputReady(output); | ||
315 | } else { | ||
316 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with bad recipient"))); | ||
317 | } | ||
318 | } | ||
319 | |||
286 | } | 320 | } |
287 | 321 | ||
288 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { | 322 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { |
289 | IRCPerson mask(message->prefix()); | 323 | IRCPerson mask(message->prefix()); |
290 | m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); | 324 | m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); |
291 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); | 325 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); |
292 | } | 326 | } |
293 | 327 | ||
294 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { | 328 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { |
295 | IRCPerson mask(message->prefix()); | 329 | IRCPerson mask(message->prefix()); |
296 | QString dest = message->ctcpDestination(); | 330 | QString dest = message->ctcpDestination(); |
297 | if (dest.startsWith("#")) { | 331 | if (dest.startsWith("#")) { |
298 | IRCChannel *channel = m_session->getChannel(dest.lower()); | 332 | IRCChannel *channel = m_session->getChannel(dest.lower()); |
299 | if (channel) { | 333 | if (channel) { |
300 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 334 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
301 | if (person) { | 335 | if (person) { |
302 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); | 336 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); |
303 | output.addParam(channel); | 337 | output.addParam(channel); |
304 | output.addParam(person); | 338 | output.addParam(person); |
305 | emit outputReady(output); | 339 | emit outputReady(output); |
306 | } else { | 340 | } else { |
307 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); | 341 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); |
308 | } | 342 | } |
309 | } else { | 343 | } else { |
310 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); | 344 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); |
311 | } | 345 | } |
312 | } else { | 346 | } else { |
313 | if (message->ctcpDestination() == m_session->m_server->nick()) { | 347 | if (message->ctcpDestination() == m_session->m_server->nick()) { |
314 | IRCPerson *person = m_session->getPerson(mask.nick()); | 348 | IRCPerson *person = m_session->getPerson(mask.nick()); |
315 | if (!person) { | 349 | if (!person) { |
316 | /* Person not yet known, create and add to the current session */ | 350 | /* Person not yet known, create and add to the current session */ |
317 | person = new IRCPerson(message->prefix()); | 351 | person = new IRCPerson(message->prefix()); |
318 | m_session->addPerson(person); | 352 | m_session->addPerson(person); |
319 | } | 353 | } |
320 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); | 354 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); |
321 | output.addParam(person); | 355 | output.addParam(person); |
322 | emit outputReady(output); | 356 | emit outputReady(output); |
323 | } else { | 357 | } else { |
324 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); | 358 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); |
325 | } | 359 | } |
326 | } | 360 | } |
327 | } | 361 | } |
328 | 362 | ||
329 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | 363 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { |
330 | IRCPerson mask(message->prefix()); | 364 | IRCPerson mask(message->prefix()); |
331 | 365 | ||
332 | if (message->param(0).startsWith("#")) { | 366 | if (message->param(0).startsWith("#")) { |
333 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 367 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
334 | if (channel) { | 368 | if (channel) { |
335 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); | 369 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); |
336 | QTextIStream stream(¶meters); | 370 | QTextIStream stream(¶meters); |
337 | bool set = FALSE; | 371 | bool set = FALSE; |
338 | while (!stream.atEnd()) { | 372 | while (!stream.atEnd()) { |
339 | stream >> temp; | 373 | stream >> temp; |
340 | if (temp.startsWith("+")) { | 374 | if (temp.startsWith("+")) { |
341 | set = TRUE; | 375 | set = TRUE; |
342 | temp = temp.right(1); | 376 | temp = temp.right(1); |
343 | } else if (temp.startsWith("-")) { | 377 | } else if (temp.startsWith("-")) { |
344 | set = FALSE; | 378 | set = FALSE; |
345 | temp = temp.right(1); | 379 | temp = temp.right(1); |
346 | } else { | 380 | } else { |
347 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); | 381 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); |
348 | return; | 382 | return; |
349 | } | 383 | } |
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp index 9b9bff8..6fc5ba0 100644 --- a/noncore/net/opieirc/ircmisc.cpp +++ b/noncore/net/opieirc/ircmisc.cpp | |||
@@ -6,128 +6,133 @@ | |||
6 | #include <opie2/okeyconfigmanager.h> | 6 | #include <opie2/okeyconfigmanager.h> |
7 | using namespace Opie::Core; | 7 | using namespace Opie::Core; |
8 | 8 | ||
9 | 9 | ||
10 | IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { | 10 | IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { |
11 | } | 11 | } |
12 | 12 | ||
13 | int IRCTabBar::insertTab(QTab *tab, int index) { | 13 | int IRCTabBar::insertTab(QTab *tab, int index) { |
14 | /* FIXME: find some nicer way to do this */ | 14 | /* FIXME: find some nicer way to do this */ |
15 | QExtTab *ext = new QExtTab(); | 15 | QExtTab *ext = new QExtTab(); |
16 | ext->color = black; | 16 | ext->color = black; |
17 | ext->label = tab->text(); | 17 | ext->label = tab->text(); |
18 | ext->r = tab->rect(); | 18 | ext->r = tab->rect(); |
19 | ext->enabled = tab->isEnabled(); | 19 | ext->enabled = tab->isEnabled(); |
20 | ext->iconset = tab->iconSet(); | 20 | ext->iconset = tab->iconSet(); |
21 | delete tab; | 21 | delete tab; |
22 | return QTabBar::insertTab(ext, index); | 22 | return QTabBar::insertTab(ext, index); |
23 | } | 23 | } |
24 | 24 | ||
25 | void IRCTabBar::setTabColor(int index, QColor color) { | 25 | void IRCTabBar::setTabColor(int index, QColor color) { |
26 | ((QExtTab *)tab(index))->color = color; | 26 | ((QExtTab *)tab(index))->color = color; |
27 | update(); | 27 | update(); |
28 | } | 28 | } |
29 | 29 | ||
30 | void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const { | 30 | void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const { |
31 | QRect r = br; | 31 | QRect r = br; |
32 | QTabBar::paintLabel(p, br, t, focus); | 32 | QTabBar::paintLabel(p, br, t, focus); |
33 | if (t->id == currentTab()) | 33 | if (t->id == currentTab()) |
34 | r.setBottom(r.bottom() - style().defaultFrameWidth()); | 34 | r.setBottom(r.bottom() - style().defaultFrameWidth()); |
35 | p->setPen(((QExtTab *)t)->color); | 35 | p->setPen(((QExtTab *)t)->color); |
36 | p->drawText(r, AlignCenter | ShowPrefix, t->label); | 36 | p->drawText(r, AlignCenter | ShowPrefix, t->label); |
37 | } | 37 | } |
38 | 38 | ||
39 | IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) { | 39 | IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) { |
40 | setTabBar(new IRCTabBar(this, "tab control")); | 40 | setTabBar(new IRCTabBar(this, "tab control")); |
41 | } | 41 | } |
42 | 42 | ||
43 | void IRCTabWidget::setTabColor(int index, QColor color) { | 43 | void IRCTabWidget::setTabColor(int index, QColor color) { |
44 | ((IRCTabBar *)tabBar())->setTabColor(index, color); | 44 | ((IRCTabBar *)tabBar())->setTabColor(index, color); |
45 | } | 45 | } |
46 | 46 | ||
47 | 47 | ||
48 | 48 | ||
49 | static OKeyConfigManager* s_manager = 0; | 49 | static OKeyConfigManager* s_manager = 0; |
50 | OKeyConfigManager* IRCHistoryLineEdit::keyConfigInstance() { | 50 | OKeyConfigManager* IRCHistoryLineEdit::keyConfigInstance() { |
51 | if ( !s_manager ) { | 51 | if ( !s_manager ) { |
52 | /* | 52 | /* |
53 | * black list with the DeviceButtons as default | 53 | * black list with the DeviceButtons as default |
54 | * because we do not grab the keyboard and they | 54 | * because we do not grab the keyboard and they |
55 | * wouldn't work | 55 | * wouldn't work |
56 | */ | 56 | */ |
57 | OKeyPair::List blackList = OKeyPair::hardwareKeys(); | 57 | OKeyPair::List blackList = OKeyPair::hardwareKeys(); |
58 | blackList.append( OKeyPair::returnKey() ); | 58 | blackList.append( OKeyPair::returnKey() ); |
59 | blackList.append( OKeyPair::leftArrowKey() ); | 59 | blackList.append( OKeyPair::leftArrowKey() ); |
60 | blackList.append( OKeyPair::upArrowKey() ); | 60 | blackList.append( OKeyPair::upArrowKey() ); |
61 | blackList.append( OKeyPair::downArrowKey() ); | 61 | blackList.append( OKeyPair::downArrowKey() ); |
62 | 62 | ||
63 | s_manager = new OKeyConfigManager(new OConfig("opieirc-keys"), | 63 | s_manager = new OKeyConfigManager(new OConfig("opieirc-keys"), |
64 | "keys", blackList, | 64 | "keys", blackList, |
65 | false, 0, "irc_history_line_keyconfigm" ); | 65 | false, 0, "irc_history_line_keyconfigm" ); |
66 | s_manager->addKeyConfig( OKeyConfigItem( tr("Next Tab"), "next_tab", QPixmap(), | 66 | s_manager->addKeyConfig( OKeyConfigItem( tr("Next Tab"), "next_tab", QPixmap(), |
67 | KeyNextTab, OKeyPair(Qt::Key_N, Qt::ControlButton) )); | 67 | KeyNextTab, OKeyPair(Qt::Key_N, Qt::ControlButton) )); |
68 | s_manager->addKeyConfig( OKeyConfigItem( tr("Previous Tab"), "prev_tab", QPixmap(), | 68 | s_manager->addKeyConfig( OKeyConfigItem( tr("Previous Tab"), "prev_tab", QPixmap(), |
69 | KeyPrevTab, OKeyPair(Qt::Key_P, Qt::ControlButton) )); | 69 | KeyPrevTab, OKeyPair(Qt::Key_P, Qt::ControlButton) )); |
70 | s_manager->addKeyConfig( OKeyConfigItem( tr("Close Tab"), "close_tab", | ||
71 | QPixmap(), KeyCloseTab, | ||
72 | OKeyPair(Qt::Key_C, Qt::ControlButton) )); | ||
70 | s_manager->load(); | 73 | s_manager->load(); |
71 | } | 74 | } |
72 | 75 | ||
73 | return s_manager; | 76 | return s_manager; |
74 | } | 77 | } |
75 | 78 | ||
76 | 79 | ||
77 | IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { | 80 | IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { |
78 | m_index = -1; | 81 | m_index = -1; |
79 | installEventFilter(this); | 82 | installEventFilter(this); |
80 | } | 83 | } |
81 | 84 | ||
82 | void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) { | 85 | void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) { |
83 | int key = event->key(); | 86 | int key = event->key(); |
84 | if (key == Key_Up) { | 87 | if (key == Key_Up) { |
85 | if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) { | 88 | if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) { |
86 | m_index++; | 89 | m_index++; |
87 | setText(m_history[m_index]); | 90 | setText(m_history[m_index]); |
88 | } | 91 | } |
89 | } else if (key == Key_Down) { | 92 | } else if (key == Key_Down) { |
90 | if (m_history.count() > 0 && m_index > 0) { | 93 | if (m_history.count() > 0 && m_index > 0) { |
91 | m_index--; | 94 | m_index--; |
92 | setText(m_history[m_index]); | 95 | setText(m_history[m_index]); |
93 | } | 96 | } |
94 | if (m_index == 0) { | 97 | if (m_index == 0) { |
95 | m_index = -1; | 98 | m_index = -1; |
96 | setText(""); | 99 | setText(""); |
97 | } | 100 | } |
98 | } else if (key == Key_Return) { | 101 | } else if (key == Key_Return) { |
99 | m_history.prepend(text()); | 102 | m_history.prepend(text()); |
100 | m_index = -1; | 103 | m_index = -1; |
101 | } | 104 | } |
102 | 105 | ||
103 | switch( keyConfigInstance()->handleKeyEventId( event ) ) { | 106 | switch( keyConfigInstance()->handleKeyEventId( event ) ) { |
104 | case KeyNextTab: | 107 | case KeyNextTab: |
105 | emit nextTab(); | 108 | emit nextTab(); |
106 | return; | 109 | return; |
107 | case KeyPrevTab: | 110 | case KeyPrevTab: |
108 | emit prevTab(); | 111 | emit prevTab(); |
109 | return; | 112 | return; |
113 | case KeyCloseTab: | ||
114 | emit closeTab(); | ||
110 | default: | 115 | default: |
111 | break; | 116 | break; |
112 | } | 117 | } |
113 | 118 | ||
114 | QLineEdit::keyPressEvent(event); | 119 | QLineEdit::keyPressEvent(event); |
115 | } | 120 | } |
116 | 121 | ||
117 | bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) { | 122 | bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) { |
118 | if (event->type() == QEvent::KeyPress) { | 123 | if (event->type() == QEvent::KeyPress) { |
119 | QKeyEvent *k = (QKeyEvent *) event; | 124 | QKeyEvent *k = (QKeyEvent *) event; |
120 | /* Catch tab characters */ | 125 | /* Catch tab characters */ |
121 | if (k->key() == Key_Tab) { | 126 | if (k->key() == Key_Tab) { |
122 | emit nextTab(); | 127 | emit nextTab(); |
123 | return TRUE; | 128 | return TRUE; |
124 | } | 129 | } |
125 | } | 130 | } |
126 | return QLineEdit::eventFilter(object, event); | 131 | return QLineEdit::eventFilter(object, event); |
127 | } | 132 | } |
128 | 133 | ||
129 | 134 | ||
130 | void IRCHistoryLineEdit::setEditFocus() { | 135 | void IRCHistoryLineEdit::setEditFocus() { |
131 | setActiveWindow(); | 136 | setActiveWindow(); |
132 | setFocus(); | 137 | setFocus(); |
133 | } | 138 | } |
diff --git a/noncore/net/opieirc/ircmisc.h b/noncore/net/opieirc/ircmisc.h index 37eed28..3cf64df 100644 --- a/noncore/net/opieirc/ircmisc.h +++ b/noncore/net/opieirc/ircmisc.h | |||
@@ -7,87 +7,88 @@ | |||
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 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 | 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 | 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __IRCMISC_H | 21 | #ifndef __IRCMISC_H |
22 | #define __IRCMISC_H | 22 | #define __IRCMISC_H |
23 | 23 | ||
24 | #include <qtabwidget.h> | 24 | #include <qtabwidget.h> |
25 | #include <qlineedit.h> | 25 | #include <qlineedit.h> |
26 | #include <qtabbar.h> | 26 | #include <qtabbar.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qcolor.h> | 28 | #include <qcolor.h> |
29 | #include <qarray.h> | 29 | #include <qarray.h> |
30 | 30 | ||
31 | namespace Opie { | 31 | namespace Opie { |
32 | namespace Core { | 32 | namespace Core { |
33 | class OKeyConfigManager; | 33 | class OKeyConfigManager; |
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
37 | 37 | ||
38 | /* Custom colored QTabWidget */ | 38 | /* Custom colored QTabWidget */ |
39 | 39 | ||
40 | class QExtTab : public QTab { | 40 | class QExtTab : public QTab { |
41 | public: | 41 | public: |
42 | QColor color; | 42 | QColor color; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | class IRCTabWidget : public QTabWidget { | 45 | class IRCTabWidget : public QTabWidget { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | public: | 47 | public: |
48 | IRCTabWidget(QWidget *parent = 0, const char *name = 0); | 48 | IRCTabWidget(QWidget *parent = 0, const char *name = 0); |
49 | void setTabColor(int index, QColor color); | 49 | void setTabColor(int index, QColor color); |
50 | }; | 50 | }; |
51 | 51 | ||
52 | class IRCTabBar : public QTabBar { | 52 | class IRCTabBar : public QTabBar { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | public: | 54 | public: |
55 | IRCTabBar(QWidget *parent = 0, const char *name = 0); | 55 | IRCTabBar(QWidget *parent = 0, const char *name = 0); |
56 | void setTabColor(int index, QColor color); | 56 | void setTabColor(int index, QColor color); |
57 | protected: | 57 | protected: |
58 | void paintLabel(QPainter*, const QRect&, QTab*, bool) const; | 58 | void paintLabel(QPainter*, const QRect&, QTab*, bool) const; |
59 | int insertTab(QTab *, int index = -1); | 59 | int insertTab(QTab *, int index = -1); |
60 | protected: | 60 | protected: |
61 | QArray<QColor> m_colors; | 61 | QArray<QColor> m_colors; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | /* A QLineEdit with history functionality and tab completion */ | 64 | /* A QLineEdit with history functionality and tab completion */ |
65 | 65 | ||
66 | class IRCHistoryLineEdit : public QLineEdit { | 66 | class IRCHistoryLineEdit : public QLineEdit { |
67 | Q_OBJECT | 67 | Q_OBJECT |
68 | public: | 68 | public: |
69 | enum KeyMode { | 69 | enum KeyMode { |
70 | KeyNextTab, | 70 | KeyNextTab, |
71 | KeyPrevTab | 71 | KeyPrevTab, |
72 | KeyCloseTab | ||
72 | }; | 73 | }; |
73 | 74 | ||
74 | static Opie::Core::OKeyConfigManager* keyConfigInstance(); | 75 | static Opie::Core::OKeyConfigManager* keyConfigInstance(); |
75 | 76 | ||
76 | IRCHistoryLineEdit(QWidget *parent = 0, const char *name = 0); | 77 | IRCHistoryLineEdit(QWidget *parent = 0, const char *name = 0); |
77 | virtual bool eventFilter(QObject *object, QEvent *event); | 78 | virtual bool eventFilter(QObject *object, QEvent *event); |
78 | public slots: | 79 | public slots: |
79 | void setEditFocus(); | 80 | void setEditFocus(); |
80 | signals: | 81 | signals: |
81 | void nextTab(); | 82 | void nextTab(); |
82 | void prevTab(); | 83 | void prevTab(); |
83 | void closeTab(); | 84 | void closeTab(); |
84 | 85 | ||
85 | 86 | ||
86 | protected: | 87 | protected: |
87 | void keyPressEvent(QKeyEvent *); | 88 | void keyPressEvent(QKeyEvent *); |
88 | protected: | 89 | protected: |
89 | QStringList m_history; | 90 | QStringList m_history; |
90 | int m_index; | 91 | int m_index; |
91 | }; | 92 | }; |
92 | 93 | ||
93 | #endif /* __IRCMISC_H */ | 94 | #endif /* __IRCMISC_H */ |
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp index 1fddc6d..53474b9 100644 --- a/noncore/net/opieirc/ircquerytab.cpp +++ b/noncore/net/opieirc/ircquerytab.cpp | |||
@@ -1,95 +1,98 @@ | |||
1 | #include <qhbox.h> | 1 | #include <qhbox.h> |
2 | #include <qwhatsthis.h> | 2 | #include <qwhatsthis.h> |
3 | #include "ircquerytab.h" | 3 | #include "ircquerytab.h" |
4 | #include "ircservertab.h" | 4 | #include "ircservertab.h" |
5 | 5 | ||
6 | IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 6 | IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
7 | m_mainWindow = mainWindow; | 7 | m_mainWindow = mainWindow; |
8 | m_parentTab = parentTab; | 8 | m_parentTab = parentTab; |
9 | m_lines = 0; | 9 | m_lines = 0; |
10 | m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */ | 10 | m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */ |
11 | m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>"); | 11 | m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>"); |
12 | QHBox *hbox = new QHBox(this); | 12 | QHBox *hbox = new QHBox(this); |
13 | m_textview = new QTextView(hbox); | 13 | m_textview = new QTextView(hbox); |
14 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 14 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
15 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 15 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
16 | m_textview->setTextFormat(RichText); | 16 | m_textview->setTextFormat(RichText); |
17 | QWhatsThis::add(m_textview, tr("Private discussion")); | 17 | QWhatsThis::add(m_textview, tr("Private discussion")); |
18 | m_field = new IRCHistoryLineEdit(this); | 18 | m_field = new IRCHistoryLineEdit(this); |
19 | |||
19 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); | 20 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); |
20 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); | 21 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); |
21 | connect(m_field, SIGNAL(closeTab()),this, SIGNAL(closeTab())); | 22 | connect(m_field, SIGNAL(closeTab()),this, SLOT(remove())); |
22 | 23 | connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); | |
23 | 24 | ||
24 | QWhatsThis::add(m_field, tr("Type your text here in order to send a message to the other person")); | 25 | QWhatsThis::add(m_field, tr("Type your text here in order to send a message to the other person")); |
25 | m_layout->add(hbox); | 26 | m_layout->add(hbox); |
26 | hbox->show(); | 27 | hbox->show(); |
27 | m_layout->add(m_field); | 28 | m_layout->add(m_field); |
28 | m_field->setFocus(); | 29 | |
29 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 30 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
30 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); | 31 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); |
31 | settingsChanged(); | 32 | settingsChanged(); |
33 | m_field->setFocus(); | ||
34 | m_field->setActiveWindow(); | ||
32 | } | 35 | } |
33 | 36 | ||
34 | void IRCQueryTab::scrolling(){ | 37 | void IRCQueryTab::scrolling(){ |
35 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 38 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
36 | } | 39 | } |
37 | 40 | ||
38 | 41 | ||
39 | void IRCQueryTab::appendText(QString text) { | 42 | void IRCQueryTab::appendText(QString text) { |
40 | /* not using append because it creates layout problems */ | 43 | /* not using append because it creates layout problems */ |
41 | QString txt = m_textview->text() + text + "\n"; | 44 | QString txt = m_textview->text() + text + "\n"; |
42 | if (m_maxLines > 0 && m_lines >= m_maxLines) { | 45 | if (m_maxLines > 0 && m_lines >= m_maxLines) { |
43 | int firstBreak = txt.find('\n'); | 46 | int firstBreak = txt.find('\n'); |
44 | if (firstBreak != -1) { | 47 | if (firstBreak != -1) { |
45 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); | 48 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); |
46 | } | 49 | } |
47 | } else { | 50 | } else { |
48 | m_lines++; | 51 | m_lines++; |
49 | } | 52 | } |
50 | m_textview->setText(txt); | 53 | m_textview->setText(txt); |
51 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 54 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
52 | 55 | ||
53 | if ( IRCServerTab::containsPing( text, m_parentTab ) ) | 56 | if ( IRCServerTab::containsPing( text, m_parentTab ) ) |
54 | emit ping( title() ); | 57 | emit ping( title() ); |
55 | 58 | ||
56 | emit changed(this); | 59 | emit changed(this); |
57 | } | 60 | } |
58 | 61 | ||
59 | IRCQueryTab::~IRCQueryTab() { | 62 | IRCQueryTab::~IRCQueryTab() { |
60 | m_parentTab->removeQueryTab(this); | 63 | m_parentTab->removeQueryTab(this); |
61 | delete m_person; | 64 | delete m_person; |
62 | } | 65 | } |
63 | 66 | ||
64 | void IRCQueryTab::processCommand() { | 67 | void IRCQueryTab::processCommand() { |
65 | QString text = m_field->text(); | 68 | QString text = m_field->text(); |
66 | if (text.length()>0) { | 69 | if (text.length()>0) { |
67 | if (session()->isSessionActive()) { | 70 | if (session()->isSessionActive()) { |
68 | if (text.startsWith("/") && !text.startsWith("//")) { | 71 | if (text.startsWith("/") && !text.startsWith("//")) { |
69 | /* Command mode */ | 72 | /* Command mode */ |
70 | m_parentTab->executeCommand(this, text);; | 73 | m_parentTab->executeCommand(this, text);; |
71 | } else { | 74 | } else { |
72 | if (text.startsWith("//")) | 75 | if (text.startsWith("//")) |
73 | text = text.right(text.length()-1); | 76 | text = text.right(text.length()-1); |
74 | session()->sendMessage(m_person, m_field->text()); | 77 | session()->sendMessage(m_person, m_field->text()); |
75 | 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>"); | 78 | 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>"); |
76 | } | 79 | } |
77 | } else { | 80 | } else { |
78 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); | 81 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); |
79 | } | 82 | } |
80 | } | 83 | } |
81 | m_field->clear(); | 84 | m_field->clear(); |
82 | } | 85 | } |
83 | 86 | ||
84 | void IRCQueryTab::display(IRCOutput output) { | 87 | void IRCQueryTab::display(IRCOutput output) { |
85 | if (output.type() == OUTPUT_QUERYPRIVMSG) { | 88 | if (output.type() == OUTPUT_QUERYPRIVMSG) { |
86 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage() + "</font><br>"); | 89 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage() + "</font><br>"); |
87 | } else if (output.type() == OUTPUT_QUERYACTION) { | 90 | } else if (output.type() == OUTPUT_QUERYACTION) { |
88 | appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>"); | 91 | appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>"); |
89 | } | 92 | } |
90 | } | 93 | } |
91 | 94 | ||
92 | void IRCQueryTab::settingsChanged() { | 95 | void IRCQueryTab::settingsChanged() { |
93 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | 96 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); |
94 | m_lines = 0; | 97 | m_lines = 0; |
95 | } | 98 | } |
diff --git a/noncore/net/opieirc/ircserverlist.cpp b/noncore/net/opieirc/ircserverlist.cpp index 62bfc17..3e78469 100644 --- a/noncore/net/opieirc/ircserverlist.cpp +++ b/noncore/net/opieirc/ircserverlist.cpp | |||
@@ -21,141 +21,150 @@ public: | |||
21 | } | 21 | } |
22 | 22 | ||
23 | IRCServer server() | 23 | IRCServer server() |
24 | { | 24 | { |
25 | return m_server; | 25 | return m_server; |
26 | } | 26 | } |
27 | 27 | ||
28 | void setServer(IRCServer server) | 28 | void setServer(IRCServer server) |
29 | { | 29 | { |
30 | m_server = server; | 30 | m_server = server; |
31 | setText(m_server.name()); | 31 | setText(m_server.name()); |
32 | } | 32 | } |
33 | protected: | 33 | protected: |
34 | IRCServer m_server; | 34 | IRCServer m_server; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) | 37 | IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) |
38 | { | 38 | { |
39 | QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); | 39 | QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); |
40 | setCaption(tr("Serverlist Browser")); | 40 | setCaption(tr("Serverlist Browser")); |
41 | QLabel *label = new QLabel(tr("Please choose a server profile"), this); | 41 | QLabel *label = new QLabel(tr("Please choose a server profile"), this); |
42 | label->setAlignment(AlignHCenter); | 42 | label->setAlignment(AlignHCenter); |
43 | layout->addWidget(label); | 43 | layout->addWidget(label); |
44 | m_list = new QListBox(this); | 44 | m_list = new QListBox(this); |
45 | QWhatsThis::add(m_list, tr("Select a server profile from this list and then tap on OK in the upper-right corner")); | 45 | QWhatsThis::add(m_list, tr("Select a server profile from this list and then tap on OK in the upper-right corner")); |
46 | layout->addWidget(m_list); | 46 | layout->addWidget(m_list); |
47 | QHBox *buttons = new QHBox(this); | 47 | QHBox *buttons = new QHBox(this); |
48 | QPushButton *del = new QPushButton(tr("Delete"), buttons); | 48 | QPushButton *del = new QPushButton(tr("Delete"), buttons); |
49 | QPushButton *edit = new QPushButton(tr("Edit"), buttons); | 49 | QPushButton *edit = new QPushButton(tr("Edit"), buttons); |
50 | QPushButton *add = new QPushButton(tr("Add"), buttons); | 50 | QPushButton *add = new QPushButton(tr("Add"), buttons); |
51 | QWhatsThis::add(del, tr("Delete the currently selected server profile")); | 51 | QWhatsThis::add(del, tr("Delete the currently selected server profile")); |
52 | QWhatsThis::add(edit, tr("Edit the currently selected server profile")); | 52 | QWhatsThis::add(edit, tr("Edit the currently selected server profile")); |
53 | QWhatsThis::add(add, tr("Add a new server profile")); | 53 | QWhatsThis::add(add, tr("Add a new server profile")); |
54 | connect(del, SIGNAL(clicked()), this, SLOT(delServer())); | 54 | connect(del, SIGNAL(clicked()), this, SLOT(delServer())); |
55 | connect(edit, SIGNAL(clicked()), this, SLOT(editServer())); | 55 | connect(edit, SIGNAL(clicked()), this, SLOT(editServer())); |
56 | connect(add, SIGNAL(clicked()), this, SLOT(addServer())); | 56 | connect(add, SIGNAL(clicked()), this, SLOT(addServer())); |
57 | layout->addWidget(buttons); | 57 | layout->addWidget(buttons); |
58 | /* Load the configuration file */ | 58 | /* Load the configuration file */ |
59 | m_config = new Config("OpieIRC"); | 59 | m_config = new Config("OpieIRC"); |
60 | m_config->setGroup("OpieIRC"); | 60 | m_config->setGroup("OpieIRC"); |
61 | int count = m_config->readNumEntry("ServerCount", 0); | 61 | int count = m_config->readNumEntry("ServerCount", 0); |
62 | if (count) | 62 | if (count) |
63 | { | 63 | { |
64 | for (int i=0; i<count; i++) | 64 | for (int i=0; i<count; i++) |
65 | { | 65 | { |
66 | m_config->setGroup("OpieIRC"); | 66 | m_config->setGroup("OpieIRC"); |
67 | QString name = m_config->readEntry("Server"+QString::number(i)); | 67 | QString name = m_config->readEntry("Server"+QString::number(i)); |
68 | if (name.length() > 0) | 68 | if (name.length() > 0) |
69 | { | 69 | { |
70 | IRCServer server; | 70 | IRCServer server; |
71 | m_config->setGroup(name); | 71 | m_config->setGroup(name); |
72 | server.setName(name); | 72 | server.setName(name); |
73 | server.setHostname(m_config->readEntry("Hostname")); | 73 | server.setHostname(m_config->readEntry("Hostname")); |
74 | server.setPort(m_config->readNumEntry("Port")); | 74 | server.setPort(m_config->readNumEntry("Port")); |
75 | server.setUsername(m_config->readEntry("Username")); | 75 | server.setUsername(m_config->readEntry("Username")); |
76 | server.setPassword(m_config->readEntry("Password")); | 76 | server.setPassword(m_config->readEntry("Password")); |
77 | server.setNick(m_config->readEntry("Nick")); | 77 | server.setNick(m_config->readEntry("Nick")); |
78 | server.setRealname(m_config->readEntry("Realname")); | 78 | server.setRealname(m_config->readEntry("Realname")); |
79 | server.setChannels(m_config->readEntry("Channels")); | 79 | server.setChannels(m_config->readEntry("Channels")); |
80 | m_list->insertItem(new IRCListBoxServer(server)); | 80 | m_list->insertItem(new IRCListBoxServer(server)); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | connect(m_list, SIGNAL(doubleClicked(QListBoxItem*)), | ||
86 | this, SLOT(acceptOnClick(QListBoxItem *))); | ||
87 | connect(m_list, SIGNAL(returnPressed(QListBoxItem*)), | ||
88 | this, SLOT(acceptOnClick(QListBoxItem*))); | ||
89 | |||
85 | QPEApplication::showDialog( this ); | 90 | QPEApplication::showDialog( this ); |
86 | } | 91 | } |
87 | 92 | ||
88 | void IRCServerList::addServer() | 93 | void IRCServerList::addServer() |
89 | { | 94 | { |
90 | IRCServer server; | 95 | IRCServer server; |
91 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); | 96 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); |
92 | if (editor.exec() == QDialog::Accepted) | 97 | if (editor.exec() == QDialog::Accepted) |
93 | { | 98 | { |
94 | server = editor.getServer(); | 99 | server = editor.getServer(); |
95 | /* Gets deleted by QListBox, so this is ok */ | 100 | /* Gets deleted by QListBox, so this is ok */ |
96 | m_list->insertItem(new IRCListBoxServer(server)); | 101 | m_list->insertItem(new IRCListBoxServer(server)); |
97 | } | 102 | } |
98 | } | 103 | } |
99 | 104 | ||
100 | void IRCServerList::delServer() | 105 | void IRCServerList::delServer() |
101 | { | 106 | { |
102 | int index = m_list->currentItem(); | 107 | int index = m_list->currentItem(); |
103 | if (index != -1) | 108 | if (index != -1) |
104 | { | 109 | { |
105 | m_list->removeItem(index); | 110 | m_list->removeItem(index); |
106 | } | 111 | } |
107 | } | 112 | } |
108 | 113 | ||
109 | void IRCServerList::editServer() | 114 | void IRCServerList::editServer() |
110 | { | 115 | { |
111 | int index = m_list->currentItem(); | 116 | int index = m_list->currentItem(); |
112 | if (index != -1) | 117 | if (index != -1) |
113 | { | 118 | { |
114 | IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); | 119 | IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); |
115 | IRCServer server = item->server(); | 120 | IRCServer server = item->server(); |
116 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); | 121 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); |
117 | if (editor.exec() == QDialog::Accepted) | 122 | if (editor.exec() == QDialog::Accepted) |
118 | { | 123 | { |
119 | server = editor.getServer(); | 124 | server = editor.getServer(); |
120 | item->setServer(server); | 125 | item->setServer(server); |
121 | } | 126 | } |
122 | } | 127 | } |
123 | } | 128 | } |
124 | 129 | ||
130 | void IRCServerList::acceptOnClick( QListBoxItem* ) { | ||
131 | accept(); | ||
132 | } | ||
133 | |||
125 | int IRCServerList::exec() | 134 | int IRCServerList::exec() |
126 | { | 135 | { |
127 | int returncode = QDialog::exec(); | 136 | int returncode = QDialog::exec(); |
128 | /* Now save the changes */ | 137 | /* Now save the changes */ |
129 | m_config->setGroup("OpieIRC"); | 138 | m_config->setGroup("OpieIRC"); |
130 | m_config->writeEntry("ServerCount", QString::number(m_list->count())); | 139 | m_config->writeEntry("ServerCount", QString::number(m_list->count())); |
131 | for (unsigned int i=0; i<m_list->count(); i++) | 140 | for (unsigned int i=0; i<m_list->count(); i++) |
132 | { | 141 | { |
133 | IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); | 142 | IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); |
134 | m_config->setGroup("OpieIRC"); | 143 | m_config->setGroup("OpieIRC"); |
135 | m_config->writeEntry("Server"+QString::number(i), server.name()); | 144 | m_config->writeEntry("Server"+QString::number(i), server.name()); |
136 | m_config->setGroup(server.name()); | 145 | m_config->setGroup(server.name()); |
137 | m_config->writeEntry("Hostname", server.hostname()); | 146 | m_config->writeEntry("Hostname", server.hostname()); |
138 | m_config->writeEntry("Port", QString::number(server.port())); | 147 | m_config->writeEntry("Port", QString::number(server.port())); |
139 | m_config->writeEntry("Username", server.username()); | 148 | m_config->writeEntry("Username", server.username()); |
140 | m_config->writeEntry("Password", server.password()); | 149 | m_config->writeEntry("Password", server.password()); |
141 | m_config->writeEntry("Nick", server.nick()); | 150 | m_config->writeEntry("Nick", server.nick()); |
142 | m_config->writeEntry("Realname", server.realname()); | 151 | m_config->writeEntry("Realname", server.realname()); |
143 | m_config->writeEntry("Channels", server.channels()); | 152 | m_config->writeEntry("Channels", server.channels()); |
144 | } | 153 | } |
145 | return returncode; | 154 | return returncode; |
146 | } | 155 | } |
147 | 156 | ||
148 | bool IRCServerList::hasServer() | 157 | bool IRCServerList::hasServer() |
149 | { | 158 | { |
150 | return (m_list->currentItem() != -1); | 159 | return (m_list->currentItem() != -1); |
151 | } | 160 | } |
152 | 161 | ||
153 | IRCServer IRCServerList::server() | 162 | IRCServer IRCServerList::server() |
154 | { | 163 | { |
155 | return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server(); | 164 | return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server(); |
156 | } | 165 | } |
157 | 166 | ||
158 | IRCServerList::~IRCServerList() | 167 | IRCServerList::~IRCServerList() |
159 | { | 168 | { |
160 | delete m_config; | 169 | delete m_config; |
161 | } | 170 | } |
diff --git a/noncore/net/opieirc/ircserverlist.h b/noncore/net/opieirc/ircserverlist.h index d61210e..869b26f 100644 --- a/noncore/net/opieirc/ircserverlist.h +++ b/noncore/net/opieirc/ircserverlist.h | |||
@@ -1,50 +1,51 @@ | |||
1 | /* | 1 | /* |
2 | OpieIRC - An embedded IRC client | 2 | OpieIRC - An embedded IRC client |
3 | Copyright (C) 2002 Wenzel Jakob | 3 | Copyright (C) 2002 Wenzel Jakob |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 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 | 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 | 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __IRCSERVERLIST_H | 21 | #ifndef __IRCSERVERLIST_H |
22 | #define __IRCSERVERLIST_H | 22 | #define __IRCSERVERLIST_H |
23 | 23 | ||
24 | #include <qdialog.h> | 24 | #include <qdialog.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qlistbox.h> | 26 | #include <qlistbox.h> |
27 | #include <qlist.h> | 27 | #include <qlist.h> |
28 | #include "ircserver.h" | 28 | #include "ircserver.h" |
29 | 29 | ||
30 | class IRCServerList : public QDialog { | 30 | class IRCServerList : public QDialog { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | public: |
33 | IRCServerList(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); | 33 | IRCServerList(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); |
34 | int exec(); | 34 | int exec(); |
35 | /* Check whether a server was selected */ | 35 | /* Check whether a server was selected */ |
36 | bool hasServer(); | 36 | bool hasServer(); |
37 | /* Return the selected server */ | 37 | /* Return the selected server */ |
38 | IRCServer server(); | 38 | IRCServer server(); |
39 | 39 | ||
40 | ~IRCServerList(); | 40 | ~IRCServerList(); |
41 | public slots: | 41 | public slots: |
42 | void addServer(); | 42 | void addServer(); |
43 | void delServer(); | 43 | void delServer(); |
44 | void editServer(); | 44 | void editServer(); |
45 | void acceptOnClick(QListBoxItem*); | ||
45 | protected: | 46 | protected: |
46 | Config *m_config; | 47 | Config *m_config; |
47 | QListBox *m_list; | 48 | QListBox *m_list; |
48 | }; | 49 | }; |
49 | 50 | ||
50 | #endif /* __IRCSERVERLIST_H */ | 51 | #endif /* __IRCSERVERLIST_H */ |
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 2a34c0b..5ca7a29 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -1,110 +1,117 @@ | |||
1 | #include <qtextstream.h> | 1 | #include <qtextstream.h> |
2 | #include <qwhatsthis.h> | 2 | #include <qwhatsthis.h> |
3 | #include "ircservertab.h" | 3 | #include "ircservertab.h" |
4 | 4 | ||
5 | 5 | ||
6 | bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) { | 6 | bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) { |
7 | return (text.find("ping") != -1 && text.find( tab->server()->nick() != -1)); | 7 | return (text.contains(IRCMessageParser::tr("Received a CTCP PING from "))) || |
8 | (text.find("ping") != -1 && text.find( tab->server()->nick() != -1)); | ||
8 | } | 9 | } |
9 | 10 | ||
10 | 11 | ||
11 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 12 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
12 | m_server = server; | 13 | m_server = server; |
13 | m_session = new IRCSession(&m_server); | 14 | m_session = new IRCSession(&m_server); |
14 | m_mainWindow = mainWindow; | 15 | m_mainWindow = mainWindow; |
15 | m_close = FALSE; | 16 | m_close = FALSE; |
16 | m_lines = 0; | 17 | m_lines = 0; |
17 | m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); | 18 | m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); |
18 | m_textview = new QTextView(this); | 19 | m_textview = new QTextView(this); |
19 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 20 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
20 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 21 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
21 | m_textview->setTextFormat(RichText); | 22 | m_textview->setTextFormat(RichText); |
22 | QWhatsThis::add(m_textview, tr("Server messages")); | 23 | QWhatsThis::add(m_textview, tr("Server messages")); |
23 | m_layout->add(m_textview); | 24 | m_layout->add(m_textview); |
24 | m_field = new IRCHistoryLineEdit(this); | 25 | m_field = new IRCHistoryLineEdit(this); |
25 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); | 26 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); |
26 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); | 27 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); |
27 | connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab())); | 28 | connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab())); |
28 | connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); | 29 | connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); |
29 | 30 | ||
30 | QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); | 31 | QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); |
31 | m_layout->add(m_field); | 32 | m_layout->add(m_field); |
32 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 33 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
33 | m_field->setFocus(); | ||
34 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); | 34 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); |
35 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); | 35 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); |
36 | settingsChanged(); | 36 | settingsChanged(); |
37 | |||
38 | m_field->setFocus(); | ||
39 | m_field->setActiveWindow(); | ||
40 | |||
37 | } | 41 | } |
38 | 42 | ||
39 | void IRCServerTab::scrolling(){ | 43 | void IRCServerTab::scrolling(){ |
40 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 44 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
41 | } | 45 | } |
42 | 46 | ||
43 | 47 | ||
44 | void IRCServerTab::appendText(QString text) { | 48 | void IRCServerTab::appendText(QString text) { |
45 | /* not using append because it creates layout problems */ | 49 | /* not using append because it creates layout problems */ |
46 | QString txt = m_textview->text() + text + "\n"; | 50 | QString txt = m_textview->text() + IRCTab::appendTimestamp( text ); |
51 | |||
52 | |||
53 | |||
47 | if (m_maxLines > 0 && m_lines >= m_maxLines) { | 54 | if (m_maxLines > 0 && m_lines >= m_maxLines) { |
48 | int firstBreak = txt.find('\n'); | 55 | int firstBreak = txt.find('\n'); |
49 | if (firstBreak != -1) { | 56 | if (firstBreak != -1) { |
50 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); | 57 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); |
51 | } | 58 | } |
52 | } else { | 59 | } else { |
53 | m_lines++; | 60 | m_lines++; |
54 | } | 61 | } |
55 | m_textview->setText(txt); | 62 | m_textview->setText(txt); |
56 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 63 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
57 | emit changed(this); | 64 | emit changed(this); |
58 | } | 65 | } |
59 | 66 | ||
60 | IRCServerTab::~IRCServerTab() { | 67 | IRCServerTab::~IRCServerTab() { |
61 | delete m_session; | 68 | delete m_session; |
62 | } | 69 | } |
63 | 70 | ||
64 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { | 71 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { |
65 | m_channelTabs.remove(tab); | 72 | m_channelTabs.remove(tab); |
66 | } | 73 | } |
67 | 74 | ||
68 | void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { | 75 | void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { |
69 | m_queryTabs.remove(tab); | 76 | m_queryTabs.remove(tab); |
70 | } | 77 | } |
71 | 78 | ||
72 | void IRCServerTab::addQueryTab(IRCQueryTab *tab) { | 79 | void IRCServerTab::addQueryTab(IRCQueryTab *tab) { |
73 | m_queryTabs.append(tab); | 80 | m_queryTabs.append(tab); |
74 | } | 81 | } |
75 | 82 | ||
76 | QString IRCServerTab::title() { | 83 | QString IRCServerTab::title() { |
77 | return "Server"; | 84 | return "Server"; |
78 | } | 85 | } |
79 | 86 | ||
80 | IRCSession *IRCServerTab::session() { | 87 | IRCSession *IRCServerTab::session() { |
81 | return m_session; | 88 | return m_session; |
82 | } | 89 | } |
83 | /* | 90 | /* |
84 | QString *IRCServerTab::mynick() { | 91 | QString *IRCServerTab::mynick() { |
85 | return (*m_server->nick()); | 92 | return (*m_server->nick()); |
86 | } */ | 93 | } */ |
87 | 94 | ||
88 | IRCServer *IRCServerTab::server() { | 95 | IRCServer *IRCServerTab::server() { |
89 | return &m_server; | 96 | return &m_server; |
90 | } | 97 | } |
91 | 98 | ||
92 | void IRCServerTab::settingsChanged() { | 99 | void IRCServerTab::settingsChanged() { |
93 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | 100 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); |
94 | m_lines = 0; | 101 | m_lines = 0; |
95 | } | 102 | } |
96 | 103 | ||
97 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { | 104 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { |
98 | QTextIStream stream(&line); | 105 | QTextIStream stream(&line); |
99 | QString command; | 106 | QString command; |
100 | stream >> command; | 107 | stream >> command; |
101 | command = command.upper().right(command.length()-1); | 108 | command = command.upper().right(command.length()-1); |
102 | 109 | ||
103 | //JOIN | 110 | //JOIN |
104 | if (command == "JOIN" || command == "J") { | 111 | if (command == "JOIN" || command == "J") { |
105 | QString channel; | 112 | QString channel; |
106 | stream >> channel; | 113 | stream >> channel; |
107 | if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { | 114 | if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { |
108 | m_session->join(channel); | 115 | m_session->join(channel); |
109 | } else { | 116 | } else { |
110 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); | 117 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); |
@@ -173,212 +180,212 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { | |||
173 | if (text.length() > 0) { | 180 | if (text.length() > 0) { |
174 | m_session->quit(text); | 181 | m_session->quit(text); |
175 | } else { | 182 | } else { |
176 | m_session->quit(); | 183 | m_session->quit(); |
177 | } | 184 | } |
178 | } | 185 | } |
179 | 186 | ||
180 | //SEND ACTION | 187 | //SEND ACTION |
181 | else if (command == "ME") { | 188 | else if (command == "ME") { |
182 | QString text = line.right(line.length()-4); | 189 | QString text = line.right(line.length()-4); |
183 | if (text.length() > 0) { | 190 | if (text.length() > 0) { |
184 | if (tab->isA("IRCChannelTab")) { | 191 | if (tab->isA("IRCChannelTab")) { |
185 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); | 192 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); |
186 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); | 193 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); |
187 | } else if (tab->isA("IRCQueryTab")) { | 194 | } else if (tab->isA("IRCQueryTab")) { |
188 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); | 195 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); |
189 | m_session->sendAction(((IRCQueryTab *)tab)->person(), text); | 196 | m_session->sendAction(((IRCQueryTab *)tab)->person(), text); |
190 | } else { | 197 | } else { |
191 | tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); | 198 | tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); |
192 | } | 199 | } |
193 | } | 200 | } |
194 | } | 201 | } |
195 | //SEND PRIVMSG | 202 | //SEND PRIVMSG |
196 | else if (command == "MSG") { | 203 | else if (command == "MSG") { |
197 | QString nickname; | 204 | QString nickname; |
198 | stream >> nickname; | 205 | stream >> nickname; |
199 | if (nickname.length() > 0) { | 206 | if (nickname.length() > 0) { |
200 | if (line.length() > 6 + nickname.length()) { | 207 | if (line.length() > 6 + nickname.length()) { |
201 | QString text = line.right(line.length()-nickname.length()-6); | 208 | QString text = line.right(line.length()-nickname.length()-6); |
202 | IRCPerson person; | 209 | IRCPerson person; |
203 | person.setNick(nickname); | 210 | person.setNick(nickname); |
204 | tab->appendText("<font color=\"" + m_textColor + "\">></font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">< "+IRCOutput::toHTML(text)+"</font><br>"); | 211 | tab->appendText("<font color=\"" + m_textColor + "\">></font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">< "+IRCOutput::toHTML(text)+"</font><br>"); |
205 | m_session->sendMessage(&person, text); | 212 | m_session->sendMessage(&person, text); |
206 | } | 213 | } |
207 | } | 214 | } |
208 | } | 215 | } |
209 | else { | 216 | else { |
210 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); | 217 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); |
211 | } | 218 | } |
212 | } | 219 | } |
213 | 220 | ||
214 | void IRCServerTab::processCommand() { | 221 | void IRCServerTab::processCommand() { |
215 | QString text = m_field->text(); | 222 | QString text = m_field->text(); |
216 | if (text.startsWith("/") && !text.startsWith("//")) { | 223 | if (text.startsWith("/") && !text.startsWith("//")) { |
217 | /* Command mode */ | 224 | /* Command mode */ |
218 | executeCommand(this, text); | 225 | executeCommand(this, text); |
219 | } | 226 | } |
220 | m_field->clear(); | 227 | m_field->clear(); |
221 | } | 228 | } |
222 | 229 | ||
223 | void IRCServerTab::doConnect() { | 230 | void IRCServerTab::doConnect() { |
224 | m_session->beginSession(); | 231 | m_session->beginSession(); |
225 | } | 232 | } |
226 | 233 | ||
227 | void IRCServerTab::remove() { | 234 | void IRCServerTab::remove() { |
228 | /* Close requested */ | 235 | /* Close requested */ |
229 | if (m_session->isSessionActive()) { | 236 | if (m_session->isSessionActive()) { |
230 | /* While there is a running session */ | 237 | /* While there is a running session */ |
231 | m_close = TRUE; | 238 | m_close = TRUE; |
232 | m_session->endSession(); | 239 | m_session->endSession(); |
233 | } else { | 240 | } else { |
234 | /* Session has previously been closed */ | 241 | /* Session has previously been closed */ |
235 | m_channelTabs.first(); | 242 | m_channelTabs.first(); |
236 | while (m_channelTabs.current() != 0) { | 243 | while (m_channelTabs.current() != 0) { |
237 | m_mainWindow->killTab(m_channelTabs.current()); | 244 | m_mainWindow->killTab(m_channelTabs.current(), true); |
238 | } | 245 | } |
239 | m_queryTabs.first(); | 246 | m_queryTabs.first(); |
240 | while (m_queryTabs.current() != 0) { | 247 | while (m_queryTabs.current() != 0) { |
241 | m_mainWindow->killTab(m_queryTabs.current()); | 248 | m_mainWindow->killTab(m_queryTabs.current(), true); |
242 | } | 249 | } |
243 | m_mainWindow->killTab(this); | 250 | m_mainWindow->killTab(this); |
244 | } | 251 | } |
245 | } | 252 | } |
246 | 253 | ||
247 | IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { | 254 | IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { |
248 | QListIterator<IRCChannelTab> it(m_channelTabs); | 255 | QListIterator<IRCChannelTab> it(m_channelTabs); |
249 | 256 | ||
250 | for (; it.current(); ++it) { | 257 | for (; it.current(); ++it) { |
251 | if (it.current()->channel() == channel) | 258 | if (it.current()->channel() == channel) |
252 | return it.current(); | 259 | return it.current(); |
253 | } | 260 | } |
254 | return 0; | 261 | return 0; |
255 | } | 262 | } |
256 | 263 | ||
257 | IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { | 264 | IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { |
258 | QListIterator<IRCQueryTab> it(m_queryTabs); | 265 | QListIterator<IRCQueryTab> it(m_queryTabs); |
259 | 266 | ||
260 | for (; it.current(); ++it) { | 267 | for (; it.current(); ++it) { |
261 | if (it.current()->person()->nick() == person->nick()) | 268 | if (it.current()->person()->nick() == person->nick()) |
262 | return it.current(); | 269 | return it.current(); |
263 | } | 270 | } |
264 | return 0; | 271 | return 0; |
265 | } | 272 | } |
266 | 273 | ||
267 | void IRCServerTab::display(IRCOutput output) { | 274 | void IRCServerTab::display(IRCOutput output) { |
268 | 275 | ||
269 | /* All messages to be displayed inside the GUI get here */ | 276 | /* All messages to be displayed inside the GUI get here */ |
270 | switch (output.type()) { | 277 | switch (output.type()) { |
271 | case OUTPUT_CONNCLOSE: | 278 | case OUTPUT_CONNCLOSE: |
272 | if (m_close) { | 279 | if (m_close) { |
273 | m_channelTabs.first(); | 280 | m_channelTabs.first(); |
274 | while (m_channelTabs.current() != 0) { | 281 | while (m_channelTabs.current() != 0) { |
275 | m_mainWindow->killTab(m_channelTabs.current()); | 282 | m_mainWindow->killTab(m_channelTabs.current(), true); |
276 | } | 283 | } |
277 | m_queryTabs.first(); | 284 | m_queryTabs.first(); |
278 | while (m_queryTabs.current() != 0) { | 285 | while (m_queryTabs.current() != 0) { |
279 | m_mainWindow->killTab(m_queryTabs.current()); | 286 | m_mainWindow->killTab(m_queryTabs.current(), true); |
280 | } | 287 | } |
281 | m_mainWindow->killTab(this); | 288 | m_mainWindow->killTab(this); |
282 | } else { | 289 | } else { |
283 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); | 290 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); |
284 | QListIterator<IRCChannelTab> it(m_channelTabs); | 291 | QListIterator<IRCChannelTab> it(m_channelTabs); |
285 | for (; it.current(); ++it) { | 292 | for (; it.current(); ++it) { |
286 | it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); | 293 | it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); |
287 | } | 294 | } |
288 | } | 295 | } |
289 | break; | 296 | break; |
290 | case OUTPUT_SELFJOIN: { | 297 | case OUTPUT_SELFJOIN: { |
291 | IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); | 298 | IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); |
292 | m_channelTabs.append(channeltab); | 299 | m_channelTabs.append(channeltab); |
293 | m_mainWindow->addTab(channeltab); | 300 | m_mainWindow->addTab(channeltab); |
294 | } | 301 | } |
295 | break; | 302 | break; |
296 | case OUTPUT_CHANPRIVMSG: { | 303 | case OUTPUT_CHANPRIVMSG: { |
297 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 304 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
298 | 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>"); | 305 | 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>"); |
299 | } | 306 | } |
300 | break; | 307 | break; |
301 | case OUTPUT_QUERYACTION: | 308 | case OUTPUT_QUERYACTION: |
302 | case OUTPUT_QUERYPRIVMSG: { | 309 | case OUTPUT_QUERYPRIVMSG: { |
303 | IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); | 310 | IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); |
304 | if (!queryTab) { | 311 | if (!queryTab) { |
305 | queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); | 312 | queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); |
306 | m_queryTabs.append(queryTab); | 313 | m_queryTabs.append(queryTab); |
307 | m_mainWindow->addTab(queryTab); | 314 | m_mainWindow->addTab(queryTab); |
308 | } | 315 | } |
309 | queryTab->display(output); | 316 | queryTab->display(output); |
310 | } | 317 | } |
311 | break; | 318 | break; |
312 | case OUTPUT_SELFPART: { | 319 | case OUTPUT_SELFPART: { |
313 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 320 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
314 | if (channelTab) | 321 | if (channelTab) |
315 | m_mainWindow->killTab(channelTab); | 322 | m_mainWindow->killTab(channelTab, true); |
316 | } | 323 | } |
317 | break; | 324 | break; |
318 | case OUTPUT_SELFKICK: { | 325 | case OUTPUT_SELFKICK: { |
319 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); | 326 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); |
320 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 327 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
321 | if (channelTab) | 328 | if (channelTab) |
322 | m_mainWindow->killTab(channelTab); | 329 | m_mainWindow->killTab(channelTab, true); |
323 | } | 330 | } |
324 | break; | 331 | break; |
325 | case OUTPUT_CHANACTION: { | 332 | case OUTPUT_CHANACTION: { |
326 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 333 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
327 | channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); | 334 | channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); |
328 | } | 335 | } |
329 | break; | 336 | break; |
330 | case OUTPUT_TOPIC: { | 337 | case OUTPUT_TOPIC: { |
331 | IRCChannel *channel = (IRCChannel *) output.getParam(0); | 338 | IRCChannel *channel = (IRCChannel *) output.getParam(0); |
332 | if (channel) { | 339 | if (channel) { |
333 | IRCChannelTab *channelTab = getTabForChannel(channel); | 340 | IRCChannelTab *channelTab = getTabForChannel(channel); |
334 | if (channelTab) { | 341 | if (channelTab) { |
335 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 342 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
336 | return; | 343 | return; |
337 | } | 344 | } |
338 | } | 345 | } |
339 | appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 346 | appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
340 | } | 347 | } |
341 | break; | 348 | break; |
342 | case OUTPUT_QUIT: { | 349 | case OUTPUT_QUIT: { |
343 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); | 350 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); |
344 | QListIterator<IRCChannelTab> it(m_channelTabs); | 351 | QListIterator<IRCChannelTab> it(m_channelTabs); |
345 | for (; it.current(); ++it) { | 352 | for (; it.current(); ++it) { |
346 | if (it.current()->list()->hasPerson(nick)) { | 353 | if (it.current()->list()->hasPerson(nick)) { |
347 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 354 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
348 | it.current()->list()->update(); | 355 | it.current()->list()->update(); |
349 | } | 356 | } |
350 | } | 357 | } |
351 | } | 358 | } |
352 | break; | 359 | break; |
353 | /* case OUTPUT_NICKCHANGE: { | 360 | /* case OUTPUT_NICKCHANGE: { |
354 | //WAS HERE | 361 | //WAS HERE |
355 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); | 362 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); |
356 | QListIterator<IRCChannelTab> it(m_channelTabs); | 363 | QListIterator<IRCChannelTab> it(m_channelTabs); |
357 | for (; it.current(); ++it) { | 364 | for (; it.current(); ++it) { |
358 | if (it.current()->list()->hasPerson(nick)) { | 365 | if (it.current()->list()->hasPerson(nick)) { |
359 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 366 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
360 | it.current()->list()->update(); | 367 | it.current()->list()->update(); |
361 | } | 368 | } |
362 | } | 369 | } |
363 | } | 370 | } |
364 | break; | 371 | break; |
365 | */ case OUTPUT_OTHERJOIN: | 372 | */ case OUTPUT_OTHERJOIN: |
366 | case OUTPUT_OTHERKICK: | 373 | case OUTPUT_OTHERKICK: |
367 | case OUTPUT_CHANPERSONMODE: | 374 | case OUTPUT_CHANPERSONMODE: |
368 | case OUTPUT_OTHERPART: { | 375 | case OUTPUT_OTHERPART: { |
369 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 376 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
370 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 377 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
371 | channelTab->list()->update(); | 378 | channelTab->list()->update(); |
372 | } | 379 | } |
373 | break; | 380 | break; |
374 | case OUTPUT_CTCP: | 381 | case OUTPUT_CTCP: |
375 | appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); | 382 | appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); |
376 | break; | 383 | break; |
377 | case OUTPUT_ERROR: | 384 | case OUTPUT_ERROR: |
378 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); | 385 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); |
379 | break; | 386 | break; |
380 | default: | 387 | default: |
381 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); | 388 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); |
382 | break; | 389 | break; |
383 | } | 390 | } |
384 | } | 391 | } |
diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp index 1fba030..7a1dd6c 100644 --- a/noncore/net/opieirc/ircsettings.cpp +++ b/noncore/net/opieirc/ircsettings.cpp | |||
@@ -1,128 +1,144 @@ | |||
1 | 1 | ||
2 | #include "ircsettings.h" | 2 | #include "ircsettings.h" |
3 | #include "irctab.h" | 3 | #include "irctab.h" |
4 | #include "ircmisc.h" | 4 | #include "ircmisc.h" |
5 | 5 | ||
6 | /* OPIE */ | 6 | /* OPIE */ |
7 | #include <opie2/ocolorbutton.h> | 7 | #include <opie2/ocolorbutton.h> |
8 | #include <opie2/otabwidget.h> | 8 | #include <opie2/otabwidget.h> |
9 | #include <opie2/okeyconfigwidget.h> | 9 | #include <opie2/okeyconfigwidget.h> |
10 | #include <qpe/qpeapplication.h> | 10 | #include <qpe/qpeapplication.h> |
11 | 11 | ||
12 | /* QT */ | 12 | /* QT */ |
13 | #include <qvalidator.h> | 13 | #include <qvalidator.h> |
14 | #include <qwhatsthis.h> | 14 | #include <qwhatsthis.h> |
15 | #include <qcheckbox.h> | ||
15 | 16 | ||
16 | using namespace Opie; | 17 | using namespace Opie; |
17 | using namespace Opie::Ui; | 18 | using namespace Opie::Ui; |
18 | IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) | 19 | IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) |
19 | { | 20 | { |
20 | setCaption(tr("Settings") ); | 21 | setCaption(tr("Settings") ); |
21 | m_config = new Config("OpieIRC"); | 22 | m_config = new Config("OpieIRC"); |
22 | m_config->setGroup("OpieIRC"); | 23 | m_config->setGroup("OpieIRC"); |
23 | QHBoxLayout *l = new QHBoxLayout(this, 2, 2); | 24 | QHBoxLayout *l = new QHBoxLayout(this, 2, 2); |
24 | OTabWidget *tw = new OTabWidget(this); | 25 | OTabWidget *tw = new OTabWidget(this); |
25 | l->addWidget(tw); | 26 | l->addWidget(tw); |
26 | /* General Configuration */ | 27 | /* General Configuration */ |
27 | QWidget *genwidget = new QWidget(tw); | 28 | QWidget *genwidget = new QWidget(tw); |
28 | QGridLayout *layout = new QGridLayout(genwidget, 1, 2, 5, 0); | 29 | QGridLayout *layout = new QGridLayout(genwidget, 1, 4, 5, 0); |
29 | QLabel *label = new QLabel(tr("Lines displayed :"), genwidget); | 30 | QLabel *label = new QLabel(tr("Lines displayed :"), genwidget); |
30 | layout->addWidget(label, 0, 0); | 31 | layout->addWidget(label, 0, 0); |
31 | m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget); | 32 | m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget); |
32 | QWhatsThis::add(m_lines, tr("Amount of lines to be displayed in chats before old lines get deleted - this is necessary to restrain memory consumption. Set to 0 if you don't need this")); | 33 | QWhatsThis::add(m_lines, tr("Amount of lines to be displayed in chats before old lines get deleted - this is necessary to restrain memory consumption. Set to 0 if you don't need this")); |
33 | QIntValidator *validator = new QIntValidator(this); | 34 | QIntValidator *validator = new QIntValidator(this); |
34 | validator->setTop(10000); | 35 | validator->setTop(10000); |
35 | validator->setBottom(0); | 36 | validator->setBottom(0); |
36 | m_lines->setValidator(validator); | 37 | m_lines->setValidator(validator); |
37 | layout->addWidget(m_lines, 0, 1); | 38 | layout->addWidget(m_lines, 0, 1); |
39 | |||
40 | /* | ||
41 | * include timestamp | ||
42 | */ | ||
43 | m_displayTime = new QCheckBox( tr("Display time in chat log"), genwidget ); | ||
44 | m_displayTime->setChecked( m_config->readBoolEntry("DisplayTime", false) ); | ||
45 | layout->addMultiCellWidget(m_displayTime, 1, 1, 0, 4 ); | ||
46 | |||
47 | // add a spacer | ||
48 | layout->addItem( new QSpacerItem(1,1, QSizePolicy::Minimum, | ||
49 | QSizePolicy::MinimumExpanding), | ||
50 | 2, 0 ); | ||
51 | |||
38 | tw->addTab(genwidget, "opieirc/settings", tr("General")); | 52 | tw->addTab(genwidget, "opieirc/settings", tr("General")); |
39 | 53 | ||
40 | /* Color configuration */ | 54 | /* Color configuration */ |
41 | QScrollView *view = new QScrollView(this); | 55 | QScrollView *view = new QScrollView(this); |
42 | view->setResizePolicy(QScrollView::AutoOneFit); | 56 | view->setResizePolicy(QScrollView::AutoOneFit); |
43 | view->setFrameStyle( QFrame::NoFrame ); | 57 | view->setFrameStyle( QFrame::NoFrame ); |
44 | QWidget *widget = new QWidget(view->viewport()); | 58 | QWidget *widget = new QWidget(view->viewport()); |
45 | view->addChild(widget); | 59 | view->addChild(widget); |
46 | layout = new QGridLayout(widget, 7, 2, 5, 0); | 60 | layout = new QGridLayout(widget, 7, 2, 5, 0); |
47 | label = new QLabel(tr("Background color :"), widget); | 61 | label = new QLabel(tr("Background color :"), widget); |
48 | layout->addWidget(label, 0, 0); | 62 | layout->addWidget(label, 0, 0); |
49 | m_background = new OColorButton(widget, m_config->readEntry("BackgroundColor", "#FFFFFF")); | 63 | m_background = new OColorButton(widget, m_config->readEntry("BackgroundColor", "#FFFFFF")); |
50 | QWhatsThis::add(m_background, tr("Background color to be used in chats")); | 64 | QWhatsThis::add(m_background, tr("Background color to be used in chats")); |
51 | layout->addWidget(m_background, 0, 1); | 65 | layout->addWidget(m_background, 0, 1); |
52 | label = new QLabel(tr("Normal text color :"), widget); | 66 | label = new QLabel(tr("Normal text color :"), widget); |
53 | layout->addWidget(label, 1, 0); | 67 | layout->addWidget(label, 1, 0); |
54 | m_text = new OColorButton(widget, m_config->readEntry("TextColor", "#000000")); | 68 | m_text = new OColorButton(widget, m_config->readEntry("TextColor", "#000000")); |
55 | QWhatsThis::add(m_text, tr("Text color to be used in chats")); | 69 | QWhatsThis::add(m_text, tr("Text color to be used in chats")); |
56 | layout->addWidget(m_text, 1, 1); | 70 | layout->addWidget(m_text, 1, 1); |
57 | label = new QLabel(tr("Error color :"), widget); | 71 | label = new QLabel(tr("Error color :"), widget); |
58 | layout->addWidget(label, 2, 0); | 72 | layout->addWidget(label, 2, 0); |
59 | m_error = new OColorButton(widget, m_config->readEntry("ErrorColor", "#FF0000")); | 73 | m_error = new OColorButton(widget, m_config->readEntry("ErrorColor", "#FF0000")); |
60 | QWhatsThis::add(m_error, tr("Text color to be used to display errors")); | 74 | QWhatsThis::add(m_error, tr("Text color to be used to display errors")); |
61 | layout->addWidget(m_error, 2, 1); | 75 | layout->addWidget(m_error, 2, 1); |
62 | label = new QLabel(tr("Text written by yourself :"), widget); | 76 | label = new QLabel(tr("Text written by yourself :"), widget); |
63 | layout->addWidget(label, 3, 0); | 77 | layout->addWidget(label, 3, 0); |
64 | m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000")); | 78 | m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000")); |
65 | QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself")); | 79 | QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself")); |
66 | layout->addWidget(m_self, 3, 1); | 80 | layout->addWidget(m_self, 3, 1); |
67 | label = new QLabel(tr("Text written by others :"), widget); | 81 | label = new QLabel(tr("Text written by others :"), widget); |
68 | layout->addWidget(label, 4, 0); | 82 | layout->addWidget(label, 4, 0); |
69 | m_other = new OColorButton(widget, m_config->readEntry("OtherColor", "#0000BB")); | 83 | m_other = new OColorButton(widget, m_config->readEntry("OtherColor", "#0000BB")); |
70 | QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others")); | 84 | QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others")); |
71 | layout->addWidget(m_other, 4, 1); | 85 | layout->addWidget(m_other, 4, 1); |
72 | label = new QLabel(tr("Text written by the server :"), widget); | 86 | label = new QLabel(tr("Text written by the server :"), widget); |
73 | layout->addWidget(label, 5, 0); | 87 | layout->addWidget(label, 5, 0); |
74 | m_server = new OColorButton(widget, m_config->readEntry("ServerColor", "#0000FF")); | 88 | m_server = new OColorButton(widget, m_config->readEntry("ServerColor", "#0000FF")); |
75 | QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server")); | 89 | QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server")); |
76 | layout->addWidget(m_server, 5, 1); | 90 | layout->addWidget(m_server, 5, 1); |
77 | label = new QLabel(tr("Notifications :"), widget); | 91 | label = new QLabel(tr("Notifications :"), widget); |
78 | layout->addWidget(label, 6, 0); | 92 | layout->addWidget(label, 6, 0); |
79 | m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300")); | 93 | m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300")); |
80 | QWhatsThis::add(m_notification, tr("Text color to be used to display notifications")); | 94 | QWhatsThis::add(m_notification, tr("Text color to be used to display notifications")); |
81 | layout->addWidget(m_notification, 6, 1); | 95 | layout->addWidget(m_notification, 6, 1); |
82 | tw->addTab(view, "opieirc/colors", tr("Colors")); | 96 | tw->addTab(view, "opieirc/colors", tr("Colors")); |
83 | 97 | ||
84 | 98 | ||
85 | /* | 99 | /* |
86 | * IRC EditLine KeyConfiguration | 100 | * IRC EditLine KeyConfiguration |
87 | */ | 101 | */ |
88 | m_keyConf = new Opie::Ui::OKeyConfigWidget(tw, "KEyConfig GUI" ); | 102 | m_keyConf = new Opie::Ui::OKeyConfigWidget(tw, "KEyConfig GUI" ); |
89 | m_keyConf->setChangeMode( OKeyConfigWidget::Queue ); | 103 | m_keyConf->setChangeMode( OKeyConfigWidget::Queue ); |
90 | m_keyConf->insert( tr("Keyboard Shortcuts"), | 104 | m_keyConf->insert( tr("Keyboard Shortcuts"), |
91 | IRCHistoryLineEdit::keyConfigInstance() ); | 105 | IRCHistoryLineEdit::keyConfigInstance() ); |
92 | m_keyConf->load(); | 106 | m_keyConf->load(); |
93 | tw->addTab(m_keyConf, "SettingsIcon", tr("Keyboard Shortcuts") ); | 107 | tw->addTab(m_keyConf, "SettingsIcon", tr("Keyboard Shortcuts") ); |
94 | 108 | ||
95 | tw->setCurrentTab( genwidget ); | 109 | tw->setCurrentTab( genwidget ); |
96 | QPEApplication::showDialog( this ); | 110 | QPEApplication::showDialog( this ); |
97 | } | 111 | } |
98 | 112 | ||
99 | void IRCSettings::accept() | 113 | void IRCSettings::accept() |
100 | { | 114 | { |
101 | IRCTab::m_backgroundColor = m_background->color().name(); | 115 | IRCTab::m_backgroundColor = m_background->color().name(); |
102 | IRCTab::m_textColor = m_text->color().name(); | 116 | IRCTab::m_textColor = m_text->color().name(); |
103 | IRCTab::m_errorColor = m_error->color().name(); | 117 | IRCTab::m_errorColor = m_error->color().name(); |
104 | IRCTab::m_selfColor = m_self->color().name(); | 118 | IRCTab::m_selfColor = m_self->color().name(); |
105 | IRCTab::m_otherColor = m_other->color().name(); | 119 | IRCTab::m_otherColor = m_other->color().name(); |
106 | IRCTab::m_serverColor = m_server->color().name(); | 120 | IRCTab::m_serverColor = m_server->color().name(); |
107 | IRCTab::m_notificationColor = m_notification->color().name(); | 121 | IRCTab::m_notificationColor = m_notification->color().name(); |
108 | IRCTab::m_maxLines = m_lines->text().toInt(); | 122 | IRCTab::m_maxLines = m_lines->text().toInt(); |
109 | m_keyConf->save(); | 123 | m_keyConf->save(); |
110 | 124 | ||
111 | 125 | ||
112 | m_config->writeEntry("BackgroundColor", IRCTab::m_backgroundColor); | 126 | m_config->writeEntry("BackgroundColor", IRCTab::m_backgroundColor); |
113 | m_config->writeEntry("TextColor", IRCTab::m_textColor); | 127 | m_config->writeEntry("TextColor", IRCTab::m_textColor); |
114 | m_config->writeEntry("ErrorColor", IRCTab::m_errorColor); | 128 | m_config->writeEntry("ErrorColor", IRCTab::m_errorColor); |
115 | m_config->writeEntry("SelfColor", IRCTab::m_selfColor); | 129 | m_config->writeEntry("SelfColor", IRCTab::m_selfColor); |
116 | m_config->writeEntry("OtherColor", IRCTab::m_otherColor); | 130 | m_config->writeEntry("OtherColor", IRCTab::m_otherColor); |
117 | m_config->writeEntry("ServerColor", IRCTab::m_serverColor); | 131 | m_config->writeEntry("ServerColor", IRCTab::m_serverColor); |
118 | m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor); | 132 | m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor); |
119 | m_config->writeEntry("Lines", m_lines->text()); | 133 | m_config->writeEntry("Lines", m_lines->text()); |
134 | m_config->writeEntry("DisplayTime", m_displayTime->isChecked() ); | ||
135 | IRCTab::setUseTimeStamps(m_displayTime->isChecked()); | ||
120 | IRCHistoryLineEdit::keyConfigInstance()->save(); | 136 | IRCHistoryLineEdit::keyConfigInstance()->save(); |
121 | 137 | ||
122 | QDialog::accept(); | 138 | QDialog::accept(); |
123 | } | 139 | } |
124 | 140 | ||
125 | IRCSettings::~IRCSettings() | 141 | IRCSettings::~IRCSettings() |
126 | { | 142 | { |
127 | delete m_config; | 143 | delete m_config; |
128 | } | 144 | } |
diff --git a/noncore/net/opieirc/ircsettings.h b/noncore/net/opieirc/ircsettings.h index a032aff..b51d535 100644 --- a/noncore/net/opieirc/ircsettings.h +++ b/noncore/net/opieirc/ircsettings.h | |||
@@ -1,55 +1,57 @@ | |||
1 | /* | 1 | /* |
2 | OpieIRC - An embedded IRC client | 2 | OpieIRC - An embedded IRC client |
3 | Copyright (C) 2002 Wenzel Jakob | 3 | Copyright (C) 2002 Wenzel Jakob |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 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 | 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 | 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __IRCSETTINGS_H | 21 | #ifndef __IRCSETTINGS_H |
22 | #define __IRCSETTINGS_H | 22 | #define __IRCSETTINGS_H |
23 | 23 | ||
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | #include <qdialog.h> | 25 | #include <qdialog.h> |
26 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
27 | 27 | ||
28 | namespace Opie { | 28 | namespace Opie { |
29 | class OColorButton; | 29 | class OColorButton; |
30 | namespace Ui { | 30 | namespace Ui { |
31 | class OKeyConfigWidget; | 31 | class OKeyConfigWidget; |
32 | } | 32 | } |
33 | } | 33 | } |
34 | 34 | ||
35 | class QCheckBox; | ||
35 | class IRCSettings : public QDialog { | 36 | class IRCSettings : public QDialog { |
36 | Q_OBJECT | 37 | Q_OBJECT |
37 | public: | 38 | public: |
38 | IRCSettings(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); | 39 | IRCSettings(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); |
39 | ~IRCSettings(); | 40 | ~IRCSettings(); |
40 | protected slots: | 41 | protected slots: |
41 | void accept(); | 42 | void accept(); |
42 | protected: | 43 | protected: |
43 | Config *m_config; | 44 | Config *m_config; |
44 | Opie::OColorButton *m_background; | 45 | Opie::OColorButton *m_background; |
45 | Opie::OColorButton *m_text; | 46 | Opie::OColorButton *m_text; |
46 | Opie::OColorButton *m_error; | 47 | Opie::OColorButton *m_error; |
47 | Opie::OColorButton *m_self; | 48 | Opie::OColorButton *m_self; |
48 | Opie::OColorButton *m_server; | 49 | Opie::OColorButton *m_server; |
49 | Opie::OColorButton *m_other; | 50 | Opie::OColorButton *m_other; |
50 | Opie::OColorButton *m_notification; | 51 | Opie::OColorButton *m_notification; |
51 | Opie::Ui::OKeyConfigWidget *m_keyConf; | 52 | Opie::Ui::OKeyConfigWidget *m_keyConf; |
52 | QLineEdit *m_lines; | 53 | QLineEdit *m_lines; |
54 | QCheckBox *m_displayTime; | ||
53 | }; | 55 | }; |
54 | 56 | ||
55 | #endif /* __IRCSETTINGS_H */ | 57 | #endif /* __IRCSETTINGS_H */ |
diff --git a/noncore/net/opieirc/irctab.cpp b/noncore/net/opieirc/irctab.cpp index 2b3ecd4..fbbf303 100644 --- a/noncore/net/opieirc/irctab.cpp +++ b/noncore/net/opieirc/irctab.cpp | |||
@@ -1,50 +1,66 @@ | |||
1 | #include "irctab.h" | 1 | #include "irctab.h" |
2 | #include "mainwindow.h" | 2 | #include "mainwindow.h" |
3 | 3 | ||
4 | #include <opie2/okeyconfigmanager.h> | 4 | #include <opie2/okeyconfigmanager.h> |
5 | #include <qpe/resource.h> | 5 | #include <qpe/resource.h> |
6 | 6 | ||
7 | 7 | ||
8 | #include <qpushbutton.h> | 8 | #include <qpushbutton.h> |
9 | #include <qwhatsthis.h> | 9 | #include <qwhatsthis.h> |
10 | 10 | ||
11 | 11 | ||
12 | QString IRCTab::m_errorColor; | 12 | QString IRCTab::m_errorColor; |
13 | QString IRCTab::m_serverColor; | 13 | QString IRCTab::m_serverColor; |
14 | QString IRCTab::m_textColor; | 14 | QString IRCTab::m_textColor; |
15 | QString IRCTab::m_backgroundColor; | 15 | QString IRCTab::m_backgroundColor; |
16 | QString IRCTab::m_selfColor; | 16 | QString IRCTab::m_selfColor; |
17 | QString IRCTab::m_otherColor; | 17 | QString IRCTab::m_otherColor; |
18 | QString IRCTab::m_notificationColor; | 18 | QString IRCTab::m_notificationColor; |
19 | int IRCTab::m_maxLines; | 19 | int IRCTab::m_maxLines; |
20 | 20 | ||
21 | |||
22 | static bool g_useTime = false; | ||
23 | |||
24 | void IRCTab::setUseTimeStamps( bool b ) { | ||
25 | g_useTime = b; | ||
26 | } | ||
27 | |||
28 | // ## FIXME use TimeString later for AM/PM Setting | ||
29 | QString IRCTab::appendTimestamp( const QString& text ) { | ||
30 | return g_useTime ? | ||
31 | "[" +QTime::currentTime().toString()+"]" + text + "\n" : | ||
32 | text + "\n"; | ||
33 | |||
34 | } | ||
35 | |||
36 | |||
21 | IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { | 37 | IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { |
22 | m_layout = new QVBoxLayout(this); | 38 | m_layout = new QVBoxLayout(this); |
23 | QHBoxLayout *descLayout = new QHBoxLayout(m_layout); | 39 | QHBoxLayout *descLayout = new QHBoxLayout(m_layout); |
24 | descLayout->setMargin(5); | 40 | descLayout->setMargin(5); |
25 | m_description = new QLabel(tr("Missing description"), this); | 41 | m_description = new QLabel(tr("Missing description"), this); |
26 | QWhatsThis::add(m_description, tr("Description of the tab's content")); | 42 | QWhatsThis::add(m_description, tr("Description of the tab's content")); |
27 | descLayout->addWidget(m_description); | 43 | descLayout->addWidget(m_description); |
28 | descLayout->setStretchFactor(m_description, 5); | 44 | descLayout->setStretchFactor(m_description, 5); |
29 | QPushButton *close = new QPushButton(this); | 45 | QPushButton *close = new QPushButton(this); |
30 | QWhatsThis::add(close, tr("Close this tab")); | 46 | QWhatsThis::add(close, tr("Close this tab")); |
31 | close->setPixmap(Resource::loadPixmap("close")); | 47 | close->setPixmap(Resource::loadPixmap("close")); |
32 | connect(close, SIGNAL(clicked()), this, SLOT(remove())); | 48 | connect(close, SIGNAL(clicked()), this, SLOT(remove())); |
33 | descLayout->addWidget(close); | 49 | descLayout->addWidget(close); |
34 | descLayout->setStretchFactor(m_description, 1); | 50 | descLayout->setStretchFactor(m_description, 1); |
35 | } | 51 | } |
36 | 52 | ||
37 | 53 | ||
38 | void IRCTab::setID(int id) { | 54 | void IRCTab::setID(int id) { |
39 | m_id = id; | 55 | m_id = id; |
40 | } | 56 | } |
41 | 57 | ||
42 | int IRCTab::id() { | 58 | int IRCTab::id() { |
43 | return m_id; | 59 | return m_id; |
44 | } | 60 | } |
45 | 61 | ||
46 | void IRCTab::showEvent( QShowEvent *ev ) { | 62 | void IRCTab::showEvent( QShowEvent *ev ) { |
47 | topLevelWidget()->setCaption( MainWindow::appCaption() + " " + title() ); | 63 | topLevelWidget()->setCaption( MainWindow::appCaption() + " " + title() ); |
48 | QWidget::showEvent( ev ); | 64 | QWidget::showEvent( ev ); |
49 | emit editFocus(); | 65 | emit editFocus(); |
50 | } | 66 | } |
diff --git a/noncore/net/opieirc/irctab.h b/noncore/net/opieirc/irctab.h index 6c29ea5..d17c530 100644 --- a/noncore/net/opieirc/irctab.h +++ b/noncore/net/opieirc/irctab.h | |||
@@ -1,76 +1,80 @@ | |||
1 | /* | 1 | /* |
2 | OpieIRC - An embedded IRC client | 2 | OpieIRC - An embedded IRC client |
3 | Copyright (C) 2002 Wenzel Jakob | 3 | Copyright (C) 2002 Wenzel Jakob |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 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 | 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 | 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __IRCTAB_H | 21 | #ifndef __IRCTAB_H |
22 | #define __IRCTAB_H | 22 | #define __IRCTAB_H |
23 | 23 | ||
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qtextview.h> | 25 | #include <qtextview.h> |
26 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include "ircsession.h" | 29 | #include "ircsession.h" |
30 | 30 | ||
31 | /* This is the base class for any tabs which need to be integrated into | 31 | /* This is the base class for any tabs which need to be integrated into |
32 | the main GUI tab widget */ | 32 | the main GUI tab widget */ |
33 | 33 | ||
34 | class IRCTab : public QWidget { | 34 | class IRCTab : public QWidget { |
35 | Q_OBJECT | 35 | Q_OBJECT |
36 | public: | 36 | 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 | /* The ID is required to store the position of this IRCTab inside the IRCTabWidget */ | 38 | /* The ID is required to store the position of this IRCTab inside the IRCTabWidget */ |
39 | void setID(int id); | 39 | void setID(int id); |
40 | int id(); | 40 | int id(); |
41 | |||
42 | static void setUseTimeStamps(bool b); | ||
43 | static QString appendTimestamp(const QString& tex); | ||
44 | |||
41 | virtual QString title() = 0; | 45 | virtual QString title() = 0; |
42 | virtual IRCSession *session() = 0; | 46 | virtual IRCSession *session() = 0; |
43 | virtual void appendText(QString text) = 0; | 47 | virtual void appendText(QString text) = 0; |
44 | signals: | 48 | signals: |
45 | void changed(IRCTab *); | 49 | void changed(IRCTab *); |
46 | void ping(const QString& ); | 50 | void ping(const QString& ); |
47 | void nextTab(); | 51 | void nextTab(); |
48 | void prevTab(); | 52 | void prevTab(); |
49 | void closeTab(); | 53 | void closeTab(); |
50 | void editFocus(); | 54 | void editFocus(); |
51 | 55 | ||
52 | public slots: | 56 | public slots: |
53 | virtual void remove() = 0; | 57 | virtual void remove() = 0; |
54 | virtual void settingsChanged() = 0; | 58 | virtual void settingsChanged() = 0; |
55 | 59 | ||
56 | protected: | 60 | protected: |
57 | void showEvent( QShowEvent* ); | 61 | void showEvent( QShowEvent* ); |
58 | 62 | ||
59 | protected: | 63 | protected: |
60 | QLabel *m_description; | 64 | QLabel *m_description; |
61 | QVBoxLayout *m_layout; | 65 | QVBoxLayout *m_layout; |
62 | int m_id; | 66 | int m_id; |
63 | public: | 67 | public: |
64 | /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */ | 68 | /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */ |
65 | static QString m_errorColor; | 69 | static QString m_errorColor; |
66 | static QString m_serverColor; | 70 | static QString m_serverColor; |
67 | static QString m_textColor; | 71 | static QString m_textColor; |
68 | static QString m_backgroundColor; | 72 | static QString m_backgroundColor; |
69 | static QString m_selfColor; | 73 | static QString m_selfColor; |
70 | static QString m_otherColor; | 74 | static QString m_otherColor; |
71 | static QString m_notificationColor; | 75 | static QString m_notificationColor; |
72 | /* Max number of lines to be displayed */ | 76 | /* Max number of lines to be displayed */ |
73 | static int m_maxLines; | 77 | static int m_maxLines; |
74 | }; | 78 | }; |
75 | 79 | ||
76 | #endif /* __IRCTAB_H */ | 80 | #endif /* __IRCTAB_H */ |
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp index 2e674c5..2562f33 100644 --- a/noncore/net/opieirc/mainwindow.cpp +++ b/noncore/net/opieirc/mainwindow.cpp | |||
@@ -1,129 +1,135 @@ | |||
1 | #include <qmenubar.h> | 1 | #include <qmenubar.h> |
2 | #include <qpe/resource.h> | 2 | #include <qpe/resource.h> |
3 | #include <qwhatsthis.h> | 3 | #include <qwhatsthis.h> |
4 | 4 | ||
5 | #include "mainwindow.h" | 5 | #include "mainwindow.h" |
6 | #include "ircservertab.h" | 6 | #include "ircservertab.h" |
7 | #include "ircserverlist.h" | 7 | #include "ircserverlist.h" |
8 | #include "ircsettings.h" | 8 | #include "ircsettings.h" |
9 | 9 | ||
10 | QString MainWindow::appCaption() { | 10 | QString MainWindow::appCaption() { |
11 | return QObject::tr("Opie IRC"); | 11 | return QObject::tr("Opie IRC"); |
12 | } | 12 | } |
13 | 13 | ||
14 | 14 | ||
15 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 15 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
16 | setCaption(tr("IRC Client")); | 16 | setCaption(tr("IRC Client")); |
17 | m_tabWidget = new IRCTabWidget(this); | 17 | m_tabWidget = new IRCTabWidget(this); |
18 | QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); | 18 | QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); |
19 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget*)), this, SLOT(selected(QWidget*))); | 19 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget*)), this, SLOT(selected(QWidget*))); |
20 | setCentralWidget(m_tabWidget); | 20 | setCentralWidget(m_tabWidget); |
21 | setToolBarsMovable(FALSE); | 21 | setToolBarsMovable(FALSE); |
22 | QMenuBar *menuBar = new QMenuBar(this); | 22 | QMenuBar *menuBar = new QMenuBar(this); |
23 | QPopupMenu *irc = new QPopupMenu(this); | 23 | QPopupMenu *irc = new QPopupMenu(this); |
24 | menuBar->insertItem(tr("IRC"), irc); | 24 | menuBar->insertItem(tr("IRC"), irc); |
25 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); | 25 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); |
26 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); | 26 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); |
27 | a->setWhatsThis(tr("Create a new connection to an IRC server")); | 27 | a->setWhatsThis(tr("Create a new connection to an IRC server")); |
28 | a->addTo(irc); | 28 | a->addTo(irc); |
29 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); | 29 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); |
30 | a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); | 30 | a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); |
31 | connect(a, SIGNAL(activated()), this, SLOT(settings())); | 31 | connect(a, SIGNAL(activated()), this, SLOT(settings())); |
32 | a->addTo(irc); | 32 | a->addTo(irc); |
33 | loadSettings(); | 33 | loadSettings(); |
34 | } | 34 | } |
35 | 35 | ||
36 | /*IRCTabWidget MainWindow::getTabWidget(){ | 36 | /*IRCTabWidget MainWindow::getTabWidget(){ |
37 | return m_tabWidget; | 37 | return m_tabWidget; |
38 | } */ | 38 | } */ |
39 | 39 | ||
40 | void MainWindow::loadSettings() { | 40 | void MainWindow::loadSettings() { |
41 | Config config("OpieIRC"); | 41 | Config config("OpieIRC"); |
42 | config.setGroup("OpieIRC"); | 42 | config.setGroup("OpieIRC"); |
43 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); | 43 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); |
44 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); | 44 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); |
45 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); | 45 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); |
46 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); | 46 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); |
47 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); | 47 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); |
48 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); | 48 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); |
49 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); | 49 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); |
50 | IRCTab::m_maxLines = config.readNumEntry("Lines", 100); | 50 | IRCTab::m_maxLines = config.readNumEntry("Lines", 100); |
51 | IRCTab::setUseTimeStamps( config.readBoolEntry("DisplayTime", false ) ); | ||
51 | } | 52 | } |
52 | 53 | ||
53 | void MainWindow::selected(QWidget *) { | 54 | void MainWindow::selected(QWidget *) { |
54 | m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); | 55 | m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); |
55 | emit updateScroll(); | 56 | emit updateScroll(); |
56 | } | 57 | } |
57 | 58 | ||
58 | void MainWindow::addTab(IRCTab *tab) { | 59 | void MainWindow::addTab(IRCTab *tab) { |
59 | connect(tab, SIGNAL(changed(IRCTab*)), this, SLOT(changeEvent(IRCTab*))); | 60 | connect(tab, SIGNAL(changed(IRCTab*)), this, SLOT(changeEvent(IRCTab*))); |
60 | connect(tab, SIGNAL(ping (const QString&)), this, SLOT(slotPing(const QString&))); | 61 | connect(tab, SIGNAL(ping (const QString&)), this, SLOT(slotPing(const QString&))); |
61 | connect(tab, SIGNAL(nextTab()), this, SLOT(slotNextTab())); | 62 | connect(tab, SIGNAL(nextTab()), this, SLOT(slotNextTab())); |
62 | connect(tab, SIGNAL(prevTab()), this, SLOT(slotPrevTab())); | 63 | connect(tab, SIGNAL(prevTab()), this, SLOT(slotPrevTab())); |
63 | connect(tab, SIGNAL(closeTab()), this, SLOT(slotCloseTab())); | ||
64 | 64 | ||
65 | m_tabWidget->addTab(tab, tab->title()); | 65 | m_tabWidget->addTab(tab, tab->title()); |
66 | m_tabWidget->showPage(tab); | 66 | m_tabWidget->showPage(tab); |
67 | tab->setID(m_tabWidget->currentPageIndex()); | 67 | tab->setID(m_tabWidget->currentPageIndex()); |
68 | m_tabs.append(tab); | 68 | m_tabs.append(tab); |
69 | } | 69 | } |
70 | 70 | ||
71 | void MainWindow::changeEvent(IRCTab *tab) { | 71 | void MainWindow::changeEvent(IRCTab *tab) { |
72 | if (tab->id() != m_tabWidget->currentPageIndex()) | 72 | if (tab->id() != m_tabWidget->currentPageIndex()) |
73 | m_tabWidget->setTabColor(tab->id(), blue); | 73 | m_tabWidget->setTabColor(tab->id(), blue); |
74 | } | 74 | } |
75 | 75 | ||
76 | void MainWindow::killTab(IRCTab *tab) { | 76 | void MainWindow::killTab(IRCTab *tab, bool imediate) { |
77 | m_tabWidget->removePage(tab); | 77 | m_toDelete.append( tab ); |
78 | m_tabs.remove(tab); | ||
79 | 78 | ||
80 | /* there might be nicer ways to do this .. */ | 79 | if ( imediate ) |
81 | delete tab; | 80 | slotKillTabsLater(); |
81 | else | ||
82 | QTimer::singleShot(0, this, SLOT(slotKillTabsLater()) ); | ||
83 | } | ||
84 | |||
85 | void MainWindow::slotKillTabsLater() { | ||
86 | for ( QListIterator<IRCTab> it(m_toDelete); it.current(); ++it ) { | ||
87 | m_tabWidget->removePage( it.current() ); | ||
88 | m_tabs.remove( it.current() ); | ||
89 | } | ||
90 | |||
91 | m_toDelete.setAutoDelete( true ); | ||
92 | m_toDelete.clear(); | ||
93 | m_toDelete.setAutoDelete( false ); | ||
82 | } | 94 | } |
83 | 95 | ||
84 | void MainWindow::newConnection() { | 96 | void MainWindow::newConnection() { |
85 | IRCServerList list(this, "ServerList", TRUE); | 97 | IRCServerList list(this, "ServerList", TRUE); |
86 | if (list.exec() == QDialog::Accepted && list.hasServer()) { | 98 | if (list.exec() == QDialog::Accepted && list.hasServer()) { |
87 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); | 99 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); |
88 | addTab(serverTab); | 100 | addTab(serverTab); |
89 | serverTab->doConnect(); | 101 | serverTab->doConnect(); |
90 | } | 102 | } |
91 | } | 103 | } |
92 | 104 | ||
93 | void MainWindow::settings() { | 105 | void MainWindow::settings() { |
94 | IRCSettings settings(this, "Settings", TRUE); | 106 | IRCSettings settings(this, "Settings", TRUE); |
95 | if (settings.exec() == QDialog::Accepted) { | 107 | if (settings.exec() == QDialog::Accepted) { |
96 | QListIterator<IRCTab> it(m_tabs); | 108 | QListIterator<IRCTab> it(m_tabs); |
97 | for (; it.current(); ++it) { | 109 | for (; it.current(); ++it) { |
98 | /* Inform all tabs about the new settings */ | 110 | /* Inform all tabs about the new settings */ |
99 | it.current()->settingsChanged(); | 111 | it.current()->settingsChanged(); |
100 | } | 112 | } |
101 | } | 113 | } |
102 | } | 114 | } |
103 | 115 | ||
104 | 116 | ||
105 | void MainWindow::slotNextTab() { | 117 | void MainWindow::slotNextTab() { |
106 | int i = m_tabWidget->currentPageIndex (); | 118 | int i = m_tabWidget->currentPageIndex (); |
107 | m_tabWidget->setCurrentPage ( i+1 ); | 119 | m_tabWidget->setCurrentPage ( i+1 ); |
108 | 120 | ||
109 | int j = m_tabWidget->currentPageIndex (); | 121 | int j = m_tabWidget->currentPageIndex (); |
110 | if ( i == j ) | 122 | if ( i == j ) |
111 | m_tabWidget->setCurrentPage ( 1 ); | 123 | m_tabWidget->setCurrentPage ( 1 ); |
112 | } | 124 | } |
113 | 125 | ||
114 | void MainWindow::slotPrevTab() { | 126 | void MainWindow::slotPrevTab() { |
115 | int i = m_tabWidget->currentPageIndex (); | 127 | int i = m_tabWidget->currentPageIndex (); |
116 | if ( i > 1 ) | 128 | if ( i > 1 ) |
117 | m_tabWidget->setCurrentPage ( i-1 ); | 129 | m_tabWidget->setCurrentPage ( i-1 ); |
118 | } | 130 | } |
119 | 131 | ||
120 | void MainWindow::slotCloseTab() { | 132 | void MainWindow::slotPing( const QString& /*channel*/ ) { |
121 | IRCTab *tab = (IRCTab *) m_tabWidget->currentPage (); | ||
122 | if ( tab ) | ||
123 | killTab ( tab ); | ||
124 | } | ||
125 | |||
126 | void MainWindow::slotPing( const QString& channel ) { | ||
127 | raise(); | 133 | raise(); |
128 | } | 134 | } |
129 | 135 | ||
diff --git a/noncore/net/opieirc/mainwindow.h b/noncore/net/opieirc/mainwindow.h index 945fc71..abf205d 100644 --- a/noncore/net/opieirc/mainwindow.h +++ b/noncore/net/opieirc/mainwindow.h | |||
@@ -1,60 +1,61 @@ | |||
1 | /* | 1 | /* |
2 | OpieIRC - An embedded IRC client | 2 | OpieIRC - An embedded IRC client |
3 | Copyright (C) 2002 Wenzel Jakob | 3 | Copyright (C) 2002 Wenzel Jakob |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 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 | 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 | 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | 18 | ||
19 | */ | 19 | */ |
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 <qlist.h> |
27 | #include "mainwindow.h" | 27 | #include "mainwindow.h" |
28 | #include "ircmisc.h" | 28 | #include "ircmisc.h" |
29 | #include "irctab.h" | 29 | #include "irctab.h" |
30 | 30 | ||
31 | class MainWindow : public QMainWindow { | 31 | class MainWindow : public QMainWindow { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
34 | MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 34 | MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
35 | // IRCTabWidget getTabWidget(); | 35 | // IRCTabWidget getTabWidget(); |
36 | void addTab(IRCTab *tab); | 36 | void addTab(IRCTab *tab); |
37 | void killTab(IRCTab *tab); | 37 | void killTab(IRCTab *tab, bool now = false); |
38 | static QString appName() { return QString::fromLatin1("opieirc"); } | 38 | static QString appName() { return QString::fromLatin1("opieirc"); } |
39 | static QString appCaption(); | 39 | static QString appCaption(); |
40 | signals: | 40 | signals: |
41 | void updateScroll(); | 41 | void updateScroll(); |
42 | protected slots: | 42 | protected slots: |
43 | void newConnection(); | 43 | void newConnection(); |
44 | void settings(); | 44 | void settings(); |
45 | void selected(QWidget *); | 45 | void selected(QWidget *); |
46 | void changeEvent(IRCTab *); | 46 | void changeEvent(IRCTab *); |
47 | 47 | ||
48 | void slotNextTab(); | 48 | void slotNextTab(); |
49 | void slotPrevTab(); | 49 | void slotPrevTab(); |
50 | void slotCloseTab(); | ||
51 | void slotPing(const QString&); | 50 | void slotPing(const QString&); |
51 | void slotKillTabsLater(); | ||
52 | 52 | ||
53 | protected: | 53 | protected: |
54 | void loadSettings(); | 54 | void loadSettings(); |
55 | protected: | 55 | protected: |
56 | IRCTabWidget *m_tabWidget; | 56 | IRCTabWidget *m_tabWidget; |
57 | QList<IRCTab> m_tabs; | 57 | QList<IRCTab> m_tabs; |
58 | QList<IRCTab> m_toDelete; | ||
58 | }; | 59 | }; |
59 | 60 | ||
60 | #endif /* __MAINWINDOW_H */ | 61 | #endif /* __MAINWINDOW_H */ |