on xenial help sign in
added missing files
c969157Michael Zanetti
tests/mocks/Unity/Application/ApplicationScreenshotProvider.cppnew file+56
@@ -0,0 +1,56 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it under
5+ * the terms of the GNU Lesser General Public License version 3, as published by
6+ * the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but WITHOUT
9+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+ * Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "ApplicationScreenshotProvider.h"
18+#include "ApplicationManager.h"
19+#include "ApplicationInfo.h"
20+
21+#include "paths.h"
22+
23+#include <QDebug>
24+
25+ApplicationScreenshotProvider::ApplicationScreenshotProvider(ApplicationManager *appManager)
26+ : QQuickImageProvider(QQuickImageProvider::Image)
27+ , m_appManager(appManager)
28+{
29+}
30+
31+QImage ApplicationScreenshotProvider::requestImage(const QString &imageId, QSize * size,
32+ const QSize &requestedSize)
33+{
34+ // We ignore requestedSize here intentionally to avoid keeping scaled copies around
35+ Q_UNUSED(requestedSize)
36+
37+ QString appId = imageId.split('/').first();
38+
39+ ApplicationInfo* app = static_cast<ApplicationInfo*>(m_appManager->findApplication(appId));
40+ if (app == NULL) {
41+ qDebug() << "ApplicationScreenshotProvider - app not found:" << appId;
42+ return QImage();
43+ }
44+
45+ QString filePath = QString("%1/Dash/graphics/phone/screenshots/%2@12.png").arg(qmlDirectory()).arg(app->icon().toString());
46+
47+ QImage image;
48+ if (!image.load(filePath)) {
49+ qDebug() << "failed loading app image" << filePath;
50+ }
51+
52+ size->setWidth(image.width());
53+ size->setHeight(image.height());
54+
55+ return image;
56+}
tests/mocks/Unity/Application/ApplicationScreenshotProvider.hnew file+34
@@ -0,0 +1,34 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it under
5+ * the terms of the GNU Lesser General Public License version 3, as published by
6+ * the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but WITHOUT
9+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+ * Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef APPLICATIONSCREENSHOTPROVIDER_H
18+#define APPLICATIONSCREENSHOTPROVIDER_H
19+
20+#include <QQuickImageProvider>
21+
22+class ApplicationManager;
23+class ApplicationScreenshotProvider : public QQuickImageProvider
24+{
25+public:
26+ explicit ApplicationScreenshotProvider(ApplicationManager *appManager);
27+
28+ QImage requestImage(const QString &appId, QSize *size, const QSize &requestedSize) override;
29+
30+private:
31+ ApplicationManager* m_appManager;
32+};
33+
34+#endif // APPLICATIONSCREENSHOTPROVIDER_H