on b2a69e2 help sign in
104 lines 3.3 kB history raw
1/*
2 * Copyright (C) 2014,2015 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 "ObjectListModel.h"
21#include "SessionModel.h"
23#include <QQuickItem>
25class ApplicationInfo;
26class MirSurface;
28class Session : public QObject
30 Q_OBJECT
31 Q_PROPERTY(QString name READ name CONSTANT)
32 Q_PROPERTY(MirSurface* lastSurface READ lastSurface NOTIFY lastSurfaceChanged)
33 Q_PROPERTY(ObjectListModel<MirSurface>* surfaces READ surfaces CONSTANT)
34 Q_PROPERTY(ApplicationInfo* application READ application NOTIFY applicationChanged)
35 Q_PROPERTY(Session* parentSession READ parentSession NOTIFY parentSessionChanged DESIGNABLE false)
36 Q_PROPERTY(SessionModel* childSessions READ childSessions DESIGNABLE false CONSTANT)
37 Q_PROPERTY(bool live READ live NOTIFY liveChanged)
39public:
40 explicit Session(const QString &name,
41 const QUrl& screenshot,
42 QObject *parent = 0);
43 ~Session();
45 Q_INVOKABLE void release();
47 //getters
48 QString name() const { return m_name; }
49 bool live() const { return m_live; }
50 bool fullscreen() const { return m_fullscreen; }
51 ApplicationInfo* application() const { return m_application; }
52 MirSurface *lastSurface() const;
53 ObjectListModel<MirSurface>* surfaces() const;
54 Session* parentSession() const { return m_parentSession; }
56 void setApplication(ApplicationInfo* item);
57 void appendSurface(MirSurface* surface);
58 void removeSurface(MirSurface* surface);
59 void setScreenshot(const QUrl& m_screenshot);
60 void setLive(bool live);
61 void setFullscreen(bool fullscreen);
63 Q_INVOKABLE void addChildSession(Session* session);
64 void insertChildSession(uint index, Session* session);
65 Q_INVOKABLE void removeChildSession(Session* session);
67Q_SIGNALS:
68 void applicationChanged(ApplicationInfo*);
69 void parentSessionChanged(Session*);
70 void liveChanged(bool live);
71 void surfaceAdded(MirSurface *surface);
72 void lastSurfaceChanged(MirSurface *surface);
73 void fullscreenChanged(bool fullscreen);
75 // internal mock use
76 void deregister();
78public Q_SLOTS:
79 Q_INVOKABLE void createSurface();
81private Q_SLOTS:
82 void updateFullscreenProperty();
84private:
85 SessionModel* childSessions() const;
86 void setParentSession(Session* session);
88 QString m_name;
89 bool m_live;
90 QUrl m_screenshot;
91 ApplicationInfo* m_application;
92 MirSurface* m_surface;
93 Session* m_parentSession;
94 SessionModel* m_children;
95 ObjectListModel<MirSurface> m_surfaces;
96 bool m_fullscreen;
98 friend class ApplicationTestInterface;
99};
101Q_DECLARE_METATYPE(Session*)
102Q_DECLARE_METATYPE(ObjectListModel<MirSurface>*)
104#endif // SESSION_H