PlayListGalleryItem::PlayListGalleryItem(PlayListRecord *record,
                                         AbstractRendererFactory *rendererFactory,
                                         QGraphicsItem *parent) :
    GalleryItem(rendererFactory, parent) ,
    m_record(record)
{
    setFlag(QGraphicsItem::ItemIsSelectable);
    setToolTip(m_record->name());
    createRenderer();

    connect(m_record, SIGNAL(saved()), this, SLOT(loadThumbnail()));
}
Esempio n. 2
0
QString SpeedDial::initialScript()
{
    if (!m_loaded) {
        loadSettings();
    }

    if (!m_regenerateScript) {
        return m_initialScript;
    }

    m_regenerateScript = false;
    m_initialScript.clear();

    QStringList entries = m_allPages.split("\";");

    foreach(QString entry, entries) {
        if (entry.isEmpty()) {
            continue;
        }

        QStringList tmp = entry.split("\"|");
        if (tmp.count() != 2) {
            continue;
        }

        QString url = tmp.at(0).mid(5);
        QString title = tmp.at(1).mid(7);

        QString imgSource = m_thumbnailsDir + QCryptographicHash::hash(url.toUtf8(), QCryptographicHash::Md4).toHex() + ".png";

        if (!QFile(imgSource).exists()) {
            loadThumbnail(url);
            imgSource = m_loadingImagePath;

            if (url.isEmpty()) {
                imgSource = "";
            }
        }
        else {
            imgSource = QUrl::fromLocalFile(imgSource).toString();
        }

        m_initialScript.append(QString("addBox('%1', '%2', '%3');\n").arg(url, title, imgSource));
    }

    return m_initialScript;
}
Esempio n. 3
0
void YTChannel::storeInfo() {
    if (channelId.isEmpty()) return;
    QSqlDatabase db = Database::instance().getConnection();
    QSqlQuery query(db);
    query.prepare("update subscriptions set "
                  "user_name=?, name=?, description=?, thumb_url=?, loaded=? "
                  "where user_id=?");
    qDebug() << userName;
    query.bindValue(0, userName);
    query.bindValue(1, displayName);
    query.bindValue(2, description);
    query.bindValue(3, thumbnailUrl);
    query.bindValue(4, QDateTime::currentDateTime().toTime_t());
    query.bindValue(5, channelId);
    bool success = query.exec();
    if (!success) qWarning() << query.lastQuery() << query.lastError().text();

    loadThumbnail();
}
void ThumbnailThread::run()
{
    LOG("");
    while (!testCancel()) {
        {
            QMutexLocker lock(&mMutex);
            // empty mPixPath means nothing to do
            LOG("Waiting for mPixPath");
            if (mPixPath.isNull()) {
                LOG("mPixPath.isNull");
                mCond.wait(&mMutex);
            }
        }
        if (testCancel()) {
            return;
        }
        {
            QMutexLocker lock(&mMutex);
            Q_ASSERT(!mPixPath.isNull());
            LOG("Loading" << mPixPath);
            bool needCaching;
            bool ok = loadThumbnail(&needCaching);
            if (ok && needCaching) {
                cacheThumbnail();
            }
            mPixPath.clear(); // done, ready for next
        }
        if (testCancel()) {
            return;
        }
        {
            QSize size(mOriginalWidth, mOriginalHeight);
            LOG("emitting done signal, size=" << size);
            QMutexLocker lock(&mMutex);
            done(mImage, size);
            LOG("Done");
        }
    }
    LOG("Ending thread");
}
void PlayListGalleryItem::load()
{
    loadThumbnail();
}