Fix setting window title as modified

This commit is contained in:
varjolintu 2024-12-08 13:12:56 +02:00
parent 0cb0373f85
commit 2653dcf9d6
No known key found for this signature in database
GPG Key ID: F6D95B66E258AD31
2 changed files with 11 additions and 11 deletions

View File

@ -6187,6 +6187,10 @@ Expect some bugs and minor issues, this version is meant for testing purposes.</
<source>Toggle Show Group Panel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Password Generator</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ManageDatabase</name>

View File

@ -1033,30 +1033,26 @@ void MainWindow::updateWindowTitle()
if (stackedWidgetIndex == DatabaseTabScreen && tabWidgetIndex != -1) {
customWindowTitlePart = m_ui->tabWidget->tabName(tabWidgetIndex);
if (isModified) {
// remove asterisk '*' from title
if (isModified && customWindowTitlePart.endsWith("*")) {
customWindowTitlePart.remove(customWindowTitlePart.size() - 1, 1);
}
m_ui->actionDatabaseSave->setEnabled(m_ui->tabWidget->canSave(tabWidgetIndex));
} else if (stackedWidgetIndex == 1) {
} else if (stackedWidgetIndex == StackedWidgetIndex::SettingsScreen) {
customWindowTitlePart = tr("Settings");
} else if (stackedWidgetIndex == StackedWidgetIndex::PasswordGeneratorScreen) {
customWindowTitlePart = tr("Password Generator");
}
QString windowTitle;
if (customWindowTitlePart.isEmpty()) {
windowTitle = BaseWindowTitle;
windowTitle = QString("%1[*]").arg(BaseWindowTitle);
} else {
windowTitle = QString("%1[*] - %2").arg(customWindowTitlePart, BaseWindowTitle);
}
if (customWindowTitlePart.isEmpty() || stackedWidgetIndex == 1) {
setWindowFilePath("");
} else {
setWindowFilePath(m_ui->tabWidget->databaseWidgetFromIndex(tabWidgetIndex)->database()->filePath());
}
setWindowTitle(windowTitle);
setWindowTitle("[*]"); // Reset title to the placeholder first
setWindowModified(isModified);
setWindowTitle(windowTitle);
updateTrayIcon();
}