X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtopia%2Fmainwidget.cpp;h=e8d118463f04908a53d71859be817a902c99895f;hp=3213e2cd84ba6102568049954c302b1a21c182c9;hb=8699dd758516d0ded076811e8ea656adc95e69d0;hpb=d079afedcfa1357afef4a20faf208588b4e97269 diff --git a/src/qtopia/mainwidget.cpp b/src/qtopia/mainwidget.cpp index 3213e2cd..e8d11846 100644 --- a/src/qtopia/mainwidget.cpp +++ b/src/qtopia/mainwidget.cpp @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * Copyright (C) 2005-08 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * (at your option) version 3. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * @@ -25,13 +25,9 @@ MainWidget::MainWidget(QWidget *parent) : QWidget(parent) { ui.setupUi(this); - -// ui.bufferLeft->setIcon(QIcon(":icon/left")); -// ui.bufferRight->setIcon(QIcon(":icon/right")); - //ui.bufferLeft->setIconSize(QSize(10, 10)); - //ui.bufferRight->setIconSize(QSize(10, 10)); - //ui.bufferLeft->setMaximumSize(QSize(10,10)); - //ui.bufferRight->setMaximumSize(QSize(10,10)); + ui.inputLine->hide(); ui.topicBar->hide(); + connect(ui.inputLine, SIGNAL(returnPressed()), this, SLOT(enterPressed())); + currentBuffer = 0; } MainWidget::~MainWidget() { @@ -41,6 +37,11 @@ MainWidget::~MainWidget() { } void MainWidget::setBuffer(Buffer *buf) { + if(!buf) { + ui.stack->setCurrentIndex(0); + currentBuffer = 0; + return; + } // TODO update topic if changed; handle status buffer display QString title = QString("%1 (%2): \"%3\"").arg(buf->name()).arg(buf->networkName()).arg(buf->topic()); ui.topicBar->setContents(title); @@ -57,16 +58,37 @@ void MainWidget::setBuffer(Buffer *buf) { QList lines; QList msgs = buf->contents(); foreach(AbstractUiMsg *msg, msgs) { - lines.append(dynamic_cast(msg)); + lines.append((ChatLine*)(msg)); } chatWidget->setContents(lines); connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatWidget, SLOT(appendMsg(AbstractUiMsg *))); connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), chatWidget, SLOT(prependMsg(AbstractUiMsg *))); - //connect(buf, SIGNAL(topicSet(QString)), this, SLOT(setTopic(QString))); + connect(buf, SIGNAL(topicSet(QString)), this, SLOT(setTopic(QString))); //connect(buf, SIGNAL(ownNickSet(QString)), this, SLOT(setOwnNick(QString))); ui.stack->addWidget(chatWidget); chatWidgets.insert(buf, chatWidget); - ui.stack->addWidget(chatWidget); + chatWidget->setFocusProxy(ui.inputLine); } else chatWidget = chatWidgets[buf]; + ui.inputLine->show(); ui.topicBar->show(); ui.stack->setCurrentWidget(chatWidget); + ui.inputLine->setFocus(); + currentBuffer = buf; +} + +void MainWidget::enterPressed() { + QStringList lines = ui.inputLine->text().split('\n', QString::SkipEmptyParts); + foreach(QString msg, lines) { + if(msg.isEmpty()) continue; + if(currentBuffer) currentBuffer->processUserInput(msg); + } + ui.inputLine->clear(); +} + +// FIXME make this more elegant, we don't need to send a string around... +void MainWidget::setTopic(QString topic) { + Q_UNUSED(topic); + if(currentBuffer) { + QString title = QString("%1 (%2): \"%3\"").arg(currentBuffer->name()).arg(currentBuffer->networkName()).arg(currentBuffer->topic()); + ui.topicBar->setContents(title); + } }