diff --git a/src/veditwindow.cpp b/src/veditwindow.cpp index 627f533a..1c4143a8 100644 --- a/src/veditwindow.cpp +++ b/src/veditwindow.cpp @@ -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()); } diff --git a/src/veditwindow.h b/src/veditwindow.h index 2c128ea1..9ea74f56 100644 --- a/src/veditwindow.h +++ b/src/veditwindow.h @@ -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