diff --git a/src/Group.qml b/src/Group.qml index 2164cc06..fab6d653 100644 --- a/src/Group.qml +++ b/src/Group.qml @@ -38,6 +38,7 @@ import QtQuick.Layouts import QuickQanava 2.0 as Qan import "qrc:/QuickQanava" as Qan +//! \brief Default delegate for `qan::GroupItem`. Qan.GroupItem { id: groupItem @@ -47,12 +48,7 @@ Qan.GroupItem { default property alias children : template container: template.container // See qan::GroupItem::container property documentation - - //! Show or hide group top left label editor (default to visible). - property alias labelEditorVisible : template.labelEditorVisible - - //! Show or hide group top left expand button (default to visible). - property alias expandButtonVisible : template.expandButtonVisible + labelEditorVisible: template.labelEditorVisible Qan.RectGroupTemplate { id: template diff --git a/src/LabelEditor.qml b/src/LabelEditor.qml index b4acd8de..711138ad 100644 --- a/src/LabelEditor.qml +++ b/src/LabelEditor.qml @@ -71,8 +71,7 @@ Loader { //! Editor target node or group (or any Qan primitive with a \c label property). property var target: undefined - property bool bold: false - property real pixelSize: 12 + property real fontPixelSize: 11 onVisibleChanged: { if (visible && !item) @@ -101,8 +100,8 @@ Loader { anchors.left: parent.left anchors.right: parent.right text: target ? target.label : "" - font.bold: labelEditorLoader.bold - font.pixelSize: labelEditorLoader.pixelSize + font.bold: false + font.pixelSize: 22 onAccepted: { if (target && text.length !== 0) @@ -115,6 +114,9 @@ Loader { text !== target.label) // Ensure that last edition text is removed text = target.label // for exemple if edition has been interrupted in a focus change } + background: Rectangle { + color: Qt.rgba(0., 0., 0., 0.) // Disable editor background + } Keys.onEscapePressed: { // Cancel edition on escape labelEditorLoader.visible = false; diff --git a/src/RectGroupTemplate.qml b/src/RectGroupTemplate.qml index 5ebf11b3..18ae8e76 100644 --- a/src/RectGroupTemplate.qml +++ b/src/RectGroupTemplate.qml @@ -49,10 +49,7 @@ Item { property var groupItem: undefined //! Show or hide group top left label editor (default to visible). - property alias labelEditorVisible : labelEditorControl.visible - - //! Show or hide group top left expand button (default to visible). - property alias expandButtonVisible : collapser.visible + readonly property alias labelEditorVisible: labelEditorControl.visible property alias header: headerLayout @@ -92,50 +89,45 @@ Item { font.pixelSize: 13 font.bold: true onClicked: groupItem.collapsed = !groupItem.collapsed + visible: groupItem?.expandButtonVisible } Item { id: labelEditorControl clip: false Layout.fillWidth: true Layout.fillHeight: true - property int fontPointSize : groupItem.style.fontPointSize // Do not set pointSize for -1 value - onFontPointSizeChanged: { - if (fontPointSize != -1) - labelEditor.pixelSize = fontPointSize - groupLabel.font.pointSize = fontPointSize - } + property int labelPointSize : groupItem?.style?.fontPointSize || Material.fontSize LabelEditor { - clip: false id: labelEditor + clip: false anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right - target: groupItem && groupItem.group ? groupItem.group : undefined + target: groupItem?.group visible: false - bold: groupItem.style.fontBold + fontPixelSize: labelEditorControl.labelPointSize } Label { id: groupLabel anchors.fill: parent + anchors.leftMargin: collapser.visible ? 0 : 10 text: groupItem && groupItem.group ? groupItem.group.label : " " visible: !labelEditor.visible verticalAlignment: Text.AlignVCenter font.bold: groupItem.style.fontBold - color: groupItem && - groupItem.style && - groupItem.style.labelColor ? groupItem.style.labelColor : "black" + font.pointSize: labelEditorControl.labelPointSize + color: groupItem?.style?.labelColor || "black" elide: Text.ElideRight - /*MouseArea { + MouseArea { anchors.fill: parent enabled: !groupItem.group.isProtected && !groupItem.group.locked // Do not allow dragging of locked groups preventStealing: true propagateComposedEvents: true // Ensure event are forwarded to collapserArea - drag.target: groupItem.draggable ? groupItem : null onDoubleClicked: labelEditor.visible = true - }*/ + } } } // labelEditor Item } // RowLayout: collapser + label diff --git a/src/TableGroup.qml b/src/TableGroup.qml index 097c9835..46495769 100644 --- a/src/TableGroup.qml +++ b/src/TableGroup.qml @@ -37,7 +37,7 @@ import QtQuick import QuickQanava 2.0 as Qan import "qrc:/QuickQanava" as Qan -//! \brief Default delegate for `qan::TableGroup`. +//! \brief Default delegate for `qan::TableGroupItem`. Qan.TableGroupItem { id: tableGroupItem @@ -47,11 +47,7 @@ Qan.TableGroupItem { default property alias children : template container: template.container // See qan::GroupItem::container property documentation - - //! Show or hide group top left label editor (default to visible). - property bool labelEditorVisible : false - //! Show or hide group top left expand button (default to visible). - property bool expandButtonVisible : false + labelEditorVisible: template.labelEditorVisible Qan.RectGroupTemplate { id: template anchors.fill: parent diff --git a/src/qanGroupItem.cpp b/src/qanGroupItem.cpp index c896e001..3d0019ba 100644 --- a/src/qanGroupItem.cpp +++ b/src/qanGroupItem.cpp @@ -98,7 +98,7 @@ auto GroupItem::setRect(const QRectF& r) noexcept -> void //----------------------------------------------------------------------------- -/* Collapse Management *///---------------------------------------------------- +/* Collapse / Edition Management *///------------------------------------------ void GroupItem::setCollapsed(bool collapsed) noexcept { qan::NodeItem::setCollapsed(collapsed); @@ -114,6 +114,12 @@ void GroupItem::setCollapsed(bool collapsed) noexcept groupMoved(); // Force update of all adjacent edges } } + +void GroupItem::setExpandButtonVisible(bool expandButtonVisible) { _expandButtonVisible = expandButtonVisible; emit expandButtonVisibleChanged(); } +bool GroupItem::getExpandButtonVisible() const { return _expandButtonVisible; } + +void GroupItem::setLabelEditorVisible(bool labelEditorVisible) { _labelEditorVisible = labelEditorVisible; emit labelEditorVisibleChanged(); } +bool GroupItem::getLabelEditorVisible() const { return _labelEditorVisible; } //----------------------------------------------------------------------------- /* Group DnD Management *///--------------------------------------------------- diff --git a/src/qanGroupItem.h b/src/qanGroupItem.h index a2d231ee..b10988d8 100644 --- a/src/qanGroupItem.h +++ b/src/qanGroupItem.h @@ -83,10 +83,38 @@ class GroupItem : public qan::NodeItem //@} //------------------------------------------------------------------------- - /*! \name Collapse Management *///----------------------------------------- + /*! \name Collapse / Edition Management *///------------------------------- //@{ protected: virtual void setCollapsed(bool collapsed) noexcept override; + +public: + //! \copydoc getExpandButtonVisible() + Q_PROPERTY(bool expandButtonVisible READ getExpandButtonVisible WRITE setExpandButtonVisible NOTIFY expandButtonVisibleChanged FINAL) + //! \copydoc getExpandButtonVisible() + void setExpandButtonVisible(bool expandButtonVisible); + //! \brief Show / hide the group expand / collapse button. + bool getExpandButtonVisible() const; +private: + //! \copydoc getExpandButtonVisible() + bool _expandButtonVisible = true; +signals: + //! \copydoc getExpandButtonVisible() + void expandButtonVisibleChanged(); + +public: + //! \copydoc getLabelEditorVisible() + Q_PROPERTY(bool labelEditorVisible READ getLabelEditorVisible WRITE setLabelEditorVisible NOTIFY labelEditorVisibleChanged FINAL) + //! \copydoc getLabelEditorVisible() + void setLabelEditorVisible(bool labelEditorVisible); + //! \brief True when the group label in group editor is beeing edited. + bool getLabelEditorVisible() const; +private: + //! \copydoc getLabelEditorVisible() + bool _labelEditorVisible = false; +signals: + //! \copydoc getLabelEditorVisible() + void labelEditorVisibleChanged(); //@} //-------------------------------------------------------------------------