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
DolphinTabWidget::DolphinTabWidget(QWidget* parent) :
QTabWidget(parent),
m_placesSelectorVisible(true),
DolphinTabWidget::DolphinTabWidget(QWidget* parent) :
QTabWidget(parent),
m_placesSelectorVisible(true),
{
connect(this, &DolphinTabWidget::tabCloseRequested,
this, static_cast<void (DolphinTabWidget::*)(int)>(&DolphinTabWidget::closeTab));
{
connect(this, &DolphinTabWidget::tabCloseRequested,
this, static_cast<void (DolphinTabWidget::*)(int)>(&DolphinTabWidget::closeTab));
return tabPageAt(currentIndex());
}
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));
DolphinTabPage* DolphinTabWidget::tabPageAt(const int index) const
{
return static_cast<DolphinTabPage*>(widget(index));
void DolphinTabWidget::currentTabChanged(int index)
{
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);
tabPage->setActive(false);
}
DolphinTabPage* tabPage = tabPageAt(index);
emit activeViewChanged(viewContainer);
emit currentUrlChanged(viewContainer->url());
tabPage->setActive(true);
emit activeViewChanged(viewContainer);
emit currentUrlChanged(viewContainer->url());
tabPage->setActive(true);
+ m_lastViewedTab = index;
}
void DolphinTabWidget::tabInserted(int index)
}
void DolphinTabWidget::tabInserted(int index)
*/
DolphinTabPage* currentTabPage() const;
*/
DolphinTabPage* currentTabPage() const;
+ /**
+ * @return the next tab page. If the current active tab is the last tab,
+ * it returns the first tab. If there is only one tab, returns nullptr
+ */
+ DolphinTabPage* nextTabPage() const;
+
+ /**
+ * @return the previous tab page. If the current active tab is the first tab,
+ * it returns the last tab. If there is only one tab, returns nullptr
+ */
+ DolphinTabPage* prevTabPage() const;
+
/**
* @return Tab page at the given \a index (can be 0 if the index is out-of-range)
*/
/**
* @return Tab page at the given \a index (can be 0 if the index is out-of-range)
*/
/** Caches the (negated) places panel visibility */
bool m_placesSelectorVisible;
/** Caches the (negated) places panel visibility */
bool m_placesSelectorVisible;