void MusicDesktopWallpaperWidget::confirmButtonPressed()
{
    if(ui->urlLineEdit->text().trimmed().isEmpty())
    {
        MusicMessageBox message;
        message.setText(tr("url is now empty!"));
        message.exec();
        return;
    }
    switch(m_currentMode)
    {
        case 0:
        {
            m_path << QString("%1%2").arg(TMP_DOWNLOAD).arg(JPG_FILE);
            MusicDataDownloadThread *background = new MusicDataDownloadThread(ui->urlLineEdit->text().trimmed(),
                                                      m_path[0], MusicDownLoadThreadAbstract::Download_BigBG, this);
            connect(background, SIGNAL(musicDownLoadFinished(QString)),SLOT(parameterFinished()));
            background->startToDownload();
            break;
        }
        case 1:
            parameterFinished(); break;
        case 2:
            m_path << "Play";
            parameterFinished(); break;
        default: break;
    }
}
Ejemplo n.º 2
0
void MusicBgThemeDownload::downLoadFinished(const QString &)
{
    QFile file(TMP_DOWNLOAD);
    ///Check if the file exists and can be written
    if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        return;
    }

    QTextStream in(&file);
    QString line = in.readLine();

    while(!line.isNull())
    {
        ///On line reading, and reading effectively 5 times
        if(line.contains("<dd>") && m_counter < 5)
        {
            line = line.split("lazy_src=").back().split(" ").front();
            line.remove(0, 1);
            line.remove(line.length() - 1, 1);
            line = line.remove("sp");
            M_LOGGER << line << LOG_END;
            MusicDataDownloadThread *down = new MusicDataDownloadThread(line, QString("%1%2%3%4").arg(ART_BG_AL)
                                    .arg(m_savePath).arg(m_counter++).arg(SKN_FILE), Download_BigBG, this);
            connect(down, SIGNAL(musicDownLoadFinished(QString)),SLOT(bgDownLoadFinished(QString)));
            down->startToDownload();
        }
        line = in.readLine();
    }
    file.close();
    //The file is closed and remove the temporary files
    QFile::remove(TMP_DOWNLOAD);
}
void MusicKWBackgroundThread::downLoadDataFinished(const QByteArray &bytes)
{
    QJson::Parser parser;
    bool ok;

    if(bytes != "NO_PIC")
    {
        QVariant data = parser.parse(bytes, &ok);
        if(ok)
        {
            QVariantMap dataMap = data.toMap();
            QVariantList datas = dataMap["array"].toList();
            foreach(const QVariant &value, datas)
            {
                dataMap = value.toMap();
                if(m_counter < 5 && !dataMap.isEmpty())
                {
                    QString url = dataMap.values().first().toString();
                    M_LOGGER_ERROR(url);
                    MusicDataDownloadThread *download = new MusicDataDownloadThread(url, QString("%1%2%3%4").arg(BACKGROUND_DIR_FULL)
                                                            .arg(m_savePath).arg(m_counter++).arg(SKN_FILE),
                                                            MusicDownLoadThreadAbstract::DownloadBigBG, this);
                    connect(download, SIGNAL(downLoadDataChanged(QString)), SLOT(downLoadFinished()));
                    download->startToDownload();
                }
            }
        }
Ejemplo n.º 4
0
MusicBgThemeDownload::MusicBgThemeDownload(const QString &name, const QString &save,
                                           QObject *parent)
    : QObject(parent), m_artName(name), m_savePath(save), m_index(0), m_counter(0)
{
    MusicDataDownloadThread *download = new MusicDataDownloadThread(
                             BIG_BG_ART_URL.arg(name), TMP_DOWNLOAD, Download_BigBG, this);
    ///Set search image API
    connect(download, SIGNAL(musicDownLoadFinished(QString)),
                      SLOT(downLoadFinished(QString)));

    M_CONNECTION->setValue("MusicBgThemeDownload", this);
    M_CONNECTION->connect("MusicBgThemeDownload", "MusicTopAreaWidget");
    download->startToDownload();
}
void MusicWebRadioObject::show()
{
    QString fileName = PLUGINS_DIR_FULL + MusicUtils::Algorithm::mdII(DOWNLOAD_NAME, false);
    if(QFile::exists(fileName))
    {
        dataDownloadFinished();
    }
    else
    {
        MusicDataDownloadThread *download = new MusicDataDownloadThread(MusicUtils::Algorithm::mdII(DOWNLOAD_URL, false),
                                                PLUGINS_DIR_FULL + MusicUtils::Algorithm::mdII(DOWNLOAD_NAME, false),
                                                MusicDownLoadThreadAbstract::DownloadOther, this);
        connect(download, SIGNAL(downLoadDataChanged(QString)), SLOT(dataDownloadFinished()));
        download->startToDownload();
    }
}
void MusicWebMusicRadioWidget::startToPlay()
{
    SongRadioInfo info;
    if(m_songsThread)
    {
        info = m_songsThread->getMusicSongInfo();
    }
    if(info.m_songUrl.isEmpty())
    {
        return;
    }

    delete m_radio;
    m_radio = new MusicCoreMPlayer(this);
    connect(m_radio, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64)));
    connect(m_radio, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64)));
    m_radio->setMedia(MusicCoreMPlayer::MusicCategory, info.m_songUrl, -1);
    m_radio->setVolume(ui->volumeSlider->value());

    QString name = LRC_DOWNLOAD_AL + info.m_artistName + " - " + info.m_songName + LRC_FILE;
    if(!QFile::exists(name))
    {
        MusicTextDownLoadThread* lrcDownload = new MusicTextDownLoadThread(info.m_lrcUrl, name,
                                 MusicDownLoadThreadAbstract::Download_Lrc, this);
        connect(lrcDownload, SIGNAL(musicDownLoadFinished(QString)), SLOT(lrcDownloadStateChanged()));
        lrcDownload->startToDownload();
    }
    else
    {
        lrcDownloadStateChanged();
    }

    name = ART_DOWNLOAD_AL + info.m_artistName + SKN_FILE;
    if(!QFile::exists(name))
    {
        MusicDataDownloadThread *picDwonload = new MusicDataDownloadThread(info.m_songPicUrl, name,
                                 MusicDownLoadThreadAbstract::Download_SmlBG, this);
        connect(picDwonload, SIGNAL(musicDownLoadFinished(QString)), SLOT(picDownloadStateChanged()));
        picDwonload->startToDownload();
    }
    else
    {
        picDownloadStateChanged();
    }
}
void MusicSongSearchOnlineTableWidget::addSearchMusicToPlayList(int row)
{
    if(!M_NETWORK->isOnline())
    {   //no network connection
        emit showDownLoadInfoFor(MusicObject::DisConnection);
        return;
    }
    if(row < 0)
    {
        MusicMessageBox message;
        message.setText(tr("Please Select One Item First!"));
        message.exec();
        return;
    }
    emit showDownLoadInfoFor(MusicObject::DownLoading);

    MusicSongInfomations musicSongInfos(m_downLoadManager->getMusicSongInfos());
    MusicSongInfomation musicSongInfo = musicSongInfos[row];
    MusicSongAttribute musicSongAttr = musicSongInfo.m_songAttrs.first();
    QString musicSong = item(row, 2)->toolTip() + " - " + item(row, 1)->toolTip();
    QString downloadName = QString("%1%2.%3").arg(MUSIC_DOWNLOAD_AL)
                                             .arg(musicSong).arg(musicSongAttr.m_format);

    MusicDataDownloadThread *downSong = new MusicDataDownloadThread( musicSongAttr.m_url, downloadName,
                                                                     MusicDownLoadThreadAbstract::Download_Music, this);
    downSong->startToDownload();

    (new MusicTextDownLoadThread(musicSongInfo.m_lrcUrl, LRC_DOWNLOAD_AL + musicSong + LRC_FILE,
                                 MusicDownLoadThreadAbstract::Download_Lrc, this))->startToDownload();
    (new MusicData2DownloadThread(musicSongInfo.m_smallPicUrl, ART_DOWNLOAD_AL + musicSongInfo.m_singerName + SKN_FILE,
                                  MusicDownLoadThreadAbstract::Download_SmlBG, this))->startToDownload();
    ///download big picture
    (new MusicBgThemeDownload(musicSongInfo.m_singerName, musicSongInfo.m_singerName, this))->startToDownload();

    emit muiscSongToPlayListChanged( musicSong, item(row, 3)->text(), musicSongAttr.m_format);
}