2 * Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2,
6 * or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU Library General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef BACKGROUNDPACKAGE_H
20 #define BACKGROUNDPACKAGE_H
24 #include <QPersistentModelIndex>
29 #include <ThreadWeaver/Job>
30 #include <Plasma/Package>
32 namespace Plasma
{ class PackageMetadata
; }
34 class DummyObject
: public QObject
38 void done(ThreadWeaver::Job
*);
41 class Background
: public QObject
54 static const int SCREENSHOT_HEIGHT
= 60;
56 virtual ~Background();
58 virtual QString
path() const = 0;
59 virtual QString
findBackground(const QSize
&resolution
,
60 ResizeMethod method
) const = 0;
61 virtual QPixmap
screenshot() const = 0;
62 virtual bool screenshotGenerationStarted() const = 0;
63 virtual void generateScreenshot(QPersistentModelIndex index
) const = 0;
64 virtual QString
title() const = 0;
65 virtual QString
author() const = 0;
66 virtual QString
email() const = 0;
67 virtual QString
license() const = 0;
69 virtual bool isValid() const = 0;
72 static QImage
defaultScreenshot();
73 static QImage
createScreenshot(const QString
&path
, float ratio
);
74 friend class ResizeThread
;
77 class BackgroundPackage
: public Background
,
78 public Plasma::Package
82 BackgroundPackage(const QString
&path
, float ratio
);
84 virtual QString
path() const;
85 virtual QString
findBackground(const QSize
&resolution
,
86 ResizeMethod method
) const;
87 virtual QPixmap
screenshot() const;
88 virtual bool screenshotGenerationStarted() const;
89 virtual void generateScreenshot(QPersistentModelIndex index
) const;
90 virtual QString
author() const;
91 virtual QString
title() const;
92 virtual QString
email() const;
93 virtual QString
license() const;
94 virtual bool isValid() const;
96 QString
resString(const QSize
&size
) const;
97 QSize
resSize(const QString
&res
) const;
99 float distance(const QSize
&size
,
100 const QSize
&desired
,
101 ResizeMethod method
) const;
105 mutable QPixmap m_screenshot
;
108 class BackgroundFile
: public Background
112 BackgroundFile(const QString
&file
, float ratio
);
113 virtual ~BackgroundFile();
115 virtual QString
path() const;
116 virtual QString
findBackground(const QSize
&resolution
,
117 ResizeMethod method
) const;
118 virtual bool screenshotGenerationStarted() const;
119 virtual void generateScreenshot(QPersistentModelIndex index
) const;
120 virtual QPixmap
screenshot() const;
121 virtual QString
author() const;
122 virtual QString
title() const;
123 virtual QString
email() const;
124 virtual QString
license() const;
125 virtual bool isValid() const;
130 mutable bool m_resizer_started
;
131 mutable QPixmap m_screenshot
;
133 void updateScreenshot(ThreadWeaver::Job
*);
135 void screenshotDone(QPersistentModelIndex index
);
138 #endif // BACKGROUNDPACKAGE_H