on bd9428e help sign in
88 lines 2.6 kB history raw
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
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.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#ifndef SESSION_H
18#define SESSION_H
20#include "SessionModel.h"
22#include <QQuickItem>
24class ApplicationInfo;
25class MirSurfaceItem;
27class Session : public QObject
29 Q_OBJECT
30 Q_PROPERTY(QString name READ name CONSTANT)
31 Q_PROPERTY(MirSurfaceItem* surface READ surface NOTIFY surfaceChanged)
32 Q_PROPERTY(Session* parentSession READ parentSession NOTIFY parentSessionChanged DESIGNABLE false)
33 Q_PROPERTY(SessionModel* childSessions READ childSessions DESIGNABLE false CONSTANT)
34 Q_PROPERTY(bool live READ live NOTIFY liveChanged)
36public:
37 explicit Session(const QString &name,
38 const QUrl& screenshot,
39 QObject *parent = 0);
40 ~Session();
42 Q_INVOKABLE void release();
44 //getters
45 QString name() const { return m_name; }
46 bool live() const { return m_live; }
47 ApplicationInfo* application() const { return m_application; }
48 MirSurfaceItem* surface() const { return m_surface; }
49 Session* parentSession() const { return m_parentSession; }
51 void setApplication(ApplicationInfo* item);
52 void setSurface(MirSurfaceItem* surface);
53 void setScreenshot(const QUrl& m_screenshot);
54 void setLive(bool live);
56 Q_INVOKABLE void addChildSession(Session* session);
57 void insertChildSession(uint index, Session* session);
58 void removeChildSession(Session* session);
60Q_SIGNALS:
61 void surfaceChanged(MirSurfaceItem*);
62 void parentSessionChanged(Session*);
63 void liveChanged(bool isLive);
65 // internal mock use
66 void deregister();
68public Q_SLOTS:
69 Q_INVOKABLE void createSurface();
71private:
72 SessionModel* childSessions() const;
73 void setParentSession(Session* session);
75 QString m_name;
76 bool m_live;
77 QUrl m_screenshot;
78 ApplicationInfo* m_application;
79 MirSurfaceItem* m_surface;
80 Session* m_parentSession;
81 SessionModel* m_children;
83 friend class ApplicationTestInterface;
84};
86Q_DECLARE_METATYPE(Session*)
88#endif // SESSION_H