From 3b4185fdb31d4acc7770241b2d483358a7dfe1be Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Mon, 23 Oct 2017 19:30:36 +0100 Subject: [PATCH 1/2] WL 21508 - Improve upon Skybox Changer This involved a second PR, due to optimizing the way the Skyboxes are laid out. All of the Skyboxes will now appear at once, with the random button being removed. You are able to scroll up and down the list and choose which Skybox you'd like to pick. --- .../resources/qml/hifi/SkyboxChanger.qml | 63 +++++-------------- .../qml/hifi/SkyboxSelectionModel.qml | 40 ------------ 2 files changed, 16 insertions(+), 87 deletions(-) delete mode 100644 interface/resources/qml/hifi/SkyboxSelectionModel.qml diff --git a/interface/resources/qml/hifi/SkyboxChanger.qml b/interface/resources/qml/hifi/SkyboxChanger.qml index 2aa0460e15..d6cfa91988 100644 --- a/interface/resources/qml/hifi/SkyboxChanger.qml +++ b/interface/resources/qml/hifi/SkyboxChanger.qml @@ -12,6 +12,7 @@ import QtQuick 2.5 import "../styles-uit" import "../controls-uit" as HifiControls +import QtQuick.Controls 2.2 Item { id: root; @@ -20,7 +21,7 @@ Item { property var defaultThumbnails: []; property var defaultFulls: []; - SkyboxSelectionModel { + ListModel { id: skyboxModel; } @@ -41,44 +42,18 @@ Item { for (var i = 0; i < arr.length; i++) { defaultThumbnails.push(arr[i].thumb); defaultFulls.push(arr[i].full); + skyboxModel.append({}); } - setDefaultSkyboxes(); + setSkyboxes(); } - function setDefaultSkyboxes() { + function setSkyboxes() { for (var i = 0; i < skyboxModel.count; i++) { skyboxModel.setProperty(i, "thumbnailPath", defaultThumbnails[i]); skyboxModel.setProperty(i, "fullSkyboxPath", defaultFulls[i]); } } - function shuffle(array) { - var tmp, current, top = array.length; - if (top) { - while (--top) { - current = Math.floor(Math.random() * (top + 1)); - tmp = array[current]; - array[current] = array[top]; - array[top] = tmp; - } - } - return array; - } - - function chooseRandom() { - for (var a = [], i=0; i < defaultFulls.length; ++i) { - a[i] = i; - } - - a = shuffle(a); - - for (var i = 0; i < skyboxModel.count; i++) { - skyboxModel.setProperty(i, "thumbnailPath", defaultThumbnails[a[i]]); - skyboxModel.setProperty(i, "fullSkyboxPath", defaultFulls[a[i]]); - } - } - - Component.onCompleted: { getSkyboxes(); } @@ -116,33 +91,19 @@ Item { horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter; } - HifiControls.Button { - id: randomButton - text: "Randomize" - color: hifi.buttons.blue - colorScheme: root.colorScheme - width: 100 - anchors.right: parent.right - anchors.top: parent.top - anchors.topMargin: 5 - anchors.rightMargin: 40 - onClicked: { - chooseRandom() - } - } } GridView { id: gridView - interactive: false + interactive: true clip: true anchors.top: titleBarContainer.bottom anchors.topMargin: 20 anchors.horizontalCenter: parent.horizontalCenter width: 400 - height: parent.height + //height: parent.height + anchors.bottom: parent.bottom currentIndex: -1 - cellWidth: 200 cellHeight: 200 model: skyboxModel @@ -168,6 +129,14 @@ Item { } } } + ScrollBar.vertical: ScrollBar { + parent: gridView.parent + anchors.top: gridView.top + anchors.left: gridView.right + anchors.bottom: gridView.bottom + anchors.leftMargin: 10 + width: 19 + } } signal sendToScript(var message); diff --git a/interface/resources/qml/hifi/SkyboxSelectionModel.qml b/interface/resources/qml/hifi/SkyboxSelectionModel.qml deleted file mode 100644 index 45a964fcb3..0000000000 --- a/interface/resources/qml/hifi/SkyboxSelectionModel.qml +++ /dev/null @@ -1,40 +0,0 @@ -// -// SkyboxSelectionModel.qml -// qml/hifi -// -// Created by Cain Kilgore on 21st October 2017 -// Copyright 2017 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 - -ListModel { - id: root; - ListElement{ - thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg" - fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg" - } - ListElement{ - thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg" - fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg" - } - ListElement{ - thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg" - fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg" - } - ListElement{ - thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg" - fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg" - } - ListElement{ - thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg" - fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg" - } - ListElement{ - thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg" - fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg" - } -} From b60b58ff35b538dd6104cc52069a40eab0f1f038 Mon Sep 17 00:00:00 2001 From: Cain Kilgore Date: Mon, 23 Oct 2017 19:40:43 +0100 Subject: [PATCH 2/2] zFox Changes --- interface/resources/qml/hifi/SkyboxChanger.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/SkyboxChanger.qml b/interface/resources/qml/hifi/SkyboxChanger.qml index d6cfa91988..f0c97a11a3 100644 --- a/interface/resources/qml/hifi/SkyboxChanger.qml +++ b/interface/resources/qml/hifi/SkyboxChanger.qml @@ -39,7 +39,8 @@ Item { function sortSkyboxes(response) { var arr = JSON.parse(response); - for (var i = 0; i < arr.length; i++) { + var arrLength = arr.length; + for (var i = 0; i < arrLength; i++) { defaultThumbnails.push(arr[i].thumb); defaultFulls.push(arr[i].full); skyboxModel.append({}); @@ -101,7 +102,6 @@ Item { anchors.topMargin: 20 anchors.horizontalCenter: parent.horizontalCenter width: 400 - //height: parent.height anchors.bottom: parent.bottom currentIndex: -1 cellWidth: 200