summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc
Unidiff
Diffstat (limited to 'noncore/net/opieirc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircservereditor.cpp10
-rw-r--r--noncore/net/opieirc/ircserverlist.cpp76
-rw-r--r--noncore/net/opieirc/ircsettings.cpp22
3 files changed, 75 insertions, 33 deletions
diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp
index 60274d1..2d11bf0 100644
--- a/noncore/net/opieirc/ircservereditor.cpp
+++ b/noncore/net/opieirc/ircservereditor.cpp
@@ -1,11 +1,16 @@
1#include "ircservereditor.h"
2
3/* OPIE */
4#include <qpe/qpeapplication.h>
5
6/* QT */
1#include <qmessagebox.h> 7#include <qmessagebox.h>
2#include <qlayout.h> 8#include <qlayout.h>
3#include <qlabel.h> 9#include <qlabel.h>
4#include <qwhatsthis.h> 10#include <qwhatsthis.h>
5#include "ircservereditor.h"
6 11
7IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { 12IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) {
8 QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); 13 QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5);
9 QLabel *label = new QLabel(tr("Profile name :"), this); 14 QLabel *label = new QLabel(tr("Profile name :"), this);
10 m_name = new QLineEdit(server.name(), this); 15 m_name = new QLineEdit(server.name(), this);
11 QWhatsThis::add(m_name, tr("The name of this server profile in the overview")); 16 QWhatsThis::add(m_name, tr("The name of this server profile in the overview"));
@@ -40,13 +45,14 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char*
40 label = new QLabel(tr("Channels :"), this); 45 label = new QLabel(tr("Channels :"), this);
41 m_channels = new QLineEdit(server.channels(), this); 46 m_channels = new QLineEdit(server.channels(), this);
42 QWhatsThis::add(m_channels, tr("Comma-Separated list of all channels you would like to join automatically")); 47 QWhatsThis::add(m_channels, tr("Comma-Separated list of all channels you would like to join automatically"));
43 layout->addWidget(label, 6, 0); 48 layout->addWidget(label, 6, 0);
44 layout->addWidget(m_channels, 6, 1); 49 layout->addWidget(m_channels, 6, 1);
45 setCaption(tr("Edit server information")); 50 setCaption(tr("Edit server information"));
46 showMaximized(); 51
52 QPEApplication::showDialog( this );
47} 53}
48 54
49 55
50void IRCServerEditor::accept() { 56void IRCServerEditor::accept() {
51 if (m_name->text().length()==0) 57 if (m_name->text().length()==0)
52 QMessageBox::critical(this, tr("Error"), tr("Profile name required")); 58 QMessageBox::critical(this, tr("Error"), tr("Profile name required"));
diff --git a/noncore/net/opieirc/ircserverlist.cpp b/noncore/net/opieirc/ircserverlist.cpp
index 595ae3e..62bfc17 100644
--- a/noncore/net/opieirc/ircserverlist.cpp
+++ b/noncore/net/opieirc/ircserverlist.cpp
@@ -1,33 +1,44 @@
1
2#include "ircserverlist.h"
3#include "ircservereditor.h"
4
5/* OPIE */
6#include <qpe/qpeapplication.h>
7
8/* QT */
1#include <qlayout.h> 9#include <qlayout.h>
2#include <qlabel.h> 10#include <qlabel.h>
3#include <qhbox.h> 11#include <qhbox.h>
4#include <qpushbutton.h> 12#include <qpushbutton.h>
5#include <qwhatsthis.h> 13#include <qwhatsthis.h>
6#include "ircserverlist.h"
7#include "ircservereditor.h"
8 14
9class IRCListBoxServer : public QListBoxText { 15class IRCListBoxServer : public QListBoxText
16{
10public: 17public:
11 IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) { 18 IRCListBoxServer(IRCServer server) : QListBoxText(server.name())
19 {
12 m_server = server; 20 m_server = server;
13 } 21 }
14 22
15 IRCServer server() { 23 IRCServer server()
24 {
16 return m_server; 25 return m_server;
17 } 26 }
18 27
19 void setServer(IRCServer server) { 28 void setServer(IRCServer server)
29 {
20 m_server = server; 30 m_server = server;
21 setText(m_server.name()); 31 setText(m_server.name());
22 } 32 }
23protected: 33protected:
24 IRCServer m_server; 34 IRCServer m_server;
25}; 35};
26 36
27IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { 37IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp)
38{
28 QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); 39 QVBoxLayout *layout = new QVBoxLayout(this, 5, 5);
29 setCaption(tr("Serverlist Browser")); 40 setCaption(tr("Serverlist Browser"));
30 QLabel *label = new QLabel(tr("Please choose a server profile"), this); 41 QLabel *label = new QLabel(tr("Please choose a server profile"), this);
31 label->setAlignment(AlignHCenter); 42 label->setAlignment(AlignHCenter);
32 layout->addWidget(label); 43 layout->addWidget(label);
33 m_list = new QListBox(this); 44 m_list = new QListBox(this);
@@ -45,17 +56,20 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
45 connect(add, SIGNAL(clicked()), this, SLOT(addServer())); 56 connect(add, SIGNAL(clicked()), this, SLOT(addServer()));
46 layout->addWidget(buttons); 57 layout->addWidget(buttons);
47 /* Load the configuration file */ 58 /* Load the configuration file */
48 m_config = new Config("OpieIRC"); 59 m_config = new Config("OpieIRC");
49 m_config->setGroup("OpieIRC"); 60 m_config->setGroup("OpieIRC");
50 int count = m_config->readNumEntry("ServerCount", 0); 61 int count = m_config->readNumEntry("ServerCount", 0);
51 if (count) { 62 if (count)
52 for (int i=0; i<count; i++) { 63 {
64 for (int i=0; i<count; i++)
65 {
53 m_config->setGroup("OpieIRC"); 66 m_config->setGroup("OpieIRC");
54 QString name = m_config->readEntry("Server"+QString::number(i)); 67 QString name = m_config->readEntry("Server"+QString::number(i));
55 if (name.length() > 0) { 68 if (name.length() > 0)
69 {
56 IRCServer server; 70 IRCServer server;
57 m_config->setGroup(name); 71 m_config->setGroup(name);
58 server.setName(name); 72 server.setName(name);
59 server.setHostname(m_config->readEntry("Hostname")); 73 server.setHostname(m_config->readEntry("Hostname"));
60 server.setPort(m_config->readNumEntry("Port")); 74 server.setPort(m_config->readNumEntry("Port"));
61 server.setUsername(m_config->readEntry("Username")); 75 server.setUsername(m_config->readEntry("Username"));
@@ -64,52 +78,61 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
64 server.setRealname(m_config->readEntry("Realname")); 78 server.setRealname(m_config->readEntry("Realname"));
65 server.setChannels(m_config->readEntry("Channels")); 79 server.setChannels(m_config->readEntry("Channels"));
66 m_list->insertItem(new IRCListBoxServer(server)); 80 m_list->insertItem(new IRCListBoxServer(server));
67 } 81 }
68 } 82 }
69 } 83 }
70 84
71 showMaximized(); 85 QPEApplication::showDialog( this );
72} 86}
73 87
74void IRCServerList::addServer() { 88void IRCServerList::addServer()
89{
75 IRCServer server; 90 IRCServer server;
76 IRCServerEditor editor(server, this, "ServerEditor", TRUE); 91 IRCServerEditor editor(server, this, "ServerEditor", TRUE);
77 if (editor.exec() == QDialog::Accepted) { 92 if (editor.exec() == QDialog::Accepted)
93 {
78 server = editor.getServer(); 94 server = editor.getServer();
79 /* Gets deleted by QListBox, so this is ok */ 95 /* Gets deleted by QListBox, so this is ok */
80 m_list->insertItem(new IRCListBoxServer(server)); 96 m_list->insertItem(new IRCListBoxServer(server));
81 } 97 }
82} 98}
83 99
84void IRCServerList::delServer() { 100void IRCServerList::delServer()
101{
85 int index = m_list->currentItem(); 102 int index = m_list->currentItem();
86 if (index != -1) { 103 if (index != -1)
104 {
87 m_list->removeItem(index); 105 m_list->removeItem(index);
88 } 106 }
89} 107}
90 108
91void IRCServerList::editServer() { 109void IRCServerList::editServer()
110{
92 int index = m_list->currentItem(); 111 int index = m_list->currentItem();
93 if (index != -1) { 112 if (index != -1)
113 {
94 IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); 114 IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index);
95 IRCServer server = item->server(); 115 IRCServer server = item->server();
96 IRCServerEditor editor(server, this, "ServerEditor", TRUE); 116 IRCServerEditor editor(server, this, "ServerEditor", TRUE);
97 if (editor.exec() == QDialog::Accepted) { 117 if (editor.exec() == QDialog::Accepted)
118 {
98 server = editor.getServer(); 119 server = editor.getServer();
99 item->setServer(server); 120 item->setServer(server);
100 } 121 }
101 } 122 }
102} 123}
103 124
104int IRCServerList::exec() { 125int IRCServerList::exec()
126{
105 int returncode = QDialog::exec(); 127 int returncode = QDialog::exec();
106 /* Now save the changes */ 128 /* Now save the changes */
107 m_config->setGroup("OpieIRC"); 129 m_config->setGroup("OpieIRC");
108 m_config->writeEntry("ServerCount", QString::number(m_list->count())); 130 m_config->writeEntry("ServerCount", QString::number(m_list->count()));
109 for (unsigned int i=0; i<m_list->count(); i++) { 131 for (unsigned int i=0; i<m_list->count(); i++)
132 {
110 IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); 133 IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server();
111 m_config->setGroup("OpieIRC"); 134 m_config->setGroup("OpieIRC");
112 m_config->writeEntry("Server"+QString::number(i), server.name()); 135 m_config->writeEntry("Server"+QString::number(i), server.name());
113 m_config->setGroup(server.name()); 136 m_config->setGroup(server.name());
114 m_config->writeEntry("Hostname", server.hostname()); 137 m_config->writeEntry("Hostname", server.hostname());
115 m_config->writeEntry("Port", QString::number(server.port())); 138 m_config->writeEntry("Port", QString::number(server.port()));
@@ -119,17 +142,20 @@ int IRCServerList::exec() {
119 m_config->writeEntry("Realname", server.realname()); 142 m_config->writeEntry("Realname", server.realname());
120 m_config->writeEntry("Channels", server.channels()); 143 m_config->writeEntry("Channels", server.channels());
121 } 144 }
122 return returncode; 145 return returncode;
123} 146}
124 147
125bool IRCServerList::hasServer() { 148bool IRCServerList::hasServer()
149{
126 return (m_list->currentItem() != -1); 150 return (m_list->currentItem() != -1);
127} 151}
128 152
129IRCServer IRCServerList::server() { 153IRCServer IRCServerList::server()
154{
130 return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server(); 155 return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server();
131} 156}
132 157
133IRCServerList::~IRCServerList() { 158IRCServerList::~IRCServerList()
159{
134 delete m_config; 160 delete m_config;
135} 161}
diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp
index 2862296..f69d2c4 100644
--- a/noncore/net/opieirc/ircsettings.cpp
+++ b/noncore/net/opieirc/ircsettings.cpp
@@ -1,14 +1,21 @@
1
2#include "ircsettings.h"
3#include "irctab.h"
4
5/* OPIE */
1#include <opie/ocolorbutton.h> 6#include <opie/ocolorbutton.h>
2#include <opie/otabwidget.h> 7#include <opie/otabwidget.h>
8#include <qpe/qpeapplication.h>
9
10/* QT */
3#include <qvalidator.h> 11#include <qvalidator.h>
4#include <qwhatsthis.h> 12#include <qwhatsthis.h>
5#include "ircsettings.h"
6#include "irctab.h"
7 13
8IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { 14IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp)
15{
9 setCaption(tr("Settings") ); 16 setCaption(tr("Settings") );
10 m_config = new Config("OpieIRC"); 17 m_config = new Config("OpieIRC");
11 m_config->setGroup("OpieIRC"); 18 m_config->setGroup("OpieIRC");
12 QHBoxLayout *l = new QHBoxLayout(this, 2, 2); 19 QHBoxLayout *l = new QHBoxLayout(this, 2, 2);
13 OTabWidget *tw = new OTabWidget(this); 20 OTabWidget *tw = new OTabWidget(this);
14 l->addWidget(tw); 21 l->addWidget(tw);
@@ -67,16 +74,18 @@ IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags)
67 layout->addWidget(label, 6, 0); 74 layout->addWidget(label, 6, 0);
68 m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300")); 75 m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300"));
69 QWhatsThis::add(m_notification, tr("Text color to be used to display notifications")); 76 QWhatsThis::add(m_notification, tr("Text color to be used to display notifications"));
70 layout->addWidget(m_notification, 6, 1); 77 layout->addWidget(m_notification, 6, 1);
71 tw->addTab(view, "opieirc/colors", tr("Colors")); 78 tw->addTab(view, "opieirc/colors", tr("Colors"));
72 tw->setCurrentTab( genwidget ); 79 tw->setCurrentTab( genwidget );
73 showMaximized(); 80
81 QPEApplication::showDialog( this );
74} 82}
75 83
76void IRCSettings::accept() { 84void IRCSettings::accept()
85{
77 IRCTab::m_backgroundColor = m_background->color().name(); 86 IRCTab::m_backgroundColor = m_background->color().name();
78 IRCTab::m_textColor = m_text->color().name(); 87 IRCTab::m_textColor = m_text->color().name();
79 IRCTab::m_errorColor = m_error->color().name(); 88 IRCTab::m_errorColor = m_error->color().name();
80 IRCTab::m_selfColor = m_self->color().name(); 89 IRCTab::m_selfColor = m_self->color().name();
81 IRCTab::m_otherColor = m_other->color().name(); 90 IRCTab::m_otherColor = m_other->color().name();
82 IRCTab::m_serverColor = m_server->color().name(); 91 IRCTab::m_serverColor = m_server->color().name();
@@ -90,9 +99,10 @@ void IRCSettings::accept() {
90 m_config->writeEntry("ServerColor", IRCTab::m_serverColor); 99 m_config->writeEntry("ServerColor", IRCTab::m_serverColor);
91 m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor); 100 m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor);
92 m_config->writeEntry("Lines", m_lines->text()); 101 m_config->writeEntry("Lines", m_lines->text());
93 QDialog::accept(); 102 QDialog::accept();
94} 103}
95 104
96IRCSettings::~IRCSettings() { 105IRCSettings::~IRCSettings()
106{
97 delete m_config; 107 delete m_config;
98} 108}