示例#1
0
void MythScreenType::LoadInBackground(QString message)
{
    m_IsLoading = true;
    m_ScreenStack->AllowReInit();

    OpenBusyPopup(message);

    ScreenLoadTask *loadTask = new ScreenLoadTask(this);
    QThreadPool::globalInstance()->start(loadTask);
}
示例#2
0
void MythScreenType::LoadInBackground(QString message)
{
    m_LoadLock.lock();

    m_IsLoading = true;
    m_IsLoaded = false;

    m_ScreenStack->AllowReInit();

    OpenBusyPopup(message);

    ScreenLoadTask *loadTask = new ScreenLoadTask(*this);
    MThreadPool::globalInstance()->start(loadTask, "ScreenLoad");
}
示例#3
0
void ThemeChooser::saveAndReload(MythUIButtonListItem *item)
{
    ThemeInfo *info = qVariantValue<ThemeInfo *>(item->GetData());

    if (!info)
        return;

    if (!info->GetDownloadURL().isEmpty())
    {
        QString downloadURL = info->GetDownloadURL();
        QFileInfo qfile(downloadURL);
        QString baseName = qfile.fileName();

        if (!gCoreContext->GetSetting("ThemeDownloadURL").isEmpty())
        {
            QStringList tokens =
                gCoreContext->GetSetting("ThemeDownloadURL")
                    .split(";", QString::SkipEmptyParts);
            QString origURL = downloadURL;
            downloadURL.replace(tokens[0], tokens[1]);
            LOG(VB_FILE, LOG_WARNING, LOC +
                QString("Theme download URL overridden from %1 to %2.")
                    .arg(origURL).arg(downloadURL));
        }

        OpenBusyPopup(tr("Downloading %1 Theme").arg(info->GetName()));
        m_downloadTheme = info;
        m_downloadFile = RemoteDownloadFile(downloadURL,
                                            "Temp", baseName);
        m_downloadState = dsDownloadingOnBackend;
    }
    else
    {
        gCoreContext->SaveSetting("Theme", info->GetDirectoryName());
        GetMythMainWindow()->JumpTo("Reload Theme");
    }
}
示例#4
0
bool ImportIconsWizard::search(const QString& strParam)
{

    QString strParam1 = QUrl::toPercentEncoding(strParam);
    bool retVal = false;
    enableControls(STATE_SEARCHING);
    QUrl url(m_url+"/search");

    CSVEntry entry2 = (*m_missingIter);
    QString channelcsv = QString("%1,%2,%3,%4,%5,%6,%7,%8\n")
                         .arg(escape_csv(entry2.strName))
                         .arg(escape_csv(entry2.strXmlTvId))
                         .arg(escape_csv(entry2.strCallsign))
                         .arg(escape_csv(entry2.strTransportId))
                         .arg(escape_csv(entry2.strAtscMajorChan))
                         .arg(escape_csv(entry2.strAtscMinorChan))
                         .arg(escape_csv(entry2.strNetworkId))
                         .arg(escape_csv(entry2.strServiceId));

    QString message = QObject::tr("Searching for icons for channel %1")
                      .arg(entry2.strName);

    OpenBusyPopup(message);

    QString str = wget(url,"s="+strParam1+"&csv="+channelcsv);
    m_listSearch.clear();
    m_iconsList->Reset();

    if (str.isEmpty() || str.startsWith("#") ||
            str.startsWith("Error", Qt::CaseInsensitive))
    {
        LOG(VB_GENERAL, LOG_ERR, QString("Error from search : %1").arg(str));
        retVal = false;
    }
    else
    {
        LOG(VB_CHANNEL, LOG_INFO,
            QString("Icon Import: Working search : %1").arg(str));
        QStringList strSplit = str.split("\n");

        // HACK HACK HACK -- begin
        // This is needed since the user can't escape out of the progress dialog
        // and the result set may contain thousands of channels.
        if (strSplit.size() > 150)
        {
            LOG(VB_GENERAL, LOG_WARNING,
                QString("Warning: Result set contains %1 items, "
                        "truncating to the first %2 results")
                .arg(strSplit.size()).arg(150));
            while (strSplit.size() > 150)
                strSplit.removeLast();
        }
        // HACK HACK HACK -- end

        QString prevIconName;
        int namei = 1;

        for (int x = 0; x < strSplit.size(); ++x)
        {
            QString row = strSplit[x];
            if (row != "#" )
            {
                QStringList ret = extract_csv(row);
                LOG(VB_CHANNEL, LOG_INFO,
                    QString("Icon Import: search : %1 %2 %3")
                    .arg(ret[0]).arg(ret[1]).arg(ret[2]));
                SearchEntry entry;
                entry.strID = ret[0];
                entry.strName = ret[1];
                entry.strLogo = ret[2];
                m_listSearch.append(entry);

                MythUIButtonListItem *item;
                if (prevIconName == entry.strName)
                {
                    QString newname = QString("%1 (%2)").arg(entry.strName)
                                      .arg(namei);
                    item = new MythUIButtonListItem(m_iconsList, newname,
                                                    qVariantFromValue(entry));
                    namei++;
                }
                else
                {
                    item = new MythUIButtonListItem(m_iconsList, entry.strName,
                                                    qVariantFromValue(entry));
                    namei=1;
                }

                QString iconname = entry.strName;

                item->SetImage(entry.strLogo, "icon", false);
                item->SetText(iconname, "iconname");

                prevIconName = entry.strName;
            }
        }

        retVal = true;
    }
    enableControls(STATE_NORMAL, retVal);
    CloseBusyPopup();
    return retVal;
}
示例#5
0
void ThemeChooser::customEvent(QEvent *e)
{
    if ((MythEvent::Type)(e->type()) == MythEvent::MythEventMessage)
    {
        MythEvent *me = (MythEvent *)e;
        QStringList tokens = me->Message().split(" ", QString::SkipEmptyParts);

        if (tokens.isEmpty())
            return;

        if (tokens[0] == "DOWNLOAD_FILE")
        {
            QStringList args = me->ExtraDataList();
            if ((m_downloadState == dsIdle) ||
                (tokens.size() != 2) ||
                (!m_downloadTheme) ||
                (args[1] != m_downloadFile))
                return;

            if (tokens[1] == "UPDATE")
            {
                updateProgressBar(args[2].toInt(), args[3].toInt());
            }
            else if (tokens[1] == "FINISHED")
            {
                bool remoteFileIsLocal = false;
                int fileSize  = args[2].toInt();
                int errorCode = args[4].toInt();

                CloseBusyPopup();

                QFileInfo file(m_downloadFile);
                if ((m_downloadState == dsDownloadingOnBackend) &&
                    (m_downloadFile.startsWith("myth://")))
                {
                    // The backend download is finished so start the
                    // frontend download
                    if ((errorCode == 0) &&
                        (fileSize > 0))
                    {
                        m_downloadState = dsDownloadingOnFrontend;
                        QString localFile = GetConfDir() + "/tmp/" +
                            file.fileName();
                        file.setFile(localFile);

                        if (file.exists())
                        {
                            remoteFileIsLocal = true;
                            m_downloadFile = localFile;
                        }
                        else
                        {
                            GetMythDownloadManager()->queueDownload(
                                m_downloadFile, localFile, this);
                            OpenBusyPopup(tr("Copying %1 Theme Package")
                                          .arg(m_downloadTheme->GetName()));
                            m_downloadFile = localFile;
                            return;
                        }
                    }
                    else
                    {
                        m_downloadState = dsIdle;
                        ShowOkPopup(tr("ERROR downloading theme package on master backend."));
                    }
                }

                if ((m_downloadState == dsDownloadingOnFrontend) &&
                    (file.exists()))
                {
                    // The frontend download is finished
                    if ((errorCode == 0) &&
                        (fileSize > 0))
                    {
                        m_downloadState = dsExtractingTheme;
                        ThemeExtractThread *extractThread =
                            new ThemeExtractThread(this, m_downloadFile,
                                                   GetConfDir() + "/themes");
                        MThreadPool::globalInstance()->start(
                            extractThread, "ThemeExtract");

                        if (!remoteFileIsLocal)
                            RemoteFile::DeleteFile(args[0]);

                        OpenBusyPopup(tr("Installing %1 Theme")
                                      .arg(m_downloadTheme->GetName()));
                    }
                    else
                    {
                        m_downloadState = dsIdle;
                        ShowOkPopup(tr("ERROR downloading theme package from master backend."));
                    }
                }
            }
        }
        else if ((me->Message() == "THEME_INSTALLED") &&
                 (m_downloadTheme) &&
                 (m_downloadState == dsExtractingTheme))
        {
            m_downloadState = dsIdle;
            CloseBusyPopup();
            QStringList args = me->ExtraDataList();
            QFile::remove(args[0]);

            QString event = QString("THEME_INSTALLED PATH %1")
                                    .arg(GetConfDir() + "/themes/" +
                                         m_downloadTheme->GetDirectoryName());
            gCoreContext->SendSystemEvent(event);

            gCoreContext->SaveSetting("Theme", m_downloadTheme->GetDirectoryName());
            GetMythMainWindow()->JumpTo("Reload Theme");
        }
    }
}