-rw-r--r-- | noncore/net/opieirc/ircchanneltab.cpp | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsession.cpp | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp index b0771f6..667e977 100644 --- a/noncore/net/opieirc/ircchanneltab.cpp +++ b/noncore/net/opieirc/ircchanneltab.cpp | |||
@@ -1,127 +1,127 @@ | |||
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_textview->setCornerWidget(m_listButton); | 18 | m_textview->setCornerWidget(m_listButton); |
19 | m_textview->setTextFormat(RichText); | 19 | m_textview->setTextFormat(RichText); |
20 | QWhatsThis::add(m_textview, tr("Channel discussion")); | 20 | QWhatsThis::add(m_textview, tr("Channel discussion")); |
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 IRCHistoryLineEdit(this); | 25 | m_field = new IRCHistoryLineEdit(this); |
26 | QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); | 26 | QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); |
27 | m_popup = new QPopupMenu(m_list); | 27 | m_popup = new QPopupMenu(m_list); |
28 | m_lines = 0; | 28 | m_lines = 0; |
29 | /* Required so that embedded-style "right" clicks work */ | 29 | /* Required so that embedded-style "right" clicks work */ |
30 | QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); | 30 | QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); |
31 | connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &))); | 31 | connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); |
32 | /* Construct the popup menu */ | 32 | /* Construct the popup menu */ |
33 | QPopupMenu *ctcpMenu = new QPopupMenu(m_list); | 33 | QPopupMenu *ctcpMenu = new QPopupMenu(m_list); |
34 | m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); | 34 | m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); |
35 | m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); | 35 | m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); |
36 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); | 36 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); |
37 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); | 37 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); |
38 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); | 38 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); |
39 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); | 39 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); |
40 | m_layout->add(hbox); | 40 | m_layout->add(hbox); |
41 | hbox->show(); | 41 | hbox->show(); |
42 | m_layout->add(m_field); | 42 | m_layout->add(m_field); |
43 | m_field->setFocus(); | 43 | m_field->setFocus(); |
44 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 44 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
45 | settingsChanged(); | 45 | settingsChanged(); |
46 | } | 46 | } |
47 | 47 | ||
48 | void IRCChannelTab::scrolling(){ | 48 | void IRCChannelTab::scrolling(){ |
49 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 49 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
50 | } | 50 | } |
51 | 51 | ||
52 | void IRCChannelTab::appendText(QString text) { | 52 | void IRCChannelTab::appendText(QString text) { |
53 | /* not using append because it creates layout problems */ | 53 | /* not using append because it creates layout problems */ |
54 | QString txt = m_textview->text() + text + "\n"; | 54 | QString txt = m_textview->text() + text + "\n"; |
55 | if (m_maxLines > 0 && m_lines >= m_maxLines) { | 55 | if (m_maxLines > 0 && m_lines >= m_maxLines) { |
56 | int firstBreak = txt.find('\n'); | 56 | int firstBreak = txt.find('\n'); |
57 | if (firstBreak != -1) { | 57 | if (firstBreak != -1) { |
58 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); | 58 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); |
59 | } | 59 | } |
60 | } else { | 60 | } else { |
61 | m_lines++; | 61 | m_lines++; |
62 | } | 62 | } |
63 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 63 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
64 | m_textview->setText(txt); | 64 | m_textview->setText(txt); |
65 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 65 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
66 | emit changed(this); | 66 | emit changed(this); |
67 | } | 67 | } |
68 | 68 | ||
69 | IRCChannelTab::~IRCChannelTab() { | 69 | IRCChannelTab::~IRCChannelTab() { |
70 | m_parentTab->removeChannelTab(this); | 70 | m_parentTab->removeChannelTab(this); |
71 | } | 71 | } |
72 | 72 | ||
73 | void IRCChannelTab::processCommand() { | 73 | void IRCChannelTab::processCommand() { |
74 | QString text = m_field->text(); | 74 | QString text = m_field->text(); |
75 | if (text.length()>0) { | 75 | if (text.length()>0) { |
76 | if (session()->isSessionActive()) { | 76 | if (session()->isSessionActive()) { |
77 | if (text.startsWith("/") && !text.startsWith("//")) { | 77 | if (text.startsWith("/") && !text.startsWith("//")) { |
78 | /* Command mode */ | 78 | /* Command mode */ |
79 | m_parentTab->executeCommand(this, text);; | 79 | m_parentTab->executeCommand(this, text);; |
80 | } else { | 80 | } else { |
81 | if (text.startsWith("//")) | 81 | if (text.startsWith("//")) |
82 | text = text.right(text.length()-1); | 82 | text = text.right(text.length()-1); |
83 | session()->sendMessage(m_channel, m_field->text()); | 83 | session()->sendMessage(m_channel, m_field->text()); |
84 | 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>"); | 84 | 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>"); |
85 | } | 85 | } |
86 | } else { | 86 | } else { |
87 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); | 87 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | m_field->clear(); | 90 | m_field->clear(); |
91 | } | 91 | } |
92 | 92 | ||
93 | void IRCChannelTab::settingsChanged() { | 93 | void IRCChannelTab::settingsChanged() { |
94 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | 94 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); |
95 | m_lines = 0; | 95 | m_lines = 0; |
96 | } | 96 | } |
97 | 97 | ||
98 | void IRCChannelTab::toggleList() { | 98 | void IRCChannelTab::toggleList() { |
99 | if (m_listVisible) { | 99 | if (m_listVisible) { |
100 | m_list->setMaximumWidth(0); | 100 | m_list->setMaximumWidth(0); |
101 | m_listButton->setText("<"); | 101 | m_listButton->setText("<"); |
102 | } else { | 102 | } else { |
103 | m_list->setMaximumWidth(LISTWIDTH); | 103 | m_list->setMaximumWidth(LISTWIDTH); |
104 | m_listButton->setText(">"); | 104 | m_listButton->setText(">"); |
105 | } | 105 | } |
106 | m_listVisible = !m_listVisible; | 106 | m_listVisible = !m_listVisible; |
107 | } | 107 | } |
108 | 108 | ||
109 | void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { | 109 | void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { |
110 | switch (mouse) { | 110 | switch (mouse) { |
111 | case 1: | 111 | case 1: |
112 | break; | 112 | break; |
113 | case 2: | 113 | case 2: |
114 | m_popup->popup(point); | 114 | m_popup->popup(point); |
115 | break; | 115 | break; |
116 | }; | 116 | }; |
117 | } | 117 | } |
118 | 118 | ||
119 | void IRCChannelTab::popupQuery() { | 119 | void IRCChannelTab::popupQuery() { |
120 | if (m_list->currentItem() != -1) { | 120 | if (m_list->currentItem() != -1) { |
121 | IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); | 121 | IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); |
122 | if (person) { | 122 | if (person) { |
123 | IRCQueryTab *tab = m_parentTab->getTabForQuery(person); | 123 | IRCQueryTab *tab = m_parentTab->getTabForQuery(person); |
124 | if (!tab) { | 124 | if (!tab) { |
125 | tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); | 125 | tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); |
126 | m_parentTab->addQueryTab(tab); | 126 | m_parentTab->addQueryTab(tab); |
127 | m_mainWindow->addTab(tab); | 127 | m_mainWindow->addTab(tab); |
diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp index 6404d71..3b176d0 100644 --- a/noncore/net/opieirc/ircsession.cpp +++ b/noncore/net/opieirc/ircsession.cpp | |||
@@ -1,105 +1,105 @@ | |||
1 | #include "ircsession.h" | 1 | #include "ircsession.h" |
2 | #include "ircmessageparser.h" | 2 | #include "ircmessageparser.h" |
3 | #include "ircversion.h" | 3 | #include "ircversion.h" |
4 | 4 | ||
5 | IRCSession::IRCSession(IRCServer *server) { | 5 | IRCSession::IRCSession(IRCServer *server) { |
6 | m_server = server; | 6 | m_server = server; |
7 | m_connection = new IRCConnection(m_server); | 7 | m_connection = new IRCConnection(m_server); |
8 | m_parser = new IRCMessageParser(this); | 8 | m_parser = new IRCMessageParser(this); |
9 | connect(m_connection, SIGNAL(messageArrived(IRCMessage *)), this, SLOT(handleMessage(IRCMessage *))); | 9 | connect(m_connection, SIGNAL(messageArrived(IRCMessage*)), this, SLOT(handleMessage(IRCMessage*))); |
10 | connect(m_parser, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); | 10 | connect(m_parser, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); |
11 | connect(m_connection, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); | 11 | connect(m_connection, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); |
12 | } | 12 | } |
13 | 13 | ||
14 | IRCSession::~IRCSession() { | 14 | IRCSession::~IRCSession() { |
15 | /* We want this to get deleted automatically */ | 15 | /* We want this to get deleted automatically */ |
16 | m_channels.setAutoDelete(TRUE); | 16 | m_channels.setAutoDelete(TRUE); |
17 | m_people.setAutoDelete(TRUE); | 17 | m_people.setAutoDelete(TRUE); |
18 | 18 | ||
19 | delete m_parser; | 19 | delete m_parser; |
20 | delete m_connection; | 20 | delete m_connection; |
21 | } | 21 | } |
22 | 22 | ||
23 | void IRCSession::beginSession() { | 23 | void IRCSession::beginSession() { |
24 | m_connection->doConnect(); | 24 | m_connection->doConnect(); |
25 | } | 25 | } |
26 | 26 | ||
27 | void IRCSession::join(QString channelname) { | 27 | void IRCSession::join(QString channelname) { |
28 | m_connection->sendLine("JOIN "+channelname); | 28 | m_connection->sendLine("JOIN "+channelname); |
29 | } | 29 | } |
30 | 30 | ||
31 | void IRCSession::quit(){ | 31 | void IRCSession::quit(){ |
32 | m_connection->sendLine("QUIT :[OI] I'm too good to need a reason"); | 32 | m_connection->sendLine("QUIT :[OI] I'm too good to need a reason"); |
33 | } | 33 | } |
34 | 34 | ||
35 | void IRCSession::quit(QString message){ | 35 | void IRCSession::quit(QString message){ |
36 | m_connection->sendLine("QUIT :" + message); | 36 | m_connection->sendLine("QUIT :" + message); |
37 | } | 37 | } |
38 | 38 | ||
39 | void IRCSession::topic(IRCChannel *channel, QString message){ | 39 | void IRCSession::topic(IRCChannel *channel, QString message){ |
40 | m_connection->sendLine("TOPIC :" + channel->channelname() + " " + message); | 40 | m_connection->sendLine("TOPIC :" + channel->channelname() + " " + message); |
41 | } | 41 | } |
42 | 42 | ||
43 | void IRCSession::mode(IRCChannel *channel, QString message){ | 43 | void IRCSession::mode(IRCChannel *channel, QString message){ |
44 | m_connection->sendLine("MODE " + channel->channelname() + " " + message); | 44 | m_connection->sendLine("MODE " + channel->channelname() + " " + message); |
45 | } | 45 | } |
46 | 46 | ||
47 | void IRCSession::mode(IRCPerson *person, QString message){ | 47 | void IRCSession::mode(IRCPerson *person, QString message){ |
48 | m_connection->sendLine("MODE " + person->nick() + " " + message); | 48 | m_connection->sendLine("MODE " + person->nick() + " " + message); |
49 | } | 49 | } |
50 | 50 | ||
51 | void IRCSession::mode(QString message){ | 51 | void IRCSession::mode(QString message){ |
52 | m_connection->sendLine("MODE " + message); | 52 | m_connection->sendLine("MODE " + message); |
53 | } | 53 | } |
54 | 54 | ||
55 | void IRCSession::raw(QString message){ | 55 | void IRCSession::raw(QString message){ |
56 | m_connection->sendLine(message); | 56 | m_connection->sendLine(message); |
57 | } | 57 | } |
58 | 58 | ||
59 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person) { | 59 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person) { |
60 | m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :0wn3d - no reason"); | 60 | m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :0wn3d - no reason"); |
61 | } | 61 | } |
62 | 62 | ||
63 | void IRCSession::op(IRCChannel *channel, IRCPerson *person) { | 63 | void IRCSession::op(IRCChannel *channel, IRCPerson *person) { |
64 | m_connection->sendLine("MODE "+ channel->channelname() + " +ooo " + person->nick()); | 64 | m_connection->sendLine("MODE "+ channel->channelname() + " +ooo " + person->nick()); |
65 | } | 65 | } |
66 | 66 | ||
67 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) { | 67 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) { |
68 | m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :" + message); | 68 | m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :" + message); |
69 | } | 69 | } |
70 | 70 | ||
71 | void IRCSession::sendMessage(IRCPerson *person, QString message) { | 71 | void IRCSession::sendMessage(IRCPerson *person, QString message) { |
72 | m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message); | 72 | m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message); |
73 | } | 73 | } |
74 | 74 | ||
75 | void IRCSession::sendMessage(IRCChannel *channel, QString message) { | 75 | void IRCSession::sendMessage(IRCChannel *channel, QString message) { |
76 | m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message); | 76 | m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message); |
77 | } | 77 | } |
78 | 78 | ||
79 | void IRCSession::sendAction(IRCChannel *channel, QString message) { | 79 | void IRCSession::sendAction(IRCChannel *channel, QString message) { |
80 | m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001"); | 80 | m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001"); |
81 | } | 81 | } |
82 | 82 | ||
83 | void IRCSession::sendAction(IRCPerson *person, QString message) { | 83 | void IRCSession::sendAction(IRCPerson *person, QString message) { |
84 | m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001"); | 84 | m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001"); |
85 | } | 85 | } |
86 | 86 | ||
87 | bool IRCSession::isSessionActive() { | 87 | bool IRCSession::isSessionActive() { |
88 | return m_connection->isConnected(); | 88 | return m_connection->isConnected(); |
89 | } | 89 | } |
90 | 90 | ||
91 | void IRCSession::endSession() { | 91 | void IRCSession::endSession() { |
92 | if (m_connection->isLoggedIn()) | 92 | if (m_connection->isLoggedIn()) |
93 | m_connection->sendLine("QUIT :" APP_VERSION); | 93 | m_connection->sendLine("QUIT :" APP_VERSION); |
94 | else | 94 | else |
95 | m_connection->close(); | 95 | m_connection->close(); |
96 | } | 96 | } |
97 | 97 | ||
98 | void IRCSession::part(IRCChannel *channel) { | 98 | void IRCSession::part(IRCChannel *channel) { |
99 | m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION); | 99 | m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION); |
100 | } | 100 | } |
101 | 101 | ||
102 | 102 | ||
103 | IRCChannel *IRCSession::getChannel(QString channelname) { | 103 | IRCChannel *IRCSession::getChannel(QString channelname) { |
104 | QListIterator<IRCChannel> it(m_channels); | 104 | QListIterator<IRCChannel> it(m_channels); |
105 | for (; it.current(); ++it) { | 105 | for (; it.current(); ++it) { |
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp index 7414154..0923a11 100644 --- a/noncore/net/opieirc/mainwindow.cpp +++ b/noncore/net/opieirc/mainwindow.cpp | |||
@@ -1,91 +1,91 @@ | |||
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 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 10 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
11 | setCaption(tr("IRC Client")); | 11 | setCaption(tr("IRC Client")); |
12 | m_tabWidget = new IRCTabWidget(this); | 12 | m_tabWidget = new IRCTabWidget(this); |
13 | QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); | 13 | QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); |
14 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(selected(QWidget *))); | 14 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget*)), this, SLOT(selected(QWidget*))); |
15 | setCentralWidget(m_tabWidget); | 15 | setCentralWidget(m_tabWidget); |
16 | setToolBarsMovable(FALSE); | 16 | setToolBarsMovable(FALSE); |
17 | QMenuBar *menuBar = new QMenuBar(this); | 17 | QMenuBar *menuBar = new QMenuBar(this); |
18 | QPopupMenu *irc = new QPopupMenu(this); | 18 | QPopupMenu *irc = new QPopupMenu(this); |
19 | menuBar->insertItem(tr("IRC"), irc); | 19 | menuBar->insertItem(tr("IRC"), irc); |
20 | 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); |
21 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); | 21 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); |
22 | a->setWhatsThis(tr("Create a new connection to an IRC server")); | 22 | a->setWhatsThis(tr("Create a new connection to an IRC server")); |
23 | a->addTo(irc); | 23 | a->addTo(irc); |
24 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); | 24 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); |
25 | a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); | 25 | a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); |
26 | connect(a, SIGNAL(activated()), this, SLOT(settings())); | 26 | connect(a, SIGNAL(activated()), this, SLOT(settings())); |
27 | a->addTo(irc); | 27 | a->addTo(irc); |
28 | loadSettings(); | 28 | loadSettings(); |
29 | } | 29 | } |
30 | 30 | ||
31 | /*IRCTabWidget MainWindow::getTabWidget(){ | 31 | /*IRCTabWidget MainWindow::getTabWidget(){ |
32 | return m_tabWidget; | 32 | return m_tabWidget; |
33 | } */ | 33 | } */ |
34 | 34 | ||
35 | void MainWindow::loadSettings() { | 35 | void MainWindow::loadSettings() { |
36 | Config config("OpieIRC"); | 36 | Config config("OpieIRC"); |
37 | config.setGroup("OpieIRC"); | 37 | config.setGroup("OpieIRC"); |
38 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); | 38 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); |
39 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); | 39 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); |
40 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); | 40 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); |
41 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); | 41 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); |
42 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); | 42 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); |
43 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); | 43 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); |
44 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); | 44 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); |
45 | IRCTab::m_maxLines = config.readNumEntry("Lines", 100); | 45 | IRCTab::m_maxLines = config.readNumEntry("Lines", 100); |
46 | } | 46 | } |
47 | 47 | ||
48 | void MainWindow::selected(QWidget *) { | 48 | void MainWindow::selected(QWidget *) { |
49 | m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); | 49 | m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); |
50 | emit updateScroll(); | 50 | emit updateScroll(); |
51 | } | 51 | } |
52 | 52 | ||
53 | void MainWindow::addTab(IRCTab *tab) { | 53 | void MainWindow::addTab(IRCTab *tab) { |
54 | connect(tab, SIGNAL(changed(IRCTab *)), this, SLOT(changeEvent(IRCTab *))); | 54 | connect(tab, SIGNAL(changed(IRCTab*)), this, SLOT(changeEvent(IRCTab*))); |
55 | m_tabWidget->addTab(tab, tab->title()); | 55 | m_tabWidget->addTab(tab, tab->title()); |
56 | m_tabWidget->showPage(tab); | 56 | m_tabWidget->showPage(tab); |
57 | tab->setID(m_tabWidget->currentPageIndex()); | 57 | tab->setID(m_tabWidget->currentPageIndex()); |
58 | m_tabs.append(tab); | 58 | m_tabs.append(tab); |
59 | } | 59 | } |
60 | 60 | ||
61 | void MainWindow::changeEvent(IRCTab *tab) { | 61 | void MainWindow::changeEvent(IRCTab *tab) { |
62 | if (tab->id() != m_tabWidget->currentPageIndex()) | 62 | if (tab->id() != m_tabWidget->currentPageIndex()) |
63 | m_tabWidget->setTabColor(tab->id(), blue); | 63 | m_tabWidget->setTabColor(tab->id(), blue); |
64 | } | 64 | } |
65 | 65 | ||
66 | void MainWindow::killTab(IRCTab *tab) { | 66 | void MainWindow::killTab(IRCTab *tab) { |
67 | m_tabWidget->removePage(tab); | 67 | m_tabWidget->removePage(tab); |
68 | m_tabs.remove(tab); | 68 | m_tabs.remove(tab); |
69 | /* there might be nicer ways to do this .. */ | 69 | /* there might be nicer ways to do this .. */ |
70 | delete tab; | 70 | delete tab; |
71 | } | 71 | } |
72 | 72 | ||
73 | void MainWindow::newConnection() { | 73 | void MainWindow::newConnection() { |
74 | IRCServerList list(this, "ServerList", TRUE); | 74 | IRCServerList list(this, "ServerList", TRUE); |
75 | if (list.exec() == QDialog::Accepted && list.hasServer()) { | 75 | if (list.exec() == QDialog::Accepted && list.hasServer()) { |
76 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); | 76 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); |
77 | addTab(serverTab); | 77 | addTab(serverTab); |
78 | serverTab->doConnect(); | 78 | serverTab->doConnect(); |
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | void MainWindow::settings() { | 82 | void MainWindow::settings() { |
83 | IRCSettings settings(this, "Settings", TRUE); | 83 | IRCSettings settings(this, "Settings", TRUE); |
84 | if (settings.exec() == QDialog::Accepted) { | 84 | if (settings.exec() == QDialog::Accepted) { |
85 | QListIterator<IRCTab> it(m_tabs); | 85 | QListIterator<IRCTab> it(m_tabs); |
86 | for (; it.current(); ++it) { | 86 | for (; it.current(); ++it) { |
87 | /* Inform all tabs about the new settings */ | 87 | /* Inform all tabs about the new settings */ |
88 | it.current()->settingsChanged(); | 88 | it.current()->settingsChanged(); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | } | 91 | } |