X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Finputwidget.cpp;h=22e0602b59ce4f000e09e9feb6d2247befd5bce6;hb=cb5a11622fe175661f7e1a0a1d545444a4ac801b;hp=ce9189eda3c858bd0b9581a09fec0c55bc9790a1;hpb=65c5a05ece190678187f8244b9752db76f45bf00;p=quassel.git diff --git a/src/qtui/inputwidget.cpp b/src/qtui/inputwidget.cpp index ce9189ed..22e0602b 100644 --- a/src/qtui/inputwidget.cpp +++ b/src/qtui/inputwidget.cpp @@ -49,10 +49,12 @@ InputWidget::InputWidget(QWidget *parent) ui.ownNick->setSizeAdjustPolicy(QComboBox::AdjustToContents); ui.ownNick->installEventFilter(new MouseWheelFilter(this)); ui.inputEdit->installEventFilter(new JumpKeyHandler(this)); + ui.inputEdit->installEventFilter(this); ui.inputEdit->setMinHeight(1); ui.inputEdit->setMaxHeight(5); ui.inputEdit->setMode(MultiLineEdit::MultiLine); + ui.inputEdit->setPasteProtectionEnabled(true); new TabCompleter(ui.inputEdit); @@ -73,8 +75,11 @@ InputWidget::InputWidget(QWidget *parent) s.notify("MaxNumLines", this, SLOT(setMaxLines(QVariant))); setMaxLines(s.value("MaxNumLines", 5)); - s.notify("EnableScrollBars", this, SLOT(setEnableScrollBars(QVariant))); - setEnableScrollBars(s.value("EnableScrollBars", true)); + s.notify("EnableScrollBars", this, SLOT(setScrollBarsEnabled(QVariant))); + setScrollBarsEnabled(s.value("EnableScrollBars", true)); + + s.notify("EnableMultiLine", this, SLOT(setMultiLineEnabled(QVariant))); + setMultiLineEnabled(s.value("EnableMultiLine", true)); ActionCollection *coll = QtUi::actionCollection(); @@ -106,40 +111,43 @@ void InputWidget::setMaxLines(const QVariant &v) { ui.inputEdit->setMaxHeight(v.toInt()); } -void InputWidget::setEnableScrollBars(const QVariant &v) { +void InputWidget::setScrollBarsEnabled(const QVariant &v) { ui.inputEdit->setScrollBarsEnabled(v.toBool()); } +void InputWidget::setMultiLineEnabled(const QVariant &v) { + ui.inputEdit->setMode(v.toBool()? MultiLineEdit::MultiLine : MultiLineEdit::SingleLine); +} + bool InputWidget::eventFilter(QObject *watched, QEvent *event) { if(event->type() != QEvent::KeyPress) return false; + QKeyEvent *keyEvent = static_cast(event); + // keys from BufferView should be sent to (and focus) the input line BufferView *view = qobject_cast(watched); if(view) { - QKeyEvent *keyEvent = static_cast(event); if(keyEvent->text().length() == 1 && !(keyEvent->modifiers() & (Qt::ControlModifier ^ Qt::AltModifier)) ) { // normal key press QChar c = keyEvent->text().at(0); if(c.isLetterOrNumber() || c.isSpace() || c.isPunct() || c.isSymbol()) { setFocus(); QCoreApplication::sendEvent(inputLine(), keyEvent); return true; - } else - return false; + } } - } - return false; -} - -void InputWidget::keyPressEvent(QKeyEvent * event) { - if(event->matches(QKeySequence::Find)) { - QAction *act = GraphicalUi::actionCollection()->action("ToggleSearchBar"); - if(act) { - act->toggle(); - return; + return false; + } else if(watched == ui.inputEdit) { + if(keyEvent->matches(QKeySequence::Find)) { + QAction *act = GraphicalUi::actionCollection()->action("ToggleSearchBar"); + if(act) { + act->toggle(); + return true; + } } + return false; } - AbstractItemView::keyPressEvent(event); + return false; } void InputWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { @@ -285,7 +293,7 @@ void InputWidget::updateNickSelector() const { if(!me->userModes().isEmpty()) nicks[nickIdx] += QString(" (+%1)").arg(me->userModes()); } - + ui.ownNick->addItems(nicks); if(me && me->isAway())