-rw-r--r-- | noncore/net/opieirc/ircservereditor.cpp | 10 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserverlist.cpp | 72 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsettings.cpp | 22 |
3 files changed, 73 insertions, 31 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 @@ +#include "ircservereditor.h" + +/* OPIE */ +#include <qpe/qpeapplication.h> + +/* QT */ #include <qmessagebox.h> #include <qlayout.h> #include <qlabel.h> #include <qwhatsthis.h> -#include "ircservereditor.h" IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); QLabel *label = new QLabel(tr("Profile name :"), this); m_name = new QLineEdit(server.name(), this); 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* label = new QLabel(tr("Channels :"), this); m_channels = new QLineEdit(server.channels(), this); QWhatsThis::add(m_channels, tr("Comma-Separated list of all channels you would like to join automatically")); layout->addWidget(label, 6, 0); layout->addWidget(m_channels, 6, 1); setCaption(tr("Edit server information")); - showMaximized(); + + QPEApplication::showDialog( this ); } void IRCServerEditor::accept() { if (m_name->text().length()==0) 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 @@ + +#include "ircserverlist.h" +#include "ircservereditor.h" + +/* OPIE */ +#include <qpe/qpeapplication.h> + +/* QT */ #include <qlayout.h> #include <qlabel.h> #include <qhbox.h> #include <qpushbutton.h> #include <qwhatsthis.h> -#include "ircserverlist.h" -#include "ircservereditor.h" -class IRCListBoxServer : public QListBoxText { +class IRCListBoxServer : public QListBoxText +{ public: - IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) { + IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) + { m_server = server; } - IRCServer server() { + IRCServer server() + { return m_server; } - void setServer(IRCServer server) { + void setServer(IRCServer server) + { m_server = server; setText(m_server.name()); } protected: IRCServer m_server; }; -IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { +IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) +{ QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); setCaption(tr("Serverlist Browser")); QLabel *label = new QLabel(tr("Please choose a server profile"), this); label->setAlignment(AlignHCenter); layout->addWidget(label); m_list = new QListBox(this); @@ -45,17 +56,20 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla connect(add, SIGNAL(clicked()), this, SLOT(addServer())); layout->addWidget(buttons); /* Load the configuration file */ m_config = new Config("OpieIRC"); m_config->setGroup("OpieIRC"); int count = m_config->readNumEntry("ServerCount", 0); - if (count) { - for (int i=0; i<count; i++) { + if (count) + { + for (int i=0; i<count; i++) + { m_config->setGroup("OpieIRC"); QString name = m_config->readEntry("Server"+QString::number(i)); - if (name.length() > 0) { + if (name.length() > 0) + { IRCServer server; m_config->setGroup(name); server.setName(name); server.setHostname(m_config->readEntry("Hostname")); server.setPort(m_config->readNumEntry("Port")); server.setUsername(m_config->readEntry("Username")); @@ -65,51 +79,60 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla server.setChannels(m_config->readEntry("Channels")); m_list->insertItem(new IRCListBoxServer(server)); } } } - showMaximized(); + QPEApplication::showDialog( this ); } -void IRCServerList::addServer() { +void IRCServerList::addServer() +{ IRCServer server; IRCServerEditor editor(server, this, "ServerEditor", TRUE); - if (editor.exec() == QDialog::Accepted) { + if (editor.exec() == QDialog::Accepted) + { server = editor.getServer(); /* Gets deleted by QListBox, so this is ok */ m_list->insertItem(new IRCListBoxServer(server)); } } -void IRCServerList::delServer() { +void IRCServerList::delServer() +{ int index = m_list->currentItem(); - if (index != -1) { + if (index != -1) + { m_list->removeItem(index); } } -void IRCServerList::editServer() { +void IRCServerList::editServer() +{ int index = m_list->currentItem(); - if (index != -1) { + if (index != -1) + { IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); IRCServer server = item->server(); IRCServerEditor editor(server, this, "ServerEditor", TRUE); - if (editor.exec() == QDialog::Accepted) { + if (editor.exec() == QDialog::Accepted) + { server = editor.getServer(); item->setServer(server); } } } -int IRCServerList::exec() { +int IRCServerList::exec() +{ int returncode = QDialog::exec(); /* Now save the changes */ m_config->setGroup("OpieIRC"); m_config->writeEntry("ServerCount", QString::number(m_list->count())); - for (unsigned int i=0; i<m_list->count(); i++) { + for (unsigned int i=0; i<m_list->count(); i++) + { IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); m_config->setGroup("OpieIRC"); m_config->writeEntry("Server"+QString::number(i), server.name()); m_config->setGroup(server.name()); m_config->writeEntry("Hostname", server.hostname()); m_config->writeEntry("Port", QString::number(server.port())); @@ -119,17 +142,20 @@ int IRCServerList::exec() { m_config->writeEntry("Realname", server.realname()); m_config->writeEntry("Channels", server.channels()); } return returncode; } -bool IRCServerList::hasServer() { +bool IRCServerList::hasServer() +{ return (m_list->currentItem() != -1); } -IRCServer IRCServerList::server() { +IRCServer IRCServerList::server() +{ return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server(); } -IRCServerList::~IRCServerList() { +IRCServerList::~IRCServerList() +{ delete m_config; } 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 @@ + +#include "ircsettings.h" +#include "irctab.h" + +/* OPIE */ #include <opie/ocolorbutton.h> #include <opie/otabwidget.h> +#include <qpe/qpeapplication.h> + +/* QT */ #include <qvalidator.h> #include <qwhatsthis.h> -#include "ircsettings.h" -#include "irctab.h" -IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { +IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) +{ setCaption(tr("Settings") ); m_config = new Config("OpieIRC"); m_config->setGroup("OpieIRC"); QHBoxLayout *l = new QHBoxLayout(this, 2, 2); OTabWidget *tw = new OTabWidget(this); l->addWidget(tw); @@ -67,16 +74,18 @@ IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) layout->addWidget(label, 6, 0); m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300")); QWhatsThis::add(m_notification, tr("Text color to be used to display notifications")); layout->addWidget(m_notification, 6, 1); tw->addTab(view, "opieirc/colors", tr("Colors")); tw->setCurrentTab( genwidget ); - showMaximized(); + + QPEApplication::showDialog( this ); } -void IRCSettings::accept() { +void IRCSettings::accept() +{ IRCTab::m_backgroundColor = m_background->color().name(); IRCTab::m_textColor = m_text->color().name(); IRCTab::m_errorColor = m_error->color().name(); IRCTab::m_selfColor = m_self->color().name(); IRCTab::m_otherColor = m_other->color().name(); IRCTab::m_serverColor = m_server->color().name(); @@ -90,9 +99,10 @@ void IRCSettings::accept() { m_config->writeEntry("ServerColor", IRCTab::m_serverColor); m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor); m_config->writeEntry("Lines", m_lines->text()); QDialog::accept(); } -IRCSettings::~IRCSettings() { +IRCSettings::~IRCSettings() +{ delete m_config; } |