mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Implement Ctrl+Tab (Move to next tab) and Ctrl+Shift+Tab (Move to previous tab)
This commit is contained in:
parent
c9df6ddaab
commit
d9f87c0824
3 changed files with 46 additions and 0 deletions
|
@ -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<NotebookPage *>(this->chatWidget->parentWidget());
|
||||
|
||||
Notebook *notebook = static_cast<Notebook *>(page->parentWidget());
|
||||
|
||||
notebook->nextTab();
|
||||
}
|
||||
} else if (event->key() == Qt::Key_Backtab) {
|
||||
if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) {
|
||||
NotebookPage *page = static_cast<NotebookPage *>(this->chatWidget->parentWidget());
|
||||
|
||||
Notebook *notebook = static_cast<Notebook *>(page->parentWidget());
|
||||
|
||||
notebook->previousTab();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 *);
|
||||
|
||||
|
|
Loading…
Reference in a new issue