~ubuntu-branches/ubuntu/wily/kscreen/wily

« back to all changes in this revision

Viewing changes to kcm/src/declarative/qmloutput.h

  • Committer: Package Import Robot
  • Author(s): Scarlett Clark, Scarlett Clark, Jonathan Riddell, Harald Sitter
  • Date: 2014-08-20 08:35:15 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20140820083515-i9lk9nyt0adwd2q5
Tags: 2.0.0~git20141114-0ubuntu1
[ Scarlett Clark ]
* Update packaging for frameworks branch
* Git snapshot of the frameworks branch

[ Jonathan Riddell ]
* Remove kscreen-console.1 manpage which is out of date

[ Harald Sitter ]
* switch to new pkg-kde-tools

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (C) 2013  Daniel Vrátil <dvratil@redhat.com>
 
3
 
 
4
    This library is free software; you can redistribute it and/or
 
5
    modify it under the terms of the GNU Lesser General Public
 
6
    License as published by the Free Software Foundation; either
 
7
    version 2.1 of the License, or (at your option) any later version.
 
8
 
 
9
    This library is distributed in the hope that it will be useful,
 
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
    Lesser General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU Lesser General Public
 
15
    License along with this library; if not, write to the Free Software
 
16
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
17
*/
 
18
 
 
19
 
 
20
#ifndef QMLOUTPUT_H
 
21
#define QMLOUTPUT_H
 
22
 
 
23
#include <QQuickItem>
 
24
#include <kscreen/mode.h>
 
25
 
 
26
class QStandardItemModel;
 
27
class QAbstractItemModel;
 
28
 
 
29
class ModesProxyModel;
 
30
class QMLScreen;
 
31
 
 
32
namespace KScreen {
 
33
class Output;
 
34
}
 
35
 
 
36
class QMLOutput : public QQuickItem
 
37
{
 
38
    Q_OBJECT
 
39
 
 
40
    Q_PROPERTY(KScreen::Output* output
 
41
               READ output
 
42
               WRITE setOutput
 
43
               NOTIFY outputChanged)
 
44
 
 
45
    Q_PROPERTY(bool isCloneMode
 
46
               READ isCloneMode
 
47
               WRITE setIsCloneMode
 
48
               NOTIFY isCloneModeChanged)
 
49
 
 
50
    Q_PROPERTY(QMLScreen* screen
 
51
               READ screen
 
52
               WRITE setScreen
 
53
               NOTIFY screenChanged)
 
54
 
 
55
    Q_PROPERTY(QMLOutput* cloneOf
 
56
               READ cloneOf
 
57
               WRITE setCloneOf
 
58
               NOTIFY cloneOfChanged)
 
59
 
 
60
    Q_PROPERTY(QMLOutput* leftDockedTo
 
61
               READ leftDockedTo
 
62
               WRITE setLeftDockedTo
 
63
               RESET undockLeft
 
64
               NOTIFY leftDockedToChanged)
 
65
 
 
66
    Q_PROPERTY(QMLOutput* topDockedTo
 
67
               READ topDockedTo
 
68
               WRITE setTopDockedTo
 
69
               RESET undockTop
 
70
               NOTIFY topDockedToChanged)
 
71
 
 
72
    Q_PROPERTY(QMLOutput* rightDockedTo
 
73
               READ rightDockedTo
 
74
               WRITE setRightDockedTo
 
75
               RESET undockRight
 
76
               NOTIFY rightDockedToChanged)
 
77
 
 
78
    Q_PROPERTY(QMLOutput* bottomDockedTo
 
79
               READ bottomDockedTo
 
80
               WRITE setBottomDockedTo
 
81
               RESET undockBottom
 
82
               NOTIFY bottomDockedToChanged)
 
83
 
 
84
    Q_PROPERTY(int currentOutputHeight
 
85
               READ currentOutputHeight
 
86
               NOTIFY currentOutputSizeChanged)
 
87
 
 
88
    Q_PROPERTY(int currentOutputWidth
 
89
               READ currentOutputWidth
 
90
               NOTIFY currentOutputSizeChanged)
 
91
 
 
92
    /* Workaround for possible QML bug when calling output.pos.y = VALUE works,
 
93
     * but output.pos.x = VALUE has no effect */
 
94
    Q_PROPERTY(int outputX
 
95
               READ outputX
 
96
               WRITE setOutputX
 
97
               NOTIFY outputXChanged)
 
98
 
 
99
    Q_PROPERTY(int outputY
 
100
               READ outputY
 
101
               WRITE setOutputY
 
102
               NOTIFY outputYChanged)
 
103
 
 
104
  public:
 
105
    enum {
 
106
      ModeRole = Qt::UserRole,
 
107
      ModeIdRole,
 
108
      SizeRole,
 
109
      RefreshRateRole
 
110
    };
 
111
 
 
112
    explicit QMLOutput(QQuickItem *parent = 0);
 
113
    virtual ~QMLOutput();
 
114
 
 
115
    KScreen::Output* output() const;
 
116
    void setOutput(KScreen::Output *output);
 
117
 
 
118
    QMLScreen* screen() const;
 
119
    void setScreen(QMLScreen *screen);
 
120
 
 
121
    QMLOutput* leftDockedTo() const;
 
122
    void setLeftDockedTo(QMLOutput *output);
 
123
    void undockLeft();
 
124
 
 
125
    QMLOutput* topDockedTo() const;
 
126
    void setTopDockedTo(QMLOutput *output);
 
127
    void undockTop();
 
128
 
 
129
    QMLOutput* rightDockedTo() const;
 
130
    void setRightDockedTo(QMLOutput *output);
 
131
    void undockRight();
 
132
 
 
133
    QMLOutput* bottomDockedTo() const;
 
134
    void setBottomDockedTo(QMLOutput *output);
 
135
    void undockBottom();
 
136
 
 
137
    Q_INVOKABLE bool collidesWithOutput(QObject *other);
 
138
    Q_INVOKABLE bool maybeSnapTo(QMLOutput *other);
 
139
 
 
140
    void setCloneOf(QMLOutput *other);
 
141
    QMLOutput* cloneOf() const;
 
142
 
 
143
    int currentOutputHeight() const;
 
144
    int currentOutputWidth() const;
 
145
 
 
146
    int outputX() const;
 
147
    void setOutputX(int x);
 
148
 
 
149
    int outputY() const;
 
150
    void setOutputY(int y);
 
151
 
 
152
    void setIsCloneMode(bool isCloneMode);
 
153
    bool isCloneMode() const;
 
154
 
 
155
  public Q_SLOTS:
 
156
    void updateRootProperties();
 
157
 
 
158
  Q_SIGNALS:
 
159
    void changed();
 
160
 
 
161
    void moved(const QString &self);
 
162
 
 
163
    /* Property notifications */
 
164
    void outputChanged();
 
165
    void screenChanged();
 
166
    void cloneOfChanged();
 
167
    void currentOutputSizeChanged();
 
168
 
 
169
    void leftDockedToChanged();
 
170
    void topDockedToChanged();
 
171
    void rightDockedToChanged();
 
172
    void bottomDockedToChanged();
 
173
 
 
174
    void outputYChanged();
 
175
    void outputXChanged();
 
176
 
 
177
    void isCloneModeChanged();
 
178
 
 
179
  private Q_SLOTS:
 
180
    void moved();
 
181
    void currentModeIdChanged();
 
182
 
 
183
  private:
 
184
    /**
 
185
     * Returns the biggest resolution available assuming it's the preferred one
 
186
     */
 
187
    KScreen::Mode* bestMode() const;
 
188
 
 
189
    KScreen::Output *m_output;
 
190
    QMLScreen *m_screen;
 
191
 
 
192
    QMLOutput *m_cloneOf;
 
193
    QMLOutput *m_leftDock;
 
194
    QMLOutput *m_topDock;
 
195
    QMLOutput *m_rightDock;
 
196
    QMLOutput *m_bottomDock;
 
197
 
 
198
    bool m_isCloneMode;
 
199
};
 
200
 
 
201
#endif // QMLOUTPUT_H
 
202