Working on message box and addressbar tweaks

This commit is contained in:
Brad Davis 2015-04-27 15:42:20 -07:00
parent ca16d37ce5
commit fd28baac8c
3 changed files with 45 additions and 52 deletions

View file

@ -4,12 +4,16 @@ import "controls"
import "styles"
Dialog {
id: root
HifiConstants { id: hifi }
title: "Go to..."
objectName: "AddressBarDialog"
height: 128
width: 512
contentImplicitWidth: addressBarDialog.implicitWidth
contentImplicitHeight: addressBarDialog.implicitHeight
destroyOnCloseButton: false
onVisibleChanged: {
if (!visible) {
reset();
@ -21,6 +25,11 @@ Dialog {
addressLine.forceActiveFocus();
}
}
onParentChanged: {
if (enabled && visible) {
addressLine.forceActiveFocus();
}
}
function reset() {
addressLine.text = ""
@ -29,24 +38,26 @@ Dialog {
AddressBarDialog {
id: addressBarDialog
// The client area
anchors.fill: parent
anchors.margins: parent.margins
anchors.topMargin: parent.topMargin
x: root.clientX
y: root.clientY
implicitWidth: 512
implicitHeight: border.height + hifi.layout.spacing * 4
Border {
id: border
height: 64
anchors.left: parent.left
anchors.leftMargin: 0
anchors.leftMargin: hifi.layout.spacing * 2
anchors.right: goButton.left
anchors.rightMargin: 8
anchors.rightMargin: hifi.layout.spacing
anchors.verticalCenter: parent.verticalCenter
TextInput {
id: addressLine
anchors.fill: parent
helperText: "domain, location, @user, /x,y,z"
anchors.margins: 8
anchors.margins: hifi.layout.spacing
onAccepted: {
event.accepted
addressBarDialog.loadAddress(addressLine.text)
@ -59,7 +70,7 @@ Dialog {
width: 32
height: 32
anchors.right: parent.right
anchors.rightMargin: 8
anchors.rightMargin: hifi.layout.spacing * 2
source: "../images/address-bar-submit.svg"
anchors.verticalCenter: parent.verticalCenter

View file

@ -3,71 +3,51 @@ import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import "controls"
import "styles"
Dialog {
id: root
property real spacing: 8
property real outerSpacing: 16
HifiConstants { id: hifi }
property real spacing: hifi.layout.spacing
property real outerSpacing: hifi.layout.spacing * 2
destroyOnCloseButton: true
destroyOnInvisible: true
implicitHeight: content.implicitHeight + outerSpacing * 2 + 48
implicitWidth: Math.min(200, Math.max(mainText.implicitWidth, content.buttonsRowImplicitWidth) + outerSpacing * 2);
contentImplicitWidth: content.implicitWidth
contentImplicitHeight: content.implicitHeight
onImplicitHeightChanged: root.height = implicitHeight
onImplicitWidthChanged: root.width = implicitWidth
function calculateImplicitWidth() {
if (buttons.visibleChildren.length < 2)
return;
var calcWidth = 0;
for (var i = 0; i < buttons.visibleChildren.length; ++i) {
calcWidth += Math.max(100, buttons.visibleChildren[i].implicitWidth) + root.spacing
}
content.buttonsRowImplicitWidth = outerSpacing + calcWidth + 48
}
Component.onCompleted: {
enabled = true
}
onEnabledChanged: {
if (enabled) {
root.forceActiveFocus();
onParentChanged: {
if (visible && enabled) {
forceActiveFocus();
}
}
Hifi.MessageDialog {
id: content
clip: true
anchors.fill: parent
anchors.topMargin: parent.topMargin + root.outerSpacing
anchors.leftMargin: parent.margins + root.outerSpacing
anchors.rightMargin: parent.margins + root.outerSpacing
anchors.bottomMargin: parent.margins + root.outerSpacing
implicitHeight: contentColumn.implicitHeight + outerSpacing * 2
implicitWidth: Math.max(mainText.implicitWidth, buttonsRowImplicitWidth);
property real buttonsRowImplicitWidth: Screen.pixelDensity * 50
onImplicitWidthChanged: root.width = implicitWidth
x: root.clientX
y: root.clientY
implicitHeight: contentColumn.implicitHeight + outerSpacing * 2
implicitWidth: mainText.implicitWidth + outerSpacing * 2
Component.onCompleted: {
root.title = title
}
onTitleChanged: {
root.title = title
}
Column {
anchors.fill: parent
anchors.margins: 8
id: contentColumn
spacing: root.outerSpacing
anchors {
top: parent.top
left: parent.left
right: parent.right
}
Item {
width: parent.width
@ -83,7 +63,7 @@ Dialog {
horizontalAlignment: Text.AlignLeft
color: iconColor()
text: iconSymbol()
function iconSymbol() {
switch (content.icon) {
case Hifi.MessageDialog.Information:
@ -262,7 +242,6 @@ Dialog {
onClicked: content.click(StandardButton.Help)
visible: content.standardButtons & StandardButton.Help
}
onVisibleChildrenChanged: root.calculateImplicitWidth()
}
}
@ -319,6 +298,7 @@ Dialog {
]
}
Keys.onPressed: {
if (event.modifiers === Qt.ControlModifier)
switch (event.key) {

View file

@ -6,13 +6,15 @@ import "../styles"
Item {
id: root
HifiConstants { id: hifi }
implicitHeight: 512
implicitWidth: 512
implicitHeight: contentImplicitHeight + titleBorder.height + hifi.styles.borderWidth
implicitWidth: contentImplicitWidth + hifi.styles.borderWidth * 2
property string title
property int titleSize: titleBorder.height + 12
property string frameColor: hifi.colors.hifiBlue
property string backgroundColor: hifi.colors.dialogBackground
property bool active: false
property real contentImplicitWidth: 800
property real contentImplicitHeight: 800
property alias titleBorder: titleBorder
readonly property alias titleX: titleBorder.x