/***************************************************************************
 **
 **  Copyright (C) 2018-2023 wangjianjun <wangjianjun1018@qq.com>
 **  Contact: https://blog.csdn.net/wocanimei007?type=blog
 **
 **
****************************************************************************/
/*******************************************************************************************
 *
 *  TabBar + Center
 *
 *  -------------------------------------------------------------------------|
 *  |   |                               Top                                  |
 *  |   |--------------------------------------------------------------------|
 *  |   |           |                                           |            |
 *  |   |           |                                           |            |
 *  |   |           |                                           |            |
 *  |   |           |                                           |            |
 *  |   |           |                                           |            |
 *  | M |           |                                           |            |
 *  | O |           |                                           |            |
 *  | D |           |                  Stack                    |   Right    |
 *  | E |           |                                           |            |
 *  |   |           |                                           |            |
 *  | B |    Left   |                                           |            |
 *  | A |           |                                           |            |
 *  | R |           |                                           |            |
 *  |   |           |                                           |            |
 *  |   |           |                                           |            |
 *  |   |           |--------------------------------------------------------|
 *  |   |           |                                                        |
 *  |   |           |                  Bottom                                |
 *  |   |           |                                                        |
 *  |   |           |                                                        |
 *  |   |--------------------------------------------------------------------|
 *  |   |                           Status Bar                               |
 *  -------------------------------------------------------------------------|
 *
 *****************************************************************************************
 */
#ifndef FANCYTABWIDGET_H
#define FANCYTABWIDGET_H

#include <QWidget>
#include "frameless_global.h"

class QStatusBar;
class QSplitter;



class FancyTabBar;
class FancyTabWidgetPrivate;
class FRAMELESS_SHARED_EXPORT FancyTabWidget : public QWidget
{
    Q_OBJECT
public:
    enum ActionPosition {Front, Middle, Back };
    enum TabType { Mode, Action };
    enum TabStyle {IconOnly, TextOnly, TextBesideIcon, TextUnderIcon};
    enum CornerPosition {Left, Top, Right, Bottom};

    explicit FancyTabWidget(QWidget *parent = nullptr);
    ~FancyTabWidget();

    int addTab(QWidget *widget, const QString &label, bool hasMenu = false);
    int addTab(QWidget *widget, const QIcon& icon, const QString &label, bool hasMenu = false);

    int insertTab(int index, QWidget *widget, const QString &label, bool hasMenu = false);
    int insertTab(int index, QWidget *widget, const QIcon &icon, const QString &label, bool hasMenu = false);

    void removeTab(int index);

    void setTabEnabled(int index, bool enable);
    bool isTabEnabled(int index) const;

    void setTabVisible(int index, bool visible);
    bool isTabVisible(int index) const;

    void setTabToolTip(int index, QString toolTip);
    QString tabToolTip(int index) const;

    void setTabShortcut(int index, const QString &shortcut);

    enum TabPosition { North, South, West, East };
    Q_ENUM(TabPosition)
    TabPosition tabPosition() const;
    void setTabPosition(TabPosition pos);

    int currentIndex() const;
    QStatusBar* statusBar() const;
    FancyTabBar* tabBar() const;

    void setTabStyle(TabType type, TabStyle style);
    void setTabFont(TabType type, QFont &font);
    void setTabSpace(TabType type, int space);
    void setTabIconSize(QSize size);

    int addAction(QAction *action, ActionPosition position = Back);
    void removeAction(QAction *action);
    void setActionStyle(QAction *action, TabStyle style);

    QSplitter *addCornerWidget(QWidget *widget, CornerPosition position);

    void setHoverColor(const QColor &color);
    QColor hoverColor() const;

    void setPressColor(const QColor &color);
    QColor pressColor() const;

    void setTextColor(const QColor &color);
    void setSelectedTextColor(const QColor &color);

    void setBackgroundColor(const QColor &color);

signals:
    void currentChanged(int index);
    void menuTriggered(int index, QPoint pos);

public slots:
    void setCurrentIndex(int index);
    void hideMenu(int index);

private:
    FancyTabWidgetPrivate *d;
};



#endif // FANCYTABWIDGET_H
