update tab list menu dynamically when menu show up

Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
Le Tan 2016-11-30 23:38:29 +08:00
parent e7c42ba5be
commit 787d54c808
2 changed files with 3 additions and 6 deletions

View File

@ -61,6 +61,8 @@ void VEditWindow::setupCornerWidget()
QMenu *leftMenu = new QMenu(this);
leftBtn->setMenu(leftMenu);
setCornerWidget(leftBtn, Qt::TopLeftCorner);
connect(leftMenu, &QMenu::aboutToShow,
this, &VEditWindow::updateTabListMenu);
}
void VEditWindow::splitWindow()
@ -143,7 +145,6 @@ bool VEditWindow::closeFile(const VFile *p_file, bool p_forced)
if (ok) {
removeEditTab(idx);
}
updateTabListMenu();
return ok;
}
@ -167,7 +168,6 @@ bool VEditWindow::closeAllFiles(bool p_forced)
break;
}
}
updateTabListMenu();
if (ret) {
emit requestRemoveSplit(this);
}
@ -187,7 +187,6 @@ int VEditWindow::openFileInTab(VFile *p_file, OpenFileMode p_mode)
this, &VEditWindow::handleTabStatusChanged);
int idx = appendEditTab(p_file, editor);
updateTabListMenu();
return idx;
}
@ -210,7 +209,6 @@ bool VEditWindow::handleTabCloseRequest(int index)
if (ok) {
removeEditTab(index);
}
updateTabListMenu();
noticeStatus(currentIndex());
// User clicks the close button. We should make this window
// to be current window.
@ -431,6 +429,5 @@ void VEditWindow::updateFileInfo(const VFile *p_file)
int idx = findTabByFile(p_file);
if (idx > -1) {
noticeStatus(idx);
updateTabListMenu();
}
}

View File

@ -59,6 +59,7 @@ private slots:
void handleOutlineChanged(const VToc &p_toc);
void handleCurHeaderChanged(const VAnchor &p_anchor);
void handleTabStatusChanged();
void updateTabListMenu();
private:
void setupCornerWidget();
@ -68,7 +69,6 @@ private:
int openFileInTab(VFile *p_file, OpenFileMode p_mode);
inline VEditTab *getTab(int tabIndex) const;
void noticeTabStatus(int p_index);
void updateTabListMenu();
void noticeStatus(int index);
inline QString generateTooltip(const VFile *p_file) const;
inline QString generateTabText(const QString &p_name, bool p_modified) const;