fix bug in VEditWindow

Bug: when we press the scroll button to the end and click the first/last
tab, it won't set current tab correctly.

We should not change anything related to current index in handling
tabbarClicked().

Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
Le Tan 2017-01-09 23:01:12 +08:00
parent 3005d9bf5c
commit 7ed92ed7eb
2 changed files with 15 additions and 3 deletions

View File

@ -32,6 +32,8 @@ VEditWindow::VEditWindow(VNote *vnote, VEditArea *editArea, QWidget *parent)
this, &VEditWindow::handleTabCloseRequest);
connect(this, &VEditWindow::tabBarClicked,
this, &VEditWindow::handleTabbarClicked);
connect(this, &VEditWindow::currentChanged,
this, &VEditWindow::handleCurrentIndexChanged);
connect(this, &VEditWindow::customContextMenuRequested,
this, &VEditWindow::contextMenuRequested);
}
@ -368,9 +370,18 @@ void VEditWindow::focusWindow()
getTab(idx)->focusTab();
}
void VEditWindow::handleTabbarClicked(int /* index */)
void VEditWindow::handleTabbarClicked(int p_index)
{
// Only handle the case when (p_index == currentIndex()) here
// because currentIndex() is not changed yet. If we focus window
// now, we may change the current index forcely.
if (p_index == currentIndex()) {
focusWindow();
}
}
void VEditWindow::handleCurrentIndexChanged(int /* p_index */)
{
// The child will emit getFocused here
focusWindow();
}

View File

@ -64,7 +64,8 @@ private slots:
bool handleTabCloseRequest(int index);
void splitWindow();
void removeSplit();
void handleTabbarClicked(int index);
void handleTabbarClicked(int p_index);
void handleCurrentIndexChanged(int p_index);
void contextMenuRequested(QPoint pos);
void tabListJump(QAction *action);
void handleOutlineChanged(const VToc &p_toc);