mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 15:29:05 +02:00
Tidy address bar dialog code
This commit is contained in:
parent
e41b4c1b7b
commit
9a8bb67f37
1 changed files with 27 additions and 29 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
//
|
||||||
|
// AddressBarDialog.qml
|
||||||
|
//
|
||||||
|
// Created by Austin Davis on 2015/04/14
|
||||||
|
// Copyright 2015 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 Hifi 1.0
|
import Hifi 1.0
|
||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
import QtQuick.Controls 1.2
|
import QtQuick.Controls 1.2
|
||||||
|
@ -12,7 +22,6 @@ Item {
|
||||||
|
|
||||||
property int animationDuration: hifi.effects.fadeInDuration
|
property int animationDuration: hifi.effects.fadeInDuration
|
||||||
property bool destroyOnInvisible: false
|
property bool destroyOnInvisible: false
|
||||||
property bool destroyOnCloseButton: true
|
|
||||||
|
|
||||||
implicitWidth: addressBarDialog.implicitWidth
|
implicitWidth: addressBarDialog.implicitWidth
|
||||||
implicitHeight: addressBarDialog.implicitHeight
|
implicitHeight: addressBarDialog.implicitHeight
|
||||||
|
@ -24,8 +33,8 @@ Item {
|
||||||
id: addressBarDialog
|
id: addressBarDialog
|
||||||
|
|
||||||
property int iconOverlap: 15 // Let the circle overlap window edges and rectangular part of dialog
|
property int iconOverlap: 15 // Let the circle overlap window edges and rectangular part of dialog
|
||||||
property int maximumX: root.parent.width - root.width
|
property int maximumX: root.parent ? root.parent.width - root.width : 0
|
||||||
property int maximumY: root.parent.height - root.height
|
property int maximumY: root.parent ? root.parent.height - root.height : 0
|
||||||
|
|
||||||
implicitWidth: box.width + icon.width - iconOverlap * 2
|
implicitWidth: box.width + icon.width - iconOverlap * 2
|
||||||
implicitHeight: addressLine.height + hifi.layout.spacing * 2
|
implicitHeight: addressLine.height + hifi.layout.spacing * 2
|
||||||
|
@ -39,13 +48,10 @@ Item {
|
||||||
radius: 6
|
radius: 6
|
||||||
color: "#ededee"
|
color: "#ededee"
|
||||||
|
|
||||||
x: icon.width - addressBarDialog.iconOverlap * 2 // W.r.t. addressBarDialog
|
x: icon.width - addressBarDialog.iconOverlap * 2 // Relative to addressBarDialog
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: boxDrag
|
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
drag {
|
drag {
|
||||||
target: root
|
target: root
|
||||||
minimumX: 0
|
minimumX: 0
|
||||||
|
@ -58,18 +64,20 @@ Item {
|
||||||
TextInput {
|
TextInput {
|
||||||
id: addressLine
|
id: addressLine
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors {
|
||||||
anchors.leftMargin: addressBarDialog.iconOverlap + hifi.layout.spacing * 2
|
fill: parent
|
||||||
anchors.rightMargin: hifi.layout.spacing * 2
|
leftMargin: addressBarDialog.iconOverlap + hifi.layout.spacing * 2
|
||||||
anchors.topMargin: hifi.layout.spacing
|
rightMargin: hifi.layout.spacing * 2
|
||||||
anchors.bottomMargin: hifi.layout.spacing
|
topMargin: hifi.layout.spacing
|
||||||
|
bottomMargin: hifi.layout.spacing
|
||||||
|
}
|
||||||
|
|
||||||
font.pointSize: 15
|
font.pointSize: 15
|
||||||
helperText: "Go to: place, @user, /path, network address"
|
helperText: "Go to: place, @user, /path, network address"
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
event.accepted
|
event.accepted = true // Generates erroneous error in program log, "ReferenceError: event is not defined".
|
||||||
addressBarDialog.loadAddress(addressLine.text)
|
addressBarDialog.loadAddress(addressLine.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,15 +87,14 @@ Item {
|
||||||
source: "../images/address-bar-icon.svg"
|
source: "../images/address-bar-icon.svg"
|
||||||
width: 80
|
width: 80
|
||||||
height: 80
|
height: 80
|
||||||
anchors.right: box.left
|
anchors {
|
||||||
anchors.rightMargin: -addressBarDialog.iconOverlap
|
right: box.left
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
rightMargin: -addressBarDialog.iconOverlap
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: iconDrag
|
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
drag {
|
drag {
|
||||||
target: root
|
target: root
|
||||||
minimumX: 0
|
minimumX: 0
|
||||||
|
@ -138,15 +145,6 @@ Item {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
|
||||||
// The close function performs the same way as the OffscreenUI class: don't do anything but manipulate the enabled flag
|
|
||||||
// and let the other mechanisms decide if the window should be destroyed after the close animation completes.
|
|
||||||
if (destroyOnCloseButton) {
|
|
||||||
destroyOnInvisible = true
|
|
||||||
}
|
|
||||||
enabled = false
|
|
||||||
}
|
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
addressLine.text = ""
|
addressLine.text = ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue