diff --git a/src/interface/modeler/quickapp/WaterModeler.cpp b/src/interface/modeler/quickapp/WaterModeler.cpp index ce905da..4ee6884 100644 --- a/src/interface/modeler/quickapp/WaterModeler.cpp +++ b/src/interface/modeler/quickapp/WaterModeler.cpp @@ -13,7 +13,7 @@ WaterModeler::WaterModeler(MainModelerWindow *ui): QObject *toggle_water = ui->findQmlObject("camera_toggle_water"); if (toggle_water) { - connect(toggle_water, SIGNAL(changed(bool)), this, SLOT(enableRendering(bool))); + connect(toggle_water, SIGNAL(toggled(bool)), this, SLOT(enableRendering(bool))); } prop_water_height = new FloatPropertyBind(ui, "water_height", "value", ui->getScenery()->getTerrain()->propWaterHeight()); diff --git a/src/interface/modeler/quickapp/qml/AtmosphereSection.qml b/src/interface/modeler/quickapp/qml/AtmosphereSection.qml index 6ac9513..08014d6 100644 --- a/src/interface/modeler/quickapp/qml/AtmosphereSection.qml +++ b/src/interface/modeler/quickapp/qml/AtmosphereSection.qml @@ -9,7 +9,7 @@ BaseSection { ToolbarButton { id: tool_daytime - selected: true + checked: true picture: "images/icon_atmosphere_daytime.png" hovertext: qsTr("Change the time of day") } @@ -37,7 +37,7 @@ BaseSection { states: [ State { name: "DayTime" - when: tool_daytime.selected + when: tool_daytime.checked PropertyChanges { target: panel_daytime enabled: true @@ -45,7 +45,7 @@ BaseSection { }, State { name: "Humidity" - when: tool_humidity.selected + when: tool_humidity.checked PropertyChanges { target: panel_humidity enabled: true diff --git a/src/interface/modeler/quickapp/qml/BaseSecondaryToolbar.qml b/src/interface/modeler/quickapp/qml/BaseSecondaryToolbar.qml index 1c4773e..a6dab66 100644 --- a/src/interface/modeler/quickapp/qml/BaseSecondaryToolbar.qml +++ b/src/interface/modeler/quickapp/qml/BaseSecondaryToolbar.qml @@ -5,10 +5,4 @@ BaseToolbar { height: parent.height - primary_toolbar.height anchors.left: primary_toolbar.left anchors.top: primary_toolbar.bottom - - onEnabledChanged: { - if (enabled) { - primary_toolbar.current = this; - } - } } diff --git a/src/interface/modeler/quickapp/qml/BaseToolbar.qml b/src/interface/modeler/quickapp/qml/BaseToolbar.qml index 8f25810..b57a941 100644 --- a/src/interface/modeler/quickapp/qml/BaseToolbar.qml +++ b/src/interface/modeler/quickapp/qml/BaseToolbar.qml @@ -1,19 +1,37 @@ import QtQuick 2.0 +import QtQuick.Controls 1.2 BaseRectangle { + id: toolbar default property alias children : inner_space.children property bool horizontal: false property list panels + property var current width: horizontal ? parent.width : 60 height: horizontal ? 60 : parent.height color: "#50888888" + ExclusiveGroup { + id: exclusive_checked + } + Grid { id: inner_space columns: parent.horizontal ? children.length : 1 rows: parent.horizontal ? 1 : children.length spacing: (parent.horizontal ? (parent.width - children.length * tool_terrain.width) : (parent.height - children.length * tool_terrain.height)) / (children.length + 1) anchors.centerIn: parent + + onChildrenChanged: { + for (var i = 0; i < children.length; ++i) + { + children[i].toolbar = toolbar; + if (!children[i].toggle) + { + children[i].exclusiveGroup = exclusive_checked; + } + } + } } } diff --git a/src/interface/modeler/quickapp/qml/CameraChoice.qml b/src/interface/modeler/quickapp/qml/CameraChoice.qml index f4ba0f1..733904d 100644 --- a/src/interface/modeler/quickapp/qml/CameraChoice.qml +++ b/src/interface/modeler/quickapp/qml/CameraChoice.qml @@ -10,7 +10,7 @@ BaseToolbar { id: camera_choice_render picture: "images/tab_display.png" hovertext: qsTr("Final render camera") - selected: true + checked: true } ToolbarButton { @@ -23,7 +23,7 @@ BaseToolbar { id: camera_toggle_water objectName: "camera_toggle_water" toggle: true - selected: true + checked: true picture: "images/toggle_water.png" hovertext: qsTr("Toggle water rendering") } @@ -31,11 +31,11 @@ BaseToolbar { states: [ State { name: "Render camera" - when: camera_choice_render.selected + when: camera_choice_render.checked }, State { name: "Top-down camera" - when: camera_choice_topdown.selected + when: camera_choice_topdown.checked } ] } diff --git a/src/interface/modeler/quickapp/qml/ToolbarButton.qml b/src/interface/modeler/quickapp/qml/ToolbarButton.qml index 6542b85..def0465 100644 --- a/src/interface/modeler/quickapp/qml/ToolbarButton.qml +++ b/src/interface/modeler/quickapp/qml/ToolbarButton.qml @@ -1,23 +1,36 @@ import QtQuick 2.0 import QtGraphicalEffects 1.0 +import QtQuick.Controls 1.2 Item { id: button + property var toolbar: null property string picture - property bool selected: false + property bool checked: false property bool hovered: false property bool toggle: false + property ExclusiveGroup exclusiveGroup: null property string helptext property string hovertext property string shortcut signal clicked - signal changed(bool value) + signal toggled(bool value) width: image.width + 10 height: image.height + 10 opacity: enabled ? 1.0 : 0.1 - onSelectedChanged: changed(selected) + onExclusiveGroupChanged: { + if (exclusiveGroup) + exclusiveGroup.bindCheckable(button) + } + + onCheckedChanged: { + toggled(checked); + if (toolbar && !toggle && checked) { + toolbar.current = button; + } + } Behavior on opacity { PropertyAnimation { @@ -31,7 +44,7 @@ Item { color: parent.toggle ? "#bbccbb" : "#cccccc" radius: 8 - opacity: button.selected ? 1.0 : (button.hovered ? 0.5 : 0.0) + opacity: button.checked ? 1.0 : (button.hovered ? 0.5 : 0.0) Behavior on opacity { PropertyAnimation { duration: 200 @@ -79,20 +92,11 @@ Item { tooltip_widget.hovertext = ""; } onClicked: { - button.selected = !button.selected; + button.checked = !button.checked; if (!button.toggle) { - if (button.selected) + if (button.checked) { - var toolbar = button.parent; - for (var i = 0; i < toolbar.children.length; ++i) - { - var child = toolbar.children[i] - if (child !== button && !child.toggle) - { - child.selected = false; - } - } tooltip_widget.helptext = helptext; } else diff --git a/src/interface/modeler/quickapp/qml/WaterSection.qml b/src/interface/modeler/quickapp/qml/WaterSection.qml index 82b6fb7..f549c8c 100644 --- a/src/interface/modeler/quickapp/qml/WaterSection.qml +++ b/src/interface/modeler/quickapp/qml/WaterSection.qml @@ -9,7 +9,7 @@ BaseSection { ToolbarButton { id: tool_water_level - selected: true + checked: true picture: "images/icon_water_level.png" hovertext: qsTr("Change the water altitude") } @@ -27,7 +27,7 @@ BaseSection { states: [ State { name: "WaterHeight" - when: tool_water_level.selected + when: tool_water_level.checked PropertyChanges { target: panel_water_level enabled: true diff --git a/src/interface/modeler/quickapp/qml/main.qml b/src/interface/modeler/quickapp/qml/main.qml index a42404f..fc9ae58 100644 --- a/src/interface/modeler/quickapp/qml/main.qml +++ b/src/interface/modeler/quickapp/qml/main.qml @@ -159,55 +159,39 @@ OpenGLView { states: [ State { name: "Water Mode" - when: tool_water.selected + when: primary_toolbar.current === tool_water PropertyChanges { target: water_section enabled: true } - PropertyChanges { - target: tool_water - selected: true - } }, State { name: "Atmosphere Mode" - when: tool_atmosphere.selected + when: primary_toolbar.current === tool_atmosphere PropertyChanges { target: atmosphere_section enabled: true } - PropertyChanges { - target: tool_atmosphere - selected: true - } }, State { name: "Render Mode" - when: tool_render.selected + when: primary_toolbar.current === tool_render PropertyChanges { target: render_toolbar enabled: true } - PropertyChanges { - target: tool_render - selected: true - } }, State { name: "File Mode" - when: tool_file.selected + when: primary_toolbar.current === tool_file PropertyChanges { target: file_toolbar enabled: true } - PropertyChanges { - target: tool_file - selected: true - } }, State { name: "Render Dialog"