Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/plugin/thumbnailer.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright (C) 2016 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Lesser General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2.1 of the License, or (at your option) any later version. | ||||
8 | | ||||
9 | This library is distributed in the hope that it will be useful, | ||||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
12 | Lesser General Public License for more details. | ||||
13 | | ||||
14 | You should have received a copy of the GNU Lesser General Public | ||||
15 | License along with this library; if not, write to the Free Software | ||||
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||
17 | */ | ||||
18 | | ||||
19 | #pragma once | ||||
20 | | ||||
21 | #include <QObject> | ||||
22 | #include <QQmlParserStatus> | ||||
23 | | ||||
24 | #include <QPixmap> | ||||
25 | #include <QSize> | ||||
26 | #include <QUrl> | ||||
27 | | ||||
28 | class Thumbnailer : public QObject, public QQmlParserStatus | ||||
29 | { | ||||
30 | Q_OBJECT | ||||
31 | Q_INTERFACES(QQmlParserStatus) | ||||
32 | | ||||
33 | Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) | ||||
34 | Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY sizeChanged) | ||||
35 | | ||||
36 | Q_PROPERTY(bool hasPreview READ hasPreview NOTIFY pixmapChanged) | ||||
37 | Q_PROPERTY(QPixmap pixmap READ pixmap NOTIFY pixmapChanged) | ||||
38 | Q_PROPERTY(QSize pixmapSize READ pixmapSize NOTIFY pixmapChanged) | ||||
39 | | ||||
40 | Q_PROPERTY(QString iconName READ iconName NOTIFY iconNameChanged) | ||||
41 | | ||||
42 | public: | ||||
43 | explicit Thumbnailer(QObject *parent = nullptr); | ||||
44 | ~Thumbnailer() override; | ||||
45 | | ||||
46 | QUrl url() const; | ||||
47 | void setUrl(const QUrl &url); | ||||
48 | | ||||
49 | QSize size() const; | ||||
50 | void setSize(const QSize &size); | ||||
51 | | ||||
52 | bool hasPreview() const; | ||||
53 | QPixmap pixmap() const; | ||||
54 | QSize pixmapSize() const; | ||||
55 | | ||||
56 | QString iconName() const; | ||||
57 | | ||||
58 | void classBegin() override; | ||||
59 | void componentComplete() override; | ||||
60 | | ||||
61 | signals: | ||||
62 | void urlChanged(); | ||||
63 | void sizeChanged(); | ||||
64 | void pixmapChanged(); | ||||
65 | void iconNameChanged(); | ||||
66 | | ||||
67 | private: | ||||
68 | void generatePreview(); | ||||
69 | | ||||
70 | bool m_inited = false; | ||||
71 | | ||||
72 | QUrl m_url; | ||||
73 | QSize m_size; | ||||
74 | | ||||
75 | QPixmap m_pixmap; | ||||
76 | | ||||
77 | QString m_iconName; | ||||
78 | | ||||
79 | }; |