┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphintabwidget.cpp
diff options
context:
space:
mode:
authorNathaniel Graham <[email protected]>2018-04-07 22:35:38 -0600
committerNathaniel Graham <[email protected]>2018-04-09 17:00:47 -0600
commitb12a7b0f24d5960b0fbf26d7ccc37605c5b03c34 (patch)
tree961b6e6ade8554f8e354f3d5a38512b2283215eb /src/dolphintabwidget.cpp
parent3a028d9db0ee4cdd9103d9ab375f95d985539fd2 (diff)
Add more tab access functions
Summary: These new functions to access the next and previous tabs are not used by anything yet, but it is envisioned that they would be useful for a variety of purposes--such as the "open path in new tab" feature from D11703 Test Plan: Dolphin still compiled and runs; new code is not actually used anywhere Reviewers: #dolphin, elvisangelaccio Reviewed By: #dolphin, elvisangelaccio Differential Revision: https://phabricator.kde.org/D12039
Diffstat (limited to 'src/dolphintabwidget.cpp')
-rw-r--r--src/dolphintabwidget.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp
index 0271ed568..a5c2f8c98 100644
--- a/src/dolphintabwidget.cpp
+++ b/src/dolphintabwidget.cpp
@@ -34,7 +34,7 @@
DolphinTabWidget::DolphinTabWidget(QWidget* parent) :
QTabWidget(parent),
m_placesSelectorVisible(true),
- m_previousTab(0)
+ m_lastViewedTab(0)
{
connect(this, &DolphinTabWidget::tabCloseRequested,
this, static_cast<void (DolphinTabWidget::*)(int)>(&DolphinTabWidget::closeTab));
@@ -61,6 +61,18 @@ DolphinTabPage* DolphinTabWidget::currentTabPage() const
return tabPageAt(currentIndex());
}
+DolphinTabPage* DolphinTabWidget::nextTabPage() const
+{
+ const int index = currentIndex() + 1;
+ return tabPageAt(index < count() ? index : 0);
+}
+
+DolphinTabPage* DolphinTabWidget::prevTabPage() const
+{
+ const int index = currentIndex() - 1;
+ return tabPageAt(index >= 0 ? index : (count() - 1));
+}
+
DolphinTabPage* DolphinTabWidget::tabPageAt(const int index) const
{
return static_cast<DolphinTabPage*>(widget(index));
@@ -305,8 +317,8 @@ void DolphinTabWidget::tabUrlChanged(const QUrl& url)
void DolphinTabWidget::currentTabChanged(int index)
{
- // previous tab deactivation
- if (DolphinTabPage* tabPage = tabPageAt(m_previousTab)) {
+ // last-viewed tab deactivation
+ if (DolphinTabPage* tabPage = tabPageAt(m_lastViewedTab)) {
tabPage->setActive(false);
}
DolphinTabPage* tabPage = tabPageAt(index);
@@ -314,7 +326,7 @@ void DolphinTabWidget::currentTabChanged(int index)
emit activeViewChanged(viewContainer);
emit currentUrlChanged(viewContainer->url());
tabPage->setActive(true);
- m_previousTab = index;
+ m_lastViewedTab = index;
}
void DolphinTabWidget::tabInserted(int index)