2
* Copyright 2015 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
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 Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Author: Andrea Bernabei <andrea.bernabei@canonical.com>
19
#ifndef UCSLOTSLAYOUT_H
20
#define UCSLOTSLAYOUT_H
22
#include <QtQuick/QQuickItem>
24
class UCSlotsAttached;
25
class UCSlotsLayoutPadding;
26
class UCSlotsLayoutPrivate;
27
class UCSlotsLayout : public QQuickItem
31
Q_PROPERTY(QQuickItem *mainSlot READ mainSlot WRITE setMainSlot NOTIFY mainSlotChanged)
32
Q_PROPERTY(UCSlotsLayoutPadding *padding READ padding CONSTANT FINAL)
34
Q_ENUMS(UCSlotPosition)
37
explicit UCSlotsLayout(QQuickItem *parent = 0);
39
virtual QQuickItem *mainSlot();
40
virtual QQuickItem *mainSlot() const;
41
virtual void setMainSlot(QQuickItem *item, bool fireSignal = true);
43
UCSlotsLayoutPadding *padding();
52
static UCSlotsAttached *qmlAttachedProperties(QObject *object);
55
void mainSlotChanged();
58
Q_DECLARE_PRIVATE(UCSlotsLayout)
59
void componentComplete();
60
void itemChange(ItemChange change, const ItemChangeData &data);
63
Q_PRIVATE_SLOT(d_func(), void _q_onGuValueChanged())
64
Q_PRIVATE_SLOT(d_func(), void _q_updateCachedHeight())
65
Q_PRIVATE_SLOT(d_func(), void _q_updateGuValues())
66
Q_PRIVATE_SLOT(d_func(), void _q_updateCachedMainSlotHeight())
67
Q_PRIVATE_SLOT(d_func(), void _q_updateSlotsBBoxHeight())
68
Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
69
Q_PRIVATE_SLOT(d_func(), void _q_onSlotWidthChanged())
70
Q_PRIVATE_SLOT(d_func(), void _q_onSlotOverrideVerticalPositioningChanged())
71
Q_PRIVATE_SLOT(d_func(), void _q_onSlotPositionChanged())
72
Q_PRIVATE_SLOT(d_func(), void _q_relayout())
74
QML_DECLARE_TYPEINFO(UCSlotsLayout, QML_HAS_ATTACHED_PROPERTIES)
76
class UCSlotsAttachedPrivate;
77
class UCSlotsAttached : public QObject
80
Q_PROPERTY(UCSlotsLayout::UCSlotPosition position READ position WRITE setPosition NOTIFY positionChanged)
81
Q_PROPERTY(UCSlotsLayoutPadding *padding READ padding CONSTANT FINAL)
82
Q_PROPERTY(bool overrideVerticalPositioning READ overrideVerticalPositioning WRITE setOverrideVerticalPositioning NOTIFY overrideVerticalPositioningChanged)
85
UCSlotsAttached(QObject *object = 0);
87
UCSlotsLayout::UCSlotPosition position() const;
88
void setPosition(UCSlotsLayout::UCSlotPosition pos);
90
UCSlotsLayoutPadding *padding();
92
bool overrideVerticalPositioning() const;
93
void setOverrideVerticalPositioning(bool val);
96
void positionChanged();
97
void overrideVerticalPositioningChanged();
100
Q_DECLARE_PRIVATE(UCSlotsAttached)
103
Q_PRIVATE_SLOT(d_func(), void _q_onGuValueChanged())
106
class UCSlotsLayoutPadding : public QObject
109
Q_PROPERTY(qreal leading READ leading WRITE setLeadingQml NOTIFY leadingChanged FINAL)
110
Q_PROPERTY(qreal trailing READ trailing WRITE setTrailingQml NOTIFY trailingChanged FINAL)
111
Q_PROPERTY(qreal top READ top WRITE setTopQml NOTIFY topChanged FINAL)
112
Q_PROPERTY(qreal bottom READ bottom WRITE setBottomQml NOTIFY bottomChanged FINAL)
115
explicit UCSlotsLayoutPadding(QObject *parent = 0);
117
qreal leading() const;
118
void setLeading(qreal val);
119
void setLeadingQml(qreal val);
121
qreal trailing() const;
122
void setTrailing(qreal val);
123
void setTrailingQml(qreal val);
126
void setTop(qreal val);
127
void setTopQml(qreal val);
129
qreal bottom() const;
130
void setBottom(qreal val);
131
void setBottomQml(qreal val);
133
//once the dev tries to change the offsets (and he does so via QML) we'll stop
134
//updating offset's value, for instance when gu value changes or when the
135
//positioning mode changes
136
bool leadingWasSetFromQml : 1;
137
bool trailingWasSetFromQml : 1;
138
bool topWasSetFromQml : 1;
139
bool bottomWasSetFromQml : 1;
142
void leadingChanged();
143
void trailingChanged();
145
void bottomChanged();
148
//similar to anchors.margins, but we don't use a contentItem so we handle this ourselves
155
#endif // UCSLOTSLAYOUT_H