diff --git a/doomsday/client/include/ui/widgets/logwidget.h b/doomsday/client/include/ui/widgets/logwidget.h index 04b6d73644..cdab4e80c1 100644 --- a/doomsday/client/include/ui/widgets/logwidget.h +++ b/doomsday/client/include/ui/widgets/logwidget.h @@ -72,6 +72,13 @@ class LogWidget : public QObject, public GuiWidget void setContentYOffset(de::Animation const &anim); + /** + * Enables or disables scrolling with Page Up/Down keys. + * + * @param enabled @c true to enable Page Up/Down. + */ + void enablePageKeys(bool enabled); + // Events. void viewResized(); void update(); diff --git a/doomsday/client/src/ui/widgets/consolewidget.cpp b/doomsday/client/src/ui/widgets/consolewidget.cpp index 2ae87bad8a..1478c09945 100644 --- a/doomsday/client/src/ui/widgets/consolewidget.cpp +++ b/doomsday/client/src/ui/widgets/consolewidget.cpp @@ -53,6 +53,17 @@ DENG2_PIMPL(ConsoleWidget) void glDeinit() { } + + void expandLog(int delta, bool useOffsetAnimation) + { + height->set(height->scalar().target() + delta, .25f); + + if(useOffsetAnimation) + { + // Sync the log content with the height animation. + log->setContentYOffset(Animation::range(Animation::EaseIn, delta, 0, .25f)); + } + } }; ConsoleWidget::ConsoleWidget() : GuiWidget("Console"), d(new Instance(this)) @@ -121,10 +132,20 @@ bool ConsoleWidget::handleEvent(Event const &event) if(event.type() == Event::KeyPress) { KeyEvent const &key = static_cast(event); + + if(key.qtKey() == Qt::Key_PageUp || + key.qtKey() == Qt::Key_PageDown) + { + d->log->enablePageKeys(true); + d->expandLog(rule().top().valuei(), false); + return true; + } + if(key.qtKey() == Qt::Key_F5) { d->height->set(0); d->log->scrollToBottom(); + d->log->enablePageKeys(false); return true; } } @@ -133,7 +154,5 @@ bool ConsoleWidget::handleEvent(Event const &event) void ConsoleWidget::logContentHeightIncreased(int delta) { - d->height->set(d->height->scalar().target() + delta, .25f); - // Sync the log content with the height animation. - d->log->setContentYOffset(Animation::range(Animation::EaseIn, delta, 0, .25f)); + d->expandLog(delta, true); } diff --git a/doomsday/client/src/ui/widgets/logwidget.cpp b/doomsday/client/src/ui/widgets/logwidget.cpp index 200a718609..20b14d5f94 100644 --- a/doomsday/client/src/ui/widgets/logwidget.cpp +++ b/doomsday/client/src/ui/widgets/logwidget.cpp @@ -301,6 +301,7 @@ DENG2_PIMPL(LogWidget), public Font::RichFormat::IStyle enum { CancelAllRewraps = 0xffffffff }; // State. + bool pageKeysEnabled; Animation visibleOffset; int totalHeight; int maxScroll; @@ -339,6 +340,7 @@ DENG2_PIMPL(LogWidget), public Font::RichFormat::IStyle sink(this), cacheWidth(0), cancelRewrap(0), + pageKeysEnabled(true), visibleOffset(0), totalHeight(0), maxScroll(0), @@ -840,6 +842,11 @@ void LogWidget::setContentYOffset(Animation const &anim) } } +void LogWidget::enablePageKeys(bool enabled) +{ + d->pageKeysEnabled = enabled; +} + void LogWidget::viewResized() { d->updateProjection(); @@ -866,7 +873,8 @@ bool LogWidget::handleEvent(Event const &event) switch(ev.ddKey()) { - case DDKEY_PGUP: + case DDKEY_PGUP: + if(!d->pageKeysEnabled) return false; if(ev.modifiers().testFlag(KeyEvent::Shift)) { d->setVisibleOffset(d->maxScroll, .3f); @@ -879,6 +887,7 @@ bool LogWidget::handleEvent(Event const &event) return true; case DDKEY_PGDN: + if(!d->pageKeysEnabled) return false; if(ev.modifiers().testFlag(KeyEvent::Shift)) { scrollToBottom();