forked from qt-creator/qt-creator
Fix missing mode changed signal on startup
Reverts commit 88fc878aa8
and fixes the original issue differently.
Introduce a currentAboutToChange signal in FancyTabBar that
is passed on via FancyTabWidget to
ModeManager::currentModeAboutToChange.
This avoids the temporary mismatch of selected indices in the
tab bar vs tab widget.
Change-Id: If1a331db5478450d7c57e5908b2bed218e9828a8
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -215,6 +215,7 @@ void FancyTabBar::mousePressEvent(QMouseEvent *event)
|
|||||||
// menu arrow clicked
|
// menu arrow clicked
|
||||||
emit menuTriggered(index, event);
|
emit menuTriggered(index, event);
|
||||||
} else {
|
} else {
|
||||||
|
emit currentAboutToChange(index);
|
||||||
m_currentIndex = index;
|
m_currentIndex = index;
|
||||||
update();
|
update();
|
||||||
// update tab bar before showing widget
|
// update tab bar before showing widget
|
||||||
@@ -396,6 +397,7 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
|
|||||||
void FancyTabBar::setCurrentIndex(int index)
|
void FancyTabBar::setCurrentIndex(int index)
|
||||||
{
|
{
|
||||||
if (isTabEnabled(index) && index != m_currentIndex) {
|
if (isTabEnabled(index) && index != m_currentIndex) {
|
||||||
|
emit currentAboutToChange(index);
|
||||||
m_currentIndex = index;
|
m_currentIndex = index;
|
||||||
update();
|
update();
|
||||||
emit currentChanged(m_currentIndex);
|
emit currentChanged(m_currentIndex);
|
||||||
@@ -520,6 +522,7 @@ FancyTabWidget::FancyTabWidget(QWidget *parent)
|
|||||||
mainLayout->addLayout(vlayout);
|
mainLayout->addLayout(vlayout);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
connect(m_tabBar, &FancyTabBar::currentAboutToChange, this, &FancyTabWidget::currentAboutToShow);
|
||||||
connect(m_tabBar, &FancyTabBar::currentChanged, this, &FancyTabWidget::showWidget);
|
connect(m_tabBar, &FancyTabBar::currentChanged, this, &FancyTabWidget::showWidget);
|
||||||
connect(m_tabBar, &FancyTabBar::menuTriggered, this, &FancyTabWidget::menuTriggered);
|
connect(m_tabBar, &FancyTabBar::menuTriggered, this, &FancyTabWidget::menuTriggered);
|
||||||
}
|
}
|
||||||
@@ -598,7 +601,7 @@ void FancyTabWidget::addCornerWidget(QWidget *widget)
|
|||||||
|
|
||||||
int FancyTabWidget::currentIndex() const
|
int FancyTabWidget::currentIndex() const
|
||||||
{
|
{
|
||||||
return m_modesStack->currentIndex();
|
return m_tabBar->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStatusBar *FancyTabWidget::statusBar() const
|
QStatusBar *FancyTabWidget::statusBar() const
|
||||||
@@ -613,7 +616,6 @@ void FancyTabWidget::setCurrentIndex(int index)
|
|||||||
|
|
||||||
void FancyTabWidget::showWidget(int index)
|
void FancyTabWidget::showWidget(int index)
|
||||||
{
|
{
|
||||||
emit currentAboutToShow(index);
|
|
||||||
m_modesStack->setCurrentIndex(index);
|
m_modesStack->setCurrentIndex(index);
|
||||||
QWidget *w = m_modesStack->currentWidget();
|
QWidget *w = m_modesStack->currentWidget();
|
||||||
if (QTC_GUARD(w)) {
|
if (QTC_GUARD(w)) {
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ public:
|
|||||||
QRect tabRect(int index) const;
|
QRect tabRect(int index) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void currentAboutToChange(int index);
|
||||||
void currentChanged(int index);
|
void currentChanged(int index);
|
||||||
void menuTriggered(int index, QMouseEvent *event);
|
void menuTriggered(int index, QMouseEvent *event);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user