Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 1 | /* |
Stepan Salenikovich | be87d2c | 2016-01-25 14:14:34 -0500 | [diff] [blame] | 2 | * Copyright (C) 2015-2016 Savoir-faire Linux Inc. |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 3 | * Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 18 | */ |
| 19 | |
Stepan Salenikovich | bbd6c13 | 2015-08-20 15:21:48 -0400 | [diff] [blame] | 20 | #pragma once |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 21 | |
| 22 | #include <gtk/gtk.h> |
| 23 | #include <memory> |
Stepan Salenikovich | bbd6c13 | 2015-08-20 15:21:48 -0400 | [diff] [blame] | 24 | #include <interfaces/pixmapmanipulatori.h> |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 25 | |
| 26 | Q_DECLARE_METATYPE(std::shared_ptr<GdkPixbuf>); |
| 27 | |
| 28 | class Person; |
| 29 | |
Stepan Salenikovich | bbd6c13 | 2015-08-20 15:21:48 -0400 | [diff] [blame] | 30 | namespace Interfaces { |
| 31 | |
| 32 | class PixbufManipulator : public PixmapManipulatorI { |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 33 | constexpr static int FALLBACK_AVATAR_SIZE {100}; |
| 34 | public: |
Stepan Salenikovich | bbd6c13 | 2015-08-20 15:21:48 -0400 | [diff] [blame] | 35 | PixbufManipulator(); |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 36 | |
| 37 | QVariant callPhoto(Call* c, const QSize& size, bool displayPresence = true) override; |
| 38 | QVariant callPhoto(const ContactMethod* n, const QSize& size, bool displayPresence = true) override; |
| 39 | QVariant contactPhoto(Person* c, const QSize& size, bool displayPresence = true) override; |
| 40 | QVariant personPhoto(const QByteArray& data, const QString& type = "PNG") override; |
| 41 | |
Stepan Salenikovich | bbd6c13 | 2015-08-20 15:21:48 -0400 | [diff] [blame] | 42 | /* TODO: the following methods return an empty QVariant/QByteArray */ |
| 43 | QVariant numberCategoryIcon(const QVariant& p, const QSize& size, bool displayPresence = false, bool isPresent = false) override; |
| 44 | QVariant securityIssueIcon(const QModelIndex& index) override; |
| 45 | QByteArray toByteArray(const QVariant& pxm) override; |
| 46 | QVariant collectionIcon(const CollectionInterface* interface, PixmapManipulatorI::CollectionIconHint hint = PixmapManipulatorI::CollectionIconHint::NONE) const override; |
| 47 | QVariant securityLevelIcon(const SecurityEvaluationModel::SecurityLevel level) const override; |
| 48 | QVariant historySortingCategoryIcon(const CategorizedHistoryModel::SortedProxy::Categories cat) const override; |
| 49 | QVariant contactSortingCategoryIcon(const CategorizedContactModel::SortedProxy::Categories cat) const override; |
| 50 | QVariant userActionIcon(const UserActionElement& state) const override; |
Stepan Salenikovich | 8d07695 | 2016-01-08 13:48:43 -0500 | [diff] [blame] | 51 | QVariant decorationRole(const QModelIndex& index) override; |
| 52 | QVariant decorationRole(const Call* c) override; |
| 53 | QVariant decorationRole(const ContactMethod* cm) override; |
| 54 | QVariant decorationRole(const Person* p) override; |
Stepan Salenikovich | bbd6c13 | 2015-08-20 15:21:48 -0400 | [diff] [blame] | 55 | |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 56 | private: |
| 57 | std::shared_ptr<GdkPixbuf> scaleAndFrame(const GdkPixbuf *photo, const QSize& size); |
| 58 | std::shared_ptr<GdkPixbuf> fallbackAvatar_; |
Stepan Salenikovich | ee8506e | 2015-08-13 11:35:14 -0400 | [diff] [blame] | 59 | std::shared_ptr<GdkPixbuf> conferenceAvatar_; |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame] | 60 | }; |
| 61 | |
Stepan Salenikovich | bbd6c13 | 2015-08-20 15:21:48 -0400 | [diff] [blame] | 62 | } // namespace Interfaces |