author | wazlaf <wazlaf> | 2002-10-15 10:11:31 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-10-15 10:11:31 (UTC) |
commit | e09b7ab685d29eba947c3bb021192408acae70be (patch) (unidiff) | |
tree | 5adf52c8d56819aab0daed8e7da189110276e90a | |
parent | 31a73cafb40fffe2bbc12bb6fd0df6dc254d6646 (diff) | |
download | opie-e09b7ab685d29eba947c3bb021192408acae70be.zip opie-e09b7ab685d29eba947c3bb021192408acae70be.tar.gz opie-e09b7ab685d29eba947c3bb021192408acae70be.tar.bz2 |
some qwhatsthis introduced, the IRCHistoryLineEdit now catches tabs
-rw-r--r-- | noncore/net/opieirc/ircmisc.cpp | 16 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmisc.h | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservereditor.cpp | 10 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserverlist.cpp | 7 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsettings.cpp | 11 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 6 |
6 files changed, 48 insertions, 5 deletions
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp index 2e7f316..c8e6190 100644 --- a/noncore/net/opieirc/ircmisc.cpp +++ b/noncore/net/opieirc/ircmisc.cpp | |||
@@ -10,88 +10,104 @@ IRCColorLabel::IRCColorLabel(QColor color, QWidget *parent, const char *name, WF | |||
10 | setFrameShadow(QFrame::Sunken); | 10 | setFrameShadow(QFrame::Sunken); |
11 | setBackgroundColor(m_color); | 11 | setBackgroundColor(m_color); |
12 | } | 12 | } |
13 | 13 | ||
14 | void IRCColorLabel::mousePressEvent(QMouseEvent *) { | 14 | void IRCColorLabel::mousePressEvent(QMouseEvent *) { |
15 | m_color = OColorDialog::getColor(m_color); | 15 | m_color = OColorDialog::getColor(m_color); |
16 | setBackgroundColor(m_color); | 16 | setBackgroundColor(m_color); |
17 | } | 17 | } |
18 | 18 | ||
19 | QColor IRCColorLabel::color() { | 19 | QColor IRCColorLabel::color() { |
20 | return m_color; | 20 | return m_color; |
21 | } | 21 | } |
22 | 22 | ||
23 | 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) { |
24 | QVBoxLayout *layout = new QVBoxLayout(this, 10, 0); | 24 | QVBoxLayout *layout = new QVBoxLayout(this, 10, 0); |
25 | m_label = new IRCColorLabel(color, this); | 25 | m_label = new IRCColorLabel(color, this); |
26 | layout->addWidget(m_label); | 26 | layout->addWidget(m_label); |
27 | } | 27 | } |
28 | 28 | ||
29 | QColor IRCFramedColorLabel::color() { | 29 | QColor IRCFramedColorLabel::color() { |
30 | return m_label->color(); | 30 | return m_label->color(); |
31 | } | 31 | } |
32 | 32 | ||
33 | 33 | ||
34 | IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { | 34 | IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) { |
35 | } | 35 | } |
36 | 36 | ||
37 | int IRCTabBar::insertTab(QTab *tab, int index = -1) { | 37 | int IRCTabBar::insertTab(QTab *tab, int index = -1) { |
38 | /* FIXME: find some nicer way to do this */ | 38 | /* FIXME: find some nicer way to do this */ |
39 | QExtTab *ext = new QExtTab(); | 39 | QExtTab *ext = new QExtTab(); |
40 | ext->color = black; | 40 | ext->color = black; |
41 | ext->label = tab->text(); | 41 | ext->label = tab->text(); |
42 | ext->r = tab->rect(); | 42 | ext->r = tab->rect(); |
43 | ext->enabled = tab->isEnabled(); | 43 | ext->enabled = tab->isEnabled(); |
44 | ext->iconset = tab->iconSet(); | 44 | ext->iconset = tab->iconSet(); |
45 | delete tab; | 45 | delete tab; |
46 | return QTabBar::insertTab(ext, index); | 46 | return QTabBar::insertTab(ext, index); |
47 | } | 47 | } |
48 | 48 | ||
49 | void IRCTabBar::setTabColor(int index, QColor color) { | 49 | void IRCTabBar::setTabColor(int index, QColor color) { |
50 | ((QExtTab *)tab(index))->color = color; | 50 | ((QExtTab *)tab(index))->color = color; |
51 | update(); | 51 | update(); |
52 | } | 52 | } |
53 | 53 | ||
54 | void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const { | 54 | void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const { |
55 | QRect r = br; | 55 | QRect r = br; |
56 | QTabBar::paintLabel(p, br, t, focus); | 56 | QTabBar::paintLabel(p, br, t, focus); |
57 | if (t->id == currentTab()) | 57 | if (t->id == currentTab()) |
58 | r.setBottom(r.bottom() - style().defaultFrameWidth()); | 58 | r.setBottom(r.bottom() - style().defaultFrameWidth()); |
59 | p->setPen(((QExtTab *)t)->color); | 59 | p->setPen(((QExtTab *)t)->color); |
60 | p->drawText(r, AlignCenter | ShowPrefix, t->label); | 60 | p->drawText(r, AlignCenter | ShowPrefix, t->label); |
61 | } | 61 | } |
62 | 62 | ||
63 | IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) { | 63 | IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) { |
64 | setTabBar(new IRCTabBar(this, "tab control")); | 64 | setTabBar(new IRCTabBar(this, "tab control")); |
65 | } | 65 | } |
66 | 66 | ||
67 | void IRCTabWidget::setTabColor(int index, QColor color) { | 67 | void IRCTabWidget::setTabColor(int index, QColor color) { |
68 | ((IRCTabBar *)tabBar())->setTabColor(index, color); | 68 | ((IRCTabBar *)tabBar())->setTabColor(index, color); |
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { | 72 | IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { |
73 | m_index = -1; | 73 | m_index = -1; |
74 | installEventFilter(this); | ||
74 | } | 75 | } |
75 | 76 | ||
76 | void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) { | 77 | void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) { |
77 | int key = event->key(); | 78 | int key = event->key(); |
78 | if (key == Key_Up) { | 79 | if (key == Key_Up) { |
79 | if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) { | 80 | if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) { |
80 | m_index++; | 81 | m_index++; |
81 | setText(m_history[m_index]); | 82 | setText(m_history[m_index]); |
82 | } | 83 | } |
83 | } else if (key == Key_Down) { | 84 | } else if (key == Key_Down) { |
84 | if (m_history.count() > 0 && m_index > 0) { | 85 | if (m_history.count() > 0 && m_index > 0) { |
85 | m_index--; | 86 | m_index--; |
86 | setText(m_history[m_index]); | 87 | setText(m_history[m_index]); |
87 | } | 88 | } |
88 | if (m_index == 0) { | 89 | if (m_index == 0) { |
89 | m_index = -1; | 90 | m_index = -1; |
90 | setText(""); | 91 | setText(""); |
91 | } | 92 | } |
92 | } else if (key == Key_Return) { | 93 | } else if (key == Key_Return) { |
93 | m_history.prepend(text()); | 94 | m_history.prepend(text()); |
94 | m_index = -1; | 95 | m_index = -1; |
96 | } else if (key == Key_Tab) { | ||
97 | printf("got tab\n"); | ||
98 | return; | ||
95 | } | 99 | } |
96 | QLineEdit::keyPressEvent(event); | 100 | QLineEdit::keyPressEvent(event); |
97 | } | 101 | } |
102 | |||
103 | bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) { | ||
104 | if (event->type() == QEvent::KeyPress) { | ||
105 | QKeyEvent *k = (QKeyEvent *) event; | ||
106 | /* Catch tab characters */ | ||
107 | if (k->key() == Key_Tab) { | ||
108 | qDebug("tab!"); | ||
109 | return TRUE; | ||
110 | } | ||
111 | } | ||
112 | return QLineEdit::eventFilter(object, event); | ||
113 | } | ||
diff --git a/noncore/net/opieirc/ircmisc.h b/noncore/net/opieirc/ircmisc.h index 7151e6b..6a8db50 100644 --- a/noncore/net/opieirc/ircmisc.h +++ b/noncore/net/opieirc/ircmisc.h | |||
@@ -14,78 +14,79 @@ | |||
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __IRCMISC_H | 21 | #ifndef __IRCMISC_H |
22 | #define __IRCMISC_H | 22 | #define __IRCMISC_H |
23 | 23 | ||
24 | #include <qtabwidget.h> | 24 | #include <qtabwidget.h> |
25 | #include <qlineedit.h> | 25 | #include <qlineedit.h> |
26 | #include <qtabbar.h> | 26 | #include <qtabbar.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qcolor.h> | 28 | #include <qcolor.h> |
29 | #include <qarray.h> | 29 | #include <qarray.h> |
30 | 30 | ||
31 | /* IRCFramedColorLabel is used to display a color */ | 31 | /* IRCFramedColorLabel is used to display a color */ |
32 | 32 | ||
33 | class IRCColorLabel : public QLabel { | 33 | class IRCColorLabel : public QLabel { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | IRCColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 36 | IRCColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
37 | QColor color(); | 37 | QColor color(); |
38 | void mousePressEvent(QMouseEvent *event); | 38 | void mousePressEvent(QMouseEvent *event); |
39 | protected: | 39 | protected: |
40 | QColor m_color; | 40 | QColor m_color; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | class IRCFramedColorLabel : public QWidget { | 43 | class IRCFramedColorLabel : public QWidget { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | IRCFramedColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 46 | IRCFramedColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
47 | QColor color(); | 47 | QColor color(); |
48 | protected: | 48 | protected: |
49 | IRCColorLabel *m_label; | 49 | IRCColorLabel *m_label; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | /* Custom colored QTabWidget */ | 52 | /* Custom colored QTabWidget */ |
53 | 53 | ||
54 | class QExtTab : public QTab { | 54 | class QExtTab : public QTab { |
55 | public: | 55 | public: |
56 | QColor color; | 56 | QColor color; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | class IRCTabWidget : public QTabWidget { | 59 | class IRCTabWidget : public QTabWidget { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | public: | 61 | public: |
62 | IRCTabWidget(QWidget *parent = 0, const char *name = 0); | 62 | IRCTabWidget(QWidget *parent = 0, const char *name = 0); |
63 | void setTabColor(int index, QColor color); | 63 | void setTabColor(int index, QColor color); |
64 | }; | 64 | }; |
65 | 65 | ||
66 | class IRCTabBar : public QTabBar { | 66 | class IRCTabBar : public QTabBar { |
67 | Q_OBJECT | 67 | Q_OBJECT |
68 | public: | 68 | public: |
69 | IRCTabBar(QWidget *parent = 0, const char *name = 0); | 69 | IRCTabBar(QWidget *parent = 0, const char *name = 0); |
70 | void setTabColor(int index, QColor color); | 70 | void setTabColor(int index, QColor color); |
71 | protected: | 71 | protected: |
72 | void paintLabel(QPainter*, const QRect&, QTab*, bool) const; | 72 | void paintLabel(QPainter*, const QRect&, QTab*, bool) const; |
73 | int insertTab(QTab *, int index = -1); | 73 | int insertTab(QTab *, int index = -1); |
74 | protected: | 74 | protected: |
75 | QArray<QColor> m_colors; | 75 | QArray<QColor> m_colors; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | /* A QLineEdit with history functionality */ | 78 | /* A QLineEdit with history functionality and tab completion */ |
79 | 79 | ||
80 | class IRCHistoryLineEdit : public QLineEdit { | 80 | class IRCHistoryLineEdit : public QLineEdit { |
81 | Q_OBJECT | 81 | Q_OBJECT |
82 | public: | 82 | public: |
83 | IRCHistoryLineEdit(QWidget *parent = 0, const char *name = 0); | 83 | IRCHistoryLineEdit(QWidget *parent = 0, const char *name = 0); |
84 | virtual bool eventFilter(QObject *object, QEvent *event); | ||
84 | protected: | 85 | protected: |
85 | void keyPressEvent(QKeyEvent *); | 86 | void keyPressEvent(QKeyEvent *); |
86 | protected: | 87 | protected: |
87 | QStringList m_history; | 88 | QStringList m_history; |
88 | int m_index; | 89 | int m_index; |
89 | }; | 90 | }; |
90 | 91 | ||
91 | #endif /* __IRCMISC_H */ | 92 | #endif /* __IRCMISC_H */ |
diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp index f976c84..8604835 100644 --- a/noncore/net/opieirc/ircservereditor.cpp +++ b/noncore/net/opieirc/ircservereditor.cpp | |||
@@ -1,77 +1,85 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qwhatsthis.h> | ||
4 | #include "ircservereditor.h" | 5 | #include "ircservereditor.h" |
5 | 6 | ||
6 | IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) { | 7 | IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { |
7 | QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); | 8 | QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); |
8 | QLabel *label = new QLabel(tr("Profile name :"), this); | 9 | QLabel *label = new QLabel(tr("Profile name :"), this); |
9 | m_name = new QLineEdit(server.name(), this); | 10 | m_name = new QLineEdit(server.name(), this); |
11 | QWhatsThis::add(m_name, tr("The name of this server profile in the overview")); | ||
10 | layout->addWidget(label, 0, 0); | 12 | layout->addWidget(label, 0, 0); |
11 | layout->addWidget(m_name, 0, 1); | 13 | layout->addWidget(m_name, 0, 1); |
12 | label = new QLabel(tr("Hostname :"), this); | 14 | label = new QLabel(tr("Hostname :"), this); |
13 | m_hostname = new QLineEdit(server.hostname(), this); | 15 | m_hostname = new QLineEdit(server.hostname(), this); |
16 | QWhatsThis::add(m_hostname, tr("The server to connect to - can be any valid host name or IP address")); | ||
14 | layout->addWidget(label, 1, 0); | 17 | layout->addWidget(label, 1, 0); |
15 | layout->addWidget(m_hostname, 1, 1); | 18 | layout->addWidget(m_hostname, 1, 1); |
16 | label = new QLabel(tr("Port :"), this); | 19 | label = new QLabel(tr("Port :"), this); |
17 | m_port = new QLineEdit(QString::number(server.port()), this); | 20 | m_port = new QLineEdit(QString::number(server.port()), this); |
21 | QWhatsThis::add(m_port, tr("The server port to connect to. Usually 6667")); | ||
18 | layout->addWidget(label, 2, 0); | 22 | layout->addWidget(label, 2, 0); |
19 | layout->addWidget(m_port, 2, 1); | 23 | layout->addWidget(m_port, 2, 1); |
20 | label = new QLabel(tr("Nickname :"), this); | 24 | label = new QLabel(tr("Nickname :"), this); |
21 | m_nickname = new QLineEdit(server.nick(), this); | 25 | m_nickname = new QLineEdit(server.nick(), this); |
26 | QWhatsThis::add(m_nickname, tr("Your nick name on the IRC network")); | ||
22 | layout->addWidget(label, 3, 0); | 27 | layout->addWidget(label, 3, 0); |
23 | layout->addWidget(m_nickname, 3, 1); | 28 | layout->addWidget(m_nickname, 3, 1); |
24 | label = new QLabel(tr("Realname :"), this); | 29 | label = new QLabel(tr("Realname :"), this); |
25 | m_realname = new QLineEdit(server.realname(), this); | 30 | m_realname = new QLineEdit(server.realname(), this); |
31 | QWhatsThis::add(m_realname, tr("Your real name")); | ||
26 | layout->addWidget(label, 4, 0); | 32 | layout->addWidget(label, 4, 0); |
27 | layout->addWidget(m_realname, 4, 1); | 33 | layout->addWidget(m_realname, 4, 1); |
28 | label = new QLabel(tr("Password :"), this); | 34 | label = new QLabel(tr("Password :"), this); |
29 | m_password = new QLineEdit(server.password(), this); | 35 | m_password = new QLineEdit(server.password(), this); |
36 | QWhatsThis::add(m_password, tr("Password to connect to the server (if required)")); | ||
30 | layout->addWidget(label, 5, 0); | 37 | layout->addWidget(label, 5, 0); |
31 | layout->addWidget(m_password, 5, 1); | 38 | layout->addWidget(m_password, 5, 1); |
32 | label = new QLabel(tr("Channels :"), this); | 39 | label = new QLabel(tr("Channels :"), this); |
33 | m_channels = new QLineEdit(server.channels(), this); | 40 | m_channels = new QLineEdit(server.channels(), this); |
41 | QWhatsThis::add(m_channels, tr("Comma-Separated list of all channels you would like to join automatically")); | ||
34 | layout->addWidget(label, 6, 0); | 42 | layout->addWidget(label, 6, 0); |
35 | layout->addWidget(m_channels, 6, 1); | 43 | layout->addWidget(m_channels, 6, 1); |
36 | setCaption(tr("Edit server information")); | 44 | setCaption(tr("Edit server information")); |
37 | showMaximized(); | 45 | showMaximized(); |
38 | } | 46 | } |
39 | 47 | ||
40 | 48 | ||
41 | void IRCServerEditor::accept() { | 49 | void IRCServerEditor::accept() { |
42 | if (m_name->text().length()==0) | 50 | if (m_name->text().length()==0) |
43 | QMessageBox::critical(this, tr("Error"), tr("Profile name required")); | 51 | QMessageBox::critical(this, tr("Error"), tr("Profile name required")); |
44 | else if (m_hostname->text().length()==0) | 52 | else if (m_hostname->text().length()==0) |
45 | QMessageBox::critical(this, tr("Error"), tr("Host name required")); | 53 | QMessageBox::critical(this, tr("Error"), tr("Host name required")); |
46 | else if (m_port->text().toInt()<=0) | 54 | else if (m_port->text().toInt()<=0) |
47 | QMessageBox::critical(this, tr("Error"), tr("Port required")); | 55 | QMessageBox::critical(this, tr("Error"), tr("Port required")); |
48 | else if (m_nickname->text().length()==0) | 56 | else if (m_nickname->text().length()==0) |
49 | QMessageBox::critical(this, tr("Error"), tr("Nickname required")); | 57 | QMessageBox::critical(this, tr("Error"), tr("Nickname required")); |
50 | else if (m_realname->text().length()==0) | 58 | else if (m_realname->text().length()==0) |
51 | QMessageBox::critical(this, tr("Error"), tr("Realname required")); | 59 | QMessageBox::critical(this, tr("Error"), tr("Realname required")); |
52 | else { | 60 | else { |
53 | /* Now verify whether the channel list has a valid format */ | 61 | /* Now verify whether the channel list has a valid format */ |
54 | QStringList channels = QStringList::split(QChar(','), m_channels->text()); | 62 | QStringList channels = QStringList::split(QChar(','), m_channels->text()); |
55 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { | 63 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { |
56 | QString channelName = (*it).stripWhiteSpace(); | 64 | QString channelName = (*it).stripWhiteSpace(); |
57 | if (!channelName.startsWith("#") && !channelName.startsWith("+")) { | 65 | if (!channelName.startsWith("#") && !channelName.startsWith("+")) { |
58 | QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with either '#' or '+'")); | 66 | QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with either '#' or '+'")); |
59 | return; | 67 | return; |
60 | } | 68 | } |
61 | } | 69 | } |
62 | QDialog::accept(); | 70 | QDialog::accept(); |
63 | } | 71 | } |
64 | } | 72 | } |
65 | 73 | ||
66 | IRCServer IRCServerEditor::getServer() { | 74 | IRCServer IRCServerEditor::getServer() { |
67 | IRCServer server; | 75 | IRCServer server; |
68 | server.setName(m_name->text()); | 76 | server.setName(m_name->text()); |
69 | server.setHostname(m_hostname->text()); | 77 | server.setHostname(m_hostname->text()); |
70 | server.setPort(m_port->text().toInt()); | 78 | server.setPort(m_port->text().toInt()); |
71 | server.setNick(m_nickname->text()); | 79 | server.setNick(m_nickname->text()); |
72 | server.setRealname(m_realname->text()); | 80 | server.setRealname(m_realname->text()); |
73 | server.setUsername(m_nickname->text()); | 81 | server.setUsername(m_nickname->text()); |
74 | server.setPassword(m_password->text()); | 82 | server.setPassword(m_password->text()); |
75 | server.setChannels(m_channels->text()); | 83 | server.setChannels(m_channels->text()); |
76 | return server; | 84 | return server; |
77 | } | 85 | } |
diff --git a/noncore/net/opieirc/ircserverlist.cpp b/noncore/net/opieirc/ircserverlist.cpp index 3293591..595ae3e 100644 --- a/noncore/net/opieirc/ircserverlist.cpp +++ b/noncore/net/opieirc/ircserverlist.cpp | |||
@@ -1,101 +1,106 @@ | |||
1 | #include <qlayout.h> | 1 | #include <qlayout.h> |
2 | #include <qlabel.h> | 2 | #include <qlabel.h> |
3 | #include <qhbox.h> | 3 | #include <qhbox.h> |
4 | #include <qpushbutton.h> | 4 | #include <qpushbutton.h> |
5 | #include <qwhatsthis.h> | ||
5 | #include "ircserverlist.h" | 6 | #include "ircserverlist.h" |
6 | #include "ircservereditor.h" | 7 | #include "ircservereditor.h" |
7 | 8 | ||
8 | class IRCListBoxServer : public QListBoxText { | 9 | class IRCListBoxServer : public QListBoxText { |
9 | public: | 10 | public: |
10 | IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) { | 11 | IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) { |
11 | m_server = server; | 12 | m_server = server; |
12 | } | 13 | } |
13 | 14 | ||
14 | IRCServer server() { | 15 | IRCServer server() { |
15 | return m_server; | 16 | return m_server; |
16 | } | 17 | } |
17 | 18 | ||
18 | void setServer(IRCServer server) { | 19 | void setServer(IRCServer server) { |
19 | m_server = server; | 20 | m_server = server; |
20 | setText(m_server.name()); | 21 | setText(m_server.name()); |
21 | } | 22 | } |
22 | protected: | 23 | protected: |
23 | IRCServer m_server; | 24 | IRCServer m_server; |
24 | }; | 25 | }; |
25 | 26 | ||
26 | IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags f) : QDialog(parent, name, modal, f) { | 27 | IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { |
27 | QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); | 28 | QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); |
28 | setCaption(tr("Serverlist Browser")); | 29 | setCaption(tr("Serverlist Browser")); |
29 | QLabel *label = new QLabel(tr("Please choose a server profile"), this); | 30 | QLabel *label = new QLabel(tr("Please choose a server profile"), this); |
30 | label->setAlignment(AlignHCenter); | 31 | label->setAlignment(AlignHCenter); |
31 | layout->addWidget(label); | 32 | layout->addWidget(label); |
32 | m_list = new QListBox(this); | 33 | m_list = new QListBox(this); |
34 | QWhatsThis::add(m_list, tr("Select a server profile from this list and then tap on OK in the upper-right corner")); | ||
33 | layout->addWidget(m_list); | 35 | layout->addWidget(m_list); |
34 | QHBox *buttons = new QHBox(this); | 36 | QHBox *buttons = new QHBox(this); |
35 | QPushButton *del = new QPushButton(tr("Delete"), buttons); | 37 | QPushButton *del = new QPushButton(tr("Delete"), buttons); |
36 | QPushButton *edit = new QPushButton(tr("Edit"), buttons); | 38 | QPushButton *edit = new QPushButton(tr("Edit"), buttons); |
37 | QPushButton *add = new QPushButton(tr("Add"), buttons); | 39 | QPushButton *add = new QPushButton(tr("Add"), buttons); |
40 | QWhatsThis::add(del, tr("Delete the currently selected server profile")); | ||
41 | QWhatsThis::add(edit, tr("Edit the currently selected server profile")); | ||
42 | QWhatsThis::add(add, tr("Add a new server profile")); | ||
38 | connect(del, SIGNAL(clicked()), this, SLOT(delServer())); | 43 | connect(del, SIGNAL(clicked()), this, SLOT(delServer())); |
39 | connect(edit, SIGNAL(clicked()), this, SLOT(editServer())); | 44 | connect(edit, SIGNAL(clicked()), this, SLOT(editServer())); |
40 | connect(add, SIGNAL(clicked()), this, SLOT(addServer())); | 45 | connect(add, SIGNAL(clicked()), this, SLOT(addServer())); |
41 | layout->addWidget(buttons); | 46 | layout->addWidget(buttons); |
42 | /* Load the configuration file */ | 47 | /* Load the configuration file */ |
43 | m_config = new Config("OpieIRC"); | 48 | m_config = new Config("OpieIRC"); |
44 | m_config->setGroup("OpieIRC"); | 49 | m_config->setGroup("OpieIRC"); |
45 | int count = m_config->readNumEntry("ServerCount", 0); | 50 | int count = m_config->readNumEntry("ServerCount", 0); |
46 | if (count) { | 51 | if (count) { |
47 | for (int i=0; i<count; i++) { | 52 | for (int i=0; i<count; i++) { |
48 | m_config->setGroup("OpieIRC"); | 53 | m_config->setGroup("OpieIRC"); |
49 | QString name = m_config->readEntry("Server"+QString::number(i)); | 54 | QString name = m_config->readEntry("Server"+QString::number(i)); |
50 | if (name.length() > 0) { | 55 | if (name.length() > 0) { |
51 | IRCServer server; | 56 | IRCServer server; |
52 | m_config->setGroup(name); | 57 | m_config->setGroup(name); |
53 | server.setName(name); | 58 | server.setName(name); |
54 | server.setHostname(m_config->readEntry("Hostname")); | 59 | server.setHostname(m_config->readEntry("Hostname")); |
55 | server.setPort(m_config->readNumEntry("Port")); | 60 | server.setPort(m_config->readNumEntry("Port")); |
56 | server.setUsername(m_config->readEntry("Username")); | 61 | server.setUsername(m_config->readEntry("Username")); |
57 | server.setPassword(m_config->readEntry("Password")); | 62 | server.setPassword(m_config->readEntry("Password")); |
58 | server.setNick(m_config->readEntry("Nick")); | 63 | server.setNick(m_config->readEntry("Nick")); |
59 | server.setRealname(m_config->readEntry("Realname")); | 64 | server.setRealname(m_config->readEntry("Realname")); |
60 | server.setChannels(m_config->readEntry("Channels")); | 65 | server.setChannels(m_config->readEntry("Channels")); |
61 | m_list->insertItem(new IRCListBoxServer(server)); | 66 | m_list->insertItem(new IRCListBoxServer(server)); |
62 | } | 67 | } |
63 | } | 68 | } |
64 | } | 69 | } |
65 | 70 | ||
66 | showMaximized(); | 71 | showMaximized(); |
67 | } | 72 | } |
68 | 73 | ||
69 | void IRCServerList::addServer() { | 74 | void IRCServerList::addServer() { |
70 | IRCServer server; | 75 | IRCServer server; |
71 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); | 76 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); |
72 | if (editor.exec() == QDialog::Accepted) { | 77 | if (editor.exec() == QDialog::Accepted) { |
73 | server = editor.getServer(); | 78 | server = editor.getServer(); |
74 | /* Gets deleted by QListBox, so this is ok */ | 79 | /* Gets deleted by QListBox, so this is ok */ |
75 | m_list->insertItem(new IRCListBoxServer(server)); | 80 | m_list->insertItem(new IRCListBoxServer(server)); |
76 | } | 81 | } |
77 | } | 82 | } |
78 | 83 | ||
79 | void IRCServerList::delServer() { | 84 | void IRCServerList::delServer() { |
80 | int index = m_list->currentItem(); | 85 | int index = m_list->currentItem(); |
81 | if (index != -1) { | 86 | if (index != -1) { |
82 | m_list->removeItem(index); | 87 | m_list->removeItem(index); |
83 | } | 88 | } |
84 | } | 89 | } |
85 | 90 | ||
86 | void IRCServerList::editServer() { | 91 | void IRCServerList::editServer() { |
87 | int index = m_list->currentItem(); | 92 | int index = m_list->currentItem(); |
88 | if (index != -1) { | 93 | if (index != -1) { |
89 | IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); | 94 | IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); |
90 | IRCServer server = item->server(); | 95 | IRCServer server = item->server(); |
91 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); | 96 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); |
92 | if (editor.exec() == QDialog::Accepted) { | 97 | if (editor.exec() == QDialog::Accepted) { |
93 | server = editor.getServer(); | 98 | server = editor.getServer(); |
94 | item->setServer(server); | 99 | item->setServer(server); |
95 | } | 100 | } |
96 | } | 101 | } |
97 | } | 102 | } |
98 | 103 | ||
99 | int IRCServerList::exec() { | 104 | int IRCServerList::exec() { |
100 | int returncode = QDialog::exec(); | 105 | int returncode = QDialog::exec(); |
101 | /* Now save the changes */ | 106 | /* Now save the changes */ |
diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp index 1903e87..78eaed3 100644 --- a/noncore/net/opieirc/ircsettings.cpp +++ b/noncore/net/opieirc/ircsettings.cpp | |||
@@ -1,95 +1,104 @@ | |||
1 | #include <qlayout.h> | 1 | #include <qlayout.h> |
2 | #include <qvalidator.h> | 2 | #include <qvalidator.h> |
3 | #include <qscrollview.h> | 3 | #include <qscrollview.h> |
4 | #include <qwhatsthis.h> | ||
4 | #include "ircsettings.h" | 5 | #include "ircsettings.h" |
5 | #include "irctab.h" | 6 | #include "irctab.h" |
6 | #include "ircmisc.h" | 7 | #include "ircmisc.h" |
7 | 8 | ||
8 | IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags f) : QDialog(parent, name, modal, f) { | 9 | IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { |
9 | setCaption("Settings"); | 10 | setCaption("Settings"); |
10 | m_config = new Config("OpieIRC"); | 11 | m_config = new Config("OpieIRC"); |
11 | m_config->setGroup("OpieIRC"); | 12 | m_config->setGroup("OpieIRC"); |
12 | QHBoxLayout *l = new QHBoxLayout(this, 2, 2); | 13 | QHBoxLayout *l = new QHBoxLayout(this, 2, 2); |
13 | QTabWidget *tw = new QTabWidget(this); | 14 | QTabWidget *tw = new QTabWidget(this); |
14 | l->addWidget(tw); | 15 | l->addWidget(tw); |
15 | /* General Configuration */ | 16 | /* General Configuration */ |
16 | QWidget *widget = new QWidget(tw); | 17 | QWidget *widget = new QWidget(tw); |
17 | QGridLayout *layout = new QGridLayout(widget, 1, 2, 5, 0); | 18 | QGridLayout *layout = new QGridLayout(widget, 1, 2, 5, 0); |
18 | QLabel *label = new QLabel(tr("Lines displayed :"), widget); | 19 | QLabel *label = new QLabel(tr("Lines displayed :"), widget); |
19 | layout->addWidget(label, 0, 0); | 20 | layout->addWidget(label, 0, 0); |
20 | m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), widget); | 21 | m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), widget); |
22 | QWhatsThis::add(m_lines, tr("Amount of lines to be displayed in chats before old lines get deleted - this is necessary to restrain memory consumption. Set to 0 if you don't need this")); | ||
21 | QIntValidator *validator = new QIntValidator(this); | 23 | QIntValidator *validator = new QIntValidator(this); |
22 | validator->setTop(10000); | 24 | validator->setTop(10000); |
23 | validator->setBottom(0); | 25 | validator->setBottom(0); |
24 | m_lines->setValidator(validator); | 26 | m_lines->setValidator(validator); |
25 | layout->addWidget(m_lines, 0, 1); | 27 | layout->addWidget(m_lines, 0, 1); |
26 | tw->addTab(widget, tr("General")); | 28 | tw->addTab(widget, tr("General")); |
27 | 29 | ||
28 | /* Color configuration */ | 30 | /* Color configuration */ |
29 | QScrollView *view = new QScrollView(tw); | 31 | QScrollView *view = new QScrollView(tw); |
30 | view->setResizePolicy(QScrollView::AutoOneFit); | 32 | view->setResizePolicy(QScrollView::AutoOneFit); |
31 | widget = new QWidget(view->viewport()); | 33 | widget = new QWidget(view->viewport()); |
32 | view->addChild(widget); | 34 | view->addChild(widget); |
33 | layout = new QGridLayout(widget, 7, 2, 5, 0); | 35 | layout = new QGridLayout(widget, 7, 2, 5, 0); |
34 | label = new QLabel(tr("Background color :"), widget); | 36 | label = new QLabel(tr("Background color :"), widget); |
35 | layout->addWidget(label, 0, 0); | 37 | layout->addWidget(label, 0, 0); |
36 | m_background = new IRCFramedColorLabel(QColor(m_config->readEntry("BackgroundColor", "#FFFFFF")), widget); | 38 | m_background = new IRCFramedColorLabel(QColor(m_config->readEntry("BackgroundColor", "#FFFFFF")), widget); |
39 | QWhatsThis::add(m_background, tr("Background color to be used in chats")); | ||
37 | layout->addWidget(m_background, 0, 1); | 40 | layout->addWidget(m_background, 0, 1); |
38 | label = new QLabel(tr("Normal text color :"), widget); | 41 | label = new QLabel(tr("Normal text color :"), widget); |
39 | layout->addWidget(label, 1, 0); | 42 | layout->addWidget(label, 1, 0); |
40 | m_text = new IRCFramedColorLabel(m_config->readEntry("TextColor", "#000000"), widget); | 43 | m_text = new IRCFramedColorLabel(m_config->readEntry("TextColor", "#000000"), widget); |
44 | QWhatsThis::add(m_text, tr("Text color to be used in chats")); | ||
41 | layout->addWidget(m_text, 1, 1); | 45 | layout->addWidget(m_text, 1, 1); |
42 | label = new QLabel(tr("Error color :"), widget); | 46 | label = new QLabel(tr("Error color :"), widget); |
43 | layout->addWidget(label, 2, 0); | 47 | layout->addWidget(label, 2, 0); |
44 | m_error = new IRCFramedColorLabel(m_config->readEntry("ErrorColor", "#FF0000"), widget); | 48 | m_error = new IRCFramedColorLabel(m_config->readEntry("ErrorColor", "#FF0000"), widget); |
49 | QWhatsThis::add(m_error, tr("Text color to be used to display errors")); | ||
45 | layout->addWidget(m_error, 2, 1); | 50 | layout->addWidget(m_error, 2, 1); |
46 | label = new QLabel(tr("Text written by yourself :"), widget); | 51 | label = new QLabel(tr("Text written by yourself :"), widget); |
47 | layout->addWidget(label, 3, 0); | 52 | layout->addWidget(label, 3, 0); |
48 | m_self = new IRCFramedColorLabel(m_config->readEntry("SelfColor", "#CC0000"), widget); | 53 | m_self = new IRCFramedColorLabel(m_config->readEntry("SelfColor", "#CC0000"), widget); |
54 | QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself")); | ||
49 | layout->addWidget(m_self, 3, 1); | 55 | layout->addWidget(m_self, 3, 1); |
50 | label = new QLabel(tr("Text written by others :"), widget); | 56 | label = new QLabel(tr("Text written by others :"), widget); |
51 | layout->addWidget(label, 4, 0); | 57 | layout->addWidget(label, 4, 0); |
52 | m_other = new IRCFramedColorLabel(m_config->readEntry("OtherColor", "#0000BB"), widget); | 58 | m_other = new IRCFramedColorLabel(m_config->readEntry("OtherColor", "#0000BB"), widget); |
59 | QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others")); | ||
53 | layout->addWidget(m_other, 4, 1); | 60 | layout->addWidget(m_other, 4, 1); |
54 | label = new QLabel(tr("Text written by the server :"), widget); | 61 | label = new QLabel(tr("Text written by the server :"), widget); |
55 | layout->addWidget(label, 5, 0); | 62 | layout->addWidget(label, 5, 0); |
56 | m_server = new IRCFramedColorLabel(m_config->readEntry("ServerColor", "#0000FF"), widget); | 63 | m_server = new IRCFramedColorLabel(m_config->readEntry("ServerColor", "#0000FF"), widget); |
64 | QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server")); | ||
57 | layout->addWidget(m_server, 5, 1); | 65 | layout->addWidget(m_server, 5, 1); |
58 | label = new QLabel(tr("Notifications :"), widget); | 66 | label = new QLabel(tr("Notifications :"), widget); |
59 | layout->addWidget(label, 6, 0); | 67 | layout->addWidget(label, 6, 0); |
60 | m_notification = new IRCFramedColorLabel(m_config->readEntry("NotificationColor", "#AAE300"), widget); | 68 | m_notification = new IRCFramedColorLabel(m_config->readEntry("NotificationColor", "#AAE300"), widget); |
69 | QWhatsThis::add(m_notification, tr("Text color to be used to display notifications")); | ||
61 | layout->addWidget(m_notification, 6, 1); | 70 | layout->addWidget(m_notification, 6, 1); |
62 | tw->addTab(view, tr("Colors")); | 71 | tw->addTab(view, tr("Colors")); |
63 | showMaximized(); | 72 | showMaximized(); |
64 | } | 73 | } |
65 | 74 | ||
66 | QString IRCSettings::getColorString(QWidget *widget) { | 75 | QString IRCSettings::getColorString(QWidget *widget) { |
67 | QColor color = ((IRCFramedColorLabel *)widget)->color(); | 76 | QColor color = ((IRCFramedColorLabel *)widget)->color(); |
68 | QString temp; | 77 | QString temp; |
69 | temp.sprintf("#%02x%02x%02x", color.red(), color.green(), color.blue()); | 78 | temp.sprintf("#%02x%02x%02x", color.red(), color.green(), color.blue()); |
70 | return temp; | 79 | return temp; |
71 | } | 80 | } |
72 | 81 | ||
73 | void IRCSettings::accept() { | 82 | void IRCSettings::accept() { |
74 | IRCTab::m_backgroundColor = getColorString(m_background); | 83 | IRCTab::m_backgroundColor = getColorString(m_background); |
75 | IRCTab::m_textColor = getColorString(m_text); | 84 | IRCTab::m_textColor = getColorString(m_text); |
76 | IRCTab::m_errorColor = getColorString(m_error); | 85 | IRCTab::m_errorColor = getColorString(m_error); |
77 | IRCTab::m_selfColor = getColorString(m_self); | 86 | IRCTab::m_selfColor = getColorString(m_self); |
78 | IRCTab::m_otherColor = getColorString(m_other); | 87 | IRCTab::m_otherColor = getColorString(m_other); |
79 | IRCTab::m_serverColor = getColorString(m_server); | 88 | IRCTab::m_serverColor = getColorString(m_server); |
80 | IRCTab::m_notificationColor = getColorString(m_notification); | 89 | IRCTab::m_notificationColor = getColorString(m_notification); |
81 | IRCTab::m_maxLines = m_lines->text().toInt(); | 90 | IRCTab::m_maxLines = m_lines->text().toInt(); |
82 | m_config->writeEntry("BackgroundColor", getColorString(m_background)); | 91 | m_config->writeEntry("BackgroundColor", getColorString(m_background)); |
83 | m_config->writeEntry("TextColor", getColorString(m_text)); | 92 | m_config->writeEntry("TextColor", getColorString(m_text)); |
84 | m_config->writeEntry("ErrorColor", getColorString(m_error)); | 93 | m_config->writeEntry("ErrorColor", getColorString(m_error)); |
85 | m_config->writeEntry("SelfColor", getColorString(m_self)); | 94 | m_config->writeEntry("SelfColor", getColorString(m_self)); |
86 | m_config->writeEntry("OtherColor", getColorString(m_other)); | 95 | m_config->writeEntry("OtherColor", getColorString(m_other)); |
87 | m_config->writeEntry("ServerColor", getColorString(m_server)); | 96 | m_config->writeEntry("ServerColor", getColorString(m_server)); |
88 | m_config->writeEntry("NotificationColor", getColorString(m_notification)); | 97 | m_config->writeEntry("NotificationColor", getColorString(m_notification)); |
89 | m_config->writeEntry("Lines", m_lines->text()); | 98 | m_config->writeEntry("Lines", m_lines->text()); |
90 | QDialog::accept(); | 99 | QDialog::accept(); |
91 | } | 100 | } |
92 | 101 | ||
93 | IRCSettings::~IRCSettings() { | 102 | IRCSettings::~IRCSettings() { |
94 | delete m_config; | 103 | delete m_config; |
95 | } | 104 | } |
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp index bb03a1c..7928310 100644 --- a/noncore/net/opieirc/mainwindow.cpp +++ b/noncore/net/opieirc/mainwindow.cpp | |||
@@ -1,84 +1,88 @@ | |||
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 | #include <qwhatsthis.h> | ||
5 | 6 | ||
6 | #include "mainwindow.h" | 7 | #include "mainwindow.h" |
7 | #include "ircservertab.h" | 8 | #include "ircservertab.h" |
8 | #include "ircserverlist.h" | 9 | #include "ircserverlist.h" |
9 | #include "ircsettings.h" | 10 | #include "ircsettings.h" |
10 | 11 | ||
11 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) { | 12 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
12 | setCaption(tr("IRC Client")); | 13 | setCaption(tr("IRC Client")); |
13 | m_tabWidget = new IRCTabWidget(this); | 14 | m_tabWidget = new IRCTabWidget(this); |
15 | 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 *))); | 16 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(selected(QWidget *))); |
15 | setCentralWidget(m_tabWidget); | 17 | setCentralWidget(m_tabWidget); |
16 | setToolBarsMovable(FALSE); | 18 | setToolBarsMovable(FALSE); |
17 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 19 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
18 | QPopupMenu *irc = new QPopupMenu(this); | 20 | QPopupMenu *irc = new QPopupMenu(this); |
19 | menuBar->insertItem(tr("IRC"), irc); | 21 | menuBar->insertItem(tr("IRC"), irc); |
20 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); | 22 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); |
21 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); | 23 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); |
24 | a->setWhatsThis(tr("Create a new connection to an IRC server")); | ||
22 | a->addTo(irc); | 25 | a->addTo(irc); |
23 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); | 26 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); |
27 | a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); | ||
24 | connect(a, SIGNAL(activated()), this, SLOT(settings())); | 28 | connect(a, SIGNAL(activated()), this, SLOT(settings())); |
25 | a->addTo(irc); | 29 | a->addTo(irc); |
26 | loadSettings(); | 30 | loadSettings(); |
27 | } | 31 | } |
28 | 32 | ||
29 | void MainWindow::loadSettings() { | 33 | void MainWindow::loadSettings() { |
30 | Config config("OpieIRC"); | 34 | Config config("OpieIRC"); |
31 | config.setGroup("OpieIRC"); | 35 | config.setGroup("OpieIRC"); |
32 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); | 36 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); |
33 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); | 37 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); |
34 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); | 38 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); |
35 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); | 39 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); |
36 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); | 40 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); |
37 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); | 41 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); |
38 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); | 42 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); |
39 | IRCTab::m_maxLines = config.readNumEntry("Lines", 100); | 43 | IRCTab::m_maxLines = config.readNumEntry("Lines", 100); |
40 | } | 44 | } |
41 | 45 | ||
42 | void MainWindow::selected(QWidget *) { | 46 | void MainWindow::selected(QWidget *) { |
43 | m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); | 47 | m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); |
44 | } | 48 | } |
45 | 49 | ||
46 | void MainWindow::addTab(IRCTab *tab) { | 50 | void MainWindow::addTab(IRCTab *tab) { |
47 | connect(tab, SIGNAL(changed(IRCTab *)), this, SLOT(changeEvent(IRCTab *))); | 51 | connect(tab, SIGNAL(changed(IRCTab *)), this, SLOT(changeEvent(IRCTab *))); |
48 | m_tabWidget->addTab(tab, tab->title()); | 52 | m_tabWidget->addTab(tab, tab->title()); |
49 | m_tabWidget->showPage(tab); | 53 | m_tabWidget->showPage(tab); |
50 | tab->setID(m_tabWidget->currentPageIndex()); | 54 | tab->setID(m_tabWidget->currentPageIndex()); |
51 | m_tabs.append(tab); | 55 | m_tabs.append(tab); |
52 | } | 56 | } |
53 | 57 | ||
54 | void MainWindow::changeEvent(IRCTab *tab) { | 58 | void MainWindow::changeEvent(IRCTab *tab) { |
55 | if (tab->id() != m_tabWidget->currentPageIndex()) | 59 | if (tab->id() != m_tabWidget->currentPageIndex()) |
56 | m_tabWidget->setTabColor(tab->id(), blue); | 60 | m_tabWidget->setTabColor(tab->id(), blue); |
57 | } | 61 | } |
58 | 62 | ||
59 | void MainWindow::killTab(IRCTab *tab) { | 63 | void MainWindow::killTab(IRCTab *tab) { |
60 | m_tabWidget->removePage(tab); | 64 | m_tabWidget->removePage(tab); |
61 | m_tabs.remove(tab); | 65 | m_tabs.remove(tab); |
62 | /* there might be nicer ways to do this .. */ | 66 | /* there might be nicer ways to do this .. */ |
63 | delete tab; | 67 | delete tab; |
64 | } | 68 | } |
65 | 69 | ||
66 | void MainWindow::newConnection() { | 70 | void MainWindow::newConnection() { |
67 | IRCServerList list(this, "ServerList", TRUE); | 71 | IRCServerList list(this, "ServerList", TRUE); |
68 | if (list.exec() == QDialog::Accepted && list.hasServer()) { | 72 | if (list.exec() == QDialog::Accepted && list.hasServer()) { |
69 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); | 73 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); |
70 | addTab(serverTab); | 74 | addTab(serverTab); |
71 | serverTab->doConnect(); | 75 | serverTab->doConnect(); |
72 | } | 76 | } |
73 | } | 77 | } |
74 | 78 | ||
75 | void MainWindow::settings() { | 79 | void MainWindow::settings() { |
76 | IRCSettings settings(this, "Settings", TRUE); | 80 | IRCSettings settings(this, "Settings", TRUE); |
77 | if (settings.exec() == QDialog::Accepted) { | 81 | if (settings.exec() == QDialog::Accepted) { |
78 | QListIterator<IRCTab> it(m_tabs); | 82 | QListIterator<IRCTab> it(m_tabs); |
79 | for (; it.current(); ++it) { | 83 | for (; it.current(); ++it) { |
80 | /* Inform all tabs about the new settings */ | 84 | /* Inform all tabs about the new settings */ |
81 | it.current()->settingsChanged(); | 85 | it.current()->settingsChanged(); |
82 | } | 86 | } |
83 | } | 87 | } |
84 | } | 88 | } |