File indexing completed on 2019-07-28 10:35:08

0001 /*
0002     This file is part of Choqok, the KDE micro-blogging client
0003 
0004     Copyright (C) 2011-2012 Mehrdad Momeny <mehrdad.momeny@gmail.com>
0005     Copyright (C) 2011-2012 Bardia Daneshvar <bardia.daneshvar@gmail.com>
0006 
0007     This program is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU General Public License as
0009     published by the Free Software Foundation; either version 2 of
0010     the License or (at your option) version 3 or any later version
0011     accepted by the membership of KDE e.V. (or its successor approved
0012     by the membership of KDE e.V.), which shall act as a proxy
0013     defined in Section 14 of version 3 of the license.
0014 
0015     This program is distributed in the hope that it will be useful,
0016     but WITHOUT ANY WARRANTY; without even the implied warranty of
0017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0018     GNU General Public License for more details.
0019 
0020     You should have received a copy of the GNU General Public License
0021     along with this program; if not, see http://www.gnu.org/licenses/
0022  */
0023 
0024 #ifndef CHOQOKTABBAR_H
0025 #define CHOQOKTABBAR_H
0026 
0027 #include <QIcon>
0028 #include <QString>
0029 #include <QWidget>
0030 
0031 #include "choqok_export.h"
0032 
0033 namespace Choqok
0034 {
0035 
0036 namespace UI
0037 {
0038 
0039 class ChoqokTabBarPrivate;
0040 class CHOQOK_EXPORT ChoqokTabBar : public QWidget
0041 {
0042     Q_OBJECT
0043 public:
0044     ChoqokTabBar(QWidget *parent = nullptr);
0045     ~ChoqokTabBar();
0046 
0047     enum TabPosition {
0048         North,
0049         South,
0050         West,
0051         East
0052     };
0053 
0054     enum SelectionBehavior {
0055         SelectLeftTab,
0056         SelectRightTab,
0057         SelectPreviousTab
0058     };
0059 
0060     enum ExtraWidgetPosition {
0061         Top,
0062         Bottom,
0063         Left,
0064         Right
0065     };
0066 
0067     void setTabPosition(TabPosition position);
0068     TabPosition tabPosition() const;
0069 
0070     void setTabsClosable(bool closeable);
0071     bool tabsClosable() const;
0072 
0073     void setCornerWidget(QWidget *w , Qt::Corner corner = Qt::TopRightCorner);
0074     QWidget *cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
0075 
0076     void setExtraWidget(QWidget *widget , ExtraWidgetPosition position);
0077     QWidget *extraWidget(ExtraWidgetPosition position);
0078 
0079     void setTabAlongsideWidget(QWidget *widget);
0080     QWidget *tabAlongsideWidget() const;
0081 
0082     void setTabCloseActivatePrevious(bool stt);
0083     bool tabCloseActivatePrevious() const;
0084 
0085     SelectionBehavior selectionBehaviorOnRemove() const;
0086     void setSelectionBehaviorOnRemove(SelectionBehavior behavior);
0087 
0088     QWidget *currentWidget() const;
0089     QWidget *widget(int index) const;
0090 
0091     int currentIndex() const;
0092     int indexOf(QWidget *widget) const;
0093 
0094     int addTab(QWidget *widget , const QString &name);
0095     int addTab(QWidget *widget , const QIcon &icon , const QString &name);
0096 
0097     int insertTab(int index , QWidget *widget , const QString &name);
0098     int insertTab(int index , QWidget *widget , const QIcon &icon , const QString &name);
0099 
0100     void moveTab(int from , int to);
0101     void removeTab(int index);
0102 
0103     void removePage(QWidget *widget);
0104 
0105     void setTabIcon(int index , const QIcon &icon);
0106     QIcon tabIcon(int index) const;
0107 
0108     void setTabText(int index , const QString &text);
0109     QString tabText(int index) const;
0110 
0111     /*! With LinkedAllTabBars function, all linked tabbars
0112      *  using unique Settings .
0113      */
0114     void setLinkedTabBar(bool stt);
0115     bool linkedTabBar() const;
0116 
0117     void setTabBarHidden(bool stt);
0118     bool isTabBarHidden() const;
0119 
0120     QSize iconSize() const;
0121     void setIconSize(const QSize &size);
0122 
0123     int count() const;
0124     Qt::ToolButtonStyle toolButtonStyle() const;
0125 
0126     void setStyledTabBar(bool stt);
0127     bool styledTabBar() const;
0128 
0129     void refreshTabBar();
0130 
0131 public Q_SLOTS:
0132     void setCurrentIndex(int index);
0133     void setCurrentWidget(QWidget *widget);
0134 
0135     void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
0136 
0137 Q_SIGNALS:
0138     void currentChanged(int index);
0139     void tabCloseRequested(int index);
0140     void tabMoved(int from , int to);
0141 
0142     void contextMenu(const QPoint &point);
0143     void contextMenu(QWidget *widget , const QPoint &point);
0144 
0145     void tabPositionChanged(TabPosition position);
0146     void styledPanelSignal(bool stt);
0147     void iconSizeChanged(const QSize &size);
0148 
0149 protected:
0150     virtual void resizeEvent(QResizeEvent *event) override;
0151     virtual void paintEvent(QPaintEvent *event) override;
0152 
0153 private Q_SLOTS:
0154     void action_triggered(QAction *action);
0155     void contextMenuRequest(const QPoint &point);
0156     void widget_destroyed(QObject *obj);
0157 
0158 private: // Private Functions
0159     void init_style();
0160     void init_position(TabPosition position);
0161     void init_extra_widget(const QSize &size);
0162     void init_alongside_widget(const QSize &size);
0163 
0164 private:
0165     ChoqokTabBarPrivate *p;
0166 };
0167 
0168 }
0169 }
0170 
0171 #endif // CHOQOKTABBAR_H