mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
TabStackedWidget: Cleanup pinUnPinTab code
This commit is contained in:
parent
398232246e
commit
1f32a018f5
@ -253,33 +253,28 @@ void TabStackedWidget::setTabToolTip(int index, const QString &tip)
|
|||||||
|
|
||||||
int TabStackedWidget::pinUnPinTab(int index, const QString &title)
|
int TabStackedWidget::pinUnPinTab(int index, const QString &title)
|
||||||
{
|
{
|
||||||
int newIndex = -1;
|
|
||||||
QWidget* widget = m_stack->widget(index);
|
QWidget* widget = m_stack->widget(index);
|
||||||
QWidget* currentWidget = m_stack->currentWidget();
|
QWidget* currentWidget = m_stack->currentWidget();
|
||||||
bool makePinned = false;
|
|
||||||
|
if (!widget || !currentWidget)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
bool makePinned = index >= m_tabBar->pinnedTabsCount();
|
||||||
|
QWidget* button = m_tabBar->tabButton(index, m_tabBar->iconButtonPosition());
|
||||||
|
|
||||||
m_tabBar->m_blockCurrentChangedSignal = true;
|
m_tabBar->m_blockCurrentChangedSignal = true;
|
||||||
|
m_tabBar->setTabButton(index, m_tabBar->iconButtonPosition(), 0);
|
||||||
|
|
||||||
if (widget) {
|
m_stack->removeWidget(widget);
|
||||||
makePinned = index >= m_tabBar->pinnedTabsCount();
|
int newIndex = insertTab(makePinned ? 0 : m_tabBar->pinnedTabsCount(), widget, title, makePinned);
|
||||||
QWidget* button = m_tabBar->tabButton(index, m_tabBar->iconButtonPosition());
|
|
||||||
|
|
||||||
m_tabBar->setTabButton(index, m_tabBar->iconButtonPosition(), 0);
|
|
||||||
|
|
||||||
m_stack->removeWidget(widget);
|
|
||||||
newIndex = insertTab(makePinned ? 0 : m_tabBar->pinnedTabsCount(), widget, title, makePinned);
|
|
||||||
|
|
||||||
m_tabBar->setTabButton(newIndex, m_tabBar->iconButtonPosition(), button);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
m_tabBar->setTabButton(newIndex, m_tabBar->iconButtonPosition(), button);
|
||||||
m_tabBar->m_blockCurrentChangedSignal = false;
|
m_tabBar->m_blockCurrentChangedSignal = false;
|
||||||
|
|
||||||
// Restore current index
|
// Restore current widget
|
||||||
setCurrentWidget(currentWidget);
|
setCurrentWidget(currentWidget);
|
||||||
|
|
||||||
if (widget) {
|
emit pinStateChanged(newIndex, makePinned);
|
||||||
emit pinStateChanged(newIndex, makePinned);
|
|
||||||
}
|
|
||||||
|
|
||||||
return newIndex;
|
return newIndex;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user