diff --git a/examples/gallerydata/contents/ui/gallery/FormLayoutGallery.qml b/examples/gallerydata/contents/ui/gallery/FormLayoutGallery.qml index 68878fb6..14d798a1 100644 --- a/examples/gallerydata/contents/ui/gallery/FormLayoutGallery.qml +++ b/examples/gallerydata/contents/ui/gallery/FormLayoutGallery.qml @@ -1,95 +1,95 @@ import QtQuick 2.6 import QtQuick.Layouts 1.2 import QtQuick.Controls 2.2 import org.kde.kirigami 2.3 as Kirigami Kirigami.ScrollablePage { title: "Form Layout" Kirigami.FormLayout { id: layout width: 500 height: 500 TextField { Kirigami.FormData.label: "Label:" } TextField { } TextField { Kirigami.FormData.label:"Lo&nger label:" } Kirigami.Separator { Kirigami.FormData.isSection: true } TextField { Kirigami.FormData.label: "After separator:" } ComboBox { Kirigami.FormData.label: "Combo:" model: ["First", "Second", "Third"] } CheckBox { checked: true text: "Option" } Kirigami.Separator { Kirigami.FormData.isSection: true Kirigami.FormData.label: "Section title" } TextField { Kirigami.FormData.label: "Label:" } Item { width:1 height:1 Kirigami.FormData.isSection: true } TextField { Kirigami.FormData.label: "Section without line:" } TextField { } Item { width:1 height:1 Kirigami.FormData.isSection: true Kirigami.FormData.label: "Section with title without line" } TextField { Kirigami.FormData.label: "Title:" } ColumnLayout { Layout.rowSpan: 3 Kirigami.FormData.label: "Label for radios:" RadioButton { checked: true text: "One" } RadioButton { text: "Two" } RadioButton { text: "Three" } } Button { text: item ? "Remove Field" : "Add Field" - property Item item + property TextField item onClicked: { if (item) { item.destroy(); } else { item = dyncomponent.createObject(layout); } } Component { id: dyncomponent TextField { Kirigami.FormData.label: "Generated Title:" } } } } } diff --git a/src/formlayoutattached.h b/src/formlayoutattached.h index 1e833e55..f99ef5de 100644 --- a/src/formlayoutattached.h +++ b/src/formlayoutattached.h @@ -1,67 +1,67 @@ /* * Copyright (C) 2017 by Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORMLAYOUTATTACHED_H #define FORMLAYOUTATTACHED_H #include #include class QQuickItem; class FormLayoutAttached : public QObject { Q_OBJECT Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) Q_PROPERTY(bool isSection READ isSection WRITE setIsSection NOTIFY isSectionChanged) Q_PROPERTY(QQuickItem *buddyFor READ buddyFor CONSTANT) public: explicit FormLayoutAttached(QObject *parent = nullptr); - ~FormLayoutAttached(); + ~FormLayoutAttached() override; void setLabel(const QString &text); QString label() const; QString decoratedLabel() const; void setIsSection(bool section); bool isSection() const; QQuickItem *buddyFor() const; //QML attached property static FormLayoutAttached *qmlAttachedProperties(QObject *object); Q_SIGNALS: void labelChanged(); void isSectionChanged(); private: QString m_label; QString m_actualDecoratedLabel; QString m_decoratedLabel; QPointer m_buddyFor; bool m_isSection = false; }; QML_DECLARE_TYPEINFO(FormLayoutAttached, QML_HAS_ATTACHED_PROPERTIES) #endif // FORMLAYOUTATTACHED_H