File indexing completed on 2024-04-28 04:55:39

0001 /*
0002     This file is part of Choqok, the KDE micro-blogging client
0003 
0004     SPDX-FileCopyrightText: 2011-2012 Mehrdad Momeny <mehrdad.momeny@gmail.com>
0005     SPDX-FileCopyrightText: 2011-2012 Bardia Daneshvar <bardia.daneshvar@gmail.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0008 */
0009 
0010 #ifndef CHOQOKTABBAR_H
0011 #define CHOQOKTABBAR_H
0012 
0013 #include <QIcon>
0014 #include <QString>
0015 #include <QWidget>
0016 
0017 #include "choqok_export.h"
0018 
0019 namespace Choqok
0020 {
0021 
0022 namespace UI
0023 {
0024 
0025 class ChoqokTabBarPrivate;
0026 class CHOQOK_EXPORT ChoqokTabBar : public QWidget
0027 {
0028     Q_OBJECT
0029 public:
0030     ChoqokTabBar(QWidget *parent = nullptr);
0031     ~ChoqokTabBar();
0032 
0033     enum TabPosition {
0034         North,
0035         South,
0036         West,
0037         East
0038     };
0039 
0040     enum SelectionBehavior {
0041         SelectLeftTab,
0042         SelectRightTab,
0043         SelectPreviousTab
0044     };
0045 
0046     enum ExtraWidgetPosition {
0047         Top,
0048         Bottom,
0049         Left,
0050         Right
0051     };
0052 
0053     void setTabPosition(TabPosition position);
0054     TabPosition tabPosition() const;
0055 
0056     void setTabsClosable(bool closeable);
0057     bool tabsClosable() const;
0058 
0059     void setCornerWidget(QWidget *w , Qt::Corner corner = Qt::TopRightCorner);
0060     QWidget *cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
0061 
0062     void setExtraWidget(QWidget *widget , ExtraWidgetPosition position);
0063     QWidget *extraWidget(ExtraWidgetPosition position);
0064 
0065     void setTabAlongsideWidget(QWidget *widget);
0066     QWidget *tabAlongsideWidget() const;
0067 
0068     void setTabCloseActivatePrevious(bool stt);
0069     bool tabCloseActivatePrevious() const;
0070 
0071     SelectionBehavior selectionBehaviorOnRemove() const;
0072     void setSelectionBehaviorOnRemove(SelectionBehavior behavior);
0073 
0074     QWidget *currentWidget() const;
0075     QWidget *widget(int index) const;
0076 
0077     int currentIndex() const;
0078     int indexOf(QWidget *widget) const;
0079 
0080     int addTab(QWidget *widget , const QString &name);
0081     int addTab(QWidget *widget , const QIcon &icon , const QString &name);
0082 
0083     int insertTab(int index , QWidget *widget , const QString &name);
0084     int insertTab(int index , QWidget *widget , const QIcon &icon , const QString &name);
0085 
0086     void moveTab(int from , int to);
0087     void removeTab(int index);
0088 
0089     void removePage(QWidget *widget);
0090 
0091     void setTabIcon(int index , const QIcon &icon);
0092     QIcon tabIcon(int index) const;
0093 
0094     void setTabText(int index , const QString &text);
0095     QString tabText(int index) const;
0096 
0097     /*! With LinkedAllTabBars function, all linked tabbars
0098      *  using unique Settings .
0099      */
0100     void setLinkedTabBar(bool stt);
0101     bool linkedTabBar() const;
0102 
0103     void setTabBarHidden(bool stt);
0104     bool isTabBarHidden() const;
0105 
0106     QSize iconSize() const;
0107     void setIconSize(const QSize &size);
0108 
0109     int count() const;
0110     Qt::ToolButtonStyle toolButtonStyle() const;
0111 
0112     void setStyledTabBar(bool stt);
0113     bool styledTabBar() const;
0114 
0115     void refreshTabBar();
0116 
0117 public Q_SLOTS:
0118     void setCurrentIndex(int index);
0119     void setCurrentWidget(QWidget *widget);
0120 
0121     void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
0122 
0123 Q_SIGNALS:
0124     void currentChanged(int index);
0125     void tabCloseRequested(int index);
0126     void tabMoved(int from , int to);
0127 
0128     void contextMenu(const QPoint &point);
0129     void contextMenu(QWidget *widget , const QPoint &point);
0130 
0131     void tabPositionChanged(TabPosition position);
0132     void styledPanelSignal(bool stt);
0133     void iconSizeChanged(const QSize &size);
0134 
0135 protected:
0136     virtual void resizeEvent(QResizeEvent *event) override;
0137     virtual void paintEvent(QPaintEvent *event) override;
0138 
0139 private Q_SLOTS:
0140     void action_triggered(QAction *action);
0141     void contextMenuRequest(const QPoint &point);
0142     void widget_destroyed(QObject *obj);
0143 
0144 private: // Private Functions
0145     void init_style();
0146     void init_position(TabPosition position);
0147     void init_extra_widget(const QSize &size);
0148     void init_alongside_widget(const QSize &size);
0149 
0150 private:
0151     ChoqokTabBarPrivate *p;
0152 };
0153 
0154 }
0155 }
0156 
0157 #endif // CHOQOKTABBAR_H