2 * Copyright (C) 2014 Canonical, Ltd.
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.
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.
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/>.
17#include "ApplicationScreenshotProvider.h"
18#include "ApplicationManager.h"
19#include "ApplicationInfo.h"
24#include <QGuiApplication>
26#include <QQuickWindow>
28ApplicationScreenshotProvider::ApplicationScreenshotProvider(ApplicationManager *appManager)
29 : QQuickImageProvider(QQuickImageProvider::Image)
30 , m_appManager(appManager)
34QImage ApplicationScreenshotProvider::requestImage(const QString &imageId, QSize * size,
35 const QSize &requestedSize)
37 // We ignore requestedSize here intentionally to avoid keeping scaled copies around
38 Q_UNUSED(requestedSize)
40 QString appId = imageId.split('/').first();
42 ApplicationInfo* app = static_cast<ApplicationInfo*>(m_appManager->findApplication(appId));
48 if (!image.load(app->screenshot())) {
49 qWarning() << "failed loading app image" << app->screenshot();
53 if (app->stage() == ApplicationInfo::SideStage) {
54 QByteArray gus = qgetenv("GRID_UNIT_PX");
55 if (gus.isEmpty() || gus.toInt() == 0) {
58 image = image.scaledToWidth(gus.toInt() * 48);
60 // Lets scale main stage applications to be the size of the screen/window.
61 QGuiApplication *unity = qobject_cast<QGuiApplication*>(qApp);
62 Q_FOREACH (QWindow *win, unity->allWindows()) {
63 QQuickWindow *quickWin = qobject_cast<QQuickWindow*>(win);
65 image = image.scaledToWidth(quickWin->width());
71 size->setWidth(image.width());
72 size->setHeight(image.height());
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list