author | wazlaf <wazlaf> | 2002-09-30 08:07:05 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-09-30 08:07:05 (UTC) |
commit | a999acbcd1b8bc1715f2ad2dda6acedf423b89ea (patch) (unidiff) | |
tree | 898d433efa8ff3b25a5d10ab4dc4a0a9bc415104 | |
parent | 75dccdfe90324e9ff2426930ae185c3a6bdab734 (diff) | |
download | opie-a999acbcd1b8bc1715f2ad2dda6acedf423b89ea.zip opie-a999acbcd1b8bc1715f2ad2dda6acedf423b89ea.tar.gz opie-a999acbcd1b8bc1715f2ad2dda6acedf423b89ea.tar.bz2 |
tabs now change their color when actions occur
-rw-r--r-- | noncore/net/opieirc/ircchanneltab.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmisc.cpp | 35 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmisc.h | 50 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/irctab.cpp | 8 | ||||
-rw-r--r-- | noncore/net/opieirc/irctab.h | 5 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 14 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.h | 6 |
9 files changed, 107 insertions, 14 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp index c1695db..ddd6cf1 100644 --- a/noncore/net/opieirc/ircchanneltab.cpp +++ b/noncore/net/opieirc/ircchanneltab.cpp | |||
@@ -1,146 +1,147 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qpe/resource.h> | 2 | #include <qpe/resource.h> |
3 | #include <qcursor.h> | 3 | #include <qcursor.h> |
4 | #include <qhbox.h> | 4 | #include <qhbox.h> |
5 | #include "ircchanneltab.h" | 5 | #include "ircchanneltab.h" |
6 | #include "ircservertab.h" | 6 | #include "ircservertab.h" |
7 | 7 | ||
8 | IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 8 | IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
9 | m_mainWindow = mainWindow; | 9 | m_mainWindow = mainWindow; |
10 | m_parentTab = parentTab; | 10 | m_parentTab = parentTab; |
11 | m_channel = channel; | 11 | m_channel = channel; |
12 | m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); | 12 | m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); |
13 | QHBox *hbox = new QHBox(this); | 13 | QHBox *hbox = new QHBox(this); |
14 | m_textview = new QTextView(hbox); | 14 | m_textview = new QTextView(hbox); |
15 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 15 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
16 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 16 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
17 | m_listVisible = TRUE; | 17 | m_listVisible = TRUE; |
18 | m_listButton = new QPushButton(">", m_textview); | 18 | m_listButton = new QPushButton(">", m_textview); |
19 | m_textview->setCornerWidget(m_listButton); | 19 | m_textview->setCornerWidget(m_listButton); |
20 | m_textview->setTextFormat(RichText); | 20 | m_textview->setTextFormat(RichText); |
21 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); | 21 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); |
22 | m_list = new IRCChannelList(m_channel, hbox); | 22 | m_list = new IRCChannelList(m_channel, hbox); |
23 | m_list->update(); | 23 | m_list->update(); |
24 | m_list->setMaximumWidth(LISTWIDTH); | 24 | m_list->setMaximumWidth(LISTWIDTH); |
25 | m_field = new QLineEdit(this); | 25 | m_field = new QLineEdit(this); |
26 | m_popup = new QPopupMenu(m_list); | 26 | m_popup = new QPopupMenu(m_list); |
27 | /* Required so that embedded-style "right" clicks work */ | 27 | /* Required so that embedded-style "right" clicks work */ |
28 | QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); | 28 | QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); |
29 | connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &))); | 29 | connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &))); |
30 | /* Construct the popup menu */ | 30 | /* Construct the popup menu */ |
31 | QPopupMenu *ctcpMenu = new QPopupMenu(m_list); | 31 | QPopupMenu *ctcpMenu = new QPopupMenu(m_list); |
32 | m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); | 32 | m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); |
33 | m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); | 33 | m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); |
34 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); | 34 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); |
35 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); | 35 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); |
36 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); | 36 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); |
37 | 37 | ||
38 | m_layout->add(hbox); | 38 | m_layout->add(hbox); |
39 | hbox->show(); | 39 | hbox->show(); |
40 | m_layout->add(m_field); | 40 | m_layout->add(m_field); |
41 | m_field->setFocus(); | 41 | m_field->setFocus(); |
42 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 42 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
43 | settingsChanged(); | 43 | settingsChanged(); |
44 | } | 44 | } |
45 | 45 | ||
46 | void IRCChannelTab::appendText(QString text) { | 46 | void IRCChannelTab::appendText(QString text) { |
47 | /* not using append because it creates layout problems */ | 47 | /* not using append because it creates layout problems */ |
48 | m_textview->setText(m_textview->text() + text); | 48 | m_textview->setText(m_textview->text() + text); |
49 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 49 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
50 | emit changed(this); | ||
50 | } | 51 | } |
51 | 52 | ||
52 | IRCChannelTab::~IRCChannelTab() { | 53 | IRCChannelTab::~IRCChannelTab() { |
53 | m_parentTab->removeChannelTab(this); | 54 | m_parentTab->removeChannelTab(this); |
54 | } | 55 | } |
55 | 56 | ||
56 | void IRCChannelTab::processCommand() { | 57 | void IRCChannelTab::processCommand() { |
57 | QString text = m_field->text(); | 58 | QString text = m_field->text(); |
58 | if (text.length()>0) { | 59 | if (text.length()>0) { |
59 | if (session()->isSessionActive()) { | 60 | if (session()->isSessionActive()) { |
60 | if (text.startsWith("/") && !text.startsWith("//")) { | 61 | if (text.startsWith("/") && !text.startsWith("//")) { |
61 | /* Command mode */ | 62 | /* Command mode */ |
62 | m_parentTab->executeCommand(this, text);; | 63 | m_parentTab->executeCommand(this, text);; |
63 | } else { | 64 | } else { |
64 | if (text.startsWith("//")) | 65 | if (text.startsWith("//")) |
65 | text = text.right(text.length()-1); | 66 | text = text.right(text.length()-1); |
66 | session()->sendMessage(m_channel, m_field->text()); | 67 | session()->sendMessage(m_channel, m_field->text()); |
67 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">> "+IRCOutput::toHTML(m_field->text())+"</font><br>"); | 68 | 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>"); |
68 | } | 69 | } |
69 | } else { | 70 | } else { |
70 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); | 71 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); |
71 | } | 72 | } |
72 | } | 73 | } |
73 | m_field->clear(); | 74 | m_field->clear(); |
74 | } | 75 | } |
75 | 76 | ||
76 | void IRCChannelTab::settingsChanged() { | 77 | void IRCChannelTab::settingsChanged() { |
77 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | 78 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); |
78 | } | 79 | } |
79 | 80 | ||
80 | void IRCChannelTab::toggleList() { | 81 | void IRCChannelTab::toggleList() { |
81 | if (m_listVisible) { | 82 | if (m_listVisible) { |
82 | m_list->setMaximumWidth(0); | 83 | m_list->setMaximumWidth(0); |
83 | m_listButton->setText("<"); | 84 | m_listButton->setText("<"); |
84 | } else { | 85 | } else { |
85 | m_list->setMaximumWidth(LISTWIDTH); | 86 | m_list->setMaximumWidth(LISTWIDTH); |
86 | m_listButton->setText(">"); | 87 | m_listButton->setText(">"); |
87 | } | 88 | } |
88 | m_listVisible = !m_listVisible; | 89 | m_listVisible = !m_listVisible; |
89 | } | 90 | } |
90 | 91 | ||
91 | void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { | 92 | void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { |
92 | switch (mouse) { | 93 | switch (mouse) { |
93 | case 1: | 94 | case 1: |
94 | break; | 95 | break; |
95 | case 2: | 96 | case 2: |
96 | m_popup->popup(point); | 97 | m_popup->popup(point); |
97 | break; | 98 | break; |
98 | }; | 99 | }; |
99 | } | 100 | } |
100 | 101 | ||
101 | void IRCChannelTab::popupQuery() { | 102 | void IRCChannelTab::popupQuery() { |
102 | if (m_list->currentItem() != -1) { | 103 | if (m_list->currentItem() != -1) { |
103 | IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); | 104 | IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); |
104 | if (person) { | 105 | if (person) { |
105 | IRCQueryTab *tab = m_parentTab->getTabForQuery(person); | 106 | IRCQueryTab *tab = m_parentTab->getTabForQuery(person); |
106 | if (!tab) { | 107 | if (!tab) { |
107 | tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); | 108 | tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); |
108 | m_parentTab->addQueryTab(tab); | 109 | m_parentTab->addQueryTab(tab); |
109 | m_mainWindow->addTab(tab); | 110 | m_mainWindow->addTab(tab); |
110 | } | 111 | } |
111 | } | 112 | } |
112 | } | 113 | } |
113 | } | 114 | } |
114 | 115 | ||
115 | void IRCChannelTab::popupPing() { | 116 | void IRCChannelTab::popupPing() { |
116 | } | 117 | } |
117 | 118 | ||
118 | void IRCChannelTab::popupVersion() { | 119 | void IRCChannelTab::popupVersion() { |
119 | } | 120 | } |
120 | 121 | ||
121 | void IRCChannelTab::popupWhois() { | 122 | void IRCChannelTab::popupWhois() { |
122 | } | 123 | } |
123 | 124 | ||
124 | QString IRCChannelTab::title() { | 125 | QString IRCChannelTab::title() { |
125 | return m_channel->channelname(); | 126 | return m_channel->channelname(); |
126 | } | 127 | } |
127 | 128 | ||
128 | IRCSession *IRCChannelTab::session() { | 129 | IRCSession *IRCChannelTab::session() { |
129 | return m_parentTab->session(); | 130 | return m_parentTab->session(); |
130 | } | 131 | } |
131 | 132 | ||
132 | void IRCChannelTab::remove() { | 133 | void IRCChannelTab::remove() { |
133 | if (session()->isSessionActive()) { | 134 | if (session()->isSessionActive()) { |
134 | session()->part(m_channel); | 135 | session()->part(m_channel); |
135 | } else { | 136 | } else { |
136 | m_mainWindow->killTab(this); | 137 | m_mainWindow->killTab(this); |
137 | } | 138 | } |
138 | } | 139 | } |
139 | 140 | ||
140 | IRCChannel *IRCChannelTab::channel() { | 141 | IRCChannel *IRCChannelTab::channel() { |
141 | return m_channel; | 142 | return m_channel; |
142 | } | 143 | } |
143 | 144 | ||
144 | IRCChannelList *IRCChannelTab::list() { | 145 | IRCChannelList *IRCChannelTab::list() { |
145 | return m_list; | 146 | return m_list; |
146 | } | 147 | } |
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp index f41a89a..dd7292c 100644 --- a/noncore/net/opieirc/ircmisc.cpp +++ b/noncore/net/opieirc/ircmisc.cpp | |||
@@ -1,31 +1,66 @@ | |||
1 | #include <opie/colordialog.h> | 1 | #include <opie/colordialog.h> |
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <stdio.h> | ||
3 | #include "ircmisc.h" | 4 | #include "ircmisc.h" |
4 | 5 | ||
5 | IRCColorLabel::IRCColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QLabel(parent, name, f) { | 6 | IRCColorLabel::IRCColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QLabel(parent, name, f) { |
6 | m_color = color; | 7 | m_color = color; |
7 | setAlignment(AlignVCenter | AlignCenter); | 8 | setAlignment(AlignVCenter | AlignCenter); |
8 | setFrameStyle(QFrame::StyledPanel); | 9 | setFrameStyle(QFrame::StyledPanel); |
9 | setFrameShadow(QFrame::Sunken); | 10 | setFrameShadow(QFrame::Sunken); |
10 | setBackgroundColor(m_color); | 11 | setBackgroundColor(m_color); |
11 | } | 12 | } |
12 | 13 | ||
13 | void IRCColorLabel::mousePressEvent(QMouseEvent *) { | 14 | void IRCColorLabel::mousePressEvent(QMouseEvent *) { |
14 | m_color = OColorDialog::getColor(m_color); | 15 | m_color = OColorDialog::getColor(m_color); |
15 | setBackgroundColor(m_color); | 16 | setBackgroundColor(m_color); |
16 | } | 17 | } |
17 | 18 | ||
18 | QColor IRCColorLabel::color() { | 19 | QColor IRCColorLabel::color() { |
19 | return m_color; | 20 | return m_color; |
20 | } | 21 | } |
21 | 22 | ||
22 | IRCFramedColorLabel::IRCFramedColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { | 23 | IRCFramedColorLabel::IRCFramedColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { |
23 | QVBoxLayout *layout = new QVBoxLayout(this, 10, 0); | 24 | QVBoxLayout *layout = new QVBoxLayout(this, 10, 0); |
24 | m_label = new IRCColorLabel(color, this); | 25 | m_label = new IRCColorLabel(color, this); |
25 | layout->addWidget(m_label); | 26 | layout->addWidget(m_label); |
26 | } | 27 | } |
27 | 28 | ||
28 | QColor IRCFramedColorLabel::color() { | 29 | QColor IRCFramedColorLabel::color() { |
29 | return m_label->color(); | 30 | return m_label->color(); |
30 | } | 31 | } |
31 | 32 | ||
33 | IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { | ||
34 | } | ||
35 | |||
36 | int IRCTabBar::insertTab(QTab *tab, int index = -1) { | ||
37 | if (m_colors.size() == (unsigned int)count()) | ||
38 | m_colors.resize(m_colors.size() * 2 + 1); | ||
39 | if (index == -1) | ||
40 | m_colors.insert(count(), &black); | ||
41 | else | ||
42 | m_colors.insert(index, &black); | ||
43 | return QTabBar::insertTab(tab, index); | ||
44 | } | ||
45 | |||
46 | void IRCTabBar::setTabColor(int index, const QColor *color) { | ||
47 | m_colors.insert(index, color); | ||
48 | update(); | ||
49 | } | ||
50 | |||
51 | void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const { | ||
52 | QRect r = br; | ||
53 | QTabBar::paintLabel(p, br, t, focus); | ||
54 | if (t->id == currentTab()) | ||
55 | r.setBottom(r.bottom() - style().defaultFrameWidth()); | ||
56 | p->setPen(*m_colors.at(t->id)); | ||
57 | p->drawText(r, AlignCenter | ShowPrefix, t->label); | ||
58 | } | ||
59 | |||
60 | IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) { | ||
61 | setTabBar(new IRCTabBar(this, "tab control")); | ||
62 | } | ||
63 | |||
64 | void IRCTabWidget::setTabColor(int index, const QColor *color) { | ||
65 | ((IRCTabBar *)tabBar())->setTabColor(index, color); | ||
66 | } | ||
diff --git a/noncore/net/opieirc/ircmisc.h b/noncore/net/opieirc/ircmisc.h index 1ea04c8..4df6ce0 100644 --- a/noncore/net/opieirc/ircmisc.h +++ b/noncore/net/opieirc/ircmisc.h | |||
@@ -1,44 +1,72 @@ | |||
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 __IRCMISC_H | 21 | #ifndef __IRCMISC_H |
22 | #define __IRCMISC_H | 22 | #define __IRCMISC_H |
23 | 23 | ||
24 | #include <qtabwidget.h> | ||
25 | #include <qtabbar.h> | ||
24 | #include <qlabel.h> | 26 | #include <qlabel.h> |
25 | #include <qcolor.h> | 27 | #include <qcolor.h> |
28 | #include <qvector.h> | ||
29 | |||
30 | /* IRCFramedColorLabel is used to display a color */ | ||
26 | 31 | ||
27 | class IRCColorLabel : public QLabel { | 32 | class IRCColorLabel : public QLabel { |
28 | public: | 33 | Q_OBJECT |
29 | IRCColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 34 | public: |
30 | QColor color(); | 35 | IRCColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
31 | void mousePressEvent(QMouseEvent *event); | 36 | QColor color(); |
32 | protected: | 37 | void mousePressEvent(QMouseEvent *event); |
33 | QColor m_color; | 38 | protected: |
39 | QColor m_color; | ||
34 | }; | 40 | }; |
35 | 41 | ||
36 | class IRCFramedColorLabel : public QWidget { | 42 | class IRCFramedColorLabel : public QWidget { |
37 | public: | 43 | Q_OBJECT |
38 | IRCFramedColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 44 | public: |
39 | QColor color(); | 45 | IRCFramedColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
40 | protected: | 46 | QColor color(); |
41 | IRCColorLabel *m_label; | 47 | protected: |
48 | IRCColorLabel *m_label; | ||
49 | }; | ||
50 | |||
51 | /* Custom colored QTabWidget */ | ||
52 | |||
53 | class IRCTabWidget : public QTabWidget { | ||
54 | Q_OBJECT | ||
55 | public: | ||
56 | IRCTabWidget(QWidget *parent = 0, const char *name = 0); | ||
57 | void setTabColor(int index, const QColor *color); | ||
58 | }; | ||
59 | |||
60 | class IRCTabBar : public QTabBar { | ||
61 | Q_OBJECT | ||
62 | public: | ||
63 | IRCTabBar(QWidget *parent = 0, const char *name = 0); | ||
64 | void setTabColor(int index, const QColor *color); | ||
65 | protected: | ||
66 | void paintLabel(QPainter*, const QRect&, QTab*, bool) const; | ||
67 | int insertTab(QTab *, int index = -1); | ||
68 | protected: | ||
69 | QVector<QColor> m_colors; | ||
42 | }; | 70 | }; |
43 | 71 | ||
44 | #endif /* __IRCMISC_H */ | 72 | #endif /* __IRCMISC_H */ |
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp index c6b8211..b946174 100644 --- a/noncore/net/opieirc/ircquerytab.cpp +++ b/noncore/net/opieirc/ircquerytab.cpp | |||
@@ -1,82 +1,83 @@ | |||
1 | #include <qhbox.h> | 1 | #include <qhbox.h> |
2 | #include "ircquerytab.h" | 2 | #include "ircquerytab.h" |
3 | #include "ircservertab.h" | 3 | #include "ircservertab.h" |
4 | 4 | ||
5 | IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 5 | IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
6 | m_mainWindow = mainWindow; | 6 | m_mainWindow = mainWindow; |
7 | m_parentTab = parentTab; | 7 | m_parentTab = parentTab; |
8 | m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */ | 8 | m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */ |
9 | m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>"); | 9 | m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>"); |
10 | QHBox *hbox = new QHBox(this); | 10 | QHBox *hbox = new QHBox(this); |
11 | m_textview = new QTextView(hbox); | 11 | m_textview = new QTextView(hbox); |
12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
14 | m_textview->setTextFormat(RichText); | 14 | m_textview->setTextFormat(RichText); |
15 | m_field = new QLineEdit(this); | 15 | m_field = new QLineEdit(this); |
16 | m_layout->add(hbox); | 16 | m_layout->add(hbox); |
17 | hbox->show(); | 17 | hbox->show(); |
18 | m_layout->add(m_field); | 18 | m_layout->add(m_field); |
19 | m_field->setFocus(); | 19 | m_field->setFocus(); |
20 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 20 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
21 | settingsChanged(); | 21 | settingsChanged(); |
22 | } | 22 | } |
23 | 23 | ||
24 | void IRCQueryTab::appendText(QString text) { | 24 | void IRCQueryTab::appendText(QString text) { |
25 | /* not using append because it creates layout problems */ | 25 | /* not using append because it creates layout problems */ |
26 | m_textview->setText(m_textview->text() + text); | 26 | m_textview->setText(m_textview->text() + text); |
27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
28 | emit changed(this); | ||
28 | } | 29 | } |
29 | 30 | ||
30 | IRCQueryTab::~IRCQueryTab() { | 31 | IRCQueryTab::~IRCQueryTab() { |
31 | m_parentTab->removeQueryTab(this); | 32 | m_parentTab->removeQueryTab(this); |
32 | delete m_person; | 33 | delete m_person; |
33 | } | 34 | } |
34 | 35 | ||
35 | void IRCQueryTab::processCommand() { | 36 | void IRCQueryTab::processCommand() { |
36 | QString text = m_field->text(); | 37 | QString text = m_field->text(); |
37 | if (text.length()>0) { | 38 | if (text.length()>0) { |
38 | if (session()->isSessionActive()) { | 39 | if (session()->isSessionActive()) { |
39 | if (text.startsWith("/") && !text.startsWith("//")) { | 40 | if (text.startsWith("/") && !text.startsWith("//")) { |
40 | /* Command mode */ | 41 | /* Command mode */ |
41 | m_parentTab->executeCommand(this, text);; | 42 | m_parentTab->executeCommand(this, text);; |
42 | } else { | 43 | } else { |
43 | if (text.startsWith("//")) | 44 | if (text.startsWith("//")) |
44 | text = text.right(text.length()-1); | 45 | text = text.right(text.length()-1); |
45 | session()->sendMessage(m_person, m_field->text()); | 46 | session()->sendMessage(m_person, m_field->text()); |
46 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">> "+IRCOutput::toHTML(m_field->text())+"</font><br>"); | 47 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">> "+IRCOutput::toHTML(m_field->text())+"</font><br>"); |
47 | } | 48 | } |
48 | } else { | 49 | } else { |
49 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); | 50 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); |
50 | } | 51 | } |
51 | } | 52 | } |
52 | m_field->clear(); | 53 | m_field->clear(); |
53 | } | 54 | } |
54 | 55 | ||
55 | void IRCQueryTab::display(IRCOutput output) { | 56 | void IRCQueryTab::display(IRCOutput output) { |
56 | if (output.type() == OUTPUT_QUERYPRIVMSG) { | 57 | if (output.type() == OUTPUT_QUERYPRIVMSG) { |
57 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage() + "</font><br>"); | 58 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage() + "</font><br>"); |
58 | } else if (output.type() == OUTPUT_QUERYACTION) { | 59 | } else if (output.type() == OUTPUT_QUERYACTION) { |
59 | appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>"); | 60 | appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>"); |
60 | } | 61 | } |
61 | } | 62 | } |
62 | 63 | ||
63 | void IRCQueryTab::settingsChanged() { | 64 | void IRCQueryTab::settingsChanged() { |
64 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | 65 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); |
65 | } | 66 | } |
66 | 67 | ||
67 | QString IRCQueryTab::title() { | 68 | QString IRCQueryTab::title() { |
68 | return m_person->nick(); | 69 | return m_person->nick(); |
69 | } | 70 | } |
70 | 71 | ||
71 | IRCSession *IRCQueryTab::session() { | 72 | IRCSession *IRCQueryTab::session() { |
72 | return m_parentTab->session(); | 73 | return m_parentTab->session(); |
73 | } | 74 | } |
74 | 75 | ||
75 | void IRCQueryTab::remove() { | 76 | void IRCQueryTab::remove() { |
76 | m_mainWindow->killTab(this); | 77 | m_mainWindow->killTab(this); |
77 | } | 78 | } |
78 | 79 | ||
79 | IRCPerson *IRCQueryTab::person() { | 80 | IRCPerson *IRCQueryTab::person() { |
80 | return m_person; | 81 | return m_person; |
81 | } | 82 | } |
82 | 83 | ||
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index d16c05f..4ed5364 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -1,264 +1,265 @@ | |||
1 | #include <qpe/config.h> | 1 | #include <qpe/config.h> |
2 | #include <qtextstream.h> | 2 | #include <qtextstream.h> |
3 | #include "ircservertab.h" | 3 | #include "ircservertab.h" |
4 | 4 | ||
5 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 5 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
6 | m_server = server; | 6 | m_server = server; |
7 | m_session = new IRCSession(&m_server); | 7 | m_session = new IRCSession(&m_server); |
8 | m_mainWindow = mainWindow; | 8 | m_mainWindow = mainWindow; |
9 | m_close = FALSE; | 9 | m_close = FALSE; |
10 | m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); | 10 | m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); |
11 | m_textview = new QTextView(this); | 11 | m_textview = new QTextView(this); |
12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
14 | m_textview->setTextFormat(RichText); | 14 | m_textview->setTextFormat(RichText); |
15 | m_layout->add(m_textview); | 15 | m_layout->add(m_textview); |
16 | m_field = new QLineEdit(this); | 16 | m_field = new QLineEdit(this); |
17 | m_layout->add(m_field); | 17 | m_layout->add(m_field); |
18 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 18 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
19 | m_field->setFocus(); | 19 | m_field->setFocus(); |
20 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); | 20 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); |
21 | settingsChanged(); | 21 | settingsChanged(); |
22 | } | 22 | } |
23 | 23 | ||
24 | void IRCServerTab::appendText(QString text) { | 24 | void IRCServerTab::appendText(QString text) { |
25 | /* not using append because it creates layout problems */ | 25 | /* not using append because it creates layout problems */ |
26 | m_textview->setText(m_textview->text() + text); | 26 | m_textview->setText(m_textview->text() + text); |
27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
28 | emit changed(this); | ||
28 | } | 29 | } |
29 | 30 | ||
30 | IRCServerTab::~IRCServerTab() { | 31 | IRCServerTab::~IRCServerTab() { |
31 | delete m_session; | 32 | delete m_session; |
32 | } | 33 | } |
33 | 34 | ||
34 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { | 35 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { |
35 | m_channelTabs.remove(tab); | 36 | m_channelTabs.remove(tab); |
36 | } | 37 | } |
37 | 38 | ||
38 | void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { | 39 | void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { |
39 | m_queryTabs.remove(tab); | 40 | m_queryTabs.remove(tab); |
40 | } | 41 | } |
41 | 42 | ||
42 | void IRCServerTab::addQueryTab(IRCQueryTab *tab) { | 43 | void IRCServerTab::addQueryTab(IRCQueryTab *tab) { |
43 | m_queryTabs.append(tab); | 44 | m_queryTabs.append(tab); |
44 | } | 45 | } |
45 | 46 | ||
46 | QString IRCServerTab::title() { | 47 | QString IRCServerTab::title() { |
47 | return "Server"; | 48 | return "Server"; |
48 | } | 49 | } |
49 | 50 | ||
50 | IRCSession *IRCServerTab::session() { | 51 | IRCSession *IRCServerTab::session() { |
51 | return m_session; | 52 | return m_session; |
52 | } | 53 | } |
53 | 54 | ||
54 | IRCServer *IRCServerTab::server() { | 55 | IRCServer *IRCServerTab::server() { |
55 | return &m_server; | 56 | return &m_server; |
56 | } | 57 | } |
57 | 58 | ||
58 | void IRCServerTab::settingsChanged() { | 59 | void IRCServerTab::settingsChanged() { |
59 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | 60 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); |
60 | } | 61 | } |
61 | 62 | ||
62 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { | 63 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { |
63 | QTextIStream stream(&line); | 64 | QTextIStream stream(&line); |
64 | QString command; | 65 | QString command; |
65 | stream >> command; | 66 | stream >> command; |
66 | command = command.upper().right(command.length()-1); | 67 | command = command.upper().right(command.length()-1); |
67 | 68 | ||
68 | if (command == "JOIN") { | 69 | if (command == "JOIN") { |
69 | QString channel; | 70 | QString channel; |
70 | stream >> channel; | 71 | stream >> channel; |
71 | if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { | 72 | if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { |
72 | m_session->join(channel); | 73 | m_session->join(channel); |
73 | } else { | 74 | } else { |
74 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); | 75 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); |
75 | } | 76 | } |
76 | } else if (command == "ME") { | 77 | } else if (command == "ME") { |
77 | QString text = line.right(line.length()-4); | 78 | QString text = line.right(line.length()-4); |
78 | if (text.length() > 0) { | 79 | if (text.length() > 0) { |
79 | if (tab->isA("IRCChannelTab")) { | 80 | if (tab->isA("IRCChannelTab")) { |
80 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); | 81 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); |
81 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); | 82 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); |
82 | } else if (tab->isA("IRCQueryTab")) { | 83 | } else if (tab->isA("IRCQueryTab")) { |
83 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); | 84 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); |
84 | m_session->sendAction(((IRCQueryTab *)tab)->person(), text); | 85 | m_session->sendAction(((IRCQueryTab *)tab)->person(), text); |
85 | } else { | 86 | } else { |
86 | tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); | 87 | tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); |
87 | } | 88 | } |
88 | } | 89 | } |
89 | } else if (command == "MSG") { | 90 | } else if (command == "MSG") { |
90 | QString nickname; | 91 | QString nickname; |
91 | stream >> nickname; | 92 | stream >> nickname; |
92 | if (nickname.length() > 0) { | 93 | if (nickname.length() > 0) { |
93 | if (line.length() > 6 + nickname.length()) { | 94 | if (line.length() > 6 + nickname.length()) { |
94 | QString text = line.right(line.length()-nickname.length()-6); | 95 | QString text = line.right(line.length()-nickname.length()-6); |
95 | IRCPerson person; | 96 | IRCPerson person; |
96 | person.setNick(nickname); | 97 | person.setNick(nickname); |
97 | tab->appendText("<font color=\"" + m_textColor + "\">></font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">< "+IRCOutput::toHTML(text)+"</font><br>"); | 98 | tab->appendText("<font color=\"" + m_textColor + "\">></font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">< "+IRCOutput::toHTML(text)+"</font><br>"); |
98 | m_session->sendMessage(&person, text); | 99 | m_session->sendMessage(&person, text); |
99 | } | 100 | } |
100 | } | 101 | } |
101 | } else { | 102 | } else { |
102 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); | 103 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); |
103 | } | 104 | } |
104 | } | 105 | } |
105 | 106 | ||
106 | void IRCServerTab::processCommand() { | 107 | void IRCServerTab::processCommand() { |
107 | QString text = m_field->text(); | 108 | QString text = m_field->text(); |
108 | if (text.startsWith("/") && !text.startsWith("//")) { | 109 | if (text.startsWith("/") && !text.startsWith("//")) { |
109 | /* Command mode */ | 110 | /* Command mode */ |
110 | executeCommand(this, text); | 111 | executeCommand(this, text); |
111 | } | 112 | } |
112 | m_field->clear(); | 113 | m_field->clear(); |
113 | } | 114 | } |
114 | 115 | ||
115 | void IRCServerTab::doConnect() { | 116 | void IRCServerTab::doConnect() { |
116 | m_session->beginSession(); | 117 | m_session->beginSession(); |
117 | } | 118 | } |
118 | 119 | ||
119 | void IRCServerTab::remove() { | 120 | void IRCServerTab::remove() { |
120 | /* Close requested */ | 121 | /* Close requested */ |
121 | if (m_session->isSessionActive()) { | 122 | if (m_session->isSessionActive()) { |
122 | /* While there is a running session */ | 123 | /* While there is a running session */ |
123 | m_close = TRUE; | 124 | m_close = TRUE; |
124 | m_session->endSession(); | 125 | m_session->endSession(); |
125 | } else { | 126 | } else { |
126 | /* Session has previously been closed */ | 127 | /* Session has previously been closed */ |
127 | m_channelTabs.first(); | 128 | m_channelTabs.first(); |
128 | while (m_channelTabs.current() != 0) { | 129 | while (m_channelTabs.current() != 0) { |
129 | m_mainWindow->killTab(m_channelTabs.current()); | 130 | m_mainWindow->killTab(m_channelTabs.current()); |
130 | } | 131 | } |
131 | m_queryTabs.first(); | 132 | m_queryTabs.first(); |
132 | while (m_queryTabs.current() != 0) { | 133 | while (m_queryTabs.current() != 0) { |
133 | m_mainWindow->killTab(m_queryTabs.current()); | 134 | m_mainWindow->killTab(m_queryTabs.current()); |
134 | } | 135 | } |
135 | m_mainWindow->killTab(this); | 136 | m_mainWindow->killTab(this); |
136 | } | 137 | } |
137 | } | 138 | } |
138 | 139 | ||
139 | IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { | 140 | IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { |
140 | QListIterator<IRCChannelTab> it(m_channelTabs); | 141 | QListIterator<IRCChannelTab> it(m_channelTabs); |
141 | 142 | ||
142 | for (; it.current(); ++it) { | 143 | for (; it.current(); ++it) { |
143 | if (it.current()->channel() == channel) | 144 | if (it.current()->channel() == channel) |
144 | return it.current(); | 145 | return it.current(); |
145 | } | 146 | } |
146 | return 0; | 147 | return 0; |
147 | } | 148 | } |
148 | 149 | ||
149 | IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { | 150 | IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { |
150 | QListIterator<IRCQueryTab> it(m_queryTabs); | 151 | QListIterator<IRCQueryTab> it(m_queryTabs); |
151 | 152 | ||
152 | for (; it.current(); ++it) { | 153 | for (; it.current(); ++it) { |
153 | if (it.current()->person()->nick() == person->nick()) | 154 | if (it.current()->person()->nick() == person->nick()) |
154 | return it.current(); | 155 | return it.current(); |
155 | } | 156 | } |
156 | return 0; | 157 | return 0; |
157 | } | 158 | } |
158 | 159 | ||
159 | void IRCServerTab::display(IRCOutput output) { | 160 | void IRCServerTab::display(IRCOutput output) { |
160 | 161 | ||
161 | /* All messages to be displayed inside the GUI get here */ | 162 | /* All messages to be displayed inside the GUI get here */ |
162 | switch (output.type()) { | 163 | switch (output.type()) { |
163 | case OUTPUT_CONNCLOSE: | 164 | case OUTPUT_CONNCLOSE: |
164 | if (m_close) { | 165 | if (m_close) { |
165 | m_channelTabs.first(); | 166 | m_channelTabs.first(); |
166 | while (m_channelTabs.current() != 0) { | 167 | while (m_channelTabs.current() != 0) { |
167 | m_mainWindow->killTab(m_channelTabs.current()); | 168 | m_mainWindow->killTab(m_channelTabs.current()); |
168 | } | 169 | } |
169 | m_queryTabs.first(); | 170 | m_queryTabs.first(); |
170 | while (m_queryTabs.current() != 0) { | 171 | while (m_queryTabs.current() != 0) { |
171 | m_mainWindow->killTab(m_queryTabs.current()); | 172 | m_mainWindow->killTab(m_queryTabs.current()); |
172 | } | 173 | } |
173 | m_mainWindow->killTab(this); | 174 | m_mainWindow->killTab(this); |
174 | } else { | 175 | } else { |
175 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); | 176 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); |
176 | QListIterator<IRCChannelTab> it(m_channelTabs); | 177 | QListIterator<IRCChannelTab> it(m_channelTabs); |
177 | for (; it.current(); ++it) { | 178 | for (; it.current(); ++it) { |
178 | it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); | 179 | it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); |
179 | } | 180 | } |
180 | } | 181 | } |
181 | break; | 182 | break; |
182 | case OUTPUT_SELFJOIN: { | 183 | case OUTPUT_SELFJOIN: { |
183 | IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); | 184 | IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); |
184 | m_channelTabs.append(channeltab); | 185 | m_channelTabs.append(channeltab); |
185 | m_mainWindow->addTab(channeltab); | 186 | m_mainWindow->addTab(channeltab); |
186 | } | 187 | } |
187 | break; | 188 | break; |
188 | case OUTPUT_CHANPRIVMSG: { | 189 | case OUTPUT_CHANPRIVMSG: { |
189 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 190 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
190 | channelTab->appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage()+"</font><br>"); | 191 | 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>"); |
191 | } | 192 | } |
192 | break; | 193 | break; |
193 | case OUTPUT_QUERYACTION: | 194 | case OUTPUT_QUERYACTION: |
194 | case OUTPUT_QUERYPRIVMSG: { | 195 | case OUTPUT_QUERYPRIVMSG: { |
195 | IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); | 196 | IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); |
196 | if (!queryTab) { | 197 | if (!queryTab) { |
197 | queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); | 198 | queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); |
198 | m_queryTabs.append(queryTab); | 199 | m_queryTabs.append(queryTab); |
199 | m_mainWindow->addTab(queryTab); | 200 | m_mainWindow->addTab(queryTab); |
200 | } | 201 | } |
201 | queryTab->display(output); | 202 | queryTab->display(output); |
202 | } | 203 | } |
203 | break; | 204 | break; |
204 | case OUTPUT_SELFPART: { | 205 | case OUTPUT_SELFPART: { |
205 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 206 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
206 | if (channelTab) | 207 | if (channelTab) |
207 | m_mainWindow->killTab(channelTab); | 208 | m_mainWindow->killTab(channelTab); |
208 | } | 209 | } |
209 | break; | 210 | break; |
210 | case OUTPUT_SELFKICK: { | 211 | case OUTPUT_SELFKICK: { |
211 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); | 212 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); |
212 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 213 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
213 | if (channelTab) | 214 | if (channelTab) |
214 | m_mainWindow->killTab(channelTab); | 215 | m_mainWindow->killTab(channelTab); |
215 | } | 216 | } |
216 | break; | 217 | break; |
217 | case OUTPUT_CHANACTION: { | 218 | case OUTPUT_CHANACTION: { |
218 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 219 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
219 | channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); | 220 | channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); |
220 | } | 221 | } |
221 | break; | 222 | break; |
222 | case OUTPUT_TOPIC: { | 223 | case OUTPUT_TOPIC: { |
223 | IRCChannel *channel = (IRCChannel *) output.getParam(0); | 224 | IRCChannel *channel = (IRCChannel *) output.getParam(0); |
224 | if (channel) { | 225 | if (channel) { |
225 | IRCChannelTab *channelTab = getTabForChannel(channel); | 226 | IRCChannelTab *channelTab = getTabForChannel(channel); |
226 | if (channelTab) { | 227 | if (channelTab) { |
227 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 228 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
228 | return; | 229 | return; |
229 | } | 230 | } |
230 | } | 231 | } |
231 | appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 232 | appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
232 | } | 233 | } |
233 | break; | 234 | break; |
234 | case OUTPUT_QUIT: { | 235 | case OUTPUT_QUIT: { |
235 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); | 236 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); |
236 | QListIterator<IRCChannelTab> it(m_channelTabs); | 237 | QListIterator<IRCChannelTab> it(m_channelTabs); |
237 | for (; it.current(); ++it) { | 238 | for (; it.current(); ++it) { |
238 | if (it.current()->list()->hasPerson(nick)) { | 239 | if (it.current()->list()->hasPerson(nick)) { |
239 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 240 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
240 | it.current()->list()->update(); | 241 | it.current()->list()->update(); |
241 | } | 242 | } |
242 | } | 243 | } |
243 | } | 244 | } |
244 | break; | 245 | break; |
245 | case OUTPUT_OTHERJOIN: | 246 | case OUTPUT_OTHERJOIN: |
246 | case OUTPUT_OTHERKICK: | 247 | case OUTPUT_OTHERKICK: |
247 | case OUTPUT_CHANPERSONMODE: | 248 | case OUTPUT_CHANPERSONMODE: |
248 | case OUTPUT_OTHERPART: { | 249 | case OUTPUT_OTHERPART: { |
249 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 250 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
250 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 251 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
251 | channelTab->list()->update(); | 252 | channelTab->list()->update(); |
252 | } | 253 | } |
253 | break; | 254 | break; |
254 | case OUTPUT_CTCP: | 255 | case OUTPUT_CTCP: |
255 | appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); | 256 | appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); |
256 | break; | 257 | break; |
257 | case OUTPUT_ERROR: | 258 | case OUTPUT_ERROR: |
258 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); | 259 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); |
259 | break; | 260 | break; |
260 | default: | 261 | default: |
261 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); | 262 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); |
262 | break; | 263 | break; |
263 | } | 264 | } |
264 | } | 265 | } |
diff --git a/noncore/net/opieirc/irctab.cpp b/noncore/net/opieirc/irctab.cpp index 6b578d1..a4dd7e2 100644 --- a/noncore/net/opieirc/irctab.cpp +++ b/noncore/net/opieirc/irctab.cpp | |||
@@ -1,28 +1,36 @@ | |||
1 | #include <qpe/resource.h> | 1 | #include <qpe/resource.h> |
2 | #include <qpixmap.h> | 2 | #include <qpixmap.h> |
3 | #include <qpushbutton.h> | 3 | #include <qpushbutton.h> |
4 | #include "irctab.h" | 4 | #include "irctab.h" |
5 | 5 | ||
6 | QString IRCTab::m_errorColor; | 6 | QString IRCTab::m_errorColor; |
7 | QString IRCTab::m_serverColor; | 7 | QString IRCTab::m_serverColor; |
8 | QString IRCTab::m_textColor; | 8 | QString IRCTab::m_textColor; |
9 | QString IRCTab::m_backgroundColor; | 9 | QString IRCTab::m_backgroundColor; |
10 | QString IRCTab::m_selfColor; | 10 | QString IRCTab::m_selfColor; |
11 | QString IRCTab::m_otherColor; | 11 | QString IRCTab::m_otherColor; |
12 | QString IRCTab::m_notificationColor; | 12 | QString IRCTab::m_notificationColor; |
13 | 13 | ||
14 | 14 | ||
15 | IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { | 15 | IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { |
16 | m_layout = new QVBoxLayout(this); | 16 | m_layout = new QVBoxLayout(this); |
17 | QHBoxLayout *descLayout = new QHBoxLayout(m_layout); | 17 | QHBoxLayout *descLayout = new QHBoxLayout(m_layout); |
18 | descLayout->setMargin(5); | 18 | descLayout->setMargin(5); |
19 | m_description = new QLabel(tr("Missing description"), this); | 19 | m_description = new QLabel(tr("Missing description"), this); |
20 | descLayout->addWidget(m_description); | 20 | descLayout->addWidget(m_description); |
21 | descLayout->setStretchFactor(m_description, 5); | 21 | descLayout->setStretchFactor(m_description, 5); |
22 | QPushButton *close = new QPushButton(this); | 22 | QPushButton *close = new QPushButton(this); |
23 | close->setPixmap(Resource::loadPixmap("close")); | 23 | close->setPixmap(Resource::loadPixmap("close")); |
24 | connect(close, SIGNAL(clicked()), this, SLOT(remove())); | 24 | connect(close, SIGNAL(clicked()), this, SLOT(remove())); |
25 | descLayout->addWidget(close); | 25 | descLayout->addWidget(close); |
26 | descLayout->setStretchFactor(m_description, 1); | 26 | descLayout->setStretchFactor(m_description, 1); |
27 | } | 27 | } |
28 | 28 | ||
29 | |||
30 | void IRCTab::setID(int id) { | ||
31 | m_id = id; | ||
32 | } | ||
33 | |||
34 | int IRCTab::id() { | ||
35 | return m_id; | ||
36 | } | ||
diff --git a/noncore/net/opieirc/irctab.h b/noncore/net/opieirc/irctab.h index 248ea13..e3a1857 100644 --- a/noncore/net/opieirc/irctab.h +++ b/noncore/net/opieirc/irctab.h | |||
@@ -1,58 +1,63 @@ | |||
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 | void setID(int id); | ||
39 | int id(); | ||
38 | virtual QString title() = 0; | 40 | virtual QString title() = 0; |
39 | virtual IRCSession *session() = 0; | 41 | virtual IRCSession *session() = 0; |
40 | virtual void appendText(QString text) = 0; | 42 | virtual void appendText(QString text) = 0; |
43 | signals: | ||
44 | void changed(IRCTab *); | ||
41 | public slots: | 45 | public slots: |
42 | virtual void remove() = 0; | 46 | virtual void remove() = 0; |
43 | virtual void settingsChanged() = 0; | 47 | virtual void settingsChanged() = 0; |
44 | protected: | 48 | protected: |
45 | QLabel *m_description; | 49 | QLabel *m_description; |
46 | QVBoxLayout *m_layout; | 50 | QVBoxLayout *m_layout; |
51 | int m_id; | ||
47 | public: | 52 | public: |
48 | /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */ | 53 | /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */ |
49 | static QString m_errorColor; | 54 | static QString m_errorColor; |
50 | static QString m_serverColor; | 55 | static QString m_serverColor; |
51 | static QString m_textColor; | 56 | static QString m_textColor; |
52 | static QString m_backgroundColor; | 57 | static QString m_backgroundColor; |
53 | static QString m_selfColor; | 58 | static QString m_selfColor; |
54 | static QString m_otherColor; | 59 | static QString m_otherColor; |
55 | static QString m_notificationColor; | 60 | static QString m_notificationColor; |
56 | }; | 61 | }; |
57 | 62 | ||
58 | #endif /* __IRCTAB_H */ | 63 | #endif /* __IRCTAB_H */ |
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp index d78e5ab..fe59c3b 100644 --- a/noncore/net/opieirc/mainwindow.cpp +++ b/noncore/net/opieirc/mainwindow.cpp | |||
@@ -1,71 +1,83 @@ | |||
1 | #include <qpe/qpemenubar.h> | 1 | #include <qpe/qpemenubar.h> |
2 | #include <qpe/resource.h> | 2 | #include <qpe/resource.h> |
3 | #include <qpe/config.h> | 3 | #include <qpe/config.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | 5 | ||
6 | #include "mainwindow.h" | 6 | #include "mainwindow.h" |
7 | #include "ircservertab.h" | 7 | #include "ircservertab.h" |
8 | #include "ircserverlist.h" | 8 | #include "ircserverlist.h" |
9 | #include "ircsettings.h" | 9 | #include "ircsettings.h" |
10 | 10 | ||
11 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) { | 11 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) { |
12 | setCaption(tr("IRC Client")); | 12 | setCaption(tr("IRC Client")); |
13 | m_tabWidget = new QTabWidget(this); | 13 | m_tabWidget = new IRCTabWidget(this); |
14 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(selected(QWidget *))); | ||
14 | setCentralWidget(m_tabWidget); | 15 | setCentralWidget(m_tabWidget); |
15 | setToolBarsMovable(FALSE); | 16 | setToolBarsMovable(FALSE); |
16 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 17 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
17 | QPopupMenu *irc = new QPopupMenu(this); | 18 | QPopupMenu *irc = new QPopupMenu(this); |
18 | menuBar->insertItem(tr("IRC"), irc); | 19 | menuBar->insertItem(tr("IRC"), irc); |
19 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); | 20 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); |
20 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); | 21 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); |
21 | a->addTo(irc); | 22 | a->addTo(irc); |
22 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); | 23 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); |
23 | connect(a, SIGNAL(activated()), this, SLOT(settings())); | 24 | connect(a, SIGNAL(activated()), this, SLOT(settings())); |
24 | a->addTo(irc); | 25 | a->addTo(irc); |
25 | loadSettings(); | 26 | loadSettings(); |
26 | } | 27 | } |
27 | 28 | ||
28 | void MainWindow::loadSettings() { | 29 | void MainWindow::loadSettings() { |
29 | Config config("OpieIRC"); | 30 | Config config("OpieIRC"); |
30 | config.setGroup("OpieIRC"); | 31 | config.setGroup("OpieIRC"); |
31 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); | 32 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); |
32 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); | 33 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); |
33 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); | 34 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); |
34 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); | 35 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); |
35 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); | 36 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); |
36 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); | 37 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); |
37 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); | 38 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); |
38 | } | 39 | } |
39 | 40 | ||
41 | void MainWindow::selected(QWidget *) { | ||
42 | m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), &black); | ||
43 | } | ||
44 | |||
40 | void MainWindow::addTab(IRCTab *tab) { | 45 | void MainWindow::addTab(IRCTab *tab) { |
46 | connect(tab, SIGNAL(changed(IRCTab *)), this, SLOT(changeEvent(IRCTab *))); | ||
41 | m_tabWidget->addTab(tab, tab->title()); | 47 | m_tabWidget->addTab(tab, tab->title()); |
42 | m_tabWidget->showPage(tab); | 48 | m_tabWidget->showPage(tab); |
49 | tab->setID(m_tabWidget->currentPageIndex()); | ||
43 | m_tabs.append(tab); | 50 | m_tabs.append(tab); |
44 | } | 51 | } |
45 | 52 | ||
53 | void MainWindow::changeEvent(IRCTab *tab) { | ||
54 | if (tab->id() != m_tabWidget->currentPageIndex()) | ||
55 | m_tabWidget->setTabColor(tab->id(), &blue); | ||
56 | } | ||
57 | |||
46 | void MainWindow::killTab(IRCTab *tab) { | 58 | void MainWindow::killTab(IRCTab *tab) { |
47 | m_tabWidget->removePage(tab); | 59 | m_tabWidget->removePage(tab); |
48 | m_tabs.remove(tab); | 60 | m_tabs.remove(tab); |
49 | /* there might be nicer ways to do this .. */ | 61 | /* there might be nicer ways to do this .. */ |
50 | delete tab; | 62 | delete tab; |
51 | } | 63 | } |
52 | 64 | ||
53 | void MainWindow::newConnection() { | 65 | void MainWindow::newConnection() { |
54 | IRCServerList list(this, "ServerList", TRUE); | 66 | IRCServerList list(this, "ServerList", TRUE); |
55 | if (list.exec() == QDialog::Accepted && list.hasServer()) { | 67 | if (list.exec() == QDialog::Accepted && list.hasServer()) { |
56 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); | 68 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); |
57 | addTab(serverTab); | 69 | addTab(serverTab); |
58 | serverTab->doConnect(); | 70 | serverTab->doConnect(); |
59 | } | 71 | } |
60 | } | 72 | } |
61 | 73 | ||
62 | void MainWindow::settings() { | 74 | void MainWindow::settings() { |
63 | IRCSettings settings(this, "Settings", TRUE); | 75 | IRCSettings settings(this, "Settings", TRUE); |
64 | if (settings.exec() == QDialog::Accepted) { | 76 | if (settings.exec() == QDialog::Accepted) { |
65 | QListIterator<IRCTab> it(m_tabs); | 77 | QListIterator<IRCTab> it(m_tabs); |
66 | for (; it.current(); ++it) { | 78 | for (; it.current(); ++it) { |
67 | /* Inform all tabs about the new settings */ | 79 | /* Inform all tabs about the new settings */ |
68 | it.current()->settingsChanged(); | 80 | it.current()->settingsChanged(); |
69 | } | 81 | } |
70 | } | 82 | } |
71 | } | 83 | } |
diff --git a/noncore/net/opieirc/mainwindow.h b/noncore/net/opieirc/mainwindow.h index d057178..9946f10 100644 --- a/noncore/net/opieirc/mainwindow.h +++ b/noncore/net/opieirc/mainwindow.h | |||
@@ -1,48 +1,50 @@ | |||
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 <qtabwidget.h> | ||
28 | #include "mainwindow.h" | 27 | #include "mainwindow.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 | 35 | ||
36 | void addTab(IRCTab *tab); | 36 | void addTab(IRCTab *tab); |
37 | void killTab(IRCTab *tab); | 37 | void killTab(IRCTab *tab); |
38 | protected slots: | 38 | protected slots: |
39 | void newConnection(); | 39 | void newConnection(); |
40 | void settings(); | 40 | void settings(); |
41 | void selected(QWidget *); | ||
42 | void changeEvent(IRCTab *); | ||
41 | protected: | 43 | protected: |
42 | void loadSettings(); | 44 | void loadSettings(); |
43 | protected: | 45 | protected: |
44 | QTabWidget *m_tabWidget; | 46 | IRCTabWidget *m_tabWidget; |
45 | QList<IRCTab> m_tabs; | 47 | QList<IRCTab> m_tabs; |
46 | }; | 48 | }; |
47 | 49 | ||
48 | #endif /* __MAINWINDOW_H */ | 50 | #endif /* __MAINWINDOW_H */ |