diff --git a/src/widgets/chatwidgetinput.cpp b/src/widgets/chatwidgetinput.cpp index 948b253c5..075e7f3d3 100644 --- a/src/widgets/chatwidgetinput.cpp +++ b/src/widgets/chatwidgetinput.cpp @@ -3,6 +3,7 @@ #include "colorscheme.hpp" #include "completionmanager.hpp" #include "ircmanager.hpp" +#include "notebook.hpp" #include "notebookpage.hpp" #include "settingsmanager.hpp" @@ -128,6 +129,22 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget) page->requestFocus(reqX, reqY); } + } else if (event->key() == Qt::Key_Tab) { + if (event->modifiers() == Qt::ControlModifier) { + NotebookPage *page = static_cast(this->chatWidget->parentWidget()); + + Notebook *notebook = static_cast(page->parentWidget()); + + notebook->nextTab(); + } + } else if (event->key() == Qt::Key_Backtab) { + if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) { + NotebookPage *page = static_cast(this->chatWidget->parentWidget()); + + Notebook *notebook = static_cast(page->parentWidget()); + + notebook->previousTab(); + } } }); diff --git a/src/widgets/notebook.cpp b/src/widgets/notebook.cpp index fa81ec102..de14444d1 100644 --- a/src/widgets/notebook.cpp +++ b/src/widgets/notebook.cpp @@ -134,6 +134,32 @@ void Notebook::rearrangePage(NotebookPage *page, int index) performLayout(); } +void Notebook::nextTab() +{ + if (this->pages.size() <= 1) { + return; + } + + int index = (this->pages.indexOf(this->selectedPage) + 1) % this->pages.size(); + + this->select(this->pages[index]); +} + +void Notebook::previousTab() +{ + if (this->pages.size() <= 1) { + return; + } + + int index = (this->pages.indexOf(this->selectedPage) - 1); + + if (index < 0) { + index += this->pages.size(); + } + + this->select(this->pages[index]); +} + void Notebook::performLayout(bool animated) { int x = 0, y = 0; diff --git a/src/widgets/notebook.hpp b/src/widgets/notebook.hpp index 2b6085334..1719edc6a 100644 --- a/src/widgets/notebook.hpp +++ b/src/widgets/notebook.hpp @@ -42,6 +42,9 @@ public: NotebookPage *tabAt(QPoint point, int &index); void rearrangePage(NotebookPage *page, int index); + void nextTab(); + void previousTab(); + protected: void resizeEvent(QResizeEvent *);