summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2012-10-16 19:47:43 +0000
committerGerald Combs <gerald@wireshark.org>2012-10-16 19:47:43 +0000
commit9f1fd13e9a678b361840a016f55d564e028f87bf (patch)
treed2894dd2301b2e44a7c7b8a59f4eff2a9f0908f5 /ui
parent696ea123be7da4b81e52dc4d65a078d97fd0c2ba (diff)
downloadwireshark-9f1fd13e9a678b361840a016f55d564e028f87bf.tar.gz
Use topic_action instead of topic_cb for the Windows file dialogs. Move
the common Qt help code to wireshark_application.cpp. svn path=/trunk/; revision=45594
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk/help_dlg.c2
-rw-r--r--ui/help_url.h6
-rw-r--r--ui/qt/capture_file_dialog.cpp28
-rw-r--r--ui/qt/export_dissection_dialog.cpp9
-rw-r--r--ui/qt/file_set_dialog.cpp12
-rw-r--r--ui/qt/import_text_dialog.cpp9
-rw-r--r--ui/qt/main_window_slots.cpp45
-rw-r--r--ui/qt/wireshark_application.cpp20
-rw-r--r--ui/qt/wireshark_application.h3
-rw-r--r--ui/win32/file_dlg_win32.c16
10 files changed, 63 insertions, 87 deletions
diff --git a/ui/gtk/help_dlg.c b/ui/gtk/help_dlg.c
index bcd77bc00e..77d437ae81 100644
--- a/ui/gtk/help_dlg.c
+++ b/ui/gtk/help_dlg.c
@@ -83,7 +83,7 @@ void help_redraw(void)
}
}
-static void
+void
topic_action(topic_action_e action)
{
char *url;
diff --git a/ui/help_url.h b/ui/help_url.h
index a2d7c4a489..c4e247813a 100644
--- a/ui/help_url.h
+++ b/ui/help_url.h
@@ -148,6 +148,12 @@ gchar *user_guide_url(const gchar *page);
*/
gchar *topic_action_url(topic_action_e action);
+/** Open a specific topic (create a "Help" dialog box or open a webpage).
+ *
+ * @param topic the topic to display
+ */
+void topic_action(topic_action_e topic);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp
index 845a635ea2..82f6773f52 100644
--- a/ui/qt/capture_file_dialog.cpp
+++ b/ui/qt/capture_file_dialog.cpp
@@ -38,6 +38,9 @@
#include "../../epan/prefs.h"
#include "../../epan/filesystem.h"
#include "../../epan/nstime.h"
+
+#include <wireshark_application.h>
+
#include <QGridLayout>
#include <QHBoxLayout>
#include <QVBoxLayout>
@@ -47,8 +50,6 @@
#include <QFileInfo>
#include <QMessageBox>
#include <QSpacerItem>
-#include <QDesktopServices>
-#include <QUrl>
#endif // Q_WS_WIN
#include <QDebug>
@@ -86,18 +87,7 @@ extern void menu_name_resolution_changed(void) {
}
-// From gtk/help_dlg.[ch]
-/** Open a specific topic (create a "Help" dialog box or open a webpage).
- *
- * @param widget parent widget (unused)
- * @param topic the topic to display
- */
-extern void topic_cb(gpointer *widget, int topic) {
- Q_UNUSED(widget);
- Q_UNUSED(topic);
-}
-
-}
+} // extern "C"
// End stub routines
#endif // Q_WS_WIN
@@ -793,15 +783,7 @@ void CaptureFileDialog::preview(const QString & path)
void CaptureFileDialog::on_buttonBox_helpRequested()
{
- gchar *url;
-
- if (help_topic_ == TOPIC_ACTION_NONE) return;
-
- url = topic_action_url(help_topic_);
- if(url != NULL) {
- QDesktopServices::openUrl(QUrl(url));
- g_free(url);
- }
+ if (help_topic_ != TOPIC_ACTION_NONE) wsApp->helpTopicAction(help_topic_);
}
#endif // Q_WS_WINDOWS
diff --git a/ui/qt/export_dissection_dialog.cpp b/ui/qt/export_dissection_dialog.cpp
index 59920d04f0..a1394a7eeb 100644
--- a/ui/qt/export_dissection_dialog.cpp
+++ b/ui/qt/export_dissection_dialog.cpp
@@ -41,8 +41,6 @@
#include <QGridLayout>
#include <QPushButton>
#include <QMessageBox>
-#include <QDesktopServices>
-#include <QUrl>
#include <QDebug>
#endif // Q_WS_WIN
@@ -246,11 +244,6 @@ void ExportDissectionDialog::checkValidity()
void ExportDissectionDialog::on_buttonBox_helpRequested()
{
- gchar *url = topic_action_url(HELP_EXPORT_FILE_DIALOG);
-
- if(url != NULL) {
- QDesktopServices::openUrl(QUrl(url));
- g_free(url);
- }
+ wsApp->helpTopicAction(HELP_EXPORT_FILE_DIALOG);
}
#endif // Q_WS_WIN
diff --git a/ui/qt/file_set_dialog.cpp b/ui/qt/file_set_dialog.cpp
index 3ee73a67ef..17f87608e1 100644
--- a/ui/qt/file_set_dialog.cpp
+++ b/ui/qt/file_set_dialog.cpp
@@ -32,15 +32,14 @@
#include "file_set_dialog.h"
#include "ui_file_set_dialog.h"
+#include "wireshark_application.h"
#include <QDialogButtonBox>
#include <QPushButton>
#include <QDateTime>
#include <QFontMetrics>
-#include <QDesktopServices>
-#include <QUrl>
#include <QFont>
-
+#include <QUrl>
Q_DECLARE_METATYPE(fileset_entry *)
@@ -169,12 +168,7 @@ QString FileSetDialog::nameToDate(const char *name) {
void FileSetDialog::on_buttonBox_helpRequested()
{
- gchar *url = topic_action_url(HELP_FILESET_DIALOG);
-
- if(url != NULL) {
- QDesktopServices::openUrl(QUrl(url));
- g_free(url);
- }
+ wsApp->helpTopicAction(HELP_FILESET_DIALOG);
}
void FileSetDialog::on_fileSetTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
diff --git a/ui/qt/import_text_dialog.cpp b/ui/qt/import_text_dialog.cpp
index 1acbcb1558..f1ab88b672 100644
--- a/ui/qt/import_text_dialog.cpp
+++ b/ui/qt/import_text_dialog.cpp
@@ -47,8 +47,6 @@
#include <QFileDialog>
#include <QDebug>
#include <QFile>
-#include <QDesktopServices>
-#include <QUrl>
ImportTextDialog::ImportTextDialog(QWidget *parent) :
QDialog(parent),
@@ -425,12 +423,7 @@ void ImportTextDialog::on_maxLengthLineEdit_textChanged(const QString &max_frame
void ImportTextDialog::on_buttonBox_helpRequested()
{
- gchar *url = topic_action_url(HELP_IMPORT_DIALOG);
-
- if(url != NULL) {
- QDesktopServices::openUrl(QUrl(url));
- g_free(url);
- }
+ wsApp->helpTopicAction(HELP_IMPORT_DIALOG);
}
/*
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 33f1b711cd..450b3148fe 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -61,21 +61,6 @@
#include "wireshark_application.h"
#include "capture_file_dialog.h"
-// Copied from gtk/help_dlg.[ch]. Need to move to qt/help_dlg.[ch].
-// Required for on_actionHelp* below.
-static void
-topic_action(topic_action_e action)
-{
- char *url;
-
- url = topic_action_url(action);
-
- if(url != NULL) {
- QDesktopServices::openUrl(QUrl(url));
- g_free(url);
- }
-}
-
//
// Public slots
//
@@ -825,70 +810,70 @@ void MainWindow::on_actionFileExportSSLSessionKeys_triggered()
// Help Menu
void MainWindow::on_actionHelpContents_triggered() {
- topic_action(HELP_CONTENT);
+ wsApp->helpTopicAction(HELP_CONTENT);
}
void MainWindow::on_actionHelpMPWireshark_triggered() {
- topic_action(LOCALPAGE_MAN_WIRESHARK);
+ wsApp->helpTopicAction(LOCALPAGE_MAN_WIRESHARK);
}
void MainWindow::on_actionHelpMPWireshark_Filter_triggered() {
- topic_action(LOCALPAGE_MAN_WIRESHARK_FILTER);
+ wsApp->helpTopicAction(LOCALPAGE_MAN_WIRESHARK_FILTER);
}
void MainWindow::on_actionHelpMPTShark_triggered() {
- topic_action(LOCALPAGE_MAN_TSHARK);
+ wsApp->helpTopicAction(LOCALPAGE_MAN_TSHARK);
}
void MainWindow::on_actionHelpMPRawShark_triggered() {
- topic_action(LOCALPAGE_MAN_RAWSHARK);
+ wsApp->helpTopicAction(LOCALPAGE_MAN_RAWSHARK);
}
void MainWindow::on_actionHelpMPDumpcap_triggered() {
- topic_action(LOCALPAGE_MAN_DUMPCAP);
+ wsApp->helpTopicAction(LOCALPAGE_MAN_DUMPCAP);
}
void MainWindow::on_actionHelpMPMergecap_triggered() {
- topic_action(LOCALPAGE_MAN_MERGECAP);
+ wsApp->helpTopicAction(LOCALPAGE_MAN_MERGECAP);
}
void MainWindow::on_actionHelpMPEditcap_triggered() {
- topic_action(LOCALPAGE_MAN_EDITCAP);
+ wsApp->helpTopicAction(LOCALPAGE_MAN_EDITCAP);
}
void MainWindow::on_actionHelpMPText2cap_triggered() {
- topic_action(LOCALPAGE_MAN_TEXT2PCAP);
+ wsApp->helpTopicAction(LOCALPAGE_MAN_TEXT2PCAP);
}
void MainWindow::on_actionHelpWebsite_triggered() {
- topic_action(ONLINEPAGE_HOME);
+ wsApp->helpTopicAction(ONLINEPAGE_HOME);
}
void MainWindow::on_actionHelpFAQ_triggered() {
- topic_action(ONLINEPAGE_FAQ);
+ wsApp->helpTopicAction(ONLINEPAGE_FAQ);
}
void MainWindow::on_actionHelpAsk_triggered() {
- topic_action(ONLINEPAGE_ASK);
+ wsApp->helpTopicAction(ONLINEPAGE_ASK);
}
void MainWindow::on_actionHelpDownloads_triggered() {
- topic_action(ONLINEPAGE_DOWNLOAD);
+ wsApp->helpTopicAction(ONLINEPAGE_DOWNLOAD);
}
void MainWindow::on_actionHelpWiki_triggered() {
- topic_action(ONLINEPAGE_WIKI);
+ wsApp->helpTopicAction(ONLINEPAGE_WIKI);
}
void MainWindow::on_actionHelpSampleCaptures_triggered() {
- topic_action(ONLINEPAGE_SAMPLE_FILES);
+ wsApp->helpTopicAction(ONLINEPAGE_SAMPLE_FILES);
}
void MainWindow::on_actionGoGoToPacket_triggered() {
diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp
index a1de3a71a7..c8d4d4f6a0 100644
--- a/ui/qt/wireshark_application.cpp
+++ b/ui/qt/wireshark_application.cpp
@@ -33,6 +33,8 @@
#include <QDir>
#include <QTimer>
+#include <QDesktopServices>
+#include <QUrl>
#ifdef Q_WS_WIN
#include <QLibrary>
@@ -48,6 +50,12 @@ static char *last_open_dir = NULL;
static bool updated_last_open_dir = FALSE;
static QList<recent_item_status *> recent_items;
+void
+topic_action(topic_action_e action)
+{
+ if (wsApp) wsApp->helpTopicAction(action);
+}
+
extern "C" char *
get_last_open_dir(void)
{
@@ -270,6 +278,18 @@ void WiresharkApplication::setLastOpenDir(QString *dir_str) {
setLastOpenDir(dir_str->toUtf8().constData());
}
+void WiresharkApplication::helpTopicAction(topic_action_e action)
+{
+ char *url;
+
+ url = topic_action_url(action);
+
+ if(url != NULL) {
+ QDesktopServices::openUrl(QUrl(url));
+ g_free(url);
+ }
+}
+
void WiresharkApplication::setLastOpenDir(const char *dir_name)
{
qint64 len;
diff --git a/ui/qt/wireshark_application.h b/ui/qt/wireshark_application.h
index c620ceff69..9b613fa242 100644
--- a/ui/qt/wireshark_application.h
+++ b/ui/qt/wireshark_application.h
@@ -31,6 +31,8 @@
#include "capture_opts.h"
#include "file.h"
+#include "ui/help_url.h"
+
#include <QApplication>
#include <QList>
#include <QFileInfo>
@@ -63,6 +65,7 @@ public:
QDir lastOpenDir();
void setLastOpenDir(const char *dir_name);
void setLastOpenDir(QString *dir_str);
+ void helpTopicAction(topic_action_e action);
private:
QTimer *recent_timer_;
diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c
index 88341eb7d3..ad1bb6478a 100644
--- a/ui/win32/file_dlg_win32.c
+++ b/ui/win32/file_dlg_win32.c
@@ -52,6 +52,7 @@
#include "merge.h"
#include "ui/alert_box.h"
+#include "ui/help_url.h"
#include "ui/file_dialog.h"
#include "ui/last_open_dir.h"
#include "ui/simple_dialog.h"
@@ -65,7 +66,6 @@
#include "ui/gtk/drag_and_drop.h"
#include "ui/gtk/capture_dlg.h"
#include "file_dlg_win32.h"
-#include "ui/gtk/help_dlg.h"
#include "ui/gtk/export_sslkeys.h"
#define FILE_OPEN_DEFAULT 1 /* All Files */
@@ -1399,7 +1399,7 @@ open_file_hook_proc(HWND of_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
preview_set_file_info(of_hwnd, utf_16to8(sel_name));
break;
case CDN_HELP:
- topic_cb(NULL, HELP_OPEN_WIN32_DIALOG);
+ topic_action(HELP_OPEN_WIN32_DIALOG);
break;
default:
break;
@@ -1659,7 +1659,7 @@ save_as_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
case WM_NOTIFY:
switch (notify->hdr.code) {
case CDN_HELP:
- topic_cb(NULL, HELP_SAVE_WIN32_DIALOG);
+ topic_action(HELP_SAVE_WIN32_DIALOG);
break;
case CDN_FILEOK: {
HWND parent;
@@ -1764,7 +1764,7 @@ export_specified_packets_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param,
case WM_NOTIFY:
switch (notify->hdr.code) {
case CDN_HELP:
- topic_cb(NULL, HELP_SAVE_WIN32_DIALOG);
+ topic_action(HELP_SAVE_WIN32_DIALOG);
break;
case CDN_FILEOK: {
HWND parent;
@@ -2163,7 +2163,7 @@ merge_file_hook_proc(HWND mf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
preview_set_file_info(mf_hwnd, utf_16to8(sel_name));
break;
case CDN_HELP:
- topic_cb(NULL, HELP_MERGE_WIN32_DIALOG);
+ topic_action(HELP_MERGE_WIN32_DIALOG);
break;
default:
break;
@@ -2234,7 +2234,7 @@ export_file_hook_proc(HWND ef_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
}
break;
case CDN_HELP:
- topic_cb(NULL, HELP_EXPORT_FILE_WIN32_DIALOG);
+ topic_action(HELP_EXPORT_FILE_WIN32_DIALOG);
break;
default:
break;
@@ -2263,7 +2263,7 @@ export_raw_file_hook_proc(HWND ef_hwnd, UINT msg, WPARAM w_param, LPARAM l_param
case WM_NOTIFY:
switch (notify->hdr.code) {
case CDN_HELP:
- topic_cb(NULL, HELP_EXPORT_BYTES_WIN32_DIALOG);
+ topic_action(HELP_EXPORT_BYTES_WIN32_DIALOG);
break;
default:
break;
@@ -2291,7 +2291,7 @@ export_sslkeys_file_hook_proc(HWND ef_hwnd, UINT msg, WPARAM w_param, LPARAM l_p
case WM_NOTIFY:
switch (notify->hdr.code) {
case CDN_HELP:
- topic_cb(NULL, HELP_EXPORT_BYTES_WIN32_DIALOG);
+ topic_action(HELP_EXPORT_BYTES_WIN32_DIALOG);
break;
default:
break;