Merge pull request #3426 from rullzer/thumbnail

Sharedialog show thumbnail of file (if available)
This commit is contained in:
Roeland Douma 2015-07-17 08:58:06 +02:00
commit bc542a4b80
2 changed files with 42 additions and 0 deletions

View file

@ -279,6 +279,12 @@ void ShareDialog::getShares()
job->addPassStatusCode(404); // don't report error if share doesn't exist yet
connect(job, SIGNAL(jobFinished(QVariantMap)), this, SLOT(slotSharesFetched(QVariantMap)));
job->start();
if (QFileInfo(_localPath).isFile()) {
ThumbnailJob *job2 = new ThumbnailJob(_sharePath, _account, this);
connect(job2, SIGNAL(jobFinished(int, QByteArray)), SLOT(slotThumbnailFetched(int, QByteArray)));
job2->start();
}
}
void ShareDialog::slotSharesFetched(const QVariantMap &reply)
@ -731,4 +737,25 @@ bool OcsShareJob::finished()
return true;
}
ThumbnailJob::ThumbnailJob(const QString &path, AccountPtr account, QObject* parent)
: AbstractNetworkJob(account, "", parent)
{
_url = Account::concatUrlPath(account->url(), QLatin1String("index.php/apps/files/api/v1/thumbnail/150/150/") + path);
setIgnoreCredentialFailure(true);
}
void ThumbnailJob::start()
{
qDebug() << Q_FUNC_INFO;
setReply(getRequest(_url));
setupConnections(reply());
AbstractNetworkJob::start();
}
bool ThumbnailJob::finished()
{
emit jobFinished(reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), reply()->readAll());
return true;
}
}

View file

@ -49,6 +49,21 @@ private:
};
class ThumbnailJob : public AbstractNetworkJob {
Q_OBJECT
public:
explicit ThumbnailJob(const QString& path, AccountPtr account, QObject* parent = 0);
public slots:
void start() Q_DECL_OVERRIDE;
signals:
void jobFinished(int statusCode, QByteArray reply);
private slots:
virtual bool finished() Q_DECL_OVERRIDE;
private:
QUrl _url;
};
namespace Ui {
class ShareDialog;
}