Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
main_window.h
Go to the documentation of this file.
1
9
10#ifndef MAINWINDOW_H
11#define MAINWINDOW_H
12
13#include <epan/prefs.h>
14#include <epan/stat_groups.h>
15#include <epan/frame_data.h>
16
17// frame_data also available with this include in the original wireshark_main_window code
18//#include "follow_stream_dialog.h"
19
20
21#include "capture_file.h"
22#include "filter_action.h"
23#include "io_graph_action.h"
24
25#include <QMainWindow>
26#include <QSplitter>
27
28class QAction;
29class QMenu;
30class QSplitter;
31class QStackedWidget;
32
33class DataSourceTab;
36class FunnelAction;
38class MainStatusBar;
39class PacketDiagram;
40class PacketList;
41class ProfileSwitcher;
42class ProtoTree;
43class WelcomePage;
44
45typedef struct _capture_file capture_file;
46
50class MainWindow : public QMainWindow
51{
52 Q_OBJECT
53public:
58 explicit MainWindow(QWidget *parent = nullptr);
59
64
69 void setMainWindowTitle(QString title = QString());
70
75 bool hasSelection();
76
81 bool hasUniqueSelection();
82
88 QList<int> selectedRows(bool useFrameNum = false);
89
96 void insertColumn(QString name, QString abbrev, int pos = -1);
97
102 void gotoFrame(int packet_num);
103
109 frame_data* frameDataForRow(int row) const;
110
115 QString getFilter();
116
122
128
137
138 // Used for managing custom packet menus
139
144 void appendPacketMenu(FunnelAction *funnel_action);
145
150 QList<QAction*> getPacketMenuActions();
151
156
163 bool addPacketMenus(QMenu * ctx_menu, GPtrArray *finfo_array);
164
165public slots:
172 void setDisplayFilter(QString filter, FilterAction::Action action, FilterAction::ActionType filterType);
173
181 void filterPackets(QString new_filter = QString(), bool force = true);
182
187 virtual void showPreferencesDialog(QString module_name) = 0;
188
194 virtual void showIOGraphDialog(io_graph_item_unit_t value_units, QString yfield) = 0;
195
201 virtual void showPlotDialog(const QString& y_field, bool filtered) = 0;
202
206 void layoutPanes();
207
212
217
222 void cyclePane(bool reverse = false);
223
224protected:
248
266
270 void showWelcome();
271
275 void showCapture();
276
281
286 void setIconForCaptureInProgress(bool capture_in_progress);
287
292 virtual void setMenusForCaptureFile(bool force_disable = false) = 0;
293
296
298 QList<register_stat_group_t> menu_groups_;
299
306
308 QStackedWidget *main_stack_;
309
312
314 QSplitter master_split_;
315
317 QSplitter extra_split_;
318
320 QWidget empty_pane_;
321
323 QVector<unsigned> cur_layout_;
324
327
330
333
336
339
342
345
348
351
353 QMap<QString, const char *> text_codec_map_;
354
355 // Recent captures menu support - set by subclasses
356
359
362#if defined(Q_OS_MAC)
364 QMenu *dock_menu_;
365#endif
366
372
381
386 virtual void openRecentCaptureFile(const QString &filename) = 0;
387
394 virtual bool tryClosingCaptureFile(QString before_what, FileCloseContext context = Default) = 0;
395
396protected slots:
401 void addDisplayFilterTranslationActions(QMenu *copy_menu);
402
407 void updateDisplayFilterTranslationActions(const QString &df_text);
408
412 void updateTitlebar();
413
419 virtual void applyFilter(QString new_filter, bool force) = 0;
420
421private:
427 QString replaceWindowTitleVariables(QString title);
428
432 void findTextCodecs();
433
435 QVector<QAction *> df_translate_actions_;
436
438 static const char *translator_;
439
441 static const char *translated_filter_;
442
443private slots:
447 void copyDisplayFilterTranslation(void);
448
449signals:
455
460 void captureActive(int active);
461
467
473
478 void framesSelected(QList<int> frames);
479
487
492 void displayFilterSuccess(bool success);
493};
494
495#endif // MAINWINDOW_H
struct _capture_file capture_file
Represents a capture file and its associated metadata.
Manages a capture file and its associated state and operations.
Definition capture_file.h:27
A tab widget that manages and displays different data sources for a packet (e.g., Hex,...
Definition data_source_tab.h:36
Display-filter entry: the FilterExpressionEdit leaf for dfilters.
Definition display_filter_entry.h:37
Represents information about a dissected packet field.
Definition field_information.h:26
Action
Defines an action to be taken with a filter.
Definition filter_action.h:30
ActionType
Defines how the new filter should be combined with the existing one.
Definition filter_action.h:43
An action representing a specific funnel menu or packet menu command.
Definition funnel_statistics.h:167
GUI-thread coordinator for local interface enumeration and statistics.
Definition interface_list_manager.h:55
The main status bar of the application.
Definition main_status_bar.h:36
virtual void showIOGraphDialog(io_graph_item_unit_t value_units, QString yfield)=0
Shows the IO graph dialog.
QAction * no_recent_files_action_
Definition main_window.h:361
QList< QAction * > getPacketMenuActions()
Retrieves the list of custom packet menu actions.
Definition main_window.cpp:300
QSplitter extra_split_
Definition main_window.h:317
void setTitlebarForCaptureInProgress()
Sets the title bar text for when a capture is in progress.
Definition main_window.cpp:527
void framesSelected(QList< int > frames)
Signal emitted when frames are selected.
virtual bool tryClosingCaptureFile(QString before_what, FileCloseContext context=Default)=0
Tries to safely close the current capture file.
MainStatusBar * main_status_bar_
Definition main_window.h:341
void setCaptureFile(capture_file *cf)
Signal emitted to set a new capture file.
virtual void applyFilter(QString new_filter, bool force)=0
Applies a new display filter to the open capture file.
bool use_capturing_title_
Definition main_window.h:350
frame_data * frameDataForRow(int row) const
Retrieves frame data for a specific row.
Definition main_window.cpp:230
PacketList * packet_list_
Definition main_window.h:326
void retranslateUiElements()
Handle retranslation of UI elements in MainWindow.
Definition main_window.cpp:650
void showWelcome()
Displays the welcome screen.
Definition main_window_layout.cpp:39
void updateDisplayFilterTranslationActions(const QString &df_text)
Updates the available translation actions based on filter text.
Definition main_window.cpp:409
QVector< unsigned > cur_layout_
Definition main_window.h:323
MainStatusBar * statusBar()
Retrieves the main status bar.
Definition main_window.cpp:262
void fieldSelected(FieldInformation *finfo)
Signal emitted when a field is selected.
void filterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type)
Signal emitted to perform a filter action.
QList< int > selectedRows(bool useFrameNum=false)
Retrieves the selected rows.
Definition main_window.cpp:223
InterfaceListManager * interfaceListManager() const
Returns the local interface enumeration/statistics coordinator.
Definition main_window.cpp:100
void filterPackets(QString new_filter=QString(), bool force=true)
Sets and applies a new display filter to the open capture file.
Definition main_window.cpp:272
void showCapture()
Displays the main capture view.
Definition main_window_layout.cpp:44
virtual void openRecentCaptureFile(const QString &filename)=0
Open a capture file from the recent files menu.
CopySelected
Enumeration for determining what to copy when items are selected.
Definition main_window.h:228
@ CopyAllVisibleItems
Copy all visible items.
Definition main_window.h:230
@ CopyListAsText
Copy the list formatted as text.
Definition main_window.h:240
@ CopySelectedFieldName
Copy the selected field name.
Definition main_window.h:236
@ CopyListAsHTML
Copy the list formatted as HTML.
Definition main_window.h:246
@ CopyAllVisibleSelectedTreeItems
Copy all visible items within the selected tree.
Definition main_window.h:232
@ CopySelectedValue
Copy the selected value.
Definition main_window.h:238
@ CopyListAsYAML
Copy the list formatted as YAML.
Definition main_window.h:244
@ CopyListAsCSV
Copy the list formatted as CSV.
Definition main_window.h:242
@ CopySelectedDescription
Copy the selected description.
Definition main_window.h:234
void fieldHighlight(FieldInformation *finfo)
Signal emitted when a field is highlighted.
void setMainWindowTitle(QString title=QString())
Sets the title of the main window.
Definition main_window.cpp:494
void appendPacketMenu(FunnelAction *funnel_action)
Appends a custom packet menu action.
Definition main_window.cpp:285
void clearAddedPacketMenus()
Clears the recently added custom packet menus.
Definition main_window.cpp:317
void layoutPanes()
Recalculates and lays out the panes.
Definition main_window_layout.cpp:107
QStackedWidget * main_stack_
Definition main_window.h:308
PacketDiagram * packet_diagram_
Definition main_window.h:335
void insertColumn(QString name, QString abbrev, int pos=-1)
Inserts a column into the view.
Definition main_window.cpp:238
void cyclePane(bool reverse=false)
Cycles the focus through the available panes.
Definition main_window_layout.cpp:76
void populateRecentCapturesMenu()
Populate the recent captures menu. Calls openRecentCaptureFile() for each menu item action.
Definition main_window.cpp:572
void setDisplayFilter(QString filter, FilterAction::Action action, FilterAction::ActionType filterType)
Sets the display filter and performs an action.
Definition main_window.cpp:267
MainWindow(QWidget *parent=nullptr)
Constructs a new MainWindow.
Definition main_window.cpp:50
CaptureFile * captureFile()
Returns a pointer to the current capture file object.
Definition main_window.h:127
QMenu * recent_captures_menu_
Definition main_window.h:358
void displayFilterSuccess(bool success)
Signal emitted when a display filter is successfully applied.
void applyRecentPaneGeometry()
Applies the most recent pane geometry settings.
Definition main_window_layout.cpp:237
QMap< QString, const char * > text_codec_map_
Definition main_window.h:353
QString getFilter()
Retrieves the current display filter.
Definition main_window.cpp:257
CaptureFile capture_file_
Definition main_window.h:295
QWidget * getLayoutWidget(layout_pane_content_e type)
Retrieves the widget corresponding to a layout pane content type.
Definition main_window_layout.cpp:52
QSplitter master_split_
Definition main_window.h:314
virtual void showPreferencesDialog(QString module_name)=0
Shows the preferences dialog for a specific module.
DataSourceTab * data_source_tab_
Definition main_window.h:332
void captureActive(int active)
Signal emitted when a capture becomes active.
void setIconForCaptureInProgress(bool capture_in_progress)
Sets the window icon to indicate if a capture is in progress.
Definition main_window.cpp:557
InterfaceListManager * interface_list_manager_
Definition main_window.h:347
bool addPacketMenus(QMenu *ctx_menu, GPtrArray *finfo_array)
Adds packet menus to the given context menu.
Definition main_window.cpp:337
void updateForUnsavedChanges()
Updates the UI to reflect unsaved changes.
Definition main_window_layout.cpp:302
QList< register_stat_group_t > menu_groups_
Definition main_window.h:298
ProtoTree * proto_tree_
Definition main_window.h:329
ProfileSwitcher * profile_switcher_
Definition main_window.h:344
void addDisplayFilterTranslationActions(QMenu *copy_menu)
Adds translation actions for the display filter to a menu.
Definition main_window.cpp:377
QWidget empty_pane_
Definition main_window.h:320
void updateTitlebar()
Updates the main title bar text.
Definition main_window.cpp:533
WelcomePage * welcome_page_
Definition main_window.h:311
~MainWindow()
Destroys the MainWindow.
Definition main_window.cpp:95
bool hasUniqueSelection()
Checks if the current selection is unique.
Definition main_window.cpp:216
bool hasSelection()
Checks if there is a current selection.
Definition main_window.cpp:204
void gotoFrame(int packet_num)
Navigates to a specific frame number.
Definition main_window.cpp:250
virtual void setMenusForCaptureFile(bool force_disable=false)=0
Sets up the menus for the active capture file.
DisplayFilterEntry * df_combo_box_
Definition main_window.h:338
FileCloseContext
Context under which a capture file is being closed.
Definition main_window.h:252
@ Update
Closing as part of an update.
Definition main_window.h:262
@ Export
Closing to export the file.
Definition main_window.h:264
@ Quit
Closing because the application is quitting.
Definition main_window.h:256
@ Restart
Closing because the application is restarting.
Definition main_window.h:258
@ Default
Default closing context.
Definition main_window.h:254
@ Reload
Closing to reload the file.
Definition main_window.h:260
virtual void showPlotDialog(const QString &y_field, bool filtered)=0
Shows a plot dialog.
A graphics view widget for displaying protocol packet diagrams.
Definition packet_diagram.h:29
The main packet list view for displaying captured packets.
Definition packet_list.h:45
Monitors incoming packets and automatically switches the active configuration profile when a packet m...
Definition profile_switcher.h:38
A tree view for displaying protocol dissection details.
Definition proto_tree.h:30
Widget displayed on application startup, providing interface selection, capture filter configuration,...
Definition welcome_page.h:31
DIAG_OFF_PEDANTIC struct _frame_data frame_data
Frame data structure.
io_graph_item_unit_t
Selects the Y-axis value unit or aggregate calculation mode for an I/O graph plot.
Definition io_graph_item.h:29
layout_pane_content_e
Content assigned to a single layout pane in the main window.
Definition prefs.h:108
Represents a capture file and its associated metadata.
Definition cfile.h:84