Style settings section headings

This commit is contained in:
David Rowe 2016-02-26 10:03:00 +13:00
parent 09029e4edd
commit 5d931523ad
3 changed files with 53 additions and 47 deletions

View file

@ -2,7 +2,7 @@
// PreferencesDialog.qml
//
// Created by Bradley Austin Davis on 24 Jan 2016
// Copyright 2015 High Fidelity, Inc.
// Copyright 2016 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -10,8 +10,6 @@
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2 as OriginalDialogs
import Qt.labs.settings 1.0
import "../controls-uit" as HifiControls
import "../styles-uit"
@ -75,10 +73,20 @@ Window {
}
if (sections.length) {
sections[0].expanded = true;
if (sections.length === 1) {
sections[0].collapsable = false
// Default sections to expanded/collapsed as appropriate for dialog.
if (title === "Avatar Preferences") {
sections[0].expanded = true;
if (sections.length === 1) {
sections[0].collapsable = false
}
} else {
for (i = 0; i < sections.length; i++) {
sections[i].collapsable = false;
sections[i].expanded = true;
}
}
sections[0].hasSeparator = false;
sections[sections.length - 1].hasSpacer = true;
}
}
@ -109,4 +117,3 @@ Window {
}
}
}

View file

@ -1,3 +1,13 @@
//
// Preference.qml
//
// Created by Bradley Austin Davis on 18 Jan 2016
// Copyright 2016 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.5
import QtQuick.Controls 1.4

View file

@ -1,20 +1,33 @@
//
// Section.qml
//
// Created by Bradley Austin Davis on 18 Jan 2016
// Copyright 2016 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.5
import QtQuick.Controls 1.4
import Hifi 1.0
import "../../controls" as VrControls
import "../../controls-uit" as HiFiControls
import "../../styles-uit"
import "."
Preference {
id: root
property bool collapsable: true
property bool expanded: false
property bool hasSeparator: true
property bool hasSpacer: false
property string name: "Header"
property real spacing: 8
readonly property alias toggle: toggle
readonly property alias header: header
default property alias preferences: contentContainer.children
HifiConstants { id: hifi }
function saveAll() {
for (var i = 0; i < d.preferences.length; ++i) {
var preference = d.preferences[i];
@ -29,47 +42,23 @@ Preference {
}
}
clip: true
children: [ toggle, header, contentContainer ]
height: expanded ? header.height + contentContainer.height + root.spacing * 3
: Math.max(toggle.height, header.height) + root.spacing * 2
Behavior on height { PropertyAnimation {} }
children: [ contentContainer ]
height: contentContainer.height + (root.hasSpacer ? 2 * hifi.dimensions.contentSpacing.y : 0)
Component.onCompleted: d.buildPreferences();
function toggleExpanded() {
root.expanded = !root.expanded;
}
VrControls.FontAwesome {
id: toggle
width: root.collapsable ? height : 0
anchors { left: parent.left; top: parent.top; margins: root.spacing }
visible: root.collapsable
enabled: root.collapsable
rotation: root.expanded ? 0 : -90
text: "\uf078"
Behavior on rotation { PropertyAnimation {} }
MouseArea { anchors.fill: parent; onClicked: root.toggleExpanded() }
}
Text {
id: header
anchors { left: toggle.right; top: parent.top; leftMargin: root.spacing * 2; margins: root.spacing }
font.bold: true
font.pointSize: 16
color: "#0e7077"
text: root.name
MouseArea { anchors.fill: parent; onClicked: root.toggleExpanded() }
}
Column {
HiFiControls.StaticSection {
id: contentContainer
spacing: root.spacing
anchors { left: toggle.right; top: header.bottom; topMargin: root.spacing; right: parent.right; margins: root.spacing }
enabled: root.expanded
visible: root.expanded
clip: true
name: root.name
hasSeparator: root.hasSeparator
anchors {
left: parent.left
right: parent.right
margins: 0
}
}
QtObject {