author | drw <drw> | 2005-05-04 23:22:17 (UTC) |
---|---|---|
committer | drw <drw> | 2005-05-04 23:22:17 (UTC) |
commit | 11833e51efabe194db59640c2d0ccea0a33c11ce (patch) (unidiff) | |
tree | ee444e1da95b52f3f74bb8eb4d2c351002969f32 | |
parent | d89cbf4ba511beaf228ce87d4e21a2a6a49767f2 (diff) | |
download | opie-11833e51efabe194db59640c2d0ccea0a33c11ce.zip opie-11833e51efabe194db59640c2d0ccea0a33c11ce.tar.gz opie-11833e51efabe194db59640c2d0ccea0a33c11ce.tar.bz2 |
Resource -> OResource
-rw-r--r-- | noncore/net/opieirc/ircchannellist.cpp | 8 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchanneltab.cpp | 14 | ||||
-rw-r--r-- | noncore/net/opieirc/irctab.cpp | 10 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 12 |
4 files changed, 25 insertions, 19 deletions
diff --git a/noncore/net/opieirc/ircchannellist.cpp b/noncore/net/opieirc/ircchannellist.cpp index 8cf144e..3982f30 100644 --- a/noncore/net/opieirc/ircchannellist.cpp +++ b/noncore/net/opieirc/ircchannellist.cpp | |||
@@ -1,67 +1,67 @@ | |||
1 | #include <qpe/resource.h> | 1 | #include <opie2/oresource.h> |
2 | 2 | ||
3 | #include "ircchannellist.h" | 3 | #include "ircchannellist.h" |
4 | #include "ircchannelperson.h" | 4 | #include "ircchannelperson.h" |
5 | 5 | ||
6 | IRCChannelList::IRCChannelList(IRCChannel *channel, QWidget *parent, const char *name, WFlags f) : QListBox(parent, name, f) { | 6 | IRCChannelList::IRCChannelList(IRCChannel *channel, QWidget *parent, const char *name, WFlags f) : QListBox(parent, name, f) { |
7 | m_channel = channel; | 7 | m_channel = channel; |
8 | } | 8 | } |
9 | 9 | ||
10 | void IRCChannelList::update() { | 10 | void IRCChannelList::update() { |
11 | QPixmap op = Resource::loadPixmap("opieirc/op"); | 11 | QPixmap op = Opie::Core::OResource::loadPixmap( "opieirc/op" ); |
12 | QPixmap hop = Resource::loadPixmap("opieirc/hop"); | 12 | QPixmap hop = Opie::Core::OResource::loadPixmap( "opieirc/hop" ); |
13 | QPixmap voice = Resource::loadPixmap("opieirc/voice"); | 13 | QPixmap voice = Opie::Core::OResource::loadPixmap( "opieirc/voice" ); |
14 | QListIterator<IRCChannelPerson> it = m_channel->people(); | 14 | QListIterator<IRCChannelPerson> it = m_channel->people(); |
15 | clear(); | 15 | clear(); |
16 | for (; it.current(); ++it) { | 16 | for (; it.current(); ++it) { |
17 | IRCChannelPerson *person = it.current(); | 17 | IRCChannelPerson *person = it.current(); |
18 | if (person->flags() & IRCChannelPerson::PERSON_FLAG_OP) { | 18 | if (person->flags() & IRCChannelPerson::PERSON_FLAG_OP) { |
19 | insertItem(op, "1" + person->nick()); | 19 | insertItem(op, "1" + person->nick()); |
20 | } else if (person->flags() & IRCChannelPerson::PERSON_FLAG_HALFOP) { | 20 | } else if (person->flags() & IRCChannelPerson::PERSON_FLAG_HALFOP) { |
21 | insertItem(op, "2" + person->nick()); | 21 | insertItem(op, "2" + person->nick()); |
22 | } else if (person->flags() & IRCChannelPerson::PERSON_FLAG_VOICE) { | 22 | } else if (person->flags() & IRCChannelPerson::PERSON_FLAG_VOICE) { |
23 | insertItem(voice, "3" + person->nick()); | 23 | insertItem(voice, "3" + person->nick()); |
24 | } else { | 24 | } else { |
25 | insertItem("4" + person->nick()); | 25 | insertItem("4" + person->nick()); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | sort(); | 28 | sort(); |
29 | adjustNicks(); | 29 | adjustNicks(); |
30 | } | 30 | } |
31 | 31 | ||
32 | 32 | ||
33 | bool IRCChannelList::hasPerson(QString nick) { | 33 | bool IRCChannelList::hasPerson(QString nick) { |
34 | for (unsigned int i=0; i<count(); i++) { | 34 | for (unsigned int i=0; i<count(); i++) { |
35 | if (text(i) == nick) | 35 | if (text(i) == nick) |
36 | return TRUE; | 36 | return TRUE; |
37 | } | 37 | } |
38 | return FALSE; | 38 | return FALSE; |
39 | } | 39 | } |
40 | 40 | ||
41 | bool IRCChannelList::removePerson(QString nick) { | 41 | bool IRCChannelList::removePerson(QString nick) { |
42 | for (unsigned int i=0; i<count(); i++) { | 42 | for (unsigned int i=0; i<count(); i++) { |
43 | if (text(i) == nick){ | 43 | if (text(i) == nick){ |
44 | removeItem(i); | 44 | removeItem(i); |
45 | return TRUE; | 45 | return TRUE; |
46 | } | 46 | } |
47 | } | 47 | } |
48 | return FALSE; | 48 | return FALSE; |
49 | } | 49 | } |
50 | 50 | ||
51 | void IRCChannelList::adjustNicks() { | 51 | void IRCChannelList::adjustNicks() { |
52 | QString txt; | 52 | QString txt; |
53 | QPixmap pm; | 53 | QPixmap pm; |
54 | 54 | ||
55 | for(unsigned int i=0; i<count(); i++) { | 55 | for(unsigned int i=0; i<count(); i++) { |
56 | txt = text(i).remove(0,1); | 56 | txt = text(i).remove(0,1); |
57 | if(pixmap(i)) { | 57 | if(pixmap(i)) { |
58 | pm = *pixmap(i); | 58 | pm = *pixmap(i); |
59 | removeItem(i); | 59 | removeItem(i); |
60 | insertItem(pm, txt, i); | 60 | insertItem(pm, txt, i); |
61 | } | 61 | } |
62 | else { | 62 | else { |
63 | removeItem(i); | 63 | removeItem(i); |
64 | insertItem(txt, i); | 64 | insertItem(txt, i); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | } | 67 | } |
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp index 3272a8a..707e17f 100644 --- a/noncore/net/opieirc/ircchanneltab.cpp +++ b/noncore/net/opieirc/ircchanneltab.cpp | |||
@@ -1,146 +1,150 @@ | |||
1 | #include <qpe/resource.h> | 1 | #include <opie2/oresource.h> |
2 | #include <qwhatsthis.h> | 2 | #include <qwhatsthis.h> |
3 | #include <qhbox.h> | 3 | #include <qhbox.h> |
4 | #include <qdict.h> | 4 | #include <qdict.h> |
5 | 5 | ||
6 | #include "ircchanneltab.h" | 6 | #include "ircchanneltab.h" |
7 | #include "ircservertab.h" | 7 | #include "ircservertab.h" |
8 | #include "ircmessageparser.h" | 8 | #include "ircmessageparser.h" |
9 | 9 | ||
10 | #include <opie2/odebug.h> | 10 | #include <opie2/odebug.h> |
11 | QDict<QString> IRCChannelTab::m_queuedMessages (17); | 11 | QDict<QString> IRCChannelTab::m_queuedMessages (17); |
12 | 12 | ||
13 | IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 13 | IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
14 | m_mainWindow = mainWindow; | 14 | m_mainWindow = mainWindow; |
15 | m_parentTab = parentTab; | 15 | m_parentTab = parentTab; |
16 | m_channel = channel; | 16 | m_channel = channel; |
17 | m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); | 17 | m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); |
18 | QHBox *hbox = new QHBox(this); | 18 | QHBox *hbox = new QHBox(this); |
19 | m_textview = new QTextView(hbox); | 19 | m_textview = new QTextView(hbox); |
20 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 20 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
21 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 21 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
22 | m_listVisible = TRUE; | 22 | m_listVisible = TRUE; |
23 | m_listButton = new QPushButton(">", m_textview); | 23 | m_listButton = new QPushButton(">", m_textview); |
24 | m_listButton->setFlat( true ); | 24 | m_listButton->setFlat( true ); |
25 | m_textview->setCornerWidget(m_listButton); | 25 | m_textview->setCornerWidget(m_listButton); |
26 | m_textview->setTextFormat(RichText); | 26 | m_textview->setTextFormat(RichText); |
27 | QWhatsThis::add(m_textview, tr("Channel discussion")); | 27 | QWhatsThis::add(m_textview, tr("Channel discussion")); |
28 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); | 28 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); |
29 | m_list = new IRCChannelList(m_channel, hbox); | 29 | m_list = new IRCChannelList(m_channel, hbox); |
30 | m_list->update(); | 30 | m_list->update(); |
31 | m_list->setMaximumWidth(LISTWIDTH); | 31 | m_list->setMaximumWidth(LISTWIDTH); |
32 | m_field = new IRCHistoryLineEdit(this); | 32 | m_field = new IRCHistoryLineEdit(this); |
33 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); | 33 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); |
34 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); | 34 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); |
35 | connect(m_field, SIGNAL(closeTab()), this, SLOT(remove())); | 35 | connect(m_field, SIGNAL(closeTab()), this, SLOT(remove())); |
36 | connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); | 36 | connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); |
37 | 37 | ||
38 | QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); | 38 | QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); |
39 | m_popup = new QPopupMenu(m_list); | 39 | m_popup = new QPopupMenu(m_list); |
40 | m_lines = 0; | 40 | m_lines = 0; |
41 | /* Required so that embedded-style "right" clicks work */ | 41 | /* Required so that embedded-style "right" clicks work */ |
42 | QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); | 42 | QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); |
43 | connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); | 43 | connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); |
44 | /* Construct the popup menu */ | 44 | /* Construct the popup menu */ |
45 | //QPopupMenu *ctcpMenu = new QPopupMenu(m_list); | 45 | //QPopupMenu *ctcpMenu = new QPopupMenu(m_list); |
46 | m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); | 46 | m_popup->insertItem(Opie::Core::OResource::loadPixmap("opieirc/query",Opie::Core::OResource::SmallIcon), |
47 | tr("Query"), this, SLOT(popupQuery())); | ||
47 | m_popup->insertSeparator(); | 48 | m_popup->insertSeparator(); |
48 | m_popup->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); | 49 | m_popup->insertItem(Opie::Core::OResource::loadPixmap("opieirc/ping",Opie::Core::OResource::SmallIcon), |
49 | m_popup->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); | 50 | tr("Ping"), this, SLOT(popupPing())); |
50 | m_popup->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); | 51 | m_popup->insertItem(Opie::Core::OResource::loadPixmap("opieirc/version",Opie::Core::OResource::SmallIcon), |
52 | tr("Version"), this, SLOT(popupVersion())); | ||
53 | m_popup->insertItem(Opie::Core::OResource::loadPixmap("opieirc/whois",Opie::Core::OResource::SmallIcon), | ||
54 | tr("Whois"), this, SLOT(popupWhois())); | ||
51 | //m_popup->insertItem(ctcpMenu, "CTCP"); | 55 | //m_popup->insertItem(ctcpMenu, "CTCP"); |
52 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); | 56 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); |
53 | m_layout->add(hbox); | 57 | m_layout->add(hbox); |
54 | hbox->show(); | 58 | hbox->show(); |
55 | m_layout->add(m_field); | 59 | m_layout->add(m_field); |
56 | m_field->setFocus(); | 60 | m_field->setFocus(); |
57 | m_field->setActiveWindow(); | 61 | m_field->setActiveWindow(); |
58 | 62 | ||
59 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 63 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
60 | connect(m_list, SIGNAL(doubleClicked ( QListBoxItem * ) ), this, SLOT(popupQuery( QListBoxItem * ) )); | 64 | connect(m_list, SIGNAL(doubleClicked ( QListBoxItem * ) ), this, SLOT(popupQuery( QListBoxItem * ) )); |
61 | settingsChanged(); | 65 | settingsChanged(); |
62 | 66 | ||
63 | if(m_queuedMessages[m_channel->channelname()]) { | 67 | if(m_queuedMessages[m_channel->channelname()]) { |
64 | appendText(*m_queuedMessages[m_channel->channelname()]); | 68 | appendText(*m_queuedMessages[m_channel->channelname()]); |
65 | delete m_queuedMessages[m_channel->channelname()]; | 69 | delete m_queuedMessages[m_channel->channelname()]; |
66 | m_queuedMessages.remove(m_channel->channelname()); | 70 | m_queuedMessages.remove(m_channel->channelname()); |
67 | } | 71 | } |
68 | } | 72 | } |
69 | 73 | ||
70 | void IRCChannelTab::scrolling(){ | 74 | void IRCChannelTab::scrolling(){ |
71 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 75 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
72 | } | 76 | } |
73 | 77 | ||
74 | void IRCChannelTab::appendText(QString text) { | 78 | void IRCChannelTab::appendText(QString text) { |
75 | /* not using append because it creates layout problems */ | 79 | /* not using append because it creates layout problems */ |
76 | QString txt = m_textview->text() + IRCTab::appendTimestamp( text ); | 80 | QString txt = m_textview->text() + IRCTab::appendTimestamp( text ); |
77 | if (m_maxLines > 0 && m_lines >= m_maxLines) { | 81 | if (m_maxLines > 0 && m_lines >= m_maxLines) { |
78 | int firstBreak = txt.find('\n'); | 82 | int firstBreak = txt.find('\n'); |
79 | if (firstBreak != -1) { | 83 | if (firstBreak != -1) { |
80 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); | 84 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); |
81 | } | 85 | } |
82 | } else { | 86 | } else { |
83 | m_lines++; | 87 | m_lines++; |
84 | } | 88 | } |
85 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 89 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
86 | m_textview->setText(txt); | 90 | m_textview->setText(txt); |
87 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 91 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
88 | 92 | ||
89 | int p1, p2; | 93 | int p1, p2; |
90 | if ( text.contains( IRCMessageParser::tr("Received a CTCP PING from ") ) ) | 94 | if ( text.contains( IRCMessageParser::tr("Received a CTCP PING from ") ) ) |
91 | emit ping( title() ); | 95 | emit ping( title() ); |
92 | else if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) { | 96 | else if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) { |
93 | int col = text.findRev("color", -1, false); | 97 | int col = text.findRev("color", -1, false); |
94 | if ( col < p2 ) | 98 | if ( col < p2 ) |
95 | emit ping( title() ); | 99 | emit ping( title() ); |
96 | 100 | ||
97 | } | 101 | } |
98 | 102 | ||
99 | emit changed(this); | 103 | emit changed(this); |
100 | } | 104 | } |
101 | 105 | ||
102 | IRCChannelTab::~IRCChannelTab() { | 106 | IRCChannelTab::~IRCChannelTab() { |
103 | m_parentTab->removeChannelTab(this); | 107 | m_parentTab->removeChannelTab(this); |
104 | } | 108 | } |
105 | 109 | ||
106 | void IRCChannelTab::processCommand() { | 110 | void IRCChannelTab::processCommand() { |
107 | QString text = m_field->text(); | 111 | QString text = m_field->text(); |
108 | if (text.length()>0) { | 112 | if (text.length()>0) { |
109 | if (session()->isSessionActive()) { | 113 | if (session()->isSessionActive()) { |
110 | if (text.startsWith("/") && !text.startsWith("//")) { | 114 | if (text.startsWith("/") && !text.startsWith("//")) { |
111 | /* Command mode */ | 115 | /* Command mode */ |
112 | m_parentTab->executeCommand(this, text);; | 116 | m_parentTab->executeCommand(this, text);; |
113 | } else { | 117 | } else { |
114 | if (text.startsWith("//")) | 118 | if (text.startsWith("//")) |
115 | text = text.right(text.length()-1); | 119 | text = text.right(text.length()-1); |
116 | session()->sendMessage(m_channel, m_field->text()); | 120 | session()->sendMessage(m_channel, m_field->text()); |
117 | 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>"); | 121 | 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>"); |
118 | } | 122 | } |
119 | } else { | 123 | } else { |
120 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); | 124 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); |
121 | } | 125 | } |
122 | } | 126 | } |
123 | m_field->clear(); | 127 | m_field->clear(); |
124 | } | 128 | } |
125 | 129 | ||
126 | void IRCChannelTab::settingsChanged() { | 130 | void IRCChannelTab::settingsChanged() { |
127 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | 131 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); |
128 | m_lines = 0; | 132 | m_lines = 0; |
129 | } | 133 | } |
130 | 134 | ||
131 | void IRCChannelTab::toggleList() { | 135 | void IRCChannelTab::toggleList() { |
132 | if (m_listVisible) { | 136 | if (m_listVisible) { |
133 | m_list->setMaximumWidth(0); | 137 | m_list->setMaximumWidth(0); |
134 | m_listButton->setText("<"); | 138 | m_listButton->setText("<"); |
135 | } else { | 139 | } else { |
136 | m_list->setMaximumWidth(LISTWIDTH); | 140 | m_list->setMaximumWidth(LISTWIDTH); |
137 | m_listButton->setText(">"); | 141 | m_listButton->setText(">"); |
138 | } | 142 | } |
139 | m_listVisible = !m_listVisible; | 143 | m_listVisible = !m_listVisible; |
140 | } | 144 | } |
141 | 145 | ||
142 | void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { | 146 | void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { |
143 | switch (mouse) { | 147 | switch (mouse) { |
144 | case 1: | 148 | case 1: |
145 | break; | 149 | break; |
146 | case 2: | 150 | case 2: |
diff --git a/noncore/net/opieirc/irctab.cpp b/noncore/net/opieirc/irctab.cpp index aee33c4..2f459a9 100644 --- a/noncore/net/opieirc/irctab.cpp +++ b/noncore/net/opieirc/irctab.cpp | |||
@@ -1,70 +1,68 @@ | |||
1 | #include "irctab.h" | 1 | #include "irctab.h" |
2 | #include "mainwindow.h" | 2 | #include "mainwindow.h" |
3 | 3 | ||
4 | #include <opie2/okeyconfigmanager.h> | 4 | #include <opie2/okeyconfigmanager.h> |
5 | #include <opie2/oresource.h> | ||
5 | 6 | ||
6 | #include <qpe/applnk.h> | 7 | #include <qpe/applnk.h> |
7 | #include <qpe/resource.h> | ||
8 | |||
9 | 8 | ||
10 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
11 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
12 | 11 | ||
13 | 12 | ||
14 | QString IRCTab::m_errorColor; | 13 | QString IRCTab::m_errorColor; |
15 | QString IRCTab::m_serverColor; | 14 | QString IRCTab::m_serverColor; |
16 | QString IRCTab::m_textColor; | 15 | QString IRCTab::m_textColor; |
17 | QString IRCTab::m_backgroundColor; | 16 | QString IRCTab::m_backgroundColor; |
18 | QString IRCTab::m_selfColor; | 17 | QString IRCTab::m_selfColor; |
19 | QString IRCTab::m_otherColor; | 18 | QString IRCTab::m_otherColor; |
20 | QString IRCTab::m_notificationColor; | 19 | QString IRCTab::m_notificationColor; |
21 | int IRCTab::m_maxLines; | 20 | int IRCTab::m_maxLines; |
22 | 21 | ||
23 | 22 | ||
24 | static bool g_useTime = false; | 23 | static bool g_useTime = false; |
25 | 24 | ||
26 | void IRCTab::setUseTimeStamps( bool b ) { | 25 | void IRCTab::setUseTimeStamps( bool b ) { |
27 | g_useTime = b; | 26 | g_useTime = b; |
28 | } | 27 | } |
29 | 28 | ||
30 | // ## FIXME use TimeString later for AM/PM Setting | 29 | // ## FIXME use TimeString later for AM/PM Setting |
31 | QString IRCTab::appendTimestamp( const QString& text ) { | 30 | QString IRCTab::appendTimestamp( const QString& text ) { |
32 | return g_useTime ? | 31 | return g_useTime ? |
33 | "[" +QTime::currentTime().toString()+"]" + text + "\n" : | 32 | "[" +QTime::currentTime().toString()+"]" + text + "\n" : |
34 | text + "\n"; | 33 | text + "\n"; |
35 | 34 | ||
36 | } | 35 | } |
37 | 36 | ||
38 | 37 | ||
39 | IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { | 38 | IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { |
40 | m_layout = new QVBoxLayout(this); | 39 | m_layout = new QVBoxLayout(this); |
41 | QHBoxLayout *descLayout = new QHBoxLayout(m_layout); | 40 | QHBoxLayout *descLayout = new QHBoxLayout(m_layout); |
42 | descLayout->setMargin(5); | 41 | descLayout->setMargin(5); |
43 | m_description = new QLabel(tr("Missing description"), this); | 42 | m_description = new QLabel(tr("Missing description"), this); |
44 | QWhatsThis::add(m_description, tr("Description of the tab's content")); | 43 | QWhatsThis::add(m_description, tr("Description of the tab's content")); |
45 | descLayout->addWidget(m_description); | 44 | descLayout->addWidget(m_description); |
46 | descLayout->setStretchFactor(m_description, 5); | 45 | descLayout->setStretchFactor(m_description, 5); |
47 | QPixmap pic; | 46 | QPushButton *close = new QPushButton( Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ), |
48 | pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 47 | QString::null, this); |
49 | QPushButton *close = new QPushButton(pic, QString::null, this); | 48 | close->setFixedSize( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
50 | close->setMaximumWidth( close->height() ); | ||
51 | QWhatsThis::add(close, tr("Close this tab")); | 49 | QWhatsThis::add(close, tr("Close this tab")); |
52 | connect(close, SIGNAL(clicked()), this, SLOT(remove())); | 50 | connect(close, SIGNAL(clicked()), this, SLOT(remove())); |
53 | descLayout->addWidget(close); | 51 | descLayout->addWidget(close); |
54 | descLayout->setStretchFactor(m_description, 1); | 52 | descLayout->setStretchFactor(m_description, 1); |
55 | } | 53 | } |
56 | 54 | ||
57 | 55 | ||
58 | void IRCTab::setID(int id) { | 56 | void IRCTab::setID(int id) { |
59 | m_id = id; | 57 | m_id = id; |
60 | } | 58 | } |
61 | 59 | ||
62 | int IRCTab::id() { | 60 | int IRCTab::id() { |
63 | return m_id; | 61 | return m_id; |
64 | } | 62 | } |
65 | 63 | ||
66 | void IRCTab::showEvent( QShowEvent *ev ) { | 64 | void IRCTab::showEvent( QShowEvent *ev ) { |
67 | topLevelWidget()->setCaption( MainWindow::appCaption() + " " + title() ); | 65 | topLevelWidget()->setCaption( MainWindow::appCaption() + " " + title() ); |
68 | QWidget::showEvent( ev ); | 66 | QWidget::showEvent( ev ); |
69 | emit editFocus(); | 67 | emit editFocus(); |
70 | } | 68 | } |
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp index 3d60107..5edcf66 100644 --- a/noncore/net/opieirc/mainwindow.cpp +++ b/noncore/net/opieirc/mainwindow.cpp | |||
@@ -1,132 +1,136 @@ | |||
1 | #include <qmenubar.h> | ||
2 | #include <qpe/resource.h> | ||
3 | 1 | ||
4 | #include <opie2/odebug.h> | 2 | #include <opie2/odebug.h> |
3 | #include <opie2/oresource.h> | ||
5 | 4 | ||
5 | #include <qmenubar.h> | ||
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | 7 | ||
8 | #include "mainwindow.h" | 8 | #include "mainwindow.h" |
9 | #include "ircservertab.h" | 9 | #include "ircservertab.h" |
10 | #include "dcctransfertab.h" | 10 | #include "dcctransfertab.h" |
11 | #include "ircserverlist.h" | 11 | #include "ircserverlist.h" |
12 | #include "ircsettings.h" | 12 | #include "ircsettings.h" |
13 | 13 | ||
14 | #include <stdio.h> | 14 | #include <stdio.h> |
15 | 15 | ||
16 | 16 | ||
17 | QString MainWindow::appCaption() { | 17 | QString MainWindow::appCaption() { |
18 | return QObject::tr("Opie IRC"); | 18 | return QObject::tr("Opie IRC"); |
19 | } | 19 | } |
20 | 20 | ||
21 | 21 | ||
22 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 22 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
23 | setCaption(tr("IRC Client")); | 23 | setCaption(tr("IRC Client")); |
24 | m_tabWidget = new IRCTabWidget(this); | 24 | m_tabWidget = new IRCTabWidget(this); |
25 | QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); | 25 | QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); |
26 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget*)), this, SLOT(selected(QWidget*))); | 26 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget*)), this, SLOT(selected(QWidget*))); |
27 | setCentralWidget(m_tabWidget); | 27 | setCentralWidget(m_tabWidget); |
28 | setToolBarsMovable(FALSE); | 28 | setToolBarsMovable(FALSE); |
29 | QMenuBar *menuBar = new QMenuBar(this); | 29 | QMenuBar *menuBar = new QMenuBar(this); |
30 | QPopupMenu *irc = new QPopupMenu(this); | 30 | QPopupMenu *irc = new QPopupMenu(this); |
31 | menuBar->insertItem(tr("IRC"), irc); | 31 | menuBar->insertItem(tr("IRC"), irc); |
32 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); | 32 | QAction *a = new QAction( tr("New connection"), |
33 | Opie::Core::OResource::loadPixmap( "pass", Opie::Core::OResource::SmallIcon ), | ||
34 | QString::null, 0, this, 0 ); | ||
33 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); | 35 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); |
34 | a->setWhatsThis(tr("Create a new connection to an IRC server")); | 36 | a->setWhatsThis(tr("Create a new connection to an IRC server")); |
35 | a->addTo(irc); | 37 | a->addTo(irc); |
36 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); | 38 | a = new QAction( tr("Settings"), |
39 | Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ), | ||
40 | QString::null, 0, this, 0 ); | ||
37 | a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); | 41 | a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); |
38 | connect(a, SIGNAL(activated()), this, SLOT(settings())); | 42 | connect(a, SIGNAL(activated()), this, SLOT(settings())); |
39 | a->addTo(irc); | 43 | a->addTo(irc); |
40 | m_dccTab = 0; | 44 | m_dccTab = 0; |
41 | loadSettings(); | 45 | loadSettings(); |
42 | } | 46 | } |
43 | 47 | ||
44 | /*IRCTabWidget MainWindow::getTabWidget(){ | 48 | /*IRCTabWidget MainWindow::getTabWidget(){ |
45 | return m_tabWidget; | 49 | return m_tabWidget; |
46 | } */ | 50 | } */ |
47 | 51 | ||
48 | void MainWindow::loadSettings() { | 52 | void MainWindow::loadSettings() { |
49 | Config config("OpieIRC"); | 53 | Config config("OpieIRC"); |
50 | config.setGroup("OpieIRC"); | 54 | config.setGroup("OpieIRC"); |
51 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); | 55 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); |
52 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); | 56 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); |
53 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); | 57 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); |
54 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); | 58 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); |
55 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); | 59 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); |
56 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); | 60 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); |
57 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); | 61 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); |
58 | IRCTab::m_maxLines = config.readNumEntry("Lines", 100); | 62 | IRCTab::m_maxLines = config.readNumEntry("Lines", 100); |
59 | IRCTab::setUseTimeStamps( config.readBoolEntry("DisplayTime", false ) ); | 63 | IRCTab::setUseTimeStamps( config.readBoolEntry("DisplayTime", false ) ); |
60 | } | 64 | } |
61 | 65 | ||
62 | void MainWindow::selected(QWidget *) { | 66 | void MainWindow::selected(QWidget *) { |
63 | m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); | 67 | m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); |
64 | emit updateScroll(); | 68 | emit updateScroll(); |
65 | } | 69 | } |
66 | 70 | ||
67 | void MainWindow::addTab(IRCTab *tab) { | 71 | void MainWindow::addTab(IRCTab *tab) { |
68 | connect(tab, SIGNAL(changed(IRCTab*)), this, SLOT(changeEvent(IRCTab*))); | 72 | connect(tab, SIGNAL(changed(IRCTab*)), this, SLOT(changeEvent(IRCTab*))); |
69 | connect(tab, SIGNAL(ping (const QString&)), this, SLOT(slotPing(const QString&))); | 73 | connect(tab, SIGNAL(ping (const QString&)), this, SLOT(slotPing(const QString&))); |
70 | connect(tab, SIGNAL(nextTab()), this, SLOT(slotNextTab())); | 74 | connect(tab, SIGNAL(nextTab()), this, SLOT(slotNextTab())); |
71 | connect(tab, SIGNAL(prevTab()), this, SLOT(slotPrevTab())); | 75 | connect(tab, SIGNAL(prevTab()), this, SLOT(slotPrevTab())); |
72 | 76 | ||
73 | m_tabWidget->addTab(tab, tab->title()); | 77 | m_tabWidget->addTab(tab, tab->title()); |
74 | m_tabWidget->showPage(tab); | 78 | m_tabWidget->showPage(tab); |
75 | tab->setID(m_tabWidget->currentPageIndex()); | 79 | tab->setID(m_tabWidget->currentPageIndex()); |
76 | m_tabs.append(tab); | 80 | m_tabs.append(tab); |
77 | } | 81 | } |
78 | 82 | ||
79 | void MainWindow::changeEvent(IRCTab *tab) { | 83 | void MainWindow::changeEvent(IRCTab *tab) { |
80 | if (tab->id() != m_tabWidget->currentPageIndex()) | 84 | if (tab->id() != m_tabWidget->currentPageIndex()) |
81 | m_tabWidget->setTabColor(tab->id(), blue); | 85 | m_tabWidget->setTabColor(tab->id(), blue); |
82 | } | 86 | } |
83 | 87 | ||
84 | void MainWindow::killTab(IRCTab *tab, bool imediate) { | 88 | void MainWindow::killTab(IRCTab *tab, bool imediate) { |
85 | if (tab == m_dccTab) | 89 | if (tab == m_dccTab) |
86 | m_dccTab = 0; | 90 | m_dccTab = 0; |
87 | 91 | ||
88 | m_toDelete.append( tab ); | 92 | m_toDelete.append( tab ); |
89 | 93 | ||
90 | if ( imediate ) | 94 | if ( imediate ) |
91 | slotKillTabsLater(); | 95 | slotKillTabsLater(); |
92 | else | 96 | else |
93 | QTimer::singleShot(0, this, SLOT(slotKillTabsLater()) ); | 97 | QTimer::singleShot(0, this, SLOT(slotKillTabsLater()) ); |
94 | } | 98 | } |
95 | 99 | ||
96 | void MainWindow::slotKillTabsLater() { | 100 | void MainWindow::slotKillTabsLater() { |
97 | for ( QListIterator<IRCTab> it(m_toDelete); it.current(); ++it ) { | 101 | for ( QListIterator<IRCTab> it(m_toDelete); it.current(); ++it ) { |
98 | m_tabWidget->removePage( it.current() ); | 102 | m_tabWidget->removePage( it.current() ); |
99 | odebug << it.current() << oendl; | 103 | odebug << it.current() << oendl; |
100 | m_tabs.remove( it.current() ); | 104 | m_tabs.remove( it.current() ); |
101 | } | 105 | } |
102 | 106 | ||
103 | m_toDelete.setAutoDelete( true ); | 107 | m_toDelete.setAutoDelete( true ); |
104 | m_toDelete.clear(); | 108 | m_toDelete.clear(); |
105 | m_toDelete.setAutoDelete( false ); | 109 | m_toDelete.setAutoDelete( false ); |
106 | } | 110 | } |
107 | 111 | ||
108 | void MainWindow::newConnection() { | 112 | void MainWindow::newConnection() { |
109 | IRCServerList list(this, "ServerList", TRUE); | 113 | IRCServerList list(this, "ServerList", TRUE); |
110 | if (list.exec() == QDialog::Accepted && list.hasServer()) { | 114 | if (list.exec() == QDialog::Accepted && list.hasServer()) { |
111 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); | 115 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); |
112 | addTab(serverTab); | 116 | addTab(serverTab); |
113 | serverTab->doConnect(); | 117 | serverTab->doConnect(); |
114 | } | 118 | } |
115 | } | 119 | } |
116 | 120 | ||
117 | void MainWindow::settings() { | 121 | void MainWindow::settings() { |
118 | IRCSettings settings(this, "Settings", TRUE); | 122 | IRCSettings settings(this, "Settings", TRUE); |
119 | if (settings.exec() == QDialog::Accepted) { | 123 | if (settings.exec() == QDialog::Accepted) { |
120 | QListIterator<IRCTab> it(m_tabs); | 124 | QListIterator<IRCTab> it(m_tabs); |
121 | for (; it.current(); ++it) { | 125 | for (; it.current(); ++it) { |
122 | /* Inform all tabs about the new settings */ | 126 | /* Inform all tabs about the new settings */ |
123 | it.current()->settingsChanged(); | 127 | it.current()->settingsChanged(); |
124 | } | 128 | } |
125 | } | 129 | } |
126 | } | 130 | } |
127 | 131 | ||
128 | 132 | ||
129 | void MainWindow::slotNextTab() { | 133 | void MainWindow::slotNextTab() { |
130 | int i = m_tabWidget->currentPageIndex (); | 134 | int i = m_tabWidget->currentPageIndex (); |
131 | m_tabWidget->setCurrentPage ( i+1 ); | 135 | m_tabWidget->setCurrentPage ( i+1 ); |
132 | 136 | ||