#ifndef SLIDERSHOW_H
#define SLIDERSHOW_H

#include <QObject>
#include <QWidget>
#include <QPushButton>
#include <QLabel>
#include <QStackedWidget>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QRect>
namespace KInstaller {
class SlideShow : public QWidget
{
    Q_OBJECT
public:
    explicit SlideShow(QWidget *parent = nullptr);
    void initUI();
    void initAllConnect();
    void addStyleSheet();
    void loadSlides();
    void updateSlides(QRect rect);
    int fileInfo();
    QImage pixmapScale(const QImage& image, const double & index);
    QImage addtransterstr(QImage& image,QRect rct,QString str,QFont font,QColor color);
    void translateStr();

private:
    void changeEvent(QEvent *event);

signals:

public slots:
    void next();
    void prev();
    void start();
    void changeSlide(int index);
protected:
    void keyPressEvent(QKeyEvent *event);
    bool eventFilter(QObject *watched, QEvent *event);

public:
    QPushButton* m_next;
    QPushButton* m_prev;
    QLabel *m_pTitleLabel;
    QTimer* timer;
    int num ;
    int m_currentIndex;
    QStackedWidget *sliderWidget;
    bool m_firstfocusget=false;//首次焦点获取标志(首次获取时隐藏边框)

    // QWidget interface
protected:
    void showEvent(QShowEvent *event);
};

class Slide : public QWidget
{
    Q_OBJECT
public:
    QLabel *m_pLabelPng = nullptr;
    QLabel *m_pLabelText = nullptr;
    QHBoxLayout *m_pHboxLayout = nullptr;
    explicit Slide(QWidget *parent = nullptr) {
        m_pHboxLayout = new QHBoxLayout();
        m_pHboxLayout->setContentsMargins(0, 0, 0, 0);
        m_pHboxLayout->setSpacing(0);
        m_pLabelPng = new QLabel();
        m_pLabelPng->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
        m_pLabelPng->setAlignment(Qt::AlignCenter);
        m_pHboxLayout->addWidget(m_pLabelPng);
        this->setLayout(m_pHboxLayout);

        m_pLabelText = new QLabel(this);
    }
};

}
#endif // SLIDERSHOW_H
