/***************************************************************************
 **
 **  Copyright (C) 2023 wangjianjun <wangjianjun1018@qq.com>
 **  Contact: https://blog.csdn.net/wocanimei007?type=blog
 **
 **
****************************************************************************/
/****************************************************************************
 * NOTES:
 *  1) the mainWidget is host-widget, FancyTitleBar is used as its event filter
 *  2) the titleWidget is the title bar area of mainWidget, used to guide the
 *     mouse event operation of FancyTitleBar
 *
 *  ------------------------------------------------,
 *  |               titleWidget                    | \
 *  |-----------------------------------------------  \
 *  |                                              |   \
 *  |                                              |    \
 *  |                                              |     \
 *  |                                              |       mainWindget
 *  |                                              |     /
 *  |                                              |    /
 *  |                                              |   /
 *  |                                              |  /
 *  |                                              | /
 *  ------------------------------------------------'
 *
 *****************************************************************************
 */
#ifndef FANCYTITLEBAR_H
#define FANCYTITLEBAR_H

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

class QMouseEvent;
class QLabel;
class QToolButton;
class QToolBar;
class QAction;



class FancyTitleBarPrivate;
class FRAMELESS_SHARED_EXPORT FancyTitleBar : public QObject
{
    Q_OBJECT
public:
    explicit FancyTitleBar(QWidget *mainWidget);
    ~FancyTitleBar();

    void setTitleWidget(QWidget *widget);
    void setMiddleWidget(QWidget* widget);

    QWidget *mainWidget() const;
    QLabel *titleLabel() const;
    QToolButton *logoButton() const;
    QWidget *systemGroup() const;

    // set nondark icon
    void setCloseIcon(QIcon &icon);
    void setMaximizeIcon(QIcon &icon);
    void setMinimizeIcon(QIcon &icon);
    void setNormalIcon(QIcon &icon);
    void setIconDark(bool dark);

    void setWidgetResizable(bool resizable);
    void setWidgetMovable(bool movable);
    void setWidgetMaximizable(bool maximizable);

    void updateWidgetFlags();

    void hideMaximizeButton();
    void showMaximizeButton();

signals:
    void windowResizable(bool resizable);
    void windowMovable(bool movable);
    void windowIconChanged(QIcon &icon);

protected:
    virtual bool eventFilter(QObject* object, QEvent* event);

private:
    FancyTitleBarPrivate *d;
};



#endif // FANCYTITLEBAR_H
