#ifndef UKUI4CUSTOMCONTROL_H
#define UKUI4CUSTOMCONTROL_H

#include <QSlider>
#include <QLabel>
#include <kslider.h>

//文本长自动省略并添加悬浮
class AutoOmitLabel : public QLabel
{
    Q_OBJECT
public:
    explicit AutoOmitLabel(QWidget* = nullptr);
    explicit AutoOmitLabel(const QString&, QWidget* = nullptr);
    ~AutoOmitLabel() = default;

public:
    void setText(const QString&, bool = true);

protected:
    void paintEvent(QPaintEvent*) override;

private:
    QString m_fullText;
};

class UkmediaVolumeSlider : public kdk::KSlider
{
    Q_OBJECT
public:
    UkmediaVolumeSlider(QWidget* = nullptr);
    ~UkmediaVolumeSlider();

Q_SIGNALS:
    void silderPressSignal();

    void silderReleaseSignal();

protected:
    void mousePressEvent(QMouseEvent*) override;

    void mouseReleaseEvent(QMouseEvent*) override;

    void mouseMoveEvent(QMouseEvent*) override;

    void wheelEvent(QWheelEvent*) override;

    void keyReleaseEvent(QKeyEvent*) override;

    void enterEvent(QEvent*) override;

    void leaveEvent(QEvent*) override;

private:
    void initStyleOption(QStyleOptionSlider*);

    void updateValue(QMouseEvent*);

private:
    bool m_bMousePress = false;
};

class UkBalanceVolumeSlider : public kdk::KSlider
{
    Q_OBJECT
public:
    UkBalanceVolumeSlider(QWidget* = nullptr);
    ~UkBalanceVolumeSlider();

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

private:
    void initStyleOption(QStyleOptionSlider*);

    void showTooltip();

};

#endif // UKUI4CUSTOMCONTROL_H
