File indexing completed on 2024-05-12 09:01:09
0001 /* This file is part of the KDE libraries 0002 SPDX-FileCopyrightText: 2003 Stephan Binner <binner@kde.org> 0003 SPDX-FileCopyrightText: 2003 Zack Rusin <zack@kde.org> 0004 SPDX-FileCopyrightText: 2009 Urs Wolfer <uwolfer @ kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef KTABBAR_H 0010 #define KTABBAR_H 0011 0012 #include <QTabBar> 0013 0014 /** 0015 * A QTabBar with extended features. 0016 * 0017 */ 0018 class KTabBar : public QTabBar 0019 { 0020 Q_OBJECT 0021 0022 public: 0023 /** 0024 * Creates a new tab bar. 0025 * 0026 * @param parent The parent widget. 0027 */ 0028 explicit KTabBar(QWidget *parent = nullptr); 0029 0030 /** 0031 * Destroys the tab bar. 0032 */ 0033 ~KTabBar() override; 0034 0035 Q_SIGNALS: 0036 /** 0037 * A right mouse button click was performed over the tab with the @param index. 0038 * The signal is emitted on the press of the mouse button. 0039 */ 0040 void contextMenu(int index, const QPoint &globalPos); 0041 /** 0042 * A right mouse button click was performed over the empty area on the tab bar. 0043 * The signal is emitted on the press of the mouse button. 0044 */ 0045 void emptyAreaContextMenu(const QPoint &globalPos); 0046 /** 0047 * A double left mouse button click was performed over the tab with the @param index. 0048 * The signal is emitted on the second press of the mouse button, before the release. 0049 */ 0050 void tabDoubleClicked(int index); 0051 /** 0052 * A double left mouse button click was performed over the empty area on the tab bar. 0053 * The signal is emitted on the second press of the mouse button, before the release. 0054 */ 0055 void newTabRequest(); 0056 /** 0057 * A double middle mouse button click was performed over the tab with the @param index. 0058 * The signal is emitted on the release of the mouse button. 0059 */ 0060 void mouseMiddleClick(int index); 0061 void initiateDrag(int); 0062 void testCanDecode(const QDragMoveEvent *, bool &); 0063 void receivedDropEvent(int, QDropEvent *); 0064 /** 0065 * Used internally by KTabBar's/KTabWidget's middle-click tab moving mechanism. 0066 * Tells the KTabWidget which owns the KTabBar to move a tab. 0067 */ 0068 void moveTab(int, int); 0069 #ifndef QT_NO_WHEELEVENT 0070 void wheelDelta(int); 0071 #endif 0072 0073 protected: 0074 void mouseDoubleClickEvent(QMouseEvent *event) override; 0075 void mousePressEvent(QMouseEvent *event) override; 0076 void mouseMoveEvent(QMouseEvent *event) override; 0077 #ifndef QT_NO_WHEELEVENT 0078 void wheelEvent(QWheelEvent *event) override; 0079 #endif 0080 0081 void dragEnterEvent(QDragEnterEvent *event) override; 0082 void dragMoveEvent(QDragMoveEvent *event) override; 0083 void dropEvent(QDropEvent *event) override; 0084 0085 void tabLayoutChange() override; 0086 0087 private Q_SLOTS: 0088 void activateDragSwitchTab(); 0089 0090 private: 0091 int selectTab(const QPoint &pos) const; 0092 0093 private: 0094 class Private; 0095 Private *const d; 0096 }; 0097 0098 #endif