Skip to content

Commit

Permalink
Qt: Add support of gui.window_title
Browse files Browse the repository at this point in the history
Ping-Bug: 11102
Bug: 11691
Change-Id: I7b1673ffafcda644f4905265061ba11733dd91d3
Reviewed-on: https://code.wireshark.org/review/12650
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
(cherry picked from commit 6c42a10)
Reviewed-on: https://code.wireshark.org/review/12920
  • Loading branch information
alagoutte committed Dec 29, 2015
1 parent 7fed2f4 commit 77a8f26
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
25 changes: 17 additions & 8 deletions ui/qt/main_window.cpp
Expand Up @@ -1827,7 +1827,7 @@ void MainWindow::setTitlebarForCaptureFile()
// XXX - on non-Mac platforms, put in the application
// name?
//
setWindowTitle(QString("[*]%1").arg(cf_get_tempfile_source(capture_file_.capFile())));
setWSWindowTitle(QString("[*]%1").arg(cf_get_tempfile_source(capture_file_.capFile())));
} else {
//
// For a user file, set the full path; that way,
Expand All @@ -1847,33 +1847,42 @@ void MainWindow::setTitlebarForCaptureFile()
QFileInfo fi(utf8_filename);
if (utf8_filename == NULL) {
// So what the heck else can we do here?
setWindowTitle(tr("(File name can't be mapped to UTF-8)"));
setWSWindowTitle(tr("(File name can't be mapped to UTF-8)"));
} else {
setWindowTitle(fi.fileName());
setWSWindowTitle(fi.fileName());
g_free(utf8_filename);
}
}
setWindowModified(cf_has_unsaved_data(capture_file_.capFile()));
} else {
/* We have no capture file. */
setWindowFilePath(NULL);
setDefaultWindowTitle();
setWSWindowTitle();
}
}

void MainWindow::setDefaultWindowTitle()
void MainWindow::setWSWindowTitle(QString title)
{
setWindowTitle(tr("The Wireshark Network Analyzer"));

if(title.isEmpty()) {
title = tr("The Wireshark Network Analyzer");
}

if((prefs.gui_window_title != NULL) && (*prefs.gui_window_title != '\0')) {
title.append(QString(" [%1]").arg(prefs.gui_window_title));
}

setWindowTitle(title);
}

void MainWindow::setTitlebarForCaptureInProgress()
{
setWindowFilePath(NULL);
if (capture_file_.capFile()) {
setWindowTitle(tr("Capturing from %1").arg(cf_get_tempfile_source(capture_file_.capFile())));
setWSWindowTitle(tr("Capturing from %1").arg(cf_get_tempfile_source(capture_file_.capFile())));
} else {
/* We have no capture in progress. */
setDefaultWindowTitle();
setWSWindowTitle();
}
}

Expand Down
3 changes: 2 additions & 1 deletion ui/qt/main_window.h
Expand Up @@ -186,7 +186,6 @@ class MainWindow : public QMainWindow
void initTimePrecisionFormatMenu();
void initFreezeActions();

void setDefaultWindowTitle();
void setTitlebarForCaptureFile();
void setTitlebarForCaptureInProgress();
void setMenusForCaptureFile(bool force_disable = false);
Expand Down Expand Up @@ -236,6 +235,8 @@ public slots:
void updatePreferenceActions();
void updateRecentActions();

void setWSWindowTitle(QString title = NULL);

void captureCapturePrepared(capture_session *);
void captureCaptureUpdateStarted(capture_session *);
void captureCaptureUpdateFinished(capture_session *);
Expand Down
2 changes: 1 addition & 1 deletion ui/qt/main_window_slots.cpp
Expand Up @@ -774,7 +774,7 @@ void MainWindow::captureFileClosed() {

main_ui_->statusBar->popFileStatus();

setDefaultWindowTitle();
setWSWindowTitle();
setWindowIcon(wsApp->normalIcon());
setMenusForSelectedPacket();
setMenusForSelectedTreeRow();
Expand Down
2 changes: 2 additions & 0 deletions wireshark-qt.cpp
Expand Up @@ -1329,6 +1329,8 @@ DIAG_ON(cast-qual)

wsApp->setMonospaceFont(prefs.gui_qt_font_name);

/* For update of WindowTitle (When use gui.window_title preference) */
main_w->setWSWindowTitle();
////////

/* Read the dynamic part of the recent file, as we have the gui now ready for
Expand Down

0 comments on commit 77a8f26

Please sign in to comment.