コード例 #1
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();
            }
        });
コード例 #2
0
void QGalleryTrackerResultSetPrivate::query()
{
    flags &= ~(Refresh | SyncFinished);
    flags |= Active;
    flags |= Reset;

    updateTimer.stop();

    rCache.count = iCache.count;
    rCache.offset = 0;

    iCache.count = 0;
    iCache.cutoff = 0;

    qSwap(rCache.values, iCache.values);

    const int limit = queryLimit < 1 || queryLimit > 1024 ? 1024 : queryLimit;

    QDBusPendingCall call = queryInterface->asyncCallWithArgumentList(
            queryMethod, QVariantList(queryArguments) << queryOffset << limit);

    if (call.isFinished()) {
        queryFinished(call);
    } else {
        queryWatcher.reset(new QDBusPendingCallWatcher(call));

        QObject::connect(
                queryWatcher.data(), SIGNAL(finished(QDBusPendingCallWatcher*)),
                q_func(), SLOT(_q_queryFinished(QDBusPendingCallWatcher*)));

        progressMaximum = 2;

        emit q_func()->progressChanged(0, progressMaximum);
    }
}
コード例 #3
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);
    }
}
コード例 #4
0
void AccountsWorker::randomUserIcon(User *user)
{
    QDBusPendingCall call = m_accountsInter->RandUserIcon();
    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
    connect(watcher, &QDBusPendingCallWatcher::finished, [=] {
        if (!call.isError()) {
            QDBusReply<QString> reply = call.reply();
            user->setCurrentAvatar(reply.value());
        }
        watcher->deleteLater();
    });
}
コード例 #5
0
void QGalleryTrackerResultSetPrivate::_q_parseFinished()
{
    processSyncEvents();

    if (parseWatcher.result()) {
        Q_ASSERT(rCache.offset == rCache.count);
        Q_ASSERT(iCache.cutoff == iCache.count);

        rCache.values.clear();
        rCache.count = 0;

        flags &= ~Active;

        if (flags & Refresh)
            update();
        else
            emit q_func()->progressChanged(progressMaximum, progressMaximum);

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

        flags &= ~Active;

        q_func()->QGalleryAbstractResponse::cancel();
    } else {
        const int offset = queryOffset + iCache.count;
        const int limit = queryLimit < 1 || queryLimit - iCache.count > 1024
                ? 1024
                : queryLimit - iCache.count;

        QDBusPendingCall call = queryInterface->asyncCallWithArgumentList(
                queryMethod, QVariantList(queryArguments) << offset << limit);

        if (call.isFinished()) {
            queryFinished(call);
        } else {
            queryWatcher.reset(new QDBusPendingCallWatcher(call));

            QObject::connect(
                    queryWatcher.data(), SIGNAL(finished(QDBusPendingCallWatcher*)),
                    q_func(), SLOT(_q_queryFinished(QDBusPendingCallWatcher*)));

            progressMaximum += 2;

            emit q_func()->progressChanged(progressMaximum - 2, progressMaximum);
        }
    }
}
コード例 #6
0
void QGalleryTrackerTypeResultSetPrivate::queryFinished(const QDBusPendingCall &call)
{
    const int oldCount = count;

    if (call.isError()) {
        q_func()->finish(QDocumentGallery::ConnectionError);

        return;
    } else if (!accumulative) {
        QDBusPendingReply<int> reply(call);

        count = reply.value();

        if (refresh) {
            refresh = false;

            queryCount();
        }

    } else {
        QDBusPendingReply<QVector<QStringList> > reply(call);

        const QVector<QStringList> counts = reply.value();

        typedef QVector<QStringList>::const_iterator iterator;
        for (iterator it = counts.begin(), end = counts.end(); it != end; ++it)
            workingCount += it->value(1).toInt();

        if (refresh) {
            refresh = false;

            currentOffset = 0;
            workingCount = 0;

            queryCount();
        } else {
            currentOffset += counts.count();

            if (counts.count() != 0) {
                if (count > workingCount)
                    count = workingCount;

                if (canceled)
                    q_func()->QGalleryAbstractResponse::cancel();
                else
                    queryCount();
            } else {
                count = workingCount;
            }
        }
    }

    if (count != oldCount)
        emit q_func()->metaDataChanged(0, 1, QList<int>() << 0);

    if (!queryWatcher)
        q_func()->finish();
}
コード例 #7
0
void QGalleryTrackerTypeResultSetPrivate::queryCount()
{
    QVariantList arguments = queryArguments;

    if (accumulative)
        arguments << currentOffset << int(0);

    QDBusPendingCall call = queryInterface->asyncCallWithArgumentList(queryMethod, arguments);

    if (call.isFinished()) {
        queryFinished(call);
    } else {
        queryWatcher = new QDBusPendingCallWatcher(call, q_func());

        QObject::connect(queryWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
                q_func(), SLOT(_q_queryFinished(QDBusPendingCallWatcher*)));
    }
}
コード例 #8
0
void AccountsWorker::setNopasswdLogin(User *user, const bool nopasswdLogin)
{
    AccountsUser *userInter = m_userInters[user];
    Q_ASSERT(userInter);

    Q_EMIT requestFrameAutoHide(false);

    QDBusPendingCall call = userInter->EnableNoPasswdLogin(nopasswdLogin);
    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] {
        if (call.isError()) {
            Q_EMIT user->nopasswdLoginChanged(user->nopasswdLogin());
        }

        Q_EMIT requestFrameAutoHide(true);
        watcher->deleteLater();
    });
}
コード例 #9
0
void AccountsWorker::setFullname(User *user, const QString &fullname)
{
    AccountsUser *ui = m_userInters[user];
    Q_ASSERT(ui);

    Q_EMIT requestFrameAutoHide(false);

    QDBusPendingCall call = ui->SetFullName(fullname);
    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] {
        if (!call.isError()) {
            Q_EMIT accountFullNameChangeFinished();
        }

        Q_EMIT requestFrameAutoHide(true);
        watcher->deleteLater();
    });
}
コード例 #10
0
void AccountsWorker::setAutoLogin(User *user, const bool autoLogin)
{
    AccountsUser *ui = m_userInters[user];
    Q_ASSERT(ui);

    // because this operate need root permission, we must wait for finished and refersh result
    Q_EMIT requestFrameAutoHide(false);

    QDBusPendingCall call = ui->SetAutomaticLogin(autoLogin);
    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] {
        if (call.isError()) {
            Q_EMIT user->autoLoginChanged(user->autoLogin());
        }

        Q_EMIT requestFrameAutoHide(true);
        watcher->deleteLater();
    });
}
コード例 #11
0
void QGalleryTrackerTypeResultSetPrivate::queryFinished(const QDBusPendingCall &call)
{
    const int oldCount = count;

    if (call.isError()) {
        q_func()->finish(QDocumentGallery::ConnectionError);

        return;
    } else if (!accumulative) {
        QDBusPendingReply<QVector<QStringList> > reply(call);

        if (queryMethod == QLatin1String("SparqlQuery")) {
            QVector<QStringList> v = reply.value();
            count = v[0].first().toInt();
        } else {
            /*
             * Process reply to org.freedesktop.Tracker.Statistics.Get -method. Value is a list of list of two strings:
             * type1 count1
             * type2 count2
             * ...
             * where typeX corresponds to the service name ( i.e. ontology class name, e.g. "nfo:FileDataObject" ).
             * Search through the list and find the requested service and extract the count from the second string.
             */
            QVector<QStringList> v = reply.value();
            QVector<QStringList>::const_iterator pos = qFind(
                    v, QGalleryTrackerType(service ));
            if (pos != v.constEnd())
                count = (*pos).last().toInt();

            // TODO Do we need this?
            if (refresh) {
                refresh = false;
                queryCount();
            }
        }
    } else {
        QDBusPendingReply<QVector<QStringList> > reply(call);

        const QVector<QStringList> counts = reply.value();

        typedef QVector<QStringList>::const_iterator iterator;
        for (iterator it = counts.begin(), end = counts.end(); it != end; ++it)
            workingCount += it->value(1).toInt();

        if (refresh) {
            refresh = false;

            currentOffset = 0;
            workingCount = 0;

            queryCount();
        } else {
            currentOffset += counts.count();

            if (counts.count() != 0) {
                if (count > workingCount)
                    count = workingCount;

                if (cancelled)
                    q_func()->QGalleryAbstractResponse::cancel();
                else
                    queryCount();
            } else {
                count = workingCount;
            }
        }
    }

    if (count != oldCount)
        emit q_func()->metaDataChanged(0, 1, QList<int>() << 0);

    if (!queryWatcher)
        q_func()->finish();
}