X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Ftopicwidget.cpp;h=8ec55e4b7d56e36d47c5adc10fefa924c603e461;hb=9f0ead1a19ea0ceff224ed42ce37bc286b62b36c;hp=0854647189b549ee62b0f8281e87c09f27f8d10f;hpb=26f4a767b58ebf412d3c7ceb8005abc1ec9ad2bd;p=quassel.git diff --git a/src/qtui/topicwidget.cpp b/src/qtui/topicwidget.cpp index 08546471..8ec55e4b 100644 --- a/src/qtui/topicwidget.cpp +++ b/src/qtui/topicwidget.cpp @@ -34,6 +34,7 @@ TopicWidget::TopicWidget(QWidget *parent) ui.topicLineEdit->installEventFilter(this); connect(ui.topicLabel, SIGNAL(clickableActivated(Clickable)), SLOT(clickableActivated(Clickable))); + connect(ui.topicLineEdit, SIGNAL(noTextEntered()), SLOT(on_topicLineEdit_textEntered())); UiSettings s("TopicWidget"); s.notify("DynamicResize", this, SLOT(updateResizeMode())); @@ -46,6 +47,7 @@ TopicWidget::TopicWidget(QWidget *parent) if(fs.value("UseCustomTopicWidgetFont", false).toBool()) setCustomFont(fs.value("TopicWidget", QFont())); + _mouseEntered = false; } void TopicWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { @@ -132,6 +134,7 @@ void TopicWidget::on_topicEditButton_clicked() { void TopicWidget::switchEditable() { ui.stackedWidget->setCurrentIndex(1); ui.topicLineEdit->setFocus(); + ui.topicLineEdit->moveCursor(QTextCursor::End,QTextCursor::MoveAnchor); updateGeometry(); } @@ -143,12 +146,21 @@ void TopicWidget::switchPlain() { // filter for the input widget to switch back to normal mode bool TopicWidget::eventFilter(QObject *obj, QEvent *event) { - if(event->type() == QEvent::FocusOut) { + + if(event->type() == QEvent::FocusOut && !_mouseEntered) { switchPlain(); return true; } - - if(event->type() != QEvent::KeyPress) + + if(event->type() == QEvent::Enter) { + _mouseEntered = true; + } + + if(event->type() == QEvent::Leave) { + _mouseEntered = false; + } + + if(event->type() != QEvent::KeyRelease) return QObject::eventFilter(obj, event); QKeyEvent *keyEvent = static_cast(event);