blob: ddeb4e1774a31c63278bc66eb747e55b2da35409 [file] [log] [blame]
Stepan Salenikovich6f687072015-03-26 10:43:37 -04001/*
Stepan Salenikovichbe87d2c2016-01-25 14:14:34 -05002 * Copyright (C) 2015-2016 Savoir-faire Linux Inc.
Stepan Salenikovich6f687072015-03-26 10:43:37 -04003 * 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 Salenikovich6f687072015-03-26 10:43:37 -040018 */
19
Stepan Salenikovichbbd6c132015-08-20 15:21:48 -040020#pragma once
Stepan Salenikovich6f687072015-03-26 10:43:37 -040021
22#include <gtk/gtk.h>
23#include <memory>
Stepan Salenikovichbbd6c132015-08-20 15:21:48 -040024#include <interfaces/pixmapmanipulatori.h>
Stepan Salenikovich6f687072015-03-26 10:43:37 -040025
26Q_DECLARE_METATYPE(std::shared_ptr<GdkPixbuf>);
27
28class Person;
29
Stepan Salenikovichbbd6c132015-08-20 15:21:48 -040030namespace Interfaces {
31
32class PixbufManipulator : public PixmapManipulatorI {
Stepan Salenikovich6f687072015-03-26 10:43:37 -040033 constexpr static int FALLBACK_AVATAR_SIZE {100};
34public:
Stepan Salenikovichbbd6c132015-08-20 15:21:48 -040035 PixbufManipulator();
Stepan Salenikovich6f687072015-03-26 10:43:37 -040036
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 Salenikovichbbd6c132015-08-20 15:21:48 -040042 /* 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 Salenikovich8d076952016-01-08 13:48:43 -050051 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;
Alexandre Lision50fd6af2016-04-20 17:13:58 -040055 QVariant decorationRole(const Account* p) override;
Stepan Salenikovichbbd6c132015-08-20 15:21:48 -040056
Stepan Salenikovich6f687072015-03-26 10:43:37 -040057private:
aviauc372e812016-12-01 16:13:16 -050058 std::shared_ptr<GdkPixbuf> scaleAndFrame(const GdkPixbuf *photo, const QSize& size, bool display_presence = false, bool is_present = false);
Stepan Salenikovich6f687072015-03-26 10:43:37 -040059 std::shared_ptr<GdkPixbuf> fallbackAvatar_;
Stepan Salenikovichee8506e2015-08-13 11:35:14 -040060 std::shared_ptr<GdkPixbuf> conferenceAvatar_;
Stepan Salenikovich6f687072015-03-26 10:43:37 -040061};
62
Stepan Salenikovichbbd6c132015-08-20 15:21:48 -040063} // namespace Interfaces