Merge pull request #6918 from jherico/running-scripts-filter

Several Small QML fixes
This commit is contained in:
Brad Hefta-Gaub 2016-01-23 22:36:36 -08:00
commit e3f861b20a
12 changed files with 129 additions and 62 deletions

View file

@ -32,17 +32,6 @@ Window {
implicitWidth: backgroundImage.width
implicitHeight: backgroundImage.height
Timer {
running: root.visible
interval: 500
repeat: true
onTriggered: {
if (root.enabled && !addressLine.activeFocus) {
addressLine.forceActiveFocus()
}
}
}
Image {
id: backgroundImage

View file

@ -78,6 +78,7 @@ Window {
source: webview.icon;
x: (parent.height - height) / 2
y: (parent.width - width) / 2
sourceSize: Qt.size(width, height);
verticalAlignment: Image.AlignVCenter;
horizontalAlignment: Image.AlignHCenter
onSourceChanged: console.log("Icon url: " + source)

View file

@ -4,6 +4,7 @@ import QtQuick.Dialogs 1.2 as OriginalDialogs;
import "../dialogs"
import "../menus"
import "../js/Utils.js" as Utils
// This is our primary 'desktop' object to which all VR dialogs and
// windows will be childed.
@ -18,11 +19,18 @@ FocusScope {
// The VR version of the primary menu
property var rootMenu: Menu { objectName: "rootMenu" }
readonly property alias zLevels: zLevels
QtObject {
id: zLevels;
readonly property real normal: 0
readonly property real top: 2000
readonly property real modal: 4000
readonly property real menu: 8000
}
QtObject {
id: d
readonly property int zBasisNormal: 0
readonly property int zBasisAlwaysOnTop: 4096
readonly property int zBasisModal: 8192
readonly property var messageDialogBuilder: Component { MessageDialog { } }
function findChild(item, name) {
for (var i = 0; i < item.children.length; ++i) {
@ -75,15 +83,12 @@ FocusScope {
return currentWindows;
}
function getDesktopWindow(item) {
return findParentMatching(item, isTopLevelWindow)
}
function fixupZOrder(windows, basis, topWindow) {
windows.sort(function(a, b){
return a.z - b.z;
});
windows.sort(function(a, b){ return a.z - b.z; });
if ((topWindow.z >= basis) && (windows[windows.length - 1] === topWindow)) {
return;
@ -122,33 +127,22 @@ FocusScope {
return lastTargetZ;
}
function raiseWindow(item) {
var targetWindow = getDesktopWindow(item);
if (!targetWindow) {
console.warn("Could not find top level window for " + item);
return;
}
if (!desktop) {
console.warn("Could not find desktop for window " + targetWindow);
return;
}
function raiseWindow(targetWindow) {
var predicate;
var zBasis;
if (isModalWindow(targetWindow)) {
predicate = isModalWindow;
zBasis = zBasisModal
zBasis = zLevels.modal
} else if (isAlwaysOnTopWindow(targetWindow)) {
predicate = function(window) {
return (isAlwaysOnTopWindow(window) && !isModalWindow(window));
}
zBasis = zBasisAlwaysOnTop
zBasis = zLevels.top
} else {
predicate = function(window) {
return (!isAlwaysOnTopWindow(window) && !isModalWindow(window));
}
zBasis = zBasisNormal
zBasis = zLevels.normal
}
var windows = getTopLevelWindows(predicate);
@ -157,11 +151,64 @@ FocusScope {
}
function raise(item) {
d.raiseWindow(item);
var targetWindow = d.getDesktopWindow(item);
if (!targetWindow) {
console.warn("Could not find top level window for " + item);
return;
}
// Fix up the Z-order (takes into account if this is a modal window)
d.raiseWindow(targetWindow);
var setFocus = true;
if (!d.isModalWindow(targetWindow)) {
var modalWindows = d.getTopLevelWindows(d.isModalWindow);
if (modalWindows.length) {
setFocus = false;
}
}
if (setFocus) {
focus = true;
}
reposition(targetWindow);
}
function reposition(item) {
if (desktop.width === 0 || desktop.height === 0) {
return;
}
var targetWindow = d.getDesktopWindow(item);
if (!targetWindow) {
console.warn("Could not find top level window for " + item);
return;
}
var windowRect = targetWindow.framedRect();
var minPosition = Qt.vector2d(-windowRect.x, -windowRect.y);
var maxPosition = Qt.vector2d(desktop.width - windowRect.width, desktop.height - windowRect.height);
var newPosition;
if (targetWindow.x === -1 && targetWindow.y === -1) {
// Set initial window position
newPosition = Utils.randomPosition(minPosition, maxPosition);
} else {
newPosition = Utils.clampVector(Qt.vector2d(targetWindow.x, targetWindow.y), minPosition, maxPosition);
}
targetWindow.x = newPosition.x;
targetWindow.y = newPosition.y;
}
function repositionAll() {
var windows = d.getTopLevelWindows();
for (var i = 0; i < windows.length; ++i) {
reposition(windows[i]);
}
}
onHeightChanged: repositionAll();
onWidthChanged: repositionAll();
Component { id: messageDialogBuilder; MessageDialog { } }
function messageBox(properties) {
return messageDialogBuilder.createObject(desktop, properties);
}
@ -217,9 +264,8 @@ FocusScope {
function onWindowFocusChanged() {
console.log("Focus item is " + offscreenWindow.activeFocusItem);
var focusedItem = offscreenWindow.activeFocusItem ;
if (DebugQML && focusedItem && false) {
if (DebugQML && focusedItem) {
var rect = desktop.mapFromItem(focusedItem, 0, 0, focusedItem.width, focusedItem.height);
focusDebugger.visible = true
focusDebugger.x = rect.x;
focusDebugger.y = rect.y;
focusDebugger.width = rect.width
@ -232,8 +278,13 @@ FocusScope {
z: 9999; visible: false; color: "red"
ColorAnimation on color { from: "#7fffff00"; to: "#7f0000ff"; duration: 1000; loops: 9999 }
}
Action {
text: "Toggle Focus Debugger"
shortcut: "Ctrl+Shift+F"
enabled: DebugQML
onTriggered: focusDebugger.visible = !focusDebugger.visible
}
}

View file

@ -202,6 +202,7 @@ Window {
anchors.bottomMargin: 8
placeholderText: "filter"
onTextChanged: scriptsModel.filterRegExp = new RegExp("^.*" + text + ".*$", "i")
Component.onCompleted: scriptsModel.filterRegExp = new RegExp("^.*$", "i")
}
TreeView {

View file

@ -1,4 +1,5 @@
import QtQuick 2.5
import QtQuick.Controls 1.4
import "../desktop"
import ".."
@ -9,6 +10,19 @@ Desktop {
// The tool window, one instance
property alias toolWindow: toolWindow
ToolWindow { id: toolWindow }
Action {
text: "Open Browser"
shortcut: "Ctrl+B"
onTriggered: {
console.log("Open browser");
browserBuilder.createObject(desktop);
}
property var browserBuilder: Component {
Browser{}
}
}
}

View file

@ -0,0 +1,16 @@
function clamp(value, min, max) {
return Math.min(Math.max(value, min), max);
}
function clampVector(value, min, max) {
return Qt.vector2d(
clamp(value.x, min.x, max.x),
clamp(value.y, min.y, max.y))
}
function randomPosition(min, max) {
return Qt.vector2d(
Math.random() * (max.x - min.x),
Math.random() * (max.y - min.y));
}

View file

@ -5,7 +5,6 @@ import "."
Item {
id: root
property int zBasis: 8192 - 1024
anchors.fill: parent
MouseArea {
@ -93,7 +92,8 @@ Item {
function buildMenu(items, targetPosition) {
var model = toModel(items);
var newMenu = menuViewMaker.createObject(menuRoot, { model: model, z: topMenu ? topMenu.z + 1 : zBasis });
// Menu's must be childed to desktop for Z-ordering
var newMenu = menuViewMaker.createObject(desktop, { model: model, z: topMenu ? topMenu.z + 1 : desktop.zLevels.menu });
if (targetPosition) {
newMenu.x = targetPosition.x
newMenu.y = targetPosition.y - newMenu.height / 3 * 1

View file

@ -1,6 +1,7 @@
import QtQuick 2.5
import "../controls"
import "../js/Utils.js" as Utils
Item {
id: frame
@ -34,7 +35,7 @@ Item {
function deltaSize(dx, dy) {
var newSize = Qt.vector2d(window.width + dx, window.height + dy);
newSize = clampVector(newSize, window.minSize, window.maxSize);
newSize = Utils.clampVector(newSize, window.minSize, window.maxSize);
window.width = newSize.x
window.height = newSize.y
}

View file

@ -19,6 +19,7 @@ Fadable {
// decorations can extend outside it.
implicitHeight: content.height
implicitWidth: content.width
x: -1; y: -1
property int modality: Qt.NonModal
@ -71,15 +72,11 @@ Fadable {
// frame styles, like a full desktop frame to simulate a modal window
property var frame: DefaultFrame { }
Component.onCompleted: raise();
children: [ frame, content, activator ]
Component.onDestruction: {
content.destroy();
console.log("Destroyed " + window);
windowDestroyed();
}
Component.onCompleted: raise();
Component.onDestruction: windowDestroyed();
onParentChanged: raise();
onVisibleChanged: {
@ -96,9 +93,6 @@ Fadable {
function raise() {
if (visible && parent) {
desktop.raise(window)
if (!focus) {
focus = true;
}
}
}
@ -118,15 +112,15 @@ Fadable {
visible = false;
}
function clamp(value, min, max) {
return Math.min(Math.max(value, min), max);
function framedRect() {
if (!frame || !frame.decoration) {
return Qt.rect(0, 0, window.width, window.height)
}
return Qt.rect(frame.decoration.anchors.leftMargin, frame.decoration.anchors.topMargin,
window.width - frame.decoration.anchors.leftMargin - frame.decoration.anchors.rightMargin,
window.height - frame.decoration.anchors.topMargin - frame.decoration.anchors.bottomMargin)
}
function clampVector(value, min, max) {
return Qt.vector2d(
clamp(value.x, min.x, max.x),
clamp(value.y, min.y, max.y))
}
Keys.onPressed: {
switch(event.key) {

View file

@ -87,8 +87,8 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
renderDomainConnectionStatusBorder(renderArgs); // renders the connected domain line
renderAudioScope(renderArgs); // audio scope in the very back - NOTE: this is the debug audio scope, not the VU meter
renderRearView(renderArgs); // renders the mirror view selfie
renderQmlUi(renderArgs); // renders a unit quad with the QML UI texture, and the text overlays from scripts
renderOverlays(renderArgs); // renders Scripts Overlay and AudioScope
renderQmlUi(renderArgs); // renders a unit quad with the QML UI texture, and the text overlays from scripts
renderStatsAndLogs(renderArgs); // currently renders nothing
});

View file

@ -185,10 +185,10 @@ void EntityItemProperties::setShapeTypeFromString(const QString& shapeName) {
}
using BackgroundPair = std::pair<const BackgroundMode, const QString>;
const std::array<BackgroundPair, BACKGROUND_MODE_ITEM_COUNT> BACKGROUND_MODES = {
const std::array<BackgroundPair, BACKGROUND_MODE_ITEM_COUNT> BACKGROUND_MODES = { {
BackgroundPair { BACKGROUND_MODE_INHERIT, { "inherit" } },
BackgroundPair { BACKGROUND_MODE_SKYBOX, { "skybox" } }
};
} };
QString EntityItemProperties::getBackgroundModeAsString() const {
return BACKGROUND_MODES[_backgroundMode].second;

View file

@ -7,7 +7,6 @@ import "../../../interface/resources/qml"
import "../../../interface/resources/qml/windows"
import "../../../interface/resources/qml/dialogs"
import "../../../interface/resources/qml/hifi"
import "../../../interface/resources/qml/hifi/dialogs"
ApplicationWindow {
id: appWindow
@ -184,6 +183,7 @@ ApplicationWindow {
Window {
id: yellow
objectName: "Yellow"
closable: true
visible: true
resizable: true