display star in tab if modified

Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
Le Tan 2016-11-16 22:29:46 +08:00
parent af38e491ba
commit 4fcdba7a11
2 changed files with 14 additions and 3 deletions

View File

@ -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 &notebook, 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());
}

View File

@ -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