aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/main_window.cpp45
1 files changed, 30 insertions, 15 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index b00fc1d463..d21a53ca85 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -2169,26 +2169,41 @@ QString MainWindow::replaceWindowTitleVariables(QString title)
{
title.replace("%P", get_profile_name());
title.replace("%V", get_ws_vcs_version_info());
- if (capture_file_.capFile()) {
- // get_dirname() will overwrite the argument so make a copy first
- char *filename = g_strdup(capture_file_.capFile()->filename);
- title.replace("%F", get_dirname(filename));
- g_free(filename);
- } else {
- // No file loaded, no folder name
- title.remove("%F");
+
+ if (title.contains("%F")) {
+ // %F is file path of the capture file.
+ if (capture_file_.capFile()) {
+ // get_dirname() will overwrite the argument so make a copy first
+ char *filename = g_strdup(capture_file_.capFile()->filename);
+ QString file(get_dirname(filename));
+ g_free(filename);
+#ifndef _WIN32
+ // Substitute HOME with ~
+ QString homedir(g_getenv("HOME"));
+ if (!homedir.isEmpty()) {
+ homedir.remove(QRegExp("[/]+$"));
+ file.replace(homedir, "~");
+ }
+#endif
+ title.replace("%F", file);
+ } else {
+ // No file loaded, no folder name
+ title.remove("%F");
+ }
}
- // %S is a conditional separator (" - ") that only shows when surrounded by variables
- // with values or static text. Remove repeating, leading and trailing separators.
- title.replace(QRegExp("(%S)+"), "%S");
- title.replace(QRegExp("^%S|%S$"), "");
+ if (title.contains("%S")) {
+ // %S is a conditional separator (" - ") that only shows when surrounded by variables
+ // with values or static text. Remove repeating, leading and trailing separators.
+ title.replace(QRegExp("(%S)+"), "%S");
+ title.remove(QRegExp("^%S|%S$"));
#ifdef __APPLE__
- // On macOS we separate with a unicode em dash
- title.replace("%S", " " UTF8_EM_DASH " ");
+ // On macOS we separate with a unicode em dash
+ title.replace("%S", " " UTF8_EM_DASH " ");
#else
- title.replace("%S", " - ");
+ title.replace("%S", " - ");
#endif
+ }
return title;
}