File indexing completed on 2024-05-12 17:21:58

0001 /*
0002     SPDX-FileCopyrightText: 2020-2022 Krusader Krew <https://krusader.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef VIEWERTABBAR_H
0008 #define VIEWERTABBAR_H
0009 
0010 // QtWidgets
0011 #include <QTabBar>
0012 #include <QTabWidget>
0013 #include <QWidget>
0014 
0015 class ViewerTabBar;
0016 
0017 /**
0018  * This class extends QTabWidget such that we can use a custom QTabBar on it
0019  */
0020 class ViewerTabWidget : public QTabWidget
0021 {
0022     Q_OBJECT
0023 public:
0024     explicit ViewerTabWidget(QWidget *parent);
0025     void adjustViewerTabBarVisibility();
0026 
0027     ViewerTabBar *tabBar() const;
0028 };
0029 
0030 /**
0031  * This class extends QTabBar such that right-clicking on a tab pops-up a menu
0032  * containing relevant actions for the tab. It also emits signals to close the
0033  * current tab.
0034  */
0035 class ViewerTabBar : public QTabBar
0036 {
0037     Q_OBJECT
0038 public:
0039     explicit ViewerTabBar(QWidget *parent)
0040         : QTabBar(parent){};
0041 
0042 protected:
0043     void mousePressEvent(QMouseEvent *) override;
0044 
0045 signals:
0046     /**
0047      * emitted when the user mid-clicks on the tab
0048      */
0049     void closeTabSignal(int index);
0050 };
0051 
0052 #endif