mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
update tab list menu dynamically when menu show up
Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
e7c42ba5be
commit
787d54c808
@ -61,6 +61,8 @@ void VEditWindow::setupCornerWidget()
|
|||||||
QMenu *leftMenu = new QMenu(this);
|
QMenu *leftMenu = new QMenu(this);
|
||||||
leftBtn->setMenu(leftMenu);
|
leftBtn->setMenu(leftMenu);
|
||||||
setCornerWidget(leftBtn, Qt::TopLeftCorner);
|
setCornerWidget(leftBtn, Qt::TopLeftCorner);
|
||||||
|
connect(leftMenu, &QMenu::aboutToShow,
|
||||||
|
this, &VEditWindow::updateTabListMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VEditWindow::splitWindow()
|
void VEditWindow::splitWindow()
|
||||||
@ -143,7 +145,6 @@ bool VEditWindow::closeFile(const VFile *p_file, bool p_forced)
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
removeEditTab(idx);
|
removeEditTab(idx);
|
||||||
}
|
}
|
||||||
updateTabListMenu();
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +168,6 @@ bool VEditWindow::closeAllFiles(bool p_forced)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateTabListMenu();
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
emit requestRemoveSplit(this);
|
emit requestRemoveSplit(this);
|
||||||
}
|
}
|
||||||
@ -187,7 +187,6 @@ int VEditWindow::openFileInTab(VFile *p_file, OpenFileMode p_mode)
|
|||||||
this, &VEditWindow::handleTabStatusChanged);
|
this, &VEditWindow::handleTabStatusChanged);
|
||||||
|
|
||||||
int idx = appendEditTab(p_file, editor);
|
int idx = appendEditTab(p_file, editor);
|
||||||
updateTabListMenu();
|
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +209,6 @@ bool VEditWindow::handleTabCloseRequest(int index)
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
removeEditTab(index);
|
removeEditTab(index);
|
||||||
}
|
}
|
||||||
updateTabListMenu();
|
|
||||||
noticeStatus(currentIndex());
|
noticeStatus(currentIndex());
|
||||||
// User clicks the close button. We should make this window
|
// User clicks the close button. We should make this window
|
||||||
// to be current window.
|
// to be current window.
|
||||||
@ -431,6 +429,5 @@ void VEditWindow::updateFileInfo(const VFile *p_file)
|
|||||||
int idx = findTabByFile(p_file);
|
int idx = findTabByFile(p_file);
|
||||||
if (idx > -1) {
|
if (idx > -1) {
|
||||||
noticeStatus(idx);
|
noticeStatus(idx);
|
||||||
updateTabListMenu();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ private slots:
|
|||||||
void handleOutlineChanged(const VToc &p_toc);
|
void handleOutlineChanged(const VToc &p_toc);
|
||||||
void handleCurHeaderChanged(const VAnchor &p_anchor);
|
void handleCurHeaderChanged(const VAnchor &p_anchor);
|
||||||
void handleTabStatusChanged();
|
void handleTabStatusChanged();
|
||||||
|
void updateTabListMenu();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupCornerWidget();
|
void setupCornerWidget();
|
||||||
@ -68,7 +69,6 @@ private:
|
|||||||
int openFileInTab(VFile *p_file, OpenFileMode p_mode);
|
int openFileInTab(VFile *p_file, OpenFileMode p_mode);
|
||||||
inline VEditTab *getTab(int tabIndex) const;
|
inline VEditTab *getTab(int tabIndex) const;
|
||||||
void noticeTabStatus(int p_index);
|
void noticeTabStatus(int p_index);
|
||||||
void updateTabListMenu();
|
|
||||||
void noticeStatus(int index);
|
void noticeStatus(int index);
|
||||||
inline QString generateTooltip(const VFile *p_file) const;
|
inline QString generateTooltip(const VFile *p_file) const;
|
||||||
inline QString generateTabText(const QString &p_name, bool p_modified) const;
|
inline QString generateTabText(const QString &p_name, bool p_modified) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user