mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
display star in tab if modified
Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
af38e491ba
commit
4fcdba7a11
@ -85,7 +85,7 @@ void VEditWindow::setRemoveSplitEnable(bool enabled)
|
||||
void VEditWindow::openWelcomePage()
|
||||
{
|
||||
int idx = openFileInTab("", vconfig.getWelcomePagePath(), false);
|
||||
setTabText(idx, "Welcome to VNote");
|
||||
setTabText(idx, generateTabText("Welcome to VNote", false));
|
||||
setTabToolTip(idx, "VNote");
|
||||
}
|
||||
|
||||
@ -290,13 +290,14 @@ void VEditWindow::handleFileRenamed(const QString ¬ebook, const QString &oldR
|
||||
if (tabJson["notebook"].toString() == notebook) {
|
||||
QString relativePath = tabJson["relative_path"].toString();
|
||||
if (relativePath == oldRelativePath) {
|
||||
VEditTab *tab = getTab(i);
|
||||
relativePath = newRelativePath;
|
||||
tabJson["relative_path"] = relativePath;
|
||||
tabs->setTabData(i, tabJson);
|
||||
tabs->setTabToolTip(i, generateTooltip(tabJson));
|
||||
tabs->setTabText(i, VUtils::fileNameFromPath(relativePath));
|
||||
tabs->setTabText(i, generateTabText(VUtils::fileNameFromPath(relativePath), tab->isModified()));
|
||||
QString path = QDir::cleanPath(QDir(vnote->getNotebookPath(notebook)).filePath(relativePath));
|
||||
getTab(i)->updatePath(path);
|
||||
tab->updatePath(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -319,6 +320,10 @@ void VEditWindow::noticeTabStatus(int index)
|
||||
bool editMode = editor->getIsEditMode();
|
||||
bool modifiable = tabJson["modifiable"].toBool();
|
||||
|
||||
// Update tab text
|
||||
tabBar()->setTabText(index, generateTabText(VUtils::fileNameFromPath(relativePath),
|
||||
editor->isModified()));
|
||||
|
||||
emit tabStatusChanged(notebook, relativePath,
|
||||
editMode, modifiable, editor->isModified());
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ private:
|
||||
void updateTabListMenu();
|
||||
void noticeStatus(int index);
|
||||
inline QString generateTooltip(const QJsonObject &tabData) const;
|
||||
inline QString generateTabText(const QString &p_name, bool p_modified) const;
|
||||
|
||||
VNote *vnote;
|
||||
// Button in the right corner
|
||||
@ -101,4 +102,9 @@ inline QString VEditWindow::generateTooltip(const QJsonObject &tabData) const
|
||||
return QString("[%1] %2").arg(tabData["notebook"].toString()).arg(tabData["relative_path"].toString());
|
||||
}
|
||||
|
||||
inline QString VEditWindow::generateTabText(const QString &p_name, bool p_modified) const
|
||||
{
|
||||
return p_modified ? (p_name + "*") : p_name;
|
||||
}
|
||||
|
||||
#endif // VEDITWINDOW_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user