mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-24 04:32:15 -04:00
Closing a tab doesn't change the current tab
Before this change, after a tab was closed its adjacent tab (the next one or, in the absence of such, the previous one) became active, no matter which tab was active before that. Now that logic applies only if the currently active tab is closed. The function responsible for that logic was removed because its name was not a good one and its existence was not justified given that it could be replaced by a oneliner and that it was used only once.
This commit is contained in:
parent
fb43b4338f
commit
94d95b68ca
@ -289,7 +289,9 @@ void TabBar::closeTab(int index)
|
||||
return;
|
||||
}
|
||||
|
||||
setSelectionBehaviorOnRemove(index);
|
||||
if ( index == currentIndex() ) {
|
||||
setCurrentIndex(index + 1 == realTabCount() ? index - 1 : index + 1);
|
||||
}
|
||||
|
||||
mp_stackedWidget->removeWidget(view);
|
||||
view->setParent(nullptr);
|
||||
@ -298,15 +300,6 @@ void TabBar::closeTab(int index)
|
||||
view->deleteLater();
|
||||
}
|
||||
|
||||
void TabBar::setSelectionBehaviorOnRemove(int index)
|
||||
{
|
||||
if (index == count() - 2) {
|
||||
setCurrentIndex(index - 1);
|
||||
} else {
|
||||
setCurrentIndex(index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void TabBar::onCurrentChanged(int index)
|
||||
{
|
||||
if (index == -1)
|
||||
|
@ -70,11 +70,10 @@ private:
|
||||
QStackedWidget* mp_stackedWidget;
|
||||
QScopedPointer<FullScreenWindow> m_fullScreenWindow;
|
||||
|
||||
void setSelectionBehaviorOnRemove(int index);
|
||||
// The "+" (new tab) button is implemented as a tab (that is always placed at the end).
|
||||
// This function returns the count of real tabs.
|
||||
int realTabCount() const;
|
||||
|
||||
|
||||
private slots:
|
||||
void onTabMoved(int from, int to);
|
||||
void onCurrentChanged(int index);
|
||||
|
Loading…
x
Reference in New Issue
Block a user