Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
detachable_tabwidget.h
1/* @file
2 *
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10#ifndef DETACHABLE_TABWIDGET_H
11#define DETACHABLE_TABWIDGET_H
12
13#include <wireshark.h>
14
15#include <QTabWidget>
16#include <QDialog>
17#include <QEvent>
18#include <QCloseEvent>
19#include <QTabBar>
20#include <QPoint>
21#include <QCursor>
22
26class DetachableTabWidget : public QTabWidget
27{
28 Q_OBJECT
29public:
34 DetachableTabWidget(QWidget * parent = nullptr);
35
40 QString tabBasename() const;
41
42protected:
43
48 void setTabBasename(QString newName);
49
50protected slots:
51
57 virtual void moveTab(int from, int to);
58
64 virtual void detachTab(int tabIdx, QPoint pos);
65
71 virtual void attachTab(QWidget * content, QString name);
72
73private:
75 QString _tabBasename;
76
77};
78
82class ToolDialog : public QDialog
83{
84 Q_OBJECT
85public:
92 explicit ToolDialog(QWidget * _contentWidget, QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
93
94protected:
95
101 virtual bool event(QEvent *event);
102
107 virtual void closeEvent(QCloseEvent *event);
108
109signals:
115 void onCloseSignal(QWidget * contentWidget, QString name);
116
117private:
119 QWidget * _contentWidget;
120};
121
125class DragDropTabBar : public QTabBar
126{
127 Q_OBJECT
128public:
133 explicit DragDropTabBar(QWidget * parent);
134
135signals:
141 void onDetachTab(int tabIdx, QPoint pos);
142
148 void onMoveTab(int oldIdx, int newIdx);
149
150protected:
155 virtual void mouseDoubleClickEvent(QMouseEvent *event);
156
161 virtual void mousePressEvent(QMouseEvent *event);
162
167 virtual void mouseMoveEvent(QMouseEvent *event);
168
173 virtual void dragEnterEvent(QDragEnterEvent *event);
174
179 virtual void dropEvent(QDropEvent *event);
180
181private:
183 QPoint _dragStartPos;
184
186 QPoint _dragDropPos;
187
189 QCursor _mouseCursor;
190
192 bool _dragInitiated;
193
194};
195
196#endif // DETACHABLE_TABWIDGET_H
A QTabWidget extension that allows tabs to be detached into separate windows.
Definition detachable_tabwidget.h:27
QString tabBasename() const
Retrieves the base name used when generating detached tab titles.
Definition detachable_tabwidget.cpp:42
virtual void detachTab(int tabIdx, QPoint pos)
Detaches a tab into its own separate dialog window.
Definition detachable_tabwidget.cpp:56
virtual void moveTab(int from, int to)
Moves a tab from one index to another.
Definition detachable_tabwidget.cpp:46
void setTabBasename(QString newName)
Sets the base name used when generating detached tab titles.
Definition detachable_tabwidget.cpp:38
virtual void attachTab(QWidget *content, QString name)
Attaches a previously detached widget back into the tab widget.
Definition detachable_tabwidget.cpp:83
A customized QTabBar supporting drag and drop operations to reorder or detach tabs.
Definition detachable_tabwidget.h:126
void onMoveTab(int oldIdx, int newIdx)
Signal emitted to indicate a tab has been moved via drag and drop.
virtual void dragEnterEvent(QDragEnterEvent *event)
Handles drag enter events to accept drops.
Definition detachable_tabwidget.cpp:195
virtual void mouseMoveEvent(QMouseEvent *event)
Handles mouse move events to trigger the actual drag operation.
Definition detachable_tabwidget.cpp:151
virtual void dropEvent(QDropEvent *event)
Handles drop events to finalize reordering.
Definition detachable_tabwidget.cpp:204
virtual void mousePressEvent(QMouseEvent *event)
Handles mouse press events to initiate drag tracking.
Definition detachable_tabwidget.cpp:140
virtual void mouseDoubleClickEvent(QMouseEvent *event)
Handles mouse double-click events.
Definition detachable_tabwidget.cpp:134
void onDetachTab(int tabIdx, QPoint pos)
Signal emitted to request a tab detachment.
A dialog wrapper for hosting a detached tab widget.
Definition detachable_tabwidget.h:83
virtual bool event(QEvent *event)
Handles general events directed to the dialog.
Definition detachable_tabwidget.cpp:103
void onCloseSignal(QWidget *contentWidget, QString name)
Signal emitted when the dialog is closing.
virtual void closeEvent(QCloseEvent *event)
Handles the close event, emitting a signal to optionally reattach the content.
Definition detachable_tabwidget.cpp:116