on bbccae6 help sign in
94 lines 2.8 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 MirSurface;
27class Session : public QObject
29 Q_OBJECT
30 Q_PROPERTY(QString name READ name CONSTANT)
31 Q_PROPERTY(MirSurface* surface READ surface NOTIFY surfaceChanged)
32 Q_PROPERTY(ApplicationInfo* application READ application NOTIFY applicationChanged)
33 Q_PROPERTY(Session* parentSession READ parentSession NOTIFY parentSessionChanged DESIGNABLE false)
34 Q_PROPERTY(SessionModel* childSessions READ childSessions DESIGNABLE false CONSTANT)
35 Q_PROPERTY(bool live READ live NOTIFY liveChanged)
37public:
38 explicit Session(const QString &name,
39 const QUrl& screenshot,
40 QObject *parent = 0);
41 ~Session();
43 Q_INVOKABLE void release();
45 //getters
46 QString name() const { return m_name; }
47 bool live() const { return m_live; }
48 ApplicationInfo* application() const { return m_application; }
49 MirSurface* surface() const { return m_surface; }
50 Session* parentSession() const { return m_parentSession; }
52 void setApplication(ApplicationInfo* item);
53 void setSurface(MirSurface* surface);
54 void setScreenshot(const QUrl& m_screenshot);
55 void setLive(bool live);
57 Q_INVOKABLE void addChildSession(Session* session);
58 void insertChildSession(uint index, Session* session);
59 Q_INVOKABLE void removeChildSession(Session* session);
61Q_SIGNALS:
62 void applicationChanged(ApplicationInfo*);
63 void surfaceChanged(MirSurface*);
64 void parentSessionChanged(Session*);
65 void liveChanged(bool live);
67 // internal mock use
68 void deregister();
70public Q_SLOTS:
71 Q_INVOKABLE void createSurface();
74private Q_SLOTS:
75 void onSurfaceDestroyed();
77private:
78 SessionModel* childSessions() const;
79 void setParentSession(Session* session);
81 QString m_name;
82 bool m_live;
83 QUrl m_screenshot;
84 ApplicationInfo* m_application;
85 MirSurface* m_surface;
86 Session* m_parentSession;
87 SessionModel* m_children;
89 friend class ApplicationTestInterface;
90};
92Q_DECLARE_METATYPE(Session*)
94#endif // SESSION_H