summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircmisc.cpp2
-rw-r--r--noncore/net/opieirc/ircservereditor.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp
index c8e6190..f94cf1b 100644
--- a/noncore/net/opieirc/ircmisc.cpp
+++ b/noncore/net/opieirc/ircmisc.cpp
@@ -1,113 +1,113 @@
#include <opie/colordialog.h>
#include <qlayout.h>
#include <stdio.h>
#include "ircmisc.h"
IRCColorLabel::IRCColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QLabel(parent, name, f) {
m_color = color;
setAlignment(AlignVCenter | AlignCenter);
setFrameStyle(QFrame::StyledPanel);
setFrameShadow(QFrame::Sunken);
setBackgroundColor(m_color);
}
void IRCColorLabel::mousePressEvent(QMouseEvent *) {
m_color = OColorDialog::getColor(m_color);
setBackgroundColor(m_color);
}
QColor IRCColorLabel::color() {
return m_color;
}
IRCFramedColorLabel::IRCFramedColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) {
QVBoxLayout *layout = new QVBoxLayout(this, 10, 0);
m_label = new IRCColorLabel(color, this);
layout->addWidget(m_label);
}
QColor IRCFramedColorLabel::color() {
return m_label->color();
}
IRCTabBar::IRCTabBar(QWidget *parent, const char *name) : QTabBar(parent, name) {
}
-int IRCTabBar::insertTab(QTab *tab, int index = -1) {
+int IRCTabBar::insertTab(QTab *tab, int index) {
/* FIXME: find some nicer way to do this */
QExtTab *ext = new QExtTab();
ext->color = black;
ext->label = tab->text();
ext->r = tab->rect();
ext->enabled = tab->isEnabled();
ext->iconset = tab->iconSet();
delete tab;
return QTabBar::insertTab(ext, index);
}
void IRCTabBar::setTabColor(int index, QColor color) {
((QExtTab *)tab(index))->color = color;
update();
}
void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const {
QRect r = br;
QTabBar::paintLabel(p, br, t, focus);
if (t->id == currentTab())
r.setBottom(r.bottom() - style().defaultFrameWidth());
p->setPen(((QExtTab *)t)->color);
p->drawText(r, AlignCenter | ShowPrefix, t->label);
}
IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) {
setTabBar(new IRCTabBar(this, "tab control"));
}
void IRCTabWidget::setTabColor(int index, QColor color) {
((IRCTabBar *)tabBar())->setTabColor(index, color);
}
IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) {
m_index = -1;
installEventFilter(this);
}
void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) {
int key = event->key();
if (key == Key_Up) {
if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) {
m_index++;
setText(m_history[m_index]);
}
} else if (key == Key_Down) {
if (m_history.count() > 0 && m_index > 0) {
m_index--;
setText(m_history[m_index]);
}
if (m_index == 0) {
m_index = -1;
setText("");
}
} else if (key == Key_Return) {
m_history.prepend(text());
m_index = -1;
} else if (key == Key_Tab) {
printf("got tab\n");
return;
}
QLineEdit::keyPressEvent(event);
}
bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *k = (QKeyEvent *) event;
/* Catch tab characters */
if (k->key() == Key_Tab) {
qDebug("tab!");
return TRUE;
}
}
return QLineEdit::eventFilter(object, event);
}
diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp
index 8604835..91384fd 100644
--- a/noncore/net/opieirc/ircservereditor.cpp
+++ b/noncore/net/opieirc/ircservereditor.cpp
@@ -1,85 +1,85 @@
#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 = FALSE, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) {
+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"));
layout->addWidget(label, 0, 0);
layout->addWidget(m_name, 0, 1);
label = new QLabel(tr("Hostname :"), this);
m_hostname = new QLineEdit(server.hostname(), this);
QWhatsThis::add(m_hostname, tr("The server to connect to - can be any valid host name or IP address"));
layout->addWidget(label, 1, 0);
layout->addWidget(m_hostname, 1, 1);
label = new QLabel(tr("Port :"), this);
m_port = new QLineEdit(QString::number(server.port()), this);
QWhatsThis::add(m_port, tr("The server port to connect to. Usually 6667"));
layout->addWidget(label, 2, 0);
layout->addWidget(m_port, 2, 1);
label = new QLabel(tr("Nickname :"), this);
m_nickname = new QLineEdit(server.nick(), this);
QWhatsThis::add(m_nickname, tr("Your nick name on the IRC network"));
layout->addWidget(label, 3, 0);
layout->addWidget(m_nickname, 3, 1);
label = new QLabel(tr("Realname :"), this);
m_realname = new QLineEdit(server.realname(), this);
QWhatsThis::add(m_realname, tr("Your real name"));
layout->addWidget(label, 4, 0);
layout->addWidget(m_realname, 4, 1);
label = new QLabel(tr("Password :"), this);
m_password = new QLineEdit(server.password(), this);
QWhatsThis::add(m_password, tr("Password to connect to the server (if required)"));
layout->addWidget(label, 5, 0);
layout->addWidget(m_password, 5, 1);
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();
}
void IRCServerEditor::accept() {
if (m_name->text().length()==0)
QMessageBox::critical(this, tr("Error"), tr("Profile name required"));
else if (m_hostname->text().length()==0)
QMessageBox::critical(this, tr("Error"), tr("Host name required"));
else if (m_port->text().toInt()<=0)
QMessageBox::critical(this, tr("Error"), tr("Port required"));
else if (m_nickname->text().length()==0)
QMessageBox::critical(this, tr("Error"), tr("Nickname required"));
else if (m_realname->text().length()==0)
QMessageBox::critical(this, tr("Error"), tr("Realname required"));
else {
/* Now verify whether the channel list has a valid format */
QStringList channels = QStringList::split(QChar(','), m_channels->text());
for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) {
QString channelName = (*it).stripWhiteSpace();
if (!channelName.startsWith("#") && !channelName.startsWith("+")) {
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 '+'"));
return;
}
}
QDialog::accept();
}
}
IRCServer IRCServerEditor::getServer() {
IRCServer server;
server.setName(m_name->text());
server.setHostname(m_hostname->text());
server.setPort(m_port->text().toInt());
server.setNick(m_nickname->text());
server.setRealname(m_realname->text());
server.setUsername(m_nickname->text());
server.setPassword(m_password->text());
server.setChannels(m_channels->text());
return server;
}