diff options
author | Gerald Combs <gerald@zing.org> | 2014-12-22 15:51:36 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2014-12-29 01:42:13 +0000 |
commit | e8ec11fb7e67f83a7296f1e87451f3d7ddd5d85d (patch) | |
tree | ebac5b8251ca402bbb09dce014bdd883fd192f3b /ui | |
parent | c1d9d93efb3581f11ea8115e5b1d6a4c7105a1d2 (diff) | |
download | wireshark-e8ec11fb7e67f83a7296f1e87451f3d7ddd5d85d.tar.gz |
Qt: Add a WiresharkDialog convenience class.
Add WiresharkDialog, a common base class for dialogs centered around
capture files. Make it a parent of Capture File Properties, Traffic
Table, Conversations, and Endpoints.
Rename CaptureFile::read_only_ to file_closed_. Add methods to
WiresharkApplication for generating consistent window titles.
Change-Id: Idc771556d8192e60f85dddc08fc4757698dee257
Reviewed-on: https://code.wireshark.org/review/6097
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/CMakeLists.txt | 2 | ||||
-rw-r--r-- | ui/qt/Makefile.common | 6 | ||||
-rw-r--r-- | ui/qt/Wireshark.pro | 4 | ||||
-rw-r--r-- | ui/qt/capture_file.cpp | 7 | ||||
-rw-r--r-- | ui/qt/capture_file.h | 5 | ||||
-rw-r--r-- | ui/qt/capture_file_properties_dialog.cpp | 41 | ||||
-rw-r--r-- | ui/qt/capture_file_properties_dialog.h | 15 | ||||
-rw-r--r-- | ui/qt/capture_file_properties_dialog.ui | 3 | ||||
-rw-r--r-- | ui/qt/conversation_dialog.cpp | 10 | ||||
-rw-r--r-- | ui/qt/conversation_dialog.h | 2 | ||||
-rw-r--r-- | ui/qt/endpoint_dialog.cpp | 2 | ||||
-rw-r--r-- | ui/qt/endpoint_dialog.h | 2 | ||||
-rw-r--r-- | ui/qt/main_window.cpp | 1 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 8 | ||||
-rw-r--r-- | ui/qt/traffic_table_dialog.cpp | 32 | ||||
-rw-r--r-- | ui/qt/traffic_table_dialog.h | 9 | ||||
-rw-r--r-- | ui/qt/wireshark_application.cpp | 18 | ||||
-rw-r--r-- | ui/qt/wireshark_application.h | 4 | ||||
-rw-r--r-- | ui/qt/wireshark_dialog.cpp | 74 | ||||
-rw-r--r-- | ui/qt/wireshark_dialog.h | 61 |
20 files changed, 212 insertions, 94 deletions
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt index 73de482498..53302a3fc2 100644 --- a/ui/qt/CMakeLists.txt +++ b/ui/qt/CMakeLists.txt @@ -100,6 +100,7 @@ set(WIRESHARK_QT_HEADERS uat_dialog.h voip_calls_dialog.h wireshark_application.h + wireshark_dialog.h ) if(HAVE_PCAP_REMOTE) @@ -199,6 +200,7 @@ set(WIRESHARK_QT_SRC uat_dialog.cpp voip_calls_dialog.cpp wireshark_application.cpp + wireshark_dialog.cpp ) if(HAVE_PCAP_REMOTE) diff --git a/ui/qt/Makefile.common b/ui/qt/Makefile.common index 6fd892c1e1..8eb0ad0f3d 100644 --- a/ui/qt/Makefile.common +++ b/ui/qt/Makefile.common @@ -193,7 +193,8 @@ MOC_HDRS = \ traffic_table_dialog.h \ uat_dialog.h \ voip_calls_dialog.h \ - wireshark_application.h + wireshark_application.h \ + wireshark_dialog.h # @@ -392,7 +393,8 @@ WIRESHARK_QT_SRC = \ traffic_table_dialog.cpp \ uat_dialog.cpp \ voip_calls_dialog.cpp \ - wireshark_application.cpp + wireshark_application.cpp \ + wireshark_dialog.cpp WIRESHARK_QT_TAP_SRC = \ stats_tree_dialog.cpp diff --git a/ui/qt/Wireshark.pro b/ui/qt/Wireshark.pro index 7390e08517..bcc44a7b39 100644 --- a/ui/qt/Wireshark.pro +++ b/ui/qt/Wireshark.pro @@ -583,6 +583,7 @@ HEADERS += \ syntax_line_edit.h \ time_shift_dialog.h \ wireshark_application.h \ + wireshark_dialog.h \ SOURCES += \ @@ -672,4 +673,5 @@ SOURCES += \ traffic_table_dialog.cpp \ uat_dialog.cpp \ voip_calls_dialog.cpp \ - wireshark_application.cpp + wireshark_application.cpp \ + wireshark_dialog.cpp diff --git a/ui/qt/capture_file.cpp b/ui/qt/capture_file.cpp index c395497457..831b65b4d0 100644 --- a/ui/qt/capture_file.cpp +++ b/ui/qt/capture_file.cpp @@ -46,7 +46,8 @@ QString CaptureFile::no_capture_file_ = QObject::tr("[no capture file]"); CaptureFile::CaptureFile(QObject *parent, capture_file *cap_file) : QObject(parent), cap_file_(cap_file), - file_title_(no_capture_file_) + file_title_(no_capture_file_), + file_state_(QString()) { #ifdef HAVE_LIBPCAP capture_callback_add(captureCallback, (gpointer) this); @@ -117,14 +118,16 @@ void CaptureFile::captureFileEvent(int event, gpointer data) } case(cf_cb_file_closing): g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Closing"); - file_title_.append(tr(" [closed]")); + file_state_ = tr(" [closing]"); emit captureFileClosing(); break; case(cf_cb_file_closed): g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Closed"); + file_state_ = tr(" [closed]"); emit captureFileClosed(); cap_file_ = NULL; file_title_ = no_capture_file_; + file_state_ = QString(); break; case(cf_cb_file_read_started): g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Read started"); diff --git a/ui/qt/capture_file.h b/ui/qt/capture_file.h index 224926b461..11418db2a1 100644 --- a/ui/qt/capture_file.h +++ b/ui/qt/capture_file.h @@ -50,9 +50,9 @@ public: /** Return a filename suitable for use in a window title. * * @return One of: the basename of the capture file without an extension, - * the basename followed by "[closed]", or "[no capture file]". + * the basename followed by "[closing", "[closed]", or "[no capture file]". */ - const QString & fileTitle() { return file_title_; } + const QString fileTitle() { return file_title_ + file_state_; } /** Retap the capture file */ @@ -94,6 +94,7 @@ private: capture_file *cap_file_; QString file_title_; + QString file_state_; }; #endif // CAPTURE_FILE_H diff --git a/ui/qt/capture_file_properties_dialog.cpp b/ui/qt/capture_file_properties_dialog.cpp index c397a0009d..1950b3bfb6 100644 --- a/ui/qt/capture_file_properties_dialog.cpp +++ b/ui/qt/capture_file_properties_dialog.cpp @@ -29,6 +29,7 @@ #include "wsutil/str_util.h" #include "wsutil/ws_version_info.h" +#include "qt_ui_utils.h" #include "wireshark_application.h" #include <QDateTime> @@ -39,17 +40,14 @@ // - Add file hashes // - Add formats (HTML, plain text, YAML)? -CaptureFilePropertiesDialog::CaptureFilePropertiesDialog(QWidget *parent, capture_file *cf) : - QDialog(parent), - ui(new Ui::CaptureFilePropertiesDialog), - cap_file_(cf) +CaptureFilePropertiesDialog::CaptureFilePropertiesDialog(QWidget &parent, CaptureFile &capture_file) : + WiresharkDialog(parent, capture_file), + ui(new Ui::CaptureFilePropertiesDialog) { ui->setupUi(this); // XXX Use recent settings instead - if (parent) { - resize(parent->width() * 2 / 3, parent->height()); - } + resize(parent.width() * 2 / 3, parent.height()); QPushButton *button = ui->buttonBox->button(QDialogButtonBox::Reset); if (button) { @@ -66,11 +64,12 @@ CaptureFilePropertiesDialog::CaptureFilePropertiesDialog(QWidget *parent, captur button->setText(tr("Save Comments")); } + setWindowSubtitle(tr("Capture File Properties")); updateWidgets(); } /* - * Slots + * Slots */ CaptureFilePropertiesDialog::~CaptureFilePropertiesDialog() @@ -80,20 +79,12 @@ CaptureFilePropertiesDialog::~CaptureFilePropertiesDialog() /**/ -void CaptureFilePropertiesDialog::setCaptureFile(capture_file *cf) -{ - if (!cf) { // We only want to know when the file closes. - cap_file_ = NULL; - } - updateWidgets(); -} - void CaptureFilePropertiesDialog::updateWidgets() { QPushButton *refresh_bt = ui->buttonBox->button(QDialogButtonBox::Reset); QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save); - if (!cap_file_) { + if (file_closed_) { if (refresh_bt) { refresh_bt->setEnabled(false); } @@ -104,12 +95,12 @@ void CaptureFilePropertiesDialog::updateWidgets() return; } - bool enable = wtap_dump_can_write(cap_file_->linktypes, WTAP_COMMENT_PER_SECTION); + bool enable = wtap_dump_can_write(cap_file_.capFile()->linktypes, WTAP_COMMENT_PER_SECTION); save_bt->setEnabled(enable); ui->commentsTextEdit->setEnabled(enable); ui->detailsTextEdit->setHtml(summaryToHtml()); - ui->commentsTextEdit->setText(cf_read_shb_comment(cap_file_)); + ui->commentsTextEdit->setText(cf_read_shb_comment(cap_file_.capFile())); } QString CaptureFilePropertiesDialog::timeToString(time_t ti_time) @@ -145,11 +136,11 @@ QString CaptureFilePropertiesDialog::summaryToHtml() table_hheader25_tmpl = "<td width=\"25%\"><u>%1</u></td>"; table_data_tmpl = "<td>%1</td>"; - if (cap_file_) { + if (!file_closed_) { /* initial computations */ - summary_fill_in(cap_file_, &summary); + summary_fill_in(cap_file_.capFile(), &summary); #ifdef HAVE_LIBPCAP - summary_fill_in_capture(cap_file_, &global_capture_opts, &summary); + summary_fill_in_capture(cap_file_.capFile(), &global_capture_opts, &summary); #endif } @@ -514,14 +505,14 @@ void CaptureFilePropertiesDialog::on_buttonBox_helpRequested() void CaptureFilePropertiesDialog::on_buttonBox_accepted() { - if (!cap_file_ || !cap_file_->filename) { + if (file_closed_ || !cap_file_.capFile()->filename) { return; } - if (wtap_dump_can_write(cap_file_->linktypes, WTAP_COMMENT_PER_SECTION)) + if (wtap_dump_can_write(cap_file_.capFile()->linktypes, WTAP_COMMENT_PER_SECTION)) { gchar *str = qstring_strdup(ui->commentsTextEdit->toPlainText()); - cf_update_capture_comment(cap_file_, str); + cf_update_capture_comment(cap_file_.capFile(), str); emit captureCommentChanged(); } } diff --git a/ui/qt/capture_file_properties_dialog.h b/ui/qt/capture_file_properties_dialog.h index 485d7920c5..09272a4994 100644 --- a/ui/qt/capture_file_properties_dialog.h +++ b/ui/qt/capture_file_properties_dialog.h @@ -26,11 +26,11 @@ #include "config.h" +#include <glib.h> + #include <string.h> #include <time.h> -#include "qt_ui_utils.h" - #include <epan/strutil.h> #include <wiretap/wtap.h> @@ -41,8 +41,9 @@ #include "ui/capture_globals.h" #endif +#include "wireshark_dialog.h" + #include <QClipboard> -#include <QDialog> namespace Ui { class CaptureFilePropertiesDialog; @@ -50,17 +51,14 @@ class CaptureFilePropertiesDialog; class QAbstractButton; -class CaptureFilePropertiesDialog : public QDialog +class CaptureFilePropertiesDialog : public WiresharkDialog { Q_OBJECT public: - explicit CaptureFilePropertiesDialog(QWidget *parent = 0, capture_file *cf = NULL); + explicit CaptureFilePropertiesDialog(QWidget &parent, CaptureFile& capture_file); ~CaptureFilePropertiesDialog(); -public slots: - void setCaptureFile(capture_file *cf); - signals: void captureCommentChanged(); @@ -70,7 +68,6 @@ protected slots: private: Ui::CaptureFilePropertiesDialog *ui; - capture_file *cap_file_; QString timeToString(time_t ti_time); QString summaryToHtml(); diff --git a/ui/qt/capture_file_properties_dialog.ui b/ui/qt/capture_file_properties_dialog.ui index 242854557e..5f41e22122 100644 --- a/ui/qt/capture_file_properties_dialog.ui +++ b/ui/qt/capture_file_properties_dialog.ui @@ -16,9 +16,6 @@ <verstretch>0</verstretch> </sizepolicy> </property> - <property name="windowTitle"> - <string>Wireshark - Capture File Properties</string> - </property> <property name="windowIcon"> <iconset resource="../../image/toolbar.qrc"> <normaloff>:/menu/help/wsicon16.png</normaloff>:/menu/help/wsicon16.png</iconset> diff --git a/ui/qt/conversation_dialog.cpp b/ui/qt/conversation_dialog.cpp index ad49ebce2c..161512e1fe 100644 --- a/ui/qt/conversation_dialog.cpp +++ b/ui/qt/conversation_dialog.cpp @@ -57,7 +57,7 @@ // - Misleading bps calculation https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8703 const QString table_name_ = QObject::tr("Conversation"); -ConversationDialog::ConversationDialog(QWidget *parent, CaptureFile &cf, int cli_proto_id, const char *filter) : +ConversationDialog::ConversationDialog(QWidget &parent, CaptureFile &cf, int cli_proto_id, const char *filter) : TrafficTableDialog(parent, cf, filter, table_name_) { follow_bt_ = buttonBox()->addButton(tr("Follow Stream..."), QDialogButtonBox::ActionRole); @@ -198,7 +198,7 @@ conv_item_t *ConversationDialog::currentConversation() void ConversationDialog::followStream() { - if (read_only_) { + if (file_closed_) { return; } @@ -231,7 +231,7 @@ void ConversationDialog::followStream() void ConversationDialog::graphTcp() { - if (read_only_) { + if (file_closed_) { return; } @@ -259,7 +259,7 @@ void ConversationDialog::itemSelectionChanged() bool follow_enable = false, graph_enable = false; conv_item_t *conv_item = currentConversation(); - if (!read_only_ && conv_item) { + if (!file_closed_ && conv_item) { switch (conv_item->ptype) { case PT_TCP: graph_enable = true; @@ -285,7 +285,7 @@ void ConversationDialog::on_nameResolutionCheckBox_toggled(bool checked) void ConversationDialog::on_displayFilterCheckBox_toggled(bool checked) { - if (read_only_) { + if (file_closed_) { return; } diff --git a/ui/qt/conversation_dialog.h b/ui/qt/conversation_dialog.h index 64e46424cc..745020f78d 100644 --- a/ui/qt/conversation_dialog.h +++ b/ui/qt/conversation_dialog.h @@ -56,7 +56,7 @@ public: * @param cli_proto_id If valid, add this protocol and bring it to the front. * @param filter Display filter to apply. */ - explicit ConversationDialog(QWidget *parent, CaptureFile &cf, int cli_proto_id = -1, const char *filter = NULL); + explicit ConversationDialog(QWidget &parent, CaptureFile &cf, int cli_proto_id = -1, const char *filter = NULL); ~ConversationDialog(); public slots: diff --git a/ui/qt/endpoint_dialog.cpp b/ui/qt/endpoint_dialog.cpp index e726a66bf6..fc884e533a 100644 --- a/ui/qt/endpoint_dialog.cpp +++ b/ui/qt/endpoint_dialog.cpp @@ -41,7 +41,7 @@ #include <QUrl> const QString table_name_ = QObject::tr("Endpoint"); -EndpointDialog::EndpointDialog(QWidget *parent, CaptureFile &cf, int cli_proto_id, const char *filter) : +EndpointDialog::EndpointDialog(QWidget &parent, CaptureFile &cf, int cli_proto_id, const char *filter) : TrafficTableDialog(parent, cf, filter, table_name_) { #ifdef HAVE_GEOIP diff --git a/ui/qt/endpoint_dialog.h b/ui/qt/endpoint_dialog.h index 7aa6e5c607..9c78fc9a8b 100644 --- a/ui/qt/endpoint_dialog.h +++ b/ui/qt/endpoint_dialog.h @@ -68,7 +68,7 @@ public: * @param cli_proto_id If valid, add this protocol and bring it to the front. * @param filter Display filter to apply. */ - explicit EndpointDialog(QWidget *parent, CaptureFile &cf, int cli_proto_id = -1, const char *filter = NULL); + explicit EndpointDialog(QWidget &parent, CaptureFile &cf, int cli_proto_id = -1, const char *filter = NULL); ~EndpointDialog(); signals: diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 35538c3aaf..d51dde109a 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -1556,6 +1556,7 @@ void MainWindow::setTitlebarForCaptureFile() // XXX - on non-Mac platforms, put in the application // name? // + // XXX - Use setWindowModified gchar *window_name; setWindowFilePath(NULL); window_name = g_strdup_printf("Capturing from %s[*]", cf_get_tempfile_source(capture_file_.capFile())); //TODO : Fix Translate diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index f1c965224e..5a81aa976a 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -2299,7 +2299,7 @@ void MainWindow::on_actionStatisticsCollectd_triggered() void MainWindow::statCommandConversations(const char *arg, void *userdata) { - ConversationDialog *conv_dialog = new ConversationDialog(this, capture_file_, GPOINTER_TO_INT(userdata), arg); + ConversationDialog *conv_dialog = new ConversationDialog(*this, capture_file_, GPOINTER_TO_INT(userdata), arg); connect(conv_dialog, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)), this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType))); connect(conv_dialog, SIGNAL(openFollowStreamDialog(follow_type_t)), @@ -2316,7 +2316,7 @@ void MainWindow::on_actionStatisticsConversations_triggered() void MainWindow::statCommandEndpoints(const char *arg, void *userdata) { - EndpointDialog *endp_dialog = new EndpointDialog(this, capture_file_, GPOINTER_TO_INT(userdata), arg); + EndpointDialog *endp_dialog = new EndpointDialog(*this, capture_file_, GPOINTER_TO_INT(userdata), arg); connect(endp_dialog, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)), this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType))); connect(endp_dialog, SIGNAL(openFollowStreamDialog(follow_type_t)), @@ -2615,11 +2615,9 @@ void MainWindow::on_actionCaptureStop_triggered() void MainWindow::on_actionStatisticsCaptureFileProperties_triggered() { - CaptureFilePropertiesDialog *capture_file_properties_dialog = new CaptureFilePropertiesDialog(this, capture_file_.capFile()); + CaptureFilePropertiesDialog *capture_file_properties_dialog = new CaptureFilePropertiesDialog(*this, capture_file_); connect(capture_file_properties_dialog, SIGNAL(captureCommentChanged()), this, SLOT(updateForUnsavedChanges())); - connect(this, SIGNAL(setCaptureFile(capture_file*)), - capture_file_properties_dialog, SLOT(setCaptureFile(capture_file*))); capture_file_properties_dialog->show(); } diff --git a/ui/qt/traffic_table_dialog.cpp b/ui/qt/traffic_table_dialog.cpp index 37c1348bc7..29d1d19fa8 100644 --- a/ui/qt/traffic_table_dialog.cpp +++ b/ui/qt/traffic_table_dialog.cpp @@ -49,24 +49,22 @@ // - Columns don't resize correctly. // - Closing the capture file clears conversation data. -TrafficTableDialog::TrafficTableDialog(QWidget *parent, CaptureFile &cf, const char *filter, const QString &table_name) : - QDialog(parent), +TrafficTableDialog::TrafficTableDialog(QWidget &parent, CaptureFile &cf, const char *filter, const QString &table_name) : + WiresharkDialog(parent, cf), ui(new Ui::TrafficTableDialog), cap_file_(cf), - read_only_(false), + file_closed_(false), filter_(filter) { ui->setupUi(this); // setAttribute(Qt::WA_DeleteOnClose, true); - window_name_ = QString("%1s").arg(table_name); - setWindowTitle(); - ui->enabledTypesPushButton->setText(tr("%1 Types").arg(window_name_)); + QString window_name = QString("%1s").arg(table_name); + setWindowSubtitle(window_name); + ui->enabledTypesPushButton->setText(tr("%1 Types").arg(window_name)); // XXX Use recent settings instead - if (parent) { - resize(parent->width(), parent->height() * 3 / 4); - } + resize(parent.width(), parent.height() * 3 / 4); QMenu *copy_menu = new QMenu(); QAction *ca; @@ -93,12 +91,6 @@ TrafficTableDialog::~TrafficTableDialog() delete ui; } -void TrafficTableDialog::captureFileClosing() -{ - setWindowTitle(); - read_only_ = true; -} - const QList<int> TrafficTableDialog::defaultProtos() const { // Reasonable defaults? @@ -226,16 +218,6 @@ void TrafficTableDialog::updateWidgets() ui->trafficTableTabWidget->setUpdatesEnabled(true); } -void TrafficTableDialog::setWindowTitle() -{ - QDialog::setWindowTitle(tr("%1 %2 %3 %4") - .arg(wsApp->windowTitlePrefix()) - .arg(window_name_) - .arg(wsApp->windowTitleSeparator()) - .arg(cap_file_.fileTitle()) - ); -} - QList<QVariant> TrafficTableDialog::curTreeRowData(int row) const { TrafficTableTreeWidget *cur_tree = qobject_cast<TrafficTableTreeWidget *>(ui->trafficTableTabWidget->currentWidget()); diff --git a/ui/qt/traffic_table_dialog.h b/ui/qt/traffic_table_dialog.h index 5fd77cab7c..aac88a40ea 100644 --- a/ui/qt/traffic_table_dialog.h +++ b/ui/qt/traffic_table_dialog.h @@ -32,6 +32,7 @@ #include "capture_file.h" #include "filter_action.h" +#include "wireshark_dialog.h" #include <QPushButton> #include <QCheckBox> @@ -91,7 +92,7 @@ signals: void filterAction(QString& filter, FilterAction::Action action, FilterAction::ActionType type); }; -class TrafficTableDialog : public QDialog +class TrafficTableDialog : public WiresharkDialog { Q_OBJECT @@ -103,11 +104,10 @@ public: * @param filter Display filter to apply. * @param table_name If valid, add this protocol and bring it to the front. */ - explicit TrafficTableDialog(QWidget *parent, CaptureFile &cf, const char *filter = NULL, const QString &table_name = tr("Unknown")); + explicit TrafficTableDialog(QWidget &parent, CaptureFile &cf, const char *filter = NULL, const QString &table_name = tr("Unknown")); ~TrafficTableDialog(); public slots: - virtual void captureFileClosing(); signals: void filterAction(QString& filter, FilterAction::Action action, FilterAction::ActionType type); @@ -118,7 +118,7 @@ protected: Ui::TrafficTableDialog *ui; CaptureFile &cap_file_; - bool read_only_; + bool file_closed_; QString filter_; QMenu traffic_type_menu_; QPushButton *copy_bt_; @@ -141,7 +141,6 @@ protected slots: void updateWidgets(); private: - void setWindowTitle(); QList<QVariant> curTreeRowData(int row) const; QString window_name_; diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp index f634fe1da7..01404eacdf 100644 --- a/ui/qt/wireshark_application.cpp +++ b/ui/qt/wireshark_application.cpp @@ -83,10 +83,7 @@ static bool updated_last_open_dir = FALSE; static QList<recent_item_status *> recent_items_; QString WiresharkApplication::application_name_ = QString("Wireshark"); -QString WiresharkApplication::window_title_separator_ = QString::fromUtf8(UTF8_MIDDLE_DOT); -QString WiresharkApplication::window_title_prefix_ = QString("%1 %2") - .arg(WiresharkApplication::application_name_) - .arg(WiresharkApplication::window_title_separator_); +QString WiresharkApplication::window_title_separator_ = QString::fromUtf8(" " UTF8_MIDDLE_DOT " "); void topic_action(topic_action_e action) @@ -375,7 +372,18 @@ void WiresharkApplication::setConfigurationProfile(const gchar *profile_name) // user_font_apply(); /* Update menus with new recent values */ -// menu_recent_read_finished(); + // menu_recent_read_finished(); +} + +const QString WiresharkApplication::windowTitleString(QStringList title_parts) +{ + QMutableStringListIterator tii(title_parts); + while (tii.hasNext()) { + QString ti = tii.next(); + if (ti.isEmpty()) tii.remove(); + } + title_parts.prepend(application_name_); + return title_parts.join(window_title_separator_); } void WiresharkApplication::setLastOpenDir(const char *dir_name) diff --git a/ui/qt/wireshark_application.h b/ui/qt/wireshark_application.h index 3de29d8695..8c7e070e4d 100644 --- a/ui/qt/wireshark_application.h +++ b/ui/qt/wireshark_application.h @@ -95,7 +95,8 @@ public: const QIcon &captureIcon() const { return capture_icon_; } const QString &applicationName() const { return application_name_; } const QString &windowTitleSeparator() const { return window_title_separator_; } - const QString &windowTitlePrefix() const { return window_title_prefix_; } + const QString windowTitleString(QStringList title_parts); + const QString windowTitleString(QString title_part) { return windowTitleString(QStringList() << title_part); } QTranslator translator; QTranslator translatorQt; @@ -113,7 +114,6 @@ private: QIcon capture_icon_; static QString application_name_; static QString window_title_separator_; - static QString window_title_prefix_; protected: bool event(QEvent *event); diff --git a/ui/qt/wireshark_dialog.cpp b/ui/qt/wireshark_dialog.cpp new file mode 100644 index 0000000000..ae1230df0b --- /dev/null +++ b/ui/qt/wireshark_dialog.cpp @@ -0,0 +1,74 @@ +/* wireshark_dialog.cpp + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* + * @file General dialog base class + * + * Base class which provides convenience methods for dialogs that handle + * capture files. "General" is a misnomer but we already have a class named + * "CaptureFileDialog". + */ + +#include "config.h" + +#include <glib.h> + +#include "wireshark_dialog.h" + +#include "wireshark_application.h" + +// To do: +// - Use a dynamic property + Q_PROPERTY for the subtitle. + + +WiresharkDialog::WiresharkDialog(QWidget &parent, CaptureFile &capture_file) : + QDialog(&parent), + cap_file_(capture_file), + file_closed_(false) +{ + connect(&cap_file_, SIGNAL(captureFileClosing()), this, SLOT(captureFileClosing())); + connect(&cap_file_, SIGNAL(captureFileClosed()), this, SLOT(captureFileClosing())); + setWindowTitle(); +} + +void WiresharkDialog::setWindowSubtitle(const QString &subtitle) +{ + subtitle_ = subtitle; + setWindowTitle(); +} + +void WiresharkDialog::setWindowTitle() +{ + QString title = wsApp->windowTitleString(QStringList() << subtitle_ << cap_file_.fileTitle()); + QDialog::setWindowTitle(title); +} + +void WiresharkDialog::updateWidgets() +{ + setWindowTitle(); +} + +void WiresharkDialog::captureFileClosing() +{ + file_closed_ = true; + setWindowTitle(); + updateWidgets(); +} diff --git a/ui/qt/wireshark_dialog.h b/ui/qt/wireshark_dialog.h new file mode 100644 index 0000000000..348bfa94cb --- /dev/null +++ b/ui/qt/wireshark_dialog.h @@ -0,0 +1,61 @@ +/* wireshark_dialog.cpp + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef WIRESHARK_DIALOG_H +#define WIRESHARK_DIALOG_H + +#include "capture_file.h" + +#include <QDialog> + +class WiresharkDialog : public QDialog +{ + Q_OBJECT + +public: + // XXX Unlike the entire QWidget API, parent is mandatory here. + explicit WiresharkDialog(QWidget &parent, CaptureFile &capture_file); + +signals: + +public slots: + +protected: + void setWindowSubtitle(const QString &subtitle); + virtual void updateWidgets(); + + CaptureFile &cap_file_; + bool file_closed_; + +protected slots: + virtual void captureFileClosing(); + +private: + const QString &windowSubtitle() { return subtitle_; } + void setWindowTitle(); + + QString subtitle_; + +private slots: + +}; + +#endif // WIRESHARK_DIALOG_H |