File indexing completed on 2024-04-14 05:38:43

0001 /*
0002  * SPDX-FileCopyrightText: 2014 Emmanuel Pescosta <emmanuelpescosta099@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef DOLPHIN_TAB_BAR_H
0008 #define DOLPHIN_TAB_BAR_H
0009 
0010 #include <QTabBar>
0011 
0012 class DolphinTabBar : public QTabBar
0013 {
0014     Q_OBJECT
0015 
0016 public:
0017     explicit DolphinTabBar(QWidget *parent);
0018 
0019 Q_SIGNALS:
0020     void openNewActivatedTab(int index);
0021     void tabDropEvent(int index, QDropEvent *event);
0022     void tabDetachRequested(int index);
0023 
0024 protected:
0025     void dragEnterEvent(QDragEnterEvent *event) override;
0026     void dragLeaveEvent(QDragLeaveEvent *event) override;
0027     void dragMoveEvent(QDragMoveEvent *event) override;
0028     void dropEvent(QDropEvent *event) override;
0029     void mousePressEvent(QMouseEvent *event) override;
0030     void mouseReleaseEvent(QMouseEvent *event) override;
0031     void mouseDoubleClickEvent(QMouseEvent *event) override;
0032 
0033     /**
0034      * Opens a context menu for the tab on the \a event position.
0035      */
0036     void contextMenuEvent(QContextMenuEvent *event) override;
0037 
0038 private Q_SLOTS:
0039     void slotAutoActivationTimeout();
0040 
0041 private:
0042     /**
0043      * If \a index is a valid index (>= 0), store the index and start the timer
0044      * (if the interval >= 0 ms). If the index is not valid (< 0), stop the timer.
0045      */
0046     void updateAutoActivationTimer(const int index);
0047 
0048 private:
0049     QTimer *m_autoActivationTimer;
0050     int m_autoActivationIndex;
0051     int m_tabToBeClosedOnMiddleMouseButtonRelease;
0052 };
0053 
0054 #endif // DOLPHIN_TAB_BAR_H