diff --git a/src/graphs3d/qml/qquickgraphsbars.cpp b/src/graphs3d/qml/qquickgraphsbars.cpp index a49ca3cd..2b83e0eb 100644 --- a/src/graphs3d/qml/qquickgraphsbars.cpp +++ b/src/graphs3d/qml/qquickgraphsbars.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "q3dscene.h" +#include "qbar3dseries.h" #include "qbar3dseries_p.h" #include "qbardataproxy_p.h" #include "qcategory3daxis_p.h" @@ -650,6 +651,17 @@ void QQuickGraphsBars::handleSeriesVisibilityChangedBySender(QObject *sender) setSelectedBar(m_selectedBar, m_selectedBarSeries, false); } +void QQuickGraphsBars::handleItemLabelVisibleChangedBySender(bool visible, QObject *sender) +{ + auto series = static_cast(sender); + if (series == m_selectedBarSeries) + { + itemLabel()->setVisible(visible); + if (auto label = sliceItemLabel(); label && isSlicingActive()) + label->setVisible(visible); + } +} + void QQuickGraphsBars::handleAxisRangeChangedBySender(QObject *sender) { // Data window changed @@ -2567,7 +2579,8 @@ void QQuickGraphsBars::updateSelectedBar() } updateItemLabel(m_selectedBarPos); - itemLabel()->setVisible(theme()->labelsVisible()); + itemLabel()->setVisible(m_selectedBarSeries->isItemLabelVisible() + && theme()->labelsVisible()); itemLabel()->setProperty("labelText", label); if (!label.compare(QString(hiddenLabelTag))) itemLabel()->setVisible(false); @@ -2644,7 +2657,8 @@ void QQuickGraphsBars::updateSliceItemLabel(const QString &label, QVector3D posi if (!label.compare(QString(hiddenLabelTag))) sliceItemLabel()->setVisible(false); sliceItemLabel()->setEulerRotation(QVector3D(0.0f, 0.0f, 90.0f)); - sliceItemLabel()->setVisible(theme()->labelsVisible()); + sliceItemLabel()->setVisible(m_selectedBarSeries->isItemLabelVisible() + && theme()->labelsVisible()); } void QQuickGraphsBars::resetClickedStatus() @@ -2933,7 +2947,8 @@ void QQuickGraphsBars::createBarItemHolders(QBar3DSeries *series, m_selectedBarPos.setY(m_selectedBarPos.y() + bih->heightValue - 0.2f); updateItemLabel(m_selectedBarPos); - itemLabel()->setVisible(theme()->labelsVisible()); + itemLabel()->setVisible(m_selectedBarSeries->isItemLabelVisible() + && theme()->labelsVisible()); itemLabel()->setProperty("labelText", label); if (!label.compare(QString(hiddenLabelTag))) itemLabel()->setVisible(false); diff --git a/src/graphs3d/qml/qquickgraphsbars_p.h b/src/graphs3d/qml/qquickgraphsbars_p.h index 9dc9d8bb..9fa3ac49 100644 --- a/src/graphs3d/qml/qquickgraphsbars_p.h +++ b/src/graphs3d/qml/qquickgraphsbars_p.h @@ -140,6 +140,7 @@ public: void handleAxisAutoAdjustRangeChangedInOrientation(QAbstract3DAxis::AxisOrientation orientation, bool autoAdjust) override; void handleSeriesVisibilityChangedBySender(QObject *sender) override; + void handleItemLabelVisibleChangedBySender(bool visible, QObject *sender) override; void handleAxisRangeChangedBySender(QObject *sender) override; void adjustAxisRanges() override; diff --git a/src/graphs3d/qml/qquickgraphsitem.cpp b/src/graphs3d/qml/qquickgraphsitem.cpp index 50e1071e..7ffaa329 100644 --- a/src/graphs3d/qml/qquickgraphsitem.cpp +++ b/src/graphs3d/qml/qquickgraphsitem.cpp @@ -1069,6 +1069,11 @@ void QQuickGraphsItem::handleSeriesVisibilityChanged(bool visible) handleSeriesVisibilityChangedBySender(sender()); } +void QQuickGraphsItem::handleItemLabelVisibleChanged(bool visible) +{ + handleItemLabelVisibleChangedBySender(visible, sender()); +} + void QQuickGraphsItem::handleRequestShadowQuality(QtGraphs3D::ShadowQuality quality) { setShadowQuality(quality); @@ -1619,6 +1624,10 @@ void QQuickGraphsItem::insertSeries(qsizetype index, QAbstract3DSeries *series) &QAbstract3DSeries::lightingModeChanged, this, &QQuickGraphsItem::handleLightingModeChanged); + QObject::connect(series, + &QAbstract3DSeries::itemLabelVisibleChanged, + this, + &QQuickGraphsItem::handleItemLabelVisibleChanged); series->d_func()->resetToTheme(*theme(), oldSize, false); qCDebug(lcSeries3D) << __FUNCTION__ << "insert" << series << "at index of:" << index; diff --git a/src/graphs3d/qml/qquickgraphsitem_p.h b/src/graphs3d/qml/qquickgraphsitem_p.h index 9b9f0806..4227e4e8 100644 --- a/src/graphs3d/qml/qquickgraphsitem_p.h +++ b/src/graphs3d/qml/qquickgraphsitem_p.h @@ -563,6 +563,8 @@ public Q_SLOTS: void handleAxisTitleOffsetChanged(float offset); void handleInputPositionChanged(QPoint position); void handleSeriesVisibilityChanged(bool visible); + void handleItemLabelVisibleChanged(bool visible); + virtual void handleItemLabelVisibleChangedBySender(bool visible, QObject *sender) = 0; void handleThemeColorStyleChanged(QGraphsTheme::ColorStyle style); void handleThemeBaseColorsChanged(const QList &color); diff --git a/src/graphs3d/qml/qquickgraphsscatter.cpp b/src/graphs3d/qml/qquickgraphsscatter.cpp index 4c0d326a..718b1098 100644 --- a/src/graphs3d/qml/qquickgraphsscatter.cpp +++ b/src/graphs3d/qml/qquickgraphsscatter.cpp @@ -5,6 +5,7 @@ #include "qgraphsinputhandler_p.h" #include "qquickgraphsscatter_p.h" #include "qquickgraphstexturedata_p.h" +#include "qscatter3dseries.h" #include "qscatter3dseries_p.h" #include "qscatterdataproxy_p.h" #include "qvalue3daxis_p.h" @@ -595,6 +596,7 @@ void QQuickGraphsScatter::updateScatterGraphItemVisuals(ScatterModel *graphModel graphModel->selectionIndicator->setRotation(dih.rotation); graphModel->selectionIndicator->setScale(dih.scale); graphModel->selectionIndicator->setVisible(true); + itemLabel()->setVisible(graphModel->series->isItemLabelVisible()); graphModel->instancing->hideDataItem(m_selectedItem); updateItemLabel(graphModel->selectionIndicator->position()); graphModel->instancing->markDataDirty(); @@ -1020,7 +1022,7 @@ void QQuickGraphsScatter::setSelectedItem(qsizetype index, QScatter3DSeries *ser } if (index != invalidSelectionIndex()) - itemLabel()->setVisible(true); + itemLabel()->setVisible(series->isItemLabelVisible()); } void QQuickGraphsScatter::setSelectionMode(QtGraphs3D::SelectionFlags mode) @@ -1916,6 +1918,13 @@ void QQuickGraphsScatter::clearAllSelectionInstanced() } } +void QQuickGraphsScatter::handleItemLabelVisibleChangedBySender(bool visible, QObject *sender) +{ + auto series = qobject_cast(sender); + if (series && series == m_selectedItemSeries) + itemLabel()->setVisible(visible); +} + void QQuickGraphsScatter::optimizationChanged(QtGraphs3D::OptimizationHint toOptimization) { if (toOptimization == QtGraphs3D::OptimizationHint::Default) { diff --git a/src/graphs3d/qml/qquickgraphsscatter_p.h b/src/graphs3d/qml/qquickgraphsscatter_p.h index 1018eca8..2a3e3457 100644 --- a/src/graphs3d/qml/qquickgraphsscatter_p.h +++ b/src/graphs3d/qml/qquickgraphsscatter_p.h @@ -262,6 +262,8 @@ private: void clearSelectionModel(); void clearAllSelectionInstanced(); + void handleItemLabelVisibleChangedBySender(bool visible, QObject *sender) override; + void optimizationChanged(QtGraphs3D::OptimizationHint toOptimization); void updateGraph() override; diff --git a/src/graphs3d/qml/qquickgraphssurface.cpp b/src/graphs3d/qml/qquickgraphssurface.cpp index 6d2776ce..cc39409a 100644 --- a/src/graphs3d/qml/qquickgraphssurface.cpp +++ b/src/graphs3d/qml/qquickgraphssurface.cpp @@ -9,6 +9,7 @@ #include "qgraphsinputhandler_p.h" #include "qquickgraphssurface_p.h" #include "qquickgraphstexturedata_p.h" +#include "qsurface3dseries.h" #include "qsurface3dseries_p.h" #include "qsurfacedataproxy_p.h" #include "qvalue3daxis_p.h" @@ -877,6 +878,17 @@ void QQuickGraphsSurface::handleSeriesVisibilityChangedBySender(QObject *sender) setSelectedPoint(m_selectedPoint, m_selectedSeries, false); } +void QQuickGraphsSurface::handleItemLabelVisibleChangedBySender(bool visible, QObject *sender) +{ + auto series = static_cast(sender); + + if (series == m_selectedSeries) { + itemLabel()->setVisible(visible); + if (auto label = sliceItemLabel(); label && isSlicingActive()) + label->setVisible(visible); + } +} + void QQuickGraphsSurface::setFlipHorizontalGrid(bool flip) { if (m_flipHorizontalGrid != flip) { diff --git a/src/graphs3d/qml/qquickgraphssurface_p.h b/src/graphs3d/qml/qquickgraphssurface_p.h index 082bb140..e8b7566b 100644 --- a/src/graphs3d/qml/qquickgraphssurface_p.h +++ b/src/graphs3d/qml/qquickgraphssurface_p.h @@ -142,6 +142,7 @@ public: bool autoAdjust) override; void handleAxisRangeChangedBySender(QObject *sender) override; void handleSeriesVisibilityChangedBySender(QObject *sender) override; + void handleItemLabelVisibleChangedBySender(bool visible, QObject *sender) override; void adjustAxisRanges() override; void handleLightingModeChanged() override; diff --git a/tests/manual/qmlbarsrowcolors/qml/qmlbarsrowcolors/main.qml b/tests/manual/qmlbarsrowcolors/qml/qmlbarsrowcolors/main.qml index 3e7b32d6..3c3584fe 100644 --- a/tests/manual/qmlbarsrowcolors/qml/qmlbarsrowcolors/main.qml +++ b/tests/manual/qmlbarsrowcolors/qml/qmlbarsrowcolors/main.qml @@ -301,6 +301,23 @@ Item { } } + Button { + id: itemlabelVisibleToggle + Layout.fillWidth: true + Layout.fillHeight: true + text: "Hide itemlabel" + clip: true + + onClicked: { + barSeries.itemLabelVisible = !barSeries.itemLabelVisible + + if (barSeries.itemLabelVisible) + text = "Hide itemLabel" + else + text = "Show itemLabel" + } + } + Column { Label { text: "ValueAxis Segments" diff --git a/tests/manual/qmlcustominput/qml/qmlcustominput/main.qml b/tests/manual/qmlcustominput/qml/qmlcustominput/main.qml index ab3f4f38..a6d9d9dc 100644 --- a/tests/manual/qmlcustominput/qml/qmlcustominput/main.qml +++ b/tests/manual/qmlcustominput/qml/qmlcustominput/main.qml @@ -280,6 +280,9 @@ Item { RowLayout { id: buttonLayout + + property int buttonCount: 5 + Layout.minimumHeight: shadowToggle.height width: parent.width anchors.left: parent.left @@ -288,7 +291,7 @@ Item { Button { id: shadowToggle Layout.fillHeight: true - Layout.minimumWidth: parent.width / 4 // 4 buttons divided equally in the layout + Layout.minimumWidth: parent.width / parent.buttonCount // Buttons divided equally in the layout text: "Hide Shadows" onClicked: { if (activeGraph.shadowQuality === Graphs3D.ShadowQuality.None) { @@ -304,7 +307,7 @@ Item { Button { id: cameraToggle Layout.fillHeight: true - Layout.minimumWidth: parent.width / 4 + Layout.minimumWidth: parent.width / parent.buttonCount text: "Pause Camera" onClicked: { @@ -321,20 +324,55 @@ Item { Button { id: graphToggle Layout.fillHeight: true - Layout.minimumWidth: parent.width / 4 + Layout.minimumWidth: parent.width / parent.buttonCount text: "Switch graph type" onClicked : { - if (activeGraph == scatterGraph) + if (activeGraph == scatterGraph) { activeGraph = surfaceGraph - else + if (surfaceSeries.itemLabelVisible) + seriesVisibilityToggle.text = "Hide surface series itemLabel" + else + seriesVisibilityToggle.text = "Show surface series itemLabel" + } + else { activeGraph = scatterGraph + if (scatterSeriesTwo.itemLabelVisible) + seriesVisibilityToggle.text = "Hide center series itemLabel" + else + seriesVisibilityToggle.text = "Show center series itemLabel" + } + } + } + + Button { + id: seriesVisibilityToggle + Layout.fillHeight: true + Layout.minimumWidth: parent.width / parent.buttonCount + text: "Hide center series itemLabel" + onClicked : { + if (activeGraph == scatterGraph) { + scatterSeriesTwo.itemLabelVisible = !scatterSeriesTwo.itemLabelVisible + + if (scatterSeriesTwo.itemLabelVisible) + text = "Hide center series itemLabel" + else + text = "Show center series itemLabel" + } + else if (activeGraph == surfaceGraph) { + surfaceSeries.itemLabelVisible = !surfaceSeries.itemLabelVisible + + if (surfaceSeries.itemLabelVisible) + text = "Hide surface series itemLabel" + else + text = "Show surface series itemLabel" + } } } Button { id: exitButton Layout.fillHeight: true - Layout.minimumWidth: parent.width / 4 + Layout.minimumWidth: parent.width / parent.buttonCount text: "Quit" onClicked: Qt.quit(); } diff --git a/tests/manual/qmldynamicdata/qml/qmldynamicdata/main.qml b/tests/manual/qmldynamicdata/qml/qmldynamicdata/main.qml index 5a838b4e..fc6672ff 100644 --- a/tests/manual/qmldynamicdata/qml/qmldynamicdata/main.qml +++ b/tests/manual/qmldynamicdata/qml/qmldynamicdata/main.qml @@ -4,10 +4,12 @@ import QtQuick import QtGraphs import QtQuick.Controls +import QtQuick.Layouts import "." Item { id: mainView + width: 1280 height: 720 visible: true @@ -199,45 +201,95 @@ Item { } } - Button { - id: shadowToggle - width: parent.width / 3 // We're adding 3 buttons and want to divide them equally - text: "Hide Shadows" + RowLayout { + id: buttonLayout + anchors.left: parent.left + anchors.right: parent.right - onClicked: { - if (scatterGraph.shadowQuality === Graphs3D.ShadowQuality.None) { - scatterGraph.shadowQuality = Graphs3D.ShadowQuality.SoftMedium; - text = "Hide Shadows"; - } else { - scatterGraph.shadowQuality = Graphs3D.ShadowQuality.None; - text = "Show Shadows"; + Button { + id: shadowToggle + + Layout.fillWidth: true + text: "Hide Shadows" + + onClicked: { + if (scatterGraph.shadowQuality === Graphs3D.ShadowQuality.None) { + scatterGraph.shadowQuality = Graphs3D.ShadowQuality.SoftMedium; + text = "Hide Shadows"; + } else { + scatterGraph.shadowQuality = Graphs3D.ShadowQuality.None; + text = "Show Shadows"; + } } } - } - Button { - id: cameraToggle - width: parent.width / 3 - text: "Pause Camera" - anchors.left: shadowToggle.right + Button { + id: cameraToggle + Layout.fillWidth: true + text: "Pause Camera" - onClicked: { - cameraAnimationX.paused = !cameraAnimationX.paused; - cameraAnimationY.paused = cameraAnimationX.paused; - if (cameraAnimationX.paused) { - text = "Animate Camera"; - } else { - text = "Pause Camera"; + onClicked: { + cameraAnimationX.paused = !cameraAnimationX.paused; + cameraAnimationY.paused = cameraAnimationX.paused; + if (cameraAnimationX.paused) { + text = "Animate Camera"; + } else { + text = "Pause Camera"; + } } } - } - Button { - id: exitButton - width: parent.width / 3 - text: "Quit" - anchors.left: cameraToggle.right - onClicked: Qt.quit(); + Button { + id: dynamicDataToggle + Layout.fillWidth: true + text: "Stop dynamic data" + + onClicked: { + dataTimer.running = !dataTimer.running + + if (dataTimer.running) + text = "Stop dynamic data"; + else + text = "Start dynamic data"; + } + } + + Button { + id: autoSelectionToggle + Layout.fillWidth: true + text: "Stop autoselection" + + onClicked: { + reselectTimer.running = !reselectTimer.running + + if (reselectTimer.running) + text = "Stop autoselection"; + else + text = "Start autoselection"; + } + } + + Button { + id: seriesItemLabelToggle + Layout.fillWidth: true + text: "Hide series item label" + + onClicked: { + scatterSeries.itemLabelVisible = !scatterSeries.itemLabelVisible + + if (scatterSeries.itemLabelVisible) + text = "Hide series item label"; + else + text = "Show series item label"; + } + } + + Button { + id: exitButton + Layout.fillWidth: true + text: "Quit" + onClicked: Qt.quit(); + } } } diff --git a/tests/manual/qmlgradient/qml/qmlgradient/main.qml b/tests/manual/qmlgradient/qml/qmlgradient/main.qml index f4443416..bf32c75e 100644 --- a/tests/manual/qmlgradient/qml/qmlgradient/main.qml +++ b/tests/manual/qmlgradient/qml/qmlgradient/main.qml @@ -162,6 +162,23 @@ Item { gradientLabel.text = "Series gradient"; } } + + Button { + id: toggleSeriesItemLabel + Layout.fillWidth: true + Layout.fillHeight: true + + text: qsTr("Hide series itemLabel") + + onClicked: { + heightSeries.itemLabelVisible = !heightSeries.itemLabelVisible + + if (heightSeries.itemLabelVisible) + text = "Hide series itemLabel" + else + text = "Show series itemLabel" + } + } } ColumnLayout {