2 * Copyright (C) 2013 Canonical, Ltd.
5 * Pawel Stolowski <pawel.stolowski@canonical.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22#include "previewaction.h"
23#include "genericpreview.h"
24#include "applicationpreview.h"
25#include "moviepreview.h"
26#include "musicpreview.h"
27#include "variantutils.h"
32#include <UnityCore/GenericPreview.h>
33#include <UnityCore/ApplicationPreview.h>
34#include <UnityCore/MoviePreview.h>
35#include <UnityCore/MusicPreview.h>
37Preview::Preview(QObject *parent):
42QString Preview::rendererName() const
45 return QString::fromStdString(m_unityPreview->renderer_name());
47 qWarning() << "Preview not set";
52QString Preview::title() const
55 return QString::fromStdString(m_unityPreview->title());
57 qWarning() << "Preview not set";
62QString Preview::subtitle () const
65 return QString::fromStdString(m_unityPreview->subtitle());
67 qWarning() << "Preview not set";
72QVariant Preview::actions()
74 QList<QObject *> alist;
76 for (auto unityAction: m_unityPreview->GetActions()) {
77 auto action = new PreviewAction(this); // preview is the owner of actions
78 action->setUnityAction(unityAction);
82 qWarning() << "Preview not set";
85 return QVariant::fromValue(alist);
88Preview* Preview::newFromUnityPreview(unity::dash::Preview::Ptr unityPreview)
90 Preview* preview = nullptr;
92 if (typeid(*unityPreview) == typeid(unity::dash::GenericPreview)) {
93 preview = new GenericPreview();
95 else if (typeid(*unityPreview) == typeid(unity::dash::MusicPreview)) {
96 preview = new MusicPreview();
98 else if (typeid(*unityPreview) == typeid(unity::dash::MoviePreview)) {
99 preview = new MoviePreview();
101 else if (typeid(*unityPreview) == typeid(unity::dash::ApplicationPreview)) {
102 preview = new ApplicationPreview();
104 qWarning() << "Unknown preview type: " << typeid(*unityPreview).name();
105 preview = new GenericPreview();
107 preview->Preview::setUnityPreview(unityPreview);
108 preview->setUnityPreview(unityPreview);
113void Preview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
115 m_unityPreview = unityPreview;
116 Q_EMIT rendererNameChanged();
117 Q_EMIT titleChanged();
118 Q_EMIT subtitleChanged();
119 Q_EMIT actionsChanged();
122void Preview::execute(const QString& actionId, const QHash<QString, QVariant>& hints)
124 if (m_unityPreview) {
125 auto unityHints = convertToHintsMap(hints);
126 m_unityPreview->PerformAction(actionId.toStdString(), unityHints);
128 qWarning() << "Preview not set";
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