From 8aa68056aec80c775a3ddb152bea8a90a7097199 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 1 Dec 2014 23:59:31 +0300 Subject: Add actions for switch to next/prev tab in inventory. Keys not assigned. --- src/gui/windows/inventorywindow.cpp | 28 ++++++++++++++++++++++++++++ src/gui/windows/inventorywindow.h | 6 ++++++ 2 files changed, 34 insertions(+) (limited to 'src/gui/windows') diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index c1fea4158..ea3cc5ad3 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -54,6 +54,7 @@ #include "gui/widgets/scrollarea.h" #include "gui/widgets/tabstrip.h" #include "gui/widgets/textfield.h" +#include "gui/widgets/windowcontainer.h" #include "net/inventoryhandler.h" @@ -746,6 +747,33 @@ bool InventoryWindow::isAnyInputFocused() return false; } +InventoryWindow *InventoryWindow::getFirstVisible() +{ + std::set list; + FOR_EACH (WindowList::const_iterator, it, invInstances) + { + if ((*it) && (*it)->isWindowVisible()) + list.insert(*it); + } + InventoryWindow *const window = dynamic_cast( + windowContainer->findFirstWidget(list)); + return window; +} + +void InventoryWindow::nextTab() +{ + InventoryWindow *const window = getFirstVisible(); + if (window) + window->mFilter->nextTab(); +} + +void InventoryWindow::prevTab() +{ + InventoryWindow *const window = getFirstVisible(); + if (window) + window->mFilter->prevTab(); +} + void InventoryWindow::widgetResized(const Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 98cac78a6..f2952c2f5 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -156,6 +156,12 @@ class InventoryWindow final : public Window, static bool isAnyInputFocused(); + static InventoryWindow *getFirstVisible(); + + static void nextTab(); + + static void prevTab(); + private: /** * Updates the weight bar. -- cgit v1.2.3-70-g09d2