on 117f2d8 help sign in
132 lines 4.2 kB history raw
1#ifndef SCREEN_H
2#define SCREEN_H
4#include <qtmir/screen.h>
5#include <QScopedPointer>
6#include <QPointer>
8#include "WorkspaceModel.h"
10class ScreenProxy;
11class ScreenAttached;
13class ScreenInterface: public QObject
15 Q_OBJECT
17 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
18 Q_PROPERTY(bool used READ used NOTIFY usedChanged)
19 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
20 Q_PROPERTY(qtmir::OutputTypes outputType READ outputType NOTIFY outputTypeChanged)
21 Q_PROPERTY(float scale READ scale NOTIFY scaleChanged)
22 Q_PROPERTY(qtmir::FormFactor formFactor READ formFactor NOTIFY formFactorChanged)
23 Q_PROPERTY(MirPowerMode powerMode READ powerMode NOTIFY powerModeChanged)
24 Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation NOTIFY orientationChanged)
25 Q_PROPERTY(QPoint position READ position NOTIFY positionChanged)
26 Q_PROPERTY(uint currentModeIndex READ currentModeIndex NOTIFY currentModeIndexChanged)
27 Q_PROPERTY(QQmlListProperty<qtmir::ScreenMode> availableModes READ availableModes NOTIFY availableModesChanged)
28 Q_PROPERTY(QSizeF physicalSize READ physicalSize NOTIFY physicalSizeChanged)
29 Q_PROPERTY(QString outputTypeName READ outputTypeName NOTIFY outputTypeChanged)
30 Q_PROPERTY(WorkspaceModel* workspaces READ workspaces CONSTANT)
31 Q_PROPERTY(Workspace* currentWorkspace READ currentWorkspace WRITE setCurrentWorkspace NOTIFY currentWorkspaceChanged)
32public:
33 // From qtmir::Screen
34 qtmir::OutputId outputId() const;
35 bool used() const;
36 QString name() const;
37 float scale() const;
38 QSizeF physicalSize() const;
39 qtmir::FormFactor formFactor() const;
40 qtmir::OutputTypes outputType() const;
41 MirPowerMode powerMode() const;
42 Qt::ScreenOrientation orientation() const;
43 QPoint position() const;
44 QQmlListProperty<qtmir::ScreenMode> availableModes();
45 uint currentModeIndex() const;
46 bool isActive() const;
47 void setActive(bool active);
48 QScreen* qscreen() const;
49 qtmir::ScreenConfiguration *beginConfiguration() const;
50 bool applyConfiguration(qtmir::ScreenConfiguration *configuration);
51 QString outputTypeName() const;
53 virtual WorkspaceModel* workspaces() const = 0;
54 virtual Workspace *currentWorkspace() const = 0;
55 virtual void setCurrentWorkspace(Workspace* workspace) = 0;
57 void sync(ScreenInterface* proxy);
59 qtmir::Screen* wrapped() const { return m_wrapped; }
61public Q_SLOTS:
62 void activate();
64Q_SIGNALS:
65 void usedChanged();
66 void nameChanged();
67 void outputTypeChanged();
68 void scaleChanged();
69 void formFactorChanged();
70 void powerModeChanged();
71 void orientationChanged();
72 void positionChanged();
73 void currentModeIndexChanged();
74 void physicalSizeChanged();
75 void availableModesChanged();
76 void activeChanged(bool active);
77 void currentWorkspaceChanged(Workspace*);
79protected:
80 ScreenInterface(QObject* parent = 0);
82 void connectToScreen(qtmir::Screen* screen);
83 void connectToScreen(ScreenInterface* screen);
85protected:
86 QPointer<qtmir::Screen> m_wrapped;
87};
90class Screen : public ScreenInterface
92 Q_OBJECT
93public:
94 explicit Screen(qtmir::Screen*const wrapped);
96 // From qtmir::Screen
97 WorkspaceModel* workspaces() const override;
98 Workspace *currentWorkspace() const override;
99 void setCurrentWorkspace(Workspace* workspace) override;
101 static ScreenAttached *qmlAttachedProperties(QObject *owner);
103protected:
104 void resetCurrentWorkspace();
106 const QScopedPointer<WorkspaceModel> m_workspaces;
107 QPointer<Workspace> m_currentWorspace;
108};
110class ScreenProxy : public ScreenInterface
112 Q_OBJECT
113public:
114 explicit ScreenProxy(ScreenInterface*const screen);
116 // From qtmir::Screen
117 WorkspaceModel* workspaces() const override;
118 Workspace *currentWorkspace() const override;
119 void setCurrentWorkspace(Workspace* workspace) override;
121 ScreenInterface* proxyObject() const { return m_original.data(); }
123public Q_SLOTS:
124 void addWorkspace();
126private:
127 const QScopedPointer<WorkspaceModel> m_workspaces;
128 const QPointer<ScreenInterface> m_original;
129 QPointer<Workspace> m_currentWorspace;
130};
132#endif // SCREEN_H