| 1 |
/* |
| 2 |
* Copyright 2013 Canonical Ltd. |
| 3 |
* |
| 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. |
| 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 Lesser General Public License for more details. |
| 12 |
* |
| 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/>. |
| 15 |
* |
| 16 |
* Author: Zsombor Egri <[email protected]> |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef ULLAYOUTS_H |
| 20 |
#define ULLAYOUTS_H |
| 21 |
|
| 22 |
#include <QtQuick/QQuickItem> |
| 23 |
|
| 24 |
#include "ulconditionallayout.h" |
| 25 |
|
| 26 |
class ULLayoutsAttached : public QObject |
| 27 |
{ |
| 28 |
Q_OBJECT |
| 29 |
Q_PROPERTY(QString item READ item WRITE setItem NOTIFY itemChanged) |
| 30 |
|
| 31 |
public: |
| 32 |
explicit ULLayoutsAttached(QObject *parent = 0); |
| 33 |
|
| 34 |
//getter/setter |
| 35 |
QString item() const; |
| 36 |
void setItem(const QString &name); |
| 37 |
|
| 38 |
bool isValid(); |
| 39 |
|
| 40 |
Q_SIGNALS: |
| 41 |
void itemChanged(); |
| 42 |
|
| 43 |
private Q_SLOTS: |
| 44 |
void validateAttachedProperties(); |
| 45 |
|
| 46 |
private: |
| 47 |
QString m_name; |
| 48 |
bool m_valid; |
| 49 |
}; |
| 50 |
|
| 51 |
class ULLayoutsPrivate; |
| 52 |
class ULLayouts : public QQuickItem |
| 53 |
{ |
| 54 |
Q_OBJECT |
| 55 |
Q_DISABLE_COPY(ULLayouts) |
| 56 |
|
| 57 |
Q_PROPERTY(QString currentLayout READ currentLayout NOTIFY currentLayoutChanged DESIGNABLE false) |
| 58 |
Q_PROPERTY(QQmlListProperty<ULConditionalLayout> layouts READ layouts DESIGNABLE false) |
| 59 |
|
| 60 |
Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) |
| 61 |
Q_PROPERTY(QQmlListProperty<QQuickItem> children READ children DESIGNABLE false) |
| 62 |
Q_CLASSINFO("DefaultProperty", "data") |
| 63 |
public: |
| 64 |
explicit ULLayouts(QQuickItem *parent = 0); |
| 65 |
~ULLayouts(); |
| 66 |
|
| 67 |
static ULLayoutsAttached * qmlAttachedProperties(QObject *owner); |
| 68 |
|
| 69 |
QString currentLayout() const; |
| 70 |
QList<ULConditionalLayout*> layoutList(); |
| 71 |
QQuickItem *contentItem() const; |
| 72 |
|
| 73 |
Q_SIGNALS: |
| 74 |
void currentLayoutChanged(); |
| 75 |
|
| 76 |
protected: |
| 77 |
void componentComplete() override; |
| 78 |
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 79 |
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
| 80 |
#else |
| 81 |
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
| 82 |
#endif |
| 83 |
|
| 84 |
private: |
| 85 |
QQmlListProperty<ULConditionalLayout> layouts(); |
| 86 |
QQmlListProperty<QObject> data(); |
| 87 |
QQmlListProperty<QQuickItem> children(); |
| 88 |
|
| 89 |
friend class ULConditionalLayout; |
| 90 |
Q_DECLARE_PRIVATE(ULLayouts) |
| 91 |
QScopedPointer<ULLayoutsPrivate> d_ptr; |
| 92 |
}; |
| 93 |
|
| 94 |
QML_DECLARE_TYPE(ULLayouts) |
| 95 |
QML_DECLARE_TYPEINFO(ULLayouts, QML_HAS_ATTACHED_PROPERTIES) |
| 96 |
|
| 97 |
|
| 98 |
#endif // ULLAYOUTS_H |