X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Finputwidget.cpp;h=d6f0aad6faf84ce8848d39563e9b32892f16b46a;hp=c2ef731e21e5fa092f63305ac56ed699cdfe6c4d;hb=f66bc9ecb5ebde376da256035db425d7dc0c74d0;hpb=fb6f5bcbdebd8660f355a558dd7cc47f6df45965 diff --git a/src/qtui/inputwidget.cpp b/src/qtui/inputwidget.cpp index c2ef731e..d6f0aad6 100644 --- a/src/qtui/inputwidget.cpp +++ b/src/qtui/inputwidget.cpp @@ -20,10 +20,12 @@ #include "inputwidget.h" +#include "ircuser.h" #include "client.h" #include "networkmodel.h" #include "jumpkeyhandler.h" + InputWidget::InputWidget(QWidget *parent) : QWidget(parent), validBuffer(false), @@ -36,6 +38,7 @@ InputWidget::InputWidget(QWidget *parent) connect(this, SIGNAL(userInput(BufferInfo, QString)), Client::instance(), SIGNAL(sendInput(BufferInfo, QString))); setFocusProxy(ui.inputEdit); + ui.ownNick->installEventFilter(new MouseWheelFilter(this)); ui.inputEdit->installEventFilter(new JumpKeyHandler(this)); } @@ -100,15 +103,21 @@ void InputWidget::setNetwork(const Network *network) { return; const Network *previousNet = Client::network(_networkId); - if(previousNet) + if(previousNet) { disconnect(previousNet, 0, this, 0); + if(previousNet->me()) + disconnect(previousNet->me(), 0, this, 0); + } if(network) { _networkId = network->networkId(); - connect(network, SIGNAL(myNickSet(QString)), - this, SLOT(updateNickSelector())); - connect(network, SIGNAL(identitySet(IdentityId)), - this, SLOT(setIdentity(IdentityId))); + connect(network, SIGNAL(identitySet(IdentityId)), this, SLOT(setIdentity(IdentityId))); + if(network->me()) { + connect(network->me(), SIGNAL(nickSet(QString)), this, SLOT(updateNickSelector())); + connect(network->me(), SIGNAL(userModesSet(QString)), this, SLOT(updateNickSelector())); + connect(network->me(), SIGNAL(userModesAdded(QString)), this, SLOT(updateNickSelector())); + connect(network->me(), SIGNAL(userModesRemoved(QString)), this, SLOT(updateNickSelector())); + } } setIdentity(network->identity()); } @@ -149,7 +158,10 @@ void InputWidget::updateNickSelector() const { nicks.prepend(net->myNick()); nickIdx = 0; } - + + if(net->me() && nickIdx < nicks.count()) + nicks[nickIdx] = net->myNick() + QString(" (%1)").arg(net->me()->userModes()); + ui.ownNick->addItems(nicks); ui.ownNick->setCurrentIndex(nickIdx); } @@ -164,3 +176,17 @@ void InputWidget::changeNick(const QString &newNick) const { void InputWidget::sendText(QString text) { emit userInput(currentBufferInfo, text); } + + +// MOUSE WHEEL FILTER +MouseWheelFilter::MouseWheelFilter(QObject *parent) + : QObject(parent) +{ +} + +bool MouseWheelFilter::eventFilter(QObject *obj, QEvent *event) { + if(event->type() != QEvent::Wheel) + return QObject::eventFilter(obj, event); + else + return true; +}