From b2a458b1f2baad7aa46cbc4755ad3d9580b2893b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Mon, 24 Aug 2015 00:39:31 +0200 Subject: [PATCH] Refactoring of QML states --- .../quickapp/qml/AtmosphereSection.qml | 35 +++++++++++++++ .../modeler/quickapp/qml/BasePanel.qml | 23 ++-------- .../quickapp/qml/BaseSecondaryToolbar.qml | 9 ++-- .../modeler/quickapp/qml/BaseSection.qml | 7 +++ .../qml/{Toolbar.qml => BaseToolbar.qml} | 14 +----- .../modeler/quickapp/qml/CameraChoice.qml | 2 +- .../modeler/quickapp/qml/PanelWaterLevel.qml | 14 ------ .../modeler/quickapp/qml/WaterSection.qml | 45 +++++++++++++++++++ src/interface/modeler/quickapp/qml/app.qrc | 6 ++- src/interface/modeler/quickapp/qml/main.qml | 37 ++++----------- src/interface/modeler/quickapp/quickapp.pro | 14 +----- 11 files changed, 113 insertions(+), 93 deletions(-) create mode 100644 src/interface/modeler/quickapp/qml/AtmosphereSection.qml create mode 100644 src/interface/modeler/quickapp/qml/BaseSection.qml rename src/interface/modeler/quickapp/qml/{Toolbar.qml => BaseToolbar.qml} (68%) delete mode 100644 src/interface/modeler/quickapp/qml/PanelWaterLevel.qml create mode 100644 src/interface/modeler/quickapp/qml/WaterSection.qml diff --git a/src/interface/modeler/quickapp/qml/AtmosphereSection.qml b/src/interface/modeler/quickapp/qml/AtmosphereSection.qml new file mode 100644 index 0000000..b10f451 --- /dev/null +++ b/src/interface/modeler/quickapp/qml/AtmosphereSection.qml @@ -0,0 +1,35 @@ +import QtQuick 2.0 + +// Atmosphere control +BaseSection { + id: section + + BaseToolbar { + id: toolbar + + ToolbarButton { + id: tool_daytime + selected: true + picture: "images/icon_atmosphere_daytime.png" + hovertext: qsTr("Change the time of day") + } + } + + PanelAtmosphereDaytime { + id: panel_daytime + anchors.left: toolbar.right + enabled: false + } + + states: [ + State { + name: "DayTime" + when: tool_daytime.selected + PropertyChanges { + target: panel_daytime + enabled: true + } + } + ] +} + diff --git a/src/interface/modeler/quickapp/qml/BasePanel.qml b/src/interface/modeler/quickapp/qml/BasePanel.qml index 6250d04..ad26f8f 100644 --- a/src/interface/modeler/quickapp/qml/BasePanel.qml +++ b/src/interface/modeler/quickapp/qml/BasePanel.qml @@ -1,26 +1,11 @@ import QtQuick 2.0 BaseRectangle { - property ToolbarButton tool id: panel - width: 200 - height: primary_toolbar.current ? primary_toolbar.current.height : 10 + height: parent.height + + anchors.top: parent.top + color: "#40909090" - - anchors.left: primary_toolbar.current ? primary_toolbar.current.right : parent.left - anchors.top: primary_toolbar.current ? primary_toolbar.current.top : parent.top - - states: [ - State { - name: "hidden" - when: !tool.selected - - PropertyChanges { - target: panel - enabled: false - } - } - - ] } diff --git a/src/interface/modeler/quickapp/qml/BaseSecondaryToolbar.qml b/src/interface/modeler/quickapp/qml/BaseSecondaryToolbar.qml index bd4670f..1c4773e 100644 --- a/src/interface/modeler/quickapp/qml/BaseSecondaryToolbar.qml +++ b/src/interface/modeler/quickapp/qml/BaseSecondaryToolbar.qml @@ -1,11 +1,14 @@ import QtQuick 2.0 -Toolbar { +BaseToolbar { enabled: false height: parent.height - primary_toolbar.height anchors.left: primary_toolbar.left anchors.top: primary_toolbar.bottom - onEnabledChanged: primary_toolbar.current = this + onEnabledChanged: { + if (enabled) { + primary_toolbar.current = this; + } + } } - diff --git a/src/interface/modeler/quickapp/qml/BaseSection.qml b/src/interface/modeler/quickapp/qml/BaseSection.qml new file mode 100644 index 0000000..1d492e5 --- /dev/null +++ b/src/interface/modeler/quickapp/qml/BaseSection.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +BaseRectangle { + anchors.bottom: main_ui.bottom + height: main_ui.height - primary_toolbar.height +} + diff --git a/src/interface/modeler/quickapp/qml/Toolbar.qml b/src/interface/modeler/quickapp/qml/BaseToolbar.qml similarity index 68% rename from src/interface/modeler/quickapp/qml/Toolbar.qml rename to src/interface/modeler/quickapp/qml/BaseToolbar.qml index 9e9eddf..8f25810 100644 --- a/src/interface/modeler/quickapp/qml/Toolbar.qml +++ b/src/interface/modeler/quickapp/qml/BaseToolbar.qml @@ -4,6 +4,7 @@ BaseRectangle { default property alias children : inner_space.children property bool horizontal: false + property list panels width: horizontal ? parent.width : 60 height: horizontal ? 60 : parent.height color: "#50888888" @@ -15,17 +16,4 @@ BaseRectangle { spacing: (parent.horizontal ? (parent.width - children.length * tool_terrain.width) : (parent.height - children.length * tool_terrain.height)) / (children.length + 1) anchors.centerIn: parent } - - onEnabledChanged: { - if (!enabled) - { - for (var i = 0; i < children.length; i++) - { - if (!children[i].toggle) - { - children[i].selected = false; - } - } - } - } } diff --git a/src/interface/modeler/quickapp/qml/CameraChoice.qml b/src/interface/modeler/quickapp/qml/CameraChoice.qml index ca82ccb..f4ba0f1 100644 --- a/src/interface/modeler/quickapp/qml/CameraChoice.qml +++ b/src/interface/modeler/quickapp/qml/CameraChoice.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 -Toolbar { +BaseToolbar { id: camera_choice horizontal: false color: "#90888888" diff --git a/src/interface/modeler/quickapp/qml/PanelWaterLevel.qml b/src/interface/modeler/quickapp/qml/PanelWaterLevel.qml deleted file mode 100644 index 74b084a..0000000 --- a/src/interface/modeler/quickapp/qml/PanelWaterLevel.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.2 - -BasePanel { - width: 40 - - BaseSlider { - objectName: "water_height" - minimumValue: -1 - maximumValue: 1 - orientation: Qt.Vertical - anchors.fill: parent - anchors.margins: 10 - } -} diff --git a/src/interface/modeler/quickapp/qml/WaterSection.qml b/src/interface/modeler/quickapp/qml/WaterSection.qml new file mode 100644 index 0000000..1e262e2 --- /dev/null +++ b/src/interface/modeler/quickapp/qml/WaterSection.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 + +// Water control +BaseSection { + id: section + + BaseToolbar { + id: toolbar + + ToolbarButton { + id: tool_water_level + selected: true + picture: "images/icon_water_level.png" + hovertext: qsTr("Change the water altitude") + } + } + + BasePanel { + id: panel_water_level + width: 40 + anchors.left: toolbar.right + enabled: false + + BaseSlider { + objectName: "water_height" + minimumValue: -1 + maximumValue: 1 + orientation: Qt.Vertical + anchors.fill: parent + anchors.margins: 10 + } + } + + states: [ + State { + name: "WaterHeight" + when: tool_water_level.selected + PropertyChanges { + target: panel_water_level + enabled: true + } + } + ] +} + diff --git a/src/interface/modeler/quickapp/qml/app.qrc b/src/interface/modeler/quickapp/qml/app.qrc index 24dc562..4b800bb 100644 --- a/src/interface/modeler/quickapp/qml/app.qrc +++ b/src/interface/modeler/quickapp/qml/app.qrc @@ -9,14 +9,13 @@ images/tab_textures.png images/tab_water.png images/tab_display.png - Toolbar.qml + BaseToolbar.qml images/display_topdown.png images/help.png Tooltip.qml images/icon_water.png images/icon_water_level.png BasePanel.qml - PanelWaterLevel.qml images/icon_atmosphere.png images/icon_atmosphere_daytime.png BaseSlider.qml @@ -40,5 +39,8 @@ images/toggle_water.png images/icon_render_quick.png images/icon_render_show.png + WaterSection.qml + BaseSection.qml + AtmosphereSection.qml diff --git a/src/interface/modeler/quickapp/qml/main.qml b/src/interface/modeler/quickapp/qml/main.qml index 56d75c0..07f0b37 100644 --- a/src/interface/modeler/quickapp/qml/main.qml +++ b/src/interface/modeler/quickapp/qml/main.qml @@ -15,7 +15,7 @@ OpenGLView { anchors.right: primary_toolbar.right } - Toolbar { + BaseToolbar { id: primary_toolbar horizontal: true color: "#90888888" @@ -61,24 +61,14 @@ OpenGLView { } } - BaseSecondaryToolbar { - id: water_toolbar - - ToolbarButton { - id: tool_water_level - picture: "images/icon_water_level.png" - hovertext: qsTr("Change the water altitude") - } + WaterSection { + id: water_section + enabled: false } - BaseSecondaryToolbar { - id: atmosphere_toolbar - - ToolbarButton { - id: tool_atmosphere_daytime - picture: "images/icon_atmosphere_daytime.png" - hovertext: qsTr("Change the time of day") - } + AtmosphereSection { + id: atmosphere_section + enabled: false } BaseSecondaryToolbar { @@ -158,22 +148,13 @@ OpenGLView { anchors.fill: parent } - PanelWaterLevel { - id: panel_water_level - tool: tool_water_level - } - PanelAtmosphereDaytime { - id: panel_atmosphere_daytime - tool: tool_atmosphere_daytime - } - states: [ State { name: "Water Mode" when: tool_water.selected PropertyChanges { - target: water_toolbar + target: water_section enabled: true } }, @@ -182,7 +163,7 @@ OpenGLView { when: tool_atmosphere.selected PropertyChanges { - target: atmosphere_toolbar + target: atmosphere_section enabled: true } }, diff --git a/src/interface/modeler/quickapp/quickapp.pro b/src/interface/modeler/quickapp/quickapp.pro index 132e58e..1af94de 100644 --- a/src/interface/modeler/quickapp/quickapp.pro +++ b/src/interface/modeler/quickapp/quickapp.pro @@ -67,16 +67,4 @@ INCLUDEPATH += $$PWD/../../../render/opengl DEPENDPATH += $$PWD/../../../render/opengl OTHER_FILES += \ - qml/main.qml \ - qml/ToolbarButton.qml \ - qml/OpenGLView.qml \ - qml/Toolbar.qml \ - qml/Tooltip.qml \ - qml/BasePanel.qml \ - qml/PanelWaterLevel.qml \ - qml/PanelAtmosphereDaytime.qml \ - qml/BaseSlider.qml \ - qml/BaseChoice.qml \ - qml/BaseChoiceItem.qml \ - qml/RenderDialog.qml \ - qml/CameraChoice.qml + qml/*.qml