show unnamed tabs as "<unnamed>" in the tab list

Wed, 09 Mar 2022 13:14:40 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 09 Mar 2022 13:14:40 +0200
changeset 174
3016b494685c
parent 173
8a3047468994
child 175
41628bdab71c
child 176
cd9d6bf6f649

show unnamed tabs as "<unnamed>" in the tab list

src/mainwindow.cpp file | annotate | diff | comparison | revisions
--- a/src/mainwindow.cpp	Wed Mar 09 13:01:50 2022 +0200
+++ b/src/mainwindow.cpp	Wed Mar 09 13:14:40 2022 +0200
@@ -199,7 +199,12 @@
 		this->statusBar()->showMessage(newStatusText);
 	});
 	const QFileInfo fileInfo{*this->documents.modelPath(modelId)};
-	this->ui->tabs->addTab(document, fileInfo.baseName());
+	QString tabName = fileInfo.baseName();
+	if (tabName.isEmpty())
+	{
+		tabName = tr("<unnamed>");
+	}
+	this->ui->tabs->addTab(document, tabName);
 	this->ui->tabs->setCurrentWidget(document);
 	document->restoreSplitterState(this->documentSplitterState);
 }

mercurial