mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Merge pull request #1180 from 23rd/patch-31-hotkey-last-tab
Added ability to open last tab with Ctrl+9.
This commit is contained in:
commit
933edb1205
|
@ -256,6 +256,17 @@ void Notebook::selectPreviousTab()
|
||||||
this->select(this->items_[index].page);
|
this->select(this->items_[index].page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Notebook::selectLastTab()
|
||||||
|
{
|
||||||
|
const auto size = this->items_.size();
|
||||||
|
if (size <= 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->select(this->items_[size - 1].page);
|
||||||
|
}
|
||||||
|
|
||||||
int Notebook::getPageCount() const
|
int Notebook::getPageCount() const
|
||||||
{
|
{
|
||||||
return this->items_.count();
|
return this->items_.count();
|
||||||
|
|
|
@ -34,6 +34,7 @@ public:
|
||||||
void selectIndex(int index);
|
void selectIndex(int index);
|
||||||
void selectNextTab();
|
void selectNextTab();
|
||||||
void selectPreviousTab();
|
void selectPreviousTab();
|
||||||
|
void selectLastTab();
|
||||||
|
|
||||||
int getPageCount() const;
|
int getPageCount() const;
|
||||||
QWidget *getPageAt(int index) const;
|
QWidget *getPageAt(int index) const;
|
||||||
|
|
|
@ -270,24 +270,17 @@ void Window::addShortcuts()
|
||||||
this->notebook_->getOrAddSelectedPage()->appendNewSplit(true);
|
this->notebook_->getOrAddSelectedPage()->appendNewSplit(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
createWindowShortcut(this, "CTRL+1",
|
// CTRL + 1-8 to open corresponding tab.
|
||||||
[this] { this->notebook_->selectIndex(0); });
|
for (auto i = 0; i < 8; i++)
|
||||||
createWindowShortcut(this, "CTRL+2",
|
{
|
||||||
[this] { this->notebook_->selectIndex(1); });
|
char hotkey[7];
|
||||||
createWindowShortcut(this, "CTRL+3",
|
std::sprintf(hotkey, "CTRL+%d", i + 1);
|
||||||
[this] { this->notebook_->selectIndex(2); });
|
const auto openTab = [this, i] { this->notebook_->selectIndex(i); };
|
||||||
createWindowShortcut(this, "CTRL+4",
|
createWindowShortcut(this, hotkey, openTab);
|
||||||
[this] { this->notebook_->selectIndex(3); });
|
}
|
||||||
createWindowShortcut(this, "CTRL+5",
|
|
||||||
[this] { this->notebook_->selectIndex(4); });
|
|
||||||
createWindowShortcut(this, "CTRL+6",
|
|
||||||
[this] { this->notebook_->selectIndex(5); });
|
|
||||||
createWindowShortcut(this, "CTRL+7",
|
|
||||||
[this] { this->notebook_->selectIndex(6); });
|
|
||||||
createWindowShortcut(this, "CTRL+8",
|
|
||||||
[this] { this->notebook_->selectIndex(7); });
|
|
||||||
createWindowShortcut(this, "CTRL+9",
|
createWindowShortcut(this, "CTRL+9",
|
||||||
[this] { this->notebook_->selectIndex(8); });
|
[this] { this->notebook_->selectLastTab(); });
|
||||||
|
|
||||||
// Zoom in
|
// Zoom in
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue