MusicVideoFloatWidget::MusicVideoFloatWidget(QWidget *parent)
    : MusicFloatAbstractWidget(parent)
{
    setStyleSheet(MusicUIObject::MCustomStyle28);

    resizeWindow(0, 0);
    m_search = new QPushButton(tr(" Search"), this);
    m_fresh = new QPushButton(tr(" Fresh"), this);
    m_fullscreen = new QPushButton(tr(" Fullscreen"), this);
    m_download = new QPushButton(tr(" Download"), this);
    m_share = new QPushButton(tr(" Share"), this);

    m_search->setIcon(QIcon(":/video/search"));
    m_fresh->setIcon(QIcon(":/video/fresh"));
    m_fullscreen->setIcon(QIcon(":/video/fullscreen"));
    m_download->setIcon(QIcon(":/video/download"));
    m_share->setIcon(QIcon(":/image/songShare"));

    m_search->setStyleSheet( MusicUIObject::MPushButtonStyle15 );
    m_fresh->setStyleSheet( MusicUIObject::MPushButtonStyle15 );
    m_fullscreen->setStyleSheet( MusicUIObject::MPushButtonStyle15 );
    m_download->setStyleSheet( MusicUIObject::MPushButtonStyle15 );
    m_share->setStyleSheet( MusicUIObject::MPushButtonStyle15 );

    m_search->move(15, 10);
    m_fresh->move(15, 50);
    m_fullscreen->move(15, 90);
    m_download->move(15, 130);
    m_share->move(15, 170);

    m_search->setCursor(QCursor(Qt::PointingHandCursor));
    m_fresh->setCursor(QCursor(Qt::PointingHandCursor));
    m_fullscreen->setCursor(QCursor(Qt::PointingHandCursor));
    m_download->setCursor(QCursor(Qt::PointingHandCursor));
    m_share->setCursor(QCursor(Qt::PointingHandCursor));

    connect(m_search, SIGNAL(clicked()), SIGNAL(searchButtonClicked()));
    connect(m_fresh, SIGNAL(clicked()), SIGNAL(freshButtonClicked()));
    connect(m_fullscreen, SIGNAL(clicked()), SIGNAL(fullscreenButtonClicked()));
    connect(m_download, SIGNAL(clicked()), SIGNAL(downloadButtonClicked()));
    connect(m_share, SIGNAL(clicked()), SIGNAL(shareButtonClicked()));

}
MusicVideoPlayWidget::MusicVideoPlayWidget(QWidget *parent)
    : MusicAbstractMoveWidget(false, parent)
{
    setWindowTitle("TTKMovie");

    m_leaverTimer = new QTimer(this);
    m_leaverTimer->setInterval(4*MT_S2MS);
    m_leaverTimer->setSingleShot(true);
    connect(m_leaverTimer, SIGNAL(timeout()), SLOT(leaveTimeout()));

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);
    m_topWidget = new QWidget(this);
    m_topWidget->setStyleSheet(MusicUIObject::MBackgroundStyle06 + MusicUIObject::MBorderStyle01);

    QHBoxLayout *topLayout = new QHBoxLayout(m_topWidget);
    topLayout->setContentsMargins(9, 4, 9, 4);

    m_textLabel = new QLabel(m_topWidget);
    m_textLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    m_textLabel->setStyleSheet(MusicUIObject::MColorStyle01);

    QWidget *searchWidget = new QWidget(m_topWidget);
    searchWidget->setFixedHeight(25);
    searchWidget->setStyleSheet(MusicUIObject::MBackgroundStyle11);
    QHBoxLayout *searchLayout = new QHBoxLayout(searchWidget);
    searchLayout->setContentsMargins(0, 0, 0, 0);
    searchLayout->setSpacing(0);

    m_searchEdit = new MusicLocalSongSearchEdit(searchWidget);
    m_searchEdit->setStyleSheet(MusicUIObject::MColorStyle09);
    m_searchEdit->setFixedHeight(25);
    m_searchButton = new QPushButton(searchWidget);
    m_searchButton->setIcon(QIcon(":/tiny/btn_search_main_hover"));
    m_searchButton->setCursor(QCursor(Qt::PointingHandCursor));
    m_searchButton->setIconSize(QSize(25, 25));
    searchLayout->addWidget(m_searchEdit);
    searchLayout->addWidget(m_searchButton);
    searchWidget->setLayout(searchLayout);

    topLayout->addWidget(m_textLabel);
    topLayout->addStretch();
    topLayout->addWidget(searchWidget);

    m_closeButton = new QPushButton(this);
    m_closeButton->setToolTip(tr("Close"));
    m_closeButton->setFixedSize(14, 14);
    m_closeButton->setStyleSheet(MusicUIObject::MKGBtnPClose);
    m_closeButton->setCursor(QCursor(Qt::PointingHandCursor));
    connect(m_closeButton, SIGNAL(clicked()), parent, SLOT(musicVideoClosed()));
    topLayout->addWidget(m_closeButton);
    m_topWidget->setLayout(topLayout);

#ifdef Q_OS_UNIX
    m_searchButton->setFocusPolicy(Qt::NoFocus);
    m_closeButton->setFocusPolicy(Qt::NoFocus);
#endif

    m_stackedWidget = new QStackedWidget(this);
    m_stackedWidget->setStyleSheet(MusicUIObject::MBorderStyle01);

    QWidget *topMaskWidget = new QWidget(this);
    topMaskWidget->setFixedHeight(35);
    topMaskWidget->setStyleSheet(MusicUIObject::MBackgroundStyle02);

    layout->addWidget(topMaskWidget);
    layout->addWidget(m_stackedWidget);
    setLayout(layout);

    m_searchEdit->hide();
    m_searchButton->hide();
    m_backButton = nullptr;
    m_topWidget->raise();

    m_videoFloatWidget = new MusicVideoFloatWidget(this);
    m_videoTable = new MusicVideoTableWidget(this);
    m_videoView = new MusicVideoView(this);
    m_stackedWidget->addWidget(m_videoView);
    m_stackedWidget->addWidget(m_videoTable);
    m_stackedWidget->setCurrentIndex(VIDEO_WINDOW_INDEX_0);
    m_videoFloatWidget->setText(MusicVideoFloatWidget::FreshType, tr("PopupMode"));

    m_leaverAnimation = new QParallelAnimationGroup(this);
    QPropertyAnimation *topAnimation = new QPropertyAnimation(m_topWidget, "pos", m_leaverAnimation);
    topAnimation->setDuration(MT_S2MS/2);
    QPropertyAnimation *ctrlAnimation = new QPropertyAnimation(m_videoView->controlBarWidget(), "pos", m_leaverAnimation);
    ctrlAnimation->setDuration(MT_S2MS/2);
    m_leaverAnimation->addAnimation(topAnimation);
    m_leaverAnimation->addAnimation(ctrlAnimation);

    connect(m_searchButton,SIGNAL(clicked(bool)), SLOT(searchButtonClicked()));
    connect(m_videoTable, SIGNAL(mvURLNameChanged(MusicVideoItem)), SLOT(mvURLNameChanged(MusicVideoItem)));
    connect(m_videoTable, SIGNAL(restartSearchQuery(QString)),
                          SLOT(videoResearchButtonSearched(QString)));
    connect(m_searchEdit, SIGNAL(enterFinished(QString)), SLOT(videoResearchButtonSearched(QString)));

    connect(m_videoFloatWidget, SIGNAL(searchButtonClicked()), SLOT(switchToSearchTable()));
    connect(m_videoFloatWidget, SIGNAL(freshButtonClicked()), SLOT(freshButtonClicked()));
    connect(m_videoFloatWidget, SIGNAL(fullscreenButtonClicked()), SLOT(fullscreenButtonClicked()));
    connect(m_videoFloatWidget, SIGNAL(downloadButtonClicked()), SLOT(downloadButtonClicked()));
    connect(m_videoFloatWidget, SIGNAL(shareButtonClicked()), SLOT(shareButtonClicked()));

}