on e174ec3 help sign in
131 lines 4.1 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)
19 Q_PROPERTY(bool used READ used NOTIFY usedChanged)
20 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
21 Q_PROPERTY(qtmir::OutputTypes outputType READ outputType NOTIFY outputTypeChanged)
22 Q_PROPERTY(float scale READ scale NOTIFY scaleChanged)
23 Q_PROPERTY(qtmir::FormFactor formFactor READ formFactor NOTIFY formFactorChanged)
24 Q_PROPERTY(MirPowerMode powerMode READ powerMode NOTIFY powerModeChanged)
25 Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation NOTIFY orientationChanged)
26 Q_PROPERTY(QPoint position READ position NOTIFY positionChanged)
27 Q_PROPERTY(uint currentModeIndex READ currentModeIndex NOTIFY currentModeIndexChanged)
28 Q_PROPERTY(QQmlListProperty<qtmir::ScreenMode> availableModes READ availableModes NOTIFY availableModesChanged)
29 Q_PROPERTY(QSizeF physicalSize READ physicalSize NOTIFY physicalSizeChanged)
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);
52 virtual WorkspaceModel* workspaces() const = 0;
53 virtual Workspace *currentWorkspace() const = 0;
54 virtual void setCurrentWorkspace(Workspace* workspace) = 0;
56 void sync(ScreenInterface* proxy);
58 qtmir::Screen* wrapped() const { return m_wrapped; }
60public Q_SLOTS:
61 void activate();
63Q_SIGNALS:
64 void usedChanged();
65 void nameChanged();
66 void outputTypeChanged();
67 void scaleChanged();
68 void formFactorChanged();
69 void powerModeChanged();
70 void orientationChanged();
71 void positionChanged();
72 void currentModeIndexChanged();
73 void physicalSizeChanged();
74 void availableModesChanged();
75 void activeChanged(bool active);
76 void currentWorkspaceChanged(Workspace*);
78protected:
79 ScreenInterface(QObject* parent = 0);
81 void connectToScreen(qtmir::Screen* screen);
82 void connectToScreen(ScreenInterface* screen);
84protected:
85 QPointer<qtmir::Screen> m_wrapped;
86};
89class Screen : public ScreenInterface
91 Q_OBJECT
92public:
93 explicit Screen(qtmir::Screen*const wrapped);
95 // From qtmir::Screen
96 WorkspaceModel* workspaces() const override;
97 Workspace *currentWorkspace() const override;
98 void setCurrentWorkspace(Workspace* workspace) override;
100 static ScreenAttached *qmlAttachedProperties(QObject *owner);
102protected:
103 void resetCurrentWorkspace();
105 const QScopedPointer<WorkspaceModel> m_workspaces;
106 QPointer<Workspace> m_currentWorspace;
107};
109class ScreenProxy : public ScreenInterface
111 Q_OBJECT
112public:
113 explicit ScreenProxy(ScreenInterface*const screen);
115 // From qtmir::Screen
116 WorkspaceModel* workspaces() const override;
117 Workspace *currentWorkspace() const override;
118 void setCurrentWorkspace(Workspace* workspace) override;
120 ScreenInterface* proxyObject() const { return m_original.data(); }
122public Q_SLOTS:
123 void addWorkspace();
125private:
126 const QScopedPointer<WorkspaceModel> m_workspaces;
127 const QPointer<ScreenInterface> m_original;
128 QPointer<Workspace> m_currentWorspace;
129};
131#endif // SCREEN_H