forked from osmocom/wireshark
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>
This commit is contained in:
parent
87e97a8e74
commit
400f748b04
12
epan/prefs.c
12
epan/prefs.c
|
@ -3266,11 +3266,19 @@ prefs_register_modules(void)
|
|||
&prefs.gui_update_interval);
|
||||
|
||||
register_string_like_preference(gui_module, "window_title", "Custom window title",
|
||||
"Custom window title to be appended to the existing title\n%P = profile name\n%V = version info",
|
||||
"Custom window title to be appended to the existing title\n"
|
||||
"%F = file path of the capture file\n"
|
||||
"%P = profile name\n"
|
||||
"%S = a conditional separator (\" - \") that only shows when surrounded by variables with values or static text\n"
|
||||
"%V = version info",
|
||||
&prefs.gui_window_title, PREF_STRING, NULL, TRUE);
|
||||
|
||||
register_string_like_preference(gui_module, "prepend_window_title", "Custom window title prefix",
|
||||
"Custom window title to be prepended to the existing title\n%P = profile name\n%V = version info",
|
||||
"Custom window title to be prepended to the existing title\n"
|
||||
"%F = file path of the capture file\n"
|
||||
"%P = profile name\n"
|
||||
"%S = a conditional separator (\" - \") that only shows when surrounded by variables with values or static text\n"
|
||||
"%V = version info",
|
||||
&prefs.gui_prepend_window_title, PREF_STRING, NULL, TRUE);
|
||||
|
||||
register_string_like_preference(gui_module, "start_title", "Custom start page title",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue