File indexing completed on 2024-04-28 05:50:53

0001 /*
0002     SPDX-FileCopyrightText: 2018 Tomaz Canabrava <tcanabrava@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef DETACHABLETABBAR_H
0008 #define DETACHABLETABBAR_H
0009 
0010 #include <QCursor>
0011 #include <QTabBar>
0012 
0013 class QColor;
0014 class QPaintEvent;
0015 
0016 namespace Konsole
0017 {
0018 class TabbedViewContainer;
0019 class DetachableTabBar : public QTabBar
0020 {
0021     Q_OBJECT
0022 public:
0023     enum class DragType : unsigned char {
0024         NONE,
0025         OUTSIDE,
0026         WINDOW,
0027     };
0028 
0029     explicit DetachableTabBar(QWidget *parent = nullptr);
0030 
0031     void setColor(int idx, const QColor &color);
0032     void removeColor(int idx);
0033 Q_SIGNALS:
0034     void detachTab(int index);
0035     void moveTabToWindow(int tabIndex, QWidget *otherWindow);
0036     void closeTab(int index);
0037     void newTabRequest();
0038 
0039 protected:
0040     void middleMouseButtonClickAt(const QPoint &pos);
0041     void mousePressEvent(QMouseEvent *event) override;
0042     void mouseMoveEvent(QMouseEvent *event) override;
0043     void mouseReleaseEvent(QMouseEvent *event) override;
0044     void dragEnterEvent(QDragEnterEvent *event) override;
0045     void dragMoveEvent(QDragMoveEvent *event) override;
0046     void paintEvent(QPaintEvent *event) override;
0047 
0048 private:
0049     DragType dragType;
0050     QCursor _originalCursor;
0051     QList<TabbedViewContainer *> _containers;
0052     int tabId;
0053 };
0054 }
0055 
0056 #endif