From 838fd6bab6f0eedf49ee2503fee4e4b617e7fdb7 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 4 Aug 2019 17:22:48 +0300 Subject: [PATCH] Added ability to open last tab with Ctrl+9. (Chromium behaviour.) - Fixed #1106. --- src/widgets/Notebook.cpp | 11 +++++++++++ src/widgets/Notebook.hpp | 1 + src/widgets/Window.cpp | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/widgets/Notebook.cpp b/src/widgets/Notebook.cpp index 416834f70..237e3e9c8 100644 --- a/src/widgets/Notebook.cpp +++ b/src/widgets/Notebook.cpp @@ -256,6 +256,17 @@ void Notebook::selectPreviousTab() 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 { return this->items_.count(); diff --git a/src/widgets/Notebook.hpp b/src/widgets/Notebook.hpp index bf4d33226..67b80e55e 100644 --- a/src/widgets/Notebook.hpp +++ b/src/widgets/Notebook.hpp @@ -34,6 +34,7 @@ public: void selectIndex(int index); void selectNextTab(); void selectPreviousTab(); + void selectLastTab(); int getPageCount() const; QWidget *getPageAt(int index) const; diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 84e1252d4..7bf9200cd 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -287,7 +287,7 @@ void Window::addShortcuts() createWindowShortcut(this, "CTRL+8", [this] { this->notebook_->selectIndex(7); }); createWindowShortcut(this, "CTRL+9", - [this] { this->notebook_->selectIndex(8); }); + [this] { this->notebook_->selectLastTab(); }); // Zoom in {