コード例 #1
0
void QGalleryTrackerResultSetPrivate::queryFinished(const QDBusPendingCall &call)
{
    if (call.isError()) {
        emit q_func()->progressChanged(progressMaximum, progressMaximum);

        qWarning("DBUS error %s", qPrintable(call.error().message()));

        flags &= ~Active;

        q_func()->finish(QDocumentGallery::ConnectionError);
    } else if (flags & Canceled) {
        iCache.count = 0;

        flags &= ~Active;

        q_func()->QGalleryAbstractResponse::cancel();
    } else {
        const int limit = queryLimit < 1 ? 1023 : queryLimit - iCache.count;
        const bool reset = flags & Reset;

        flags &= ~Reset;

        parseWatcher.setFuture(QtConcurrent::run(
                this, &QGalleryTrackerResultSetPrivate::parseRows, call, limit, reset));

        emit q_func()->progressChanged(progressMaximum - 1, progressMaximum);
    }
}
コード例 #2
0
void Frame::refreshList()
{
    m_wallpaperList->clear();

    if (m_mode == WallpaperMode) {
        QDBusPendingCall call = m_dbusAppearance->List("background");
        QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
        connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, call] {
            if (call.isError()) {
                qWarning() << "failed to get all backgrounds: " << call.error().message();
            } else {
                QDBusReply<QString> reply = call.reply();
                QString value = reply.value();
                QStringList strings = processListReply(value);

                foreach (QString path, strings) {
                    WallpaperItem * item = m_wallpaperList->addWallpaper(path);
                    item->setData(item->getPath());
                    item->setDeletable(m_deletableInfo.value(path));
                    item->addButton(DESKTOP_BUTTON_ID, tr("Only desktop"));
                    item->addButton(LOCK_SCREEN_BUTTON_ID, tr("Only lock screen"));
                    item->show();

                    connect(item, &WallpaperItem::buttonClicked, this, &Frame::onItemButtonClicked);
                }

                m_wallpaperList->setFixedWidth(width());
                m_wallpaperList->updateItemThumb();
                m_wallpaperList->show();
            }
        });