| Wireshark 4.7.3 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
26 class DetachableTabWidget : public QTabWidget
27{
28 Q_OBJECT
29 public:
34 DetachableTabWidget(QWidget * parent = nullptr);
35
40 QString tabBasename() const;
41
42 protected:
43
48 void setTabBasename(QString newName);
49
50 protected 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
73 private:
75 QString _tabBasename;
76
77};
78
82 class ToolDialog : public QDialog
83{
84 Q_OBJECT
85 public:
92 explicit ToolDialog(QWidget * _contentWidget, QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
93
94 protected:
95
101 virtual bool event(QEvent *event) override;
102
107 virtual void closeEvent(QCloseEvent *event) override;
108
109signals:
115 void onCloseSignal(QWidget * contentWidget, QString name);
116
117 private:
119 QWidget * _contentWidget;
120};
121
125 class DragDropTabBar : public QTabBar
126{
127 Q_OBJECT
128 public:
133 explicit DragDropTabBar(QWidget * parent);
134
135signals:
141 void onDetachTab(int tabIdx, QPoint pos);
142
148 void onMoveTab(int oldIdx, int newIdx);
149
150 protected:
155 virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
156
161 virtual void mousePressEvent(QMouseEvent *event) override;
162
167 virtual void mouseMoveEvent(QMouseEvent *event) override;
168
173 virtual void dragEnterEvent(QDragEnterEvent *event) override;
174
179 virtual void dropEvent(QDropEvent *event) override;
180
181 private:
183 QPoint _dragStartPos;
184
186 QPoint _dragDropPos;
187
189 QCursor _mouseCursor;
190
192 bool _dragInitiated;
193
194};
195
196#endif // DETACHABLE_TABWIDGET_H
DetachableTabWidget::tabBasename
QString tabBasename() const
Retrieves the base name used when generating detached tab titles.
Definition detachable_tabwidget.cpp:42
DetachableTabWidget::detachTab
virtual void detachTab(int tabIdx, QPoint pos)
Detaches a tab into its own separate dialog window.
Definition detachable_tabwidget.cpp:56
DetachableTabWidget::moveTab
virtual void moveTab(int from, int to)
Moves a tab from one index to another.
Definition detachable_tabwidget.cpp:46
DetachableTabWidget::DetachableTabWidget
DetachableTabWidget(QWidget *parent=nullptr)
Constructs a new DetachableTabWidget.
Definition detachable_tabwidget.cpp:26
DetachableTabWidget::setTabBasename
void setTabBasename(QString newName)
Sets the base name used when generating detached tab titles.
Definition detachable_tabwidget.cpp:38
DetachableTabWidget::attachTab
virtual void attachTab(QWidget *content, QString name)
Attaches a previously detached widget back into the tab widget.
Definition detachable_tabwidget.cpp:83
DragDropTabBar::mousePressEvent
virtual void mousePressEvent(QMouseEvent *event) override
Handles mouse press events to initiate drag tracking.
Definition detachable_tabwidget.cpp:140
DragDropTabBar::onMoveTab
void onMoveTab(int oldIdx, int newIdx)
Signal emitted to indicate a tab has been moved via drag and drop.
DragDropTabBar::dragEnterEvent
virtual void dragEnterEvent(QDragEnterEvent *event) override
Handles drag enter events to accept drops.
Definition detachable_tabwidget.cpp:195
DragDropTabBar::dropEvent
virtual void dropEvent(QDropEvent *event) override
Handles drop events to finalize reordering.
Definition detachable_tabwidget.cpp:204
DragDropTabBar::DragDropTabBar
DragDropTabBar(QWidget *parent)
Constructs a new DragDropTabBar.
Definition detachable_tabwidget.cpp:121
DragDropTabBar::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *event) override
Handles mouse move events to trigger the actual drag operation.
Definition detachable_tabwidget.cpp:151
DragDropTabBar::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(QMouseEvent *event) override
Handles mouse double-click events.
Definition detachable_tabwidget.cpp:134
DragDropTabBar::onDetachTab
void onDetachTab(int tabIdx, QPoint pos)
Signal emitted to request a tab detachment.
ToolDialog::event
virtual bool event(QEvent *event) override
Handles general events directed to the dialog.
Definition detachable_tabwidget.cpp:103
ToolDialog::ToolDialog
ToolDialog(QWidget *_contentWidget, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
Constructs a new ToolDialog.
Definition detachable_tabwidget.cpp:92
ToolDialog::closeEvent
virtual void closeEvent(QCloseEvent *event) override
Handles the close event, emitting a signal to optionally reattach the content.
Definition detachable_tabwidget.cpp:116
ToolDialog::onCloseSignal
void onCloseSignal(QWidget *contentWidget, QString name)
Signal emitted when the dialog is closing.