-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40aa630
commit 8cbcb2c
Showing
6 changed files
with
85 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (C) by Hannah von Reth <hannah.vonreth@owncloud.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
*/ | ||
#include "spaceimageprovider.h" | ||
#include "libsync/graphapi/spacesmanager.h" | ||
#include "resources/resources.h" | ||
|
||
using namespace OCC; | ||
using namespace Spaces; | ||
|
||
SpaceImageProvider::SpaceImageProvider(const AccountPtr &account) | ||
: QQuickImageProvider(QQuickImageProvider::Pixmap, QQuickImageProvider::ForceAsynchronousImageLoading) | ||
, _account(account) | ||
{ | ||
} | ||
|
||
QPixmap SpaceImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) | ||
{ | ||
// TODO: the url hast random parts to enforce a reload | ||
const auto ids = id.split(QLatin1Char('/')); | ||
const auto *space = _account->spacesManager()->space(ids.last()); | ||
QIcon icon; | ||
if (space) { | ||
icon = space->image(); | ||
} else { | ||
icon = Resources::getCoreIcon(QStringLiteral("space")); | ||
} | ||
const QSize actualSize = requestedSize.isValid() ? requestedSize : icon.availableSizes().first(); | ||
if (size) { | ||
*size = actualSize; | ||
} | ||
return icon.pixmap(actualSize); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (C) by Hannah von Reth <hannah.vonreth@owncloud.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
*/ | ||
|
||
#pragma once | ||
|
||
|
||
#include "gui/spaces/spaceslib.h" | ||
#include "libsync/account.h" | ||
|
||
#include <QQuickImageProvider> | ||
|
||
namespace OCC::Spaces { | ||
class SPACES_EXPORT SpaceImageProvider : public QQuickImageProvider | ||
{ | ||
Q_OBJECT | ||
public: | ||
SpaceImageProvider(const AccountPtr &account); | ||
QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override; | ||
|
||
|
||
private: | ||
AccountPtr _account; | ||
}; | ||
|
||
} |