From 907ac0c1a85060525bdac8ae5b09e11270ef59f0 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Fri, 8 Jan 2010 20:08:48 +0000 Subject: [PATCH] Let the background widget also dispatch the keypresses to guiApp. Now, the Alt-? shortcuts (e.g., Alt-X for the minibuffer) also works when there is no document open. Besides the code is slightly simpler. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32898 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiView.cpp | 36 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index c6b8474b99..186c95111c 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -154,6 +154,7 @@ public: font.setPointSize(int(toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble())); pain.setFont(font); pain.drawText(260, 15, text); + setFocusPolicy(Qt::StrongFocus); } void paintEvent(QPaintEvent *) @@ -164,6 +165,18 @@ public: pain.drawPixmap(x, y, splash_); } + void keyPressEvent(QKeyEvent * ev) + { + KeySymbol sym; + setKeySymbol(&sym, ev); + if (sym.isOK()) { + guiApp->processKeySym(sym, q_key_state(ev->modifiers())); + ev->accept(); + } else { + ev->ignore(); + } + } + private: QPixmap splash_; }; @@ -248,6 +261,7 @@ struct GuiView::GuiViewPrivate { stack_widget_->setCurrentWidget(bg_widget_); bg_widget_->setUpdatesEnabled(true); + bg_widget_->setFocus(); } TabWorkArea * tabWorkArea(int i) @@ -576,6 +590,8 @@ void GuiView::setFocus() QMainWindow::setFocus(); if (d.current_work_area_) d.current_work_area_->setFocus(); + else + d.bg_widget_->setFocus(); } @@ -913,25 +929,7 @@ bool GuiView::event(QEvent * e) } } #endif - - if (d.current_work_area_) - // Nothing special to do. - return QMainWindow::event(e); - - QKeyEvent * ke = static_cast(e); - // Let Qt handle menu access and the Tab keys to navigate keys to navigate - // between controls. - if (ke->modifiers() & Qt::AltModifier || ke->key() == Qt::Key_Tab - || ke->key() == Qt::Key_Backtab) - return QMainWindow::event(e); - - // Allow processing of shortcuts that are allowed even when no Buffer - // is viewed. - KeySymbol sym; - setKeySymbol(&sym, ke); - guiApp->processKeySym(sym, q_key_state(ke->modifiers())); - e->accept(); - return true; + return QMainWindow::event(e); } default: -- 2.39.2