diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2018-09-10 11:31:43 +0200 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2018-09-10 19:50:55 +0000 |
commit | 400f748b04da6dfaf26404aa6dabfec11b3c7607 (patch) | |
tree | 336fd7a178076c6590f56454246ef3bdb4b34160 /ui | |
parent | 87e97a8e74ede780c4d9c02701f2984bb4723f6d (diff) |
Qt: Add some window title variables
Add some new variables to be used in custom window title.
%F = file path of the capture file
%S = a conditional separator (" - ") that only shows when surrounded
by variables with values or static text
Change-Id: I20a60a3018cc86236f4991030eadb7f51681cc32
Reviewed-on: https://code.wireshark.org/review/29534
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/main_window.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 52d71d69f8..b00fc1d463 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -2167,8 +2167,28 @@ void MainWindow::setTitlebarForCaptureFile() QString MainWindow::replaceWindowTitleVariables(QString title) { - title.replace ("%P", get_profile_name()); - title.replace ("%V", get_ws_vcs_version_info()); + 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"); + } + + // %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$"), ""); +#ifdef __APPLE__ + // On macOS we separate with a unicode em dash + title.replace("%S", " " UTF8_EM_DASH " "); +#else + title.replace("%S", " - "); +#endif return title; } |