Qt: Add support of gui.window_title

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>
This commit is contained in:
Alexis La Goutte 2015-12-15 12:12:27 +01:00
parent f145108f5e
commit 6c42a103e8
4 changed files with 22 additions and 10 deletions

View File

@ -1843,7 +1843,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,
@ -1863,9 +1863,9 @@ 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);
}
}
@ -1873,23 +1873,32 @@ void MainWindow::setTitlebarForCaptureFile()
} 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();
}
}

View File

@ -188,7 +188,6 @@ private:
void initTimePrecisionFormatMenu();
void initFreezeActions();
void setDefaultWindowTitle();
void setTitlebarForCaptureFile();
void setTitlebarForCaptureInProgress();
void setMenusForCaptureFile(bool force_disable = false);
@ -238,6 +237,8 @@ public slots:
void updatePreferenceActions();
void updateRecentActions();
void setWSWindowTitle(QString title = NULL);
void captureCapturePrepared(capture_session *);
void captureCaptureUpdateStarted(capture_session *);
void captureCaptureUpdateFinished(capture_session *);

View File

@ -765,7 +765,7 @@ void MainWindow::captureFileClosed() {
main_ui_->statusBar->popFileStatus();
setDefaultWindowTitle();
setWSWindowTitle();
setWindowIcon(wsApp->normalIcon());
setMenusForSelectedPacket();
setMenusForSelectedTreeRow();

View File

@ -1331,6 +1331,8 @@ int main(int argc, char *argv[])
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