summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircquerytab.cpp
Unidiff
Diffstat (limited to 'noncore/net/opieirc/ircquerytab.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opieirc/ircquerytab.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp
index 642cc5b..c6b8211 100644
--- a/noncore/net/opieirc/ircquerytab.cpp
+++ b/noncore/net/opieirc/ircquerytab.cpp
@@ -9,64 +9,68 @@ IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow
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 21 settingsChanged();
22} 22}
23 23
24void IRCQueryTab::appendText(QString text) { 24void 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} 28}
29 29
30IRCQueryTab::~IRCQueryTab() { 30IRCQueryTab::~IRCQueryTab() {
31 m_parentTab->removeQueryTab(this); 31 m_parentTab->removeQueryTab(this);
32 delete m_person; 32 delete m_person;
33} 33}
34 34
35void IRCQueryTab::processCommand() { 35void IRCQueryTab::processCommand() {
36 QString text = m_field->text(); 36 QString text = m_field->text();
37 if (text.length()>0) { 37 if (text.length()>0) {
38 if (session()->isSessionActive()) { 38 if (session()->isSessionActive()) {
39 if (text.startsWith("/") && !text.startsWith("//")) { 39 if (text.startsWith("/") && !text.startsWith("//")) {
40 /* Command mode */ 40 /* Command mode */
41 m_parentTab->executeCommand(this, text);; 41 m_parentTab->executeCommand(this, text);;
42 } else { 42 } else {
43 if (text.startsWith("//")) 43 if (text.startsWith("//"))
44 text = text.right(text.length()-1); 44 text = text.right(text.length()-1);
45 session()->sendMessage(m_person, m_field->text()); 45 session()->sendMessage(m_person, m_field->text());
46 appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+IRCOutput::toHTML(m_field->text())+"<br>"); 46 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>");
47 } 47 }
48 } else { 48 } else {
49 appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); 49 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
50 } 50 }
51 } 51 }
52 m_field->clear(); 52 m_field->clear();
53} 53}
54 54
55void IRCQueryTab::display(IRCOutput output) { 55void IRCQueryTab::display(IRCOutput output) {
56 if (output.type() == OUTPUT_QUERYPRIVMSG) { 56 if (output.type() == OUTPUT_QUERYPRIVMSG) {
57 appendText("&lt;<font color=\"#0000dd\">"+m_person->nick()+"</font>&gt; " + output.htmlMessage() + "<br>"); 57 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage() + "</font><br>");
58 } else if (output.type() == OUTPUT_QUERYACTION) { 58 } else if (output.type() == OUTPUT_QUERYACTION) {
59 appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "<br>"); 59 appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>");
60 }
60 } 61 }
62
63void IRCQueryTab::settingsChanged() {
64 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
61} 65}
62 66
63QString IRCQueryTab::title() { 67QString IRCQueryTab::title() {
64 return m_person->nick(); 68 return m_person->nick();
65} 69}
66 70
67IRCSession *IRCQueryTab::session() { 71IRCSession *IRCQueryTab::session() {
68 return m_parentTab->session(); 72 return m_parentTab->session();
69} 73}
70 74
71void IRCQueryTab::remove() { 75void IRCQueryTab::remove() {
72 m_mainWindow->killTab(this); 76 m_mainWindow->killTab(this);