summaryrefslogtreecommitdiffstats
path: root/tools/viewer/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tools/viewer/qml')
-rw-r--r--tools/viewer/qml/StyledButton.qml52
-rw-r--r--tools/viewer/qml/StyledMenu.qml95
-rw-r--r--tools/viewer/qml/StyledMenuButton.qml71
-rw-r--r--tools/viewer/qml/StyledMenuItem.qml159
-rw-r--r--tools/viewer/qml/StyledMenuSeparator.qml47
-rw-r--r--tools/viewer/qml/main.qml594
6 files changed, 1018 insertions, 0 deletions
diff --git a/tools/viewer/qml/StyledButton.qml b/tools/viewer/qml/StyledButton.qml
new file mode 100644
index 0000000..400179d
--- /dev/null
+++ b/tools/viewer/qml/StyledButton.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Controls 2.2
+
+Button {
+ id: control
+ implicitWidth: _controlBaseWidth
+ implicitHeight: _controlBaseHeight
+
+ contentItem: Text {
+ width: _controlBaseWidth
+ text: control.text
+ height: _controlBaseHeight
+ font.pixelSize: _fontSize
+ color: _textColor
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+ background: Rectangle {
+ color: control.down ? _menuSelectionColor : _dialogFieldColor
+ border.color: _dialogFieldBorderColor
+ radius: 2
+ }
+}
diff --git a/tools/viewer/qml/StyledMenu.qml b/tools/viewer/qml/StyledMenu.qml
new file mode 100644
index 0000000..6275dbc
--- /dev/null
+++ b/tools/viewer/qml/StyledMenu.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Controls 2.2
+
+Menu {
+ id: control
+
+ property alias hovered: menuArea.containsMouse
+
+ width: contentItem.width + leftPadding + rightPadding
+ height: contentItem.height + topPadding + bottomPadding
+ padding: 1 // For background border
+ x: 0
+ y: parent.height
+ closePolicy: Popup.CloseOnPressOutsideParent | Popup.CloseOnEscape
+
+ contentItem: MouseArea {
+ id: menuArea
+ hoverEnabled: true
+ height: list.height
+ width: list.width
+ ListView {
+ id: list
+ boundsBehavior: Flickable.StopAtBounds
+ clip: true
+ model: control.contentModel
+ currentIndex: control.currentIndex
+ highlightRangeMode: ListView.ApplyRange
+ highlightMoveDuration: 0
+ Component.onCompleted: {
+ var maxItemWidth = 0;
+ var maxShortcutWidth = 0;
+ var totalHeight = 0
+ var extraWidth = 0
+ var i;
+ for (i = control.contentData.length - 1; i >= 0; --i) {
+ if (control.contentData[i].itemWidth !== undefined) {
+ maxItemWidth = Math.max(maxItemWidth, control.contentData[i].itemWidth);
+ maxShortcutWidth = Math.max(maxShortcutWidth,
+ control.contentData[i].shortcutWidth);
+ }
+ totalHeight += control.contentData[i].height
+ }
+ maxItemWidth += _controlPadding // minimum item spacer
+ for (i = control.contentData.length - 1; i >= 0; --i) {
+ if (control.contentData[i].itemSpacerWidth !== undefined) {
+ control.contentData[i].itemSpacerWidth
+ = maxItemWidth - control.contentData[i].itemWidth;
+ control.contentData[i].shortcutSpacerWidth
+ = maxShortcutWidth - control.contentData[i].shortcutWidth;
+ }
+ }
+ width = maxItemWidth + maxShortcutWidth + extraWidth
+ + control.contentData[0].leftPadding + control.contentData[0].rightPadding
+ + control.contentData[0].arrowWidth + control.contentData[0].checkMarkWidth;
+ height = totalHeight
+ }
+ }
+ }
+
+ background: Rectangle {
+ width: control.width
+ height: control.height
+ color: _menuBackgroundColor
+ border.color: _menuBorderColor
+ }
+}
diff --git a/tools/viewer/qml/StyledMenuButton.qml b/tools/viewer/qml/StyledMenuButton.qml
new file mode 100644
index 0000000..b5290c3
--- /dev/null
+++ b/tools/viewer/qml/StyledMenuButton.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Controls 2.2
+
+Button {
+ id: control
+
+ property Menu menu: null
+ property ApplicationWindow window: null
+
+ onPressed: {
+ if (menu.visible)
+ menu.close();
+ else
+ menu.open();
+ }
+
+ onHoveredChanged: {
+ if (hovered && window.menuOpen) {
+ window.closeMenus();
+ menu.open();
+ }
+ }
+
+ hoverEnabled: true
+ width: contentItem.contentWidth + leftPadding + rightPadding
+ leftPadding: _controlPadding
+ rightPadding: _controlPadding
+ height: _controlBaseHeight
+ contentItem: Text {
+ text: control.text
+ font.pixelSize: _fontSize
+ opacity: enabled ? 1.0 : 0.3
+ color: _textColor
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+ background: Rectangle {
+ opacity: enabled ? 1 : 0.3
+ color: control.down || control.hovered
+ ? _menuSelectionColor : _menuBackgroundColor
+ }
+}
diff --git a/tools/viewer/qml/StyledMenuItem.qml b/tools/viewer/qml/StyledMenuItem.qml
new file mode 100644
index 0000000..79049a9
--- /dev/null
+++ b/tools/viewer/qml/StyledMenuItem.qml
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Controls 2.2
+
+MenuItem {
+ id: control
+
+ property alias shortcut: shortcut.sequence
+ property string shortcutText
+ property alias itemSpacerWidth: itemSpacer.width
+ property alias shortcutSpacerWidth: shortcutSpacer.width
+ property alias itemWidth: itemLabel.width
+ property alias shortcutWidth: shortcutLabel.width
+ property bool showArrow: false
+ property int arrowWidth: arrow.width
+ property int checkMarkWidth: checkMark.width
+ property bool showCheckMark: false
+ property Menu arrowMenu: null
+
+ hoverEnabled: true
+ width: contentItem.width + leftPadding + rightPadding
+ height: contentItem.height + topPadding + bottomPadding
+ padding: 0
+ leftPadding: 0
+ rightPadding: 0
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: {
+ if (showArrow) {
+ if (!arrowMenu.visible) {
+ arrowMenuDelay.stop();
+ arrowMenu.open();
+ }
+ } else {
+ mouse.accepted = false;
+ }
+ }
+ }
+
+ onHoveredChanged: {
+ if (showArrow)
+ arrowMenuDelay.start();
+ }
+
+ Timer {
+ id: arrowMenuDelay
+ interval: 500
+ repeat: false
+ onTriggered: {
+ if (arrowMenu.visible) {
+ if (!control.hovered && !arrowMenu.hovered)
+ arrowMenu.close();
+ } else {
+ if (control.hovered)
+ arrowMenu.open();
+ }
+ }
+ }
+
+ Shortcut {
+ id: shortcut
+ context: Qt.ApplicationShortcut
+ onActivated: control.triggered()
+ }
+
+ contentItem: Row {
+ width: checkMark.width + itemLabel.width + itemSpacer.width
+ + shortcutLabel.width + shortcutSpacer.width + arrow.width
+ height: _controlBaseHeight
+ Item {
+ id: checkMark
+ width: 16
+ height: _controlBaseHeight
+ Image {
+ anchors.fill: parent
+ visible: control.showCheckMark
+ fillMode: Image.Pad
+ source: "qrc:/images/check.png"
+ }
+ }
+ Label {
+ id: itemLabel
+ text: control.text
+ font.pixelSize: _fontSize
+ horizontalAlignment: Text.AlignLeft
+ color: control.enabled ? _textColor : _disabledColor
+ verticalAlignment: Text.AlignVCenter
+ clip: true
+ width: contentWidth
+ height: _controlBaseHeight
+ }
+ Item {
+ id: itemSpacer
+ width: _controlPadding
+ height: _controlBaseHeight
+ }
+ Label {
+ id: shortcutLabel
+ text: shortcut.nativeText === "" ? control.shortcutText : shortcut.nativeText
+ font.pixelSize: _fontSize
+ horizontalAlignment: Text.AlignLeft
+ color: control.enabled ? _textColor : _disabledColor
+ verticalAlignment: Text.AlignVCenter
+ clip: true
+ width: contentWidth
+ height: _controlBaseHeight
+ }
+ Item {
+ id: shortcutSpacer
+ width: 0
+ height: _controlBaseHeight
+ }
+ Item {
+ id: arrow
+ width: 16
+ height: _controlBaseHeight
+ Image {
+ anchors.fill: parent
+ visible: control.showArrow
+ fillMode: Image.Pad
+ source: "qrc:/images/arrow.png"
+ }
+ }
+ }
+ background: Rectangle {
+ width: control.width
+ height: control.height
+ color: control.hovered ? _menuSelectionColor : _menuBackgroundColor
+ }
+}
diff --git a/tools/viewer/qml/StyledMenuSeparator.qml b/tools/viewer/qml/StyledMenuSeparator.qml
new file mode 100644
index 0000000..344d667
--- /dev/null
+++ b/tools/viewer/qml/StyledMenuSeparator.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Controls 2.2
+
+MenuSeparator {
+ id: control
+ padding: 0
+ topPadding: 0
+ bottomPadding: 0
+ leftPadding: 0
+ rightPadding: 0
+ width: parent.width
+ height: 1
+ contentItem: Rectangle {
+ width: control.width - control.leftPadding - control.rightPadding
+ height: 1
+ color: _menuBorderColor
+ }
+}
diff --git a/tools/viewer/qml/main.qml b/tools/viewer/qml/main.qml
new file mode 100644
index 0000000..1357f39
--- /dev/null
+++ b/tools/viewer/qml/main.qml
@@ -0,0 +1,594 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Controls 2.2
+import QtQuick.Dialogs 1.2
+import Qt3DStudioViewer 1.0
+import QtStudio3D.OpenGL 2.4
+import QtQuick.Window 2.2
+
+ApplicationWindow {
+ id: window
+ width: 1280
+ height: 768
+ visible: true
+ title: qsTr("Qt 3D Studio Viewer")
+
+ property bool menuOpen: fileMenu.visible || viewMenu.visible
+ property Item loadedContent: contentLoader ? contentLoader.item : null
+ property string error
+ property int previousVisibility
+
+ property color showMatteColor: Qt.rgba(0.2, 0.2, 0.2, 1)
+ property color hideMatteColor: Qt.rgba(0, 0, 0, 1)
+ property color matteColor: hideMatteColor
+ property bool showRenderStats: false
+ property int scaleMode: ViewerSettings.ScaleModeCenter
+
+ function closeMenus() {
+ fileMenu.close();
+ scaleMenu.close();
+ viewMenu.close();
+ }
+
+ Component.onCompleted: {
+ _viewerHelper.restoreWindowState(window);
+ previousVisibility = visibility;
+ }
+
+ onClosing: {
+ _viewerHelper.storeWindowState(window);
+ }
+
+ Timer {
+ id: infoTimer
+ repeat: false
+ interval: 5000
+
+ onTriggered: {
+ infoOverlay.visible = false;
+ }
+ }
+
+ Rectangle {
+ id: infoOverlay
+ visible: false
+ color: "black"
+ border.color: _dialogBorderColor
+ x: parent.width * 0.2
+ y: parent.height * 0.4
+ width: parent.width * 0.6
+ height: parent.height * 0.2
+ z: 20
+ Label {
+ id: infoLabel
+ anchors.fill: parent
+ color: _textColor
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: window.width / 40
+ }
+ }
+
+ Connections {
+ target: _viewerHelper
+ onShowInfoOverlay: {
+ // Show a brief info overlay
+ infoLabel.text = infoStr;
+ infoOverlay.visible = true;
+ infoTimer.restart();
+ }
+ }
+
+ MouseArea {
+ property int swipeStart: 0
+
+ anchors.fill: parent
+ z: 10
+ enabled: !ipEntry.visible
+
+ onPressed: {
+ if (window.visibility === Window.FullScreen)
+ swipeStart = mouse.y;
+ _viewerHelper.handleMousePress(mouse.x, mouse.y, mouse.button, mouse.buttons,
+ mouse.modifiers);
+ mouse.accepted = true;
+ }
+ onReleased: {
+ _viewerHelper.handleMouseRelease(mouse.x, mouse.y, mouse.button, mouse.buttons,
+ mouse.modifiers);
+ mouse.accepted = true;
+ }
+ onPositionChanged: {
+ // Swipe down to exit fullscreen mode
+ if (window.visibility === Window.FullScreen && mouse.y > swipeStart + (height / 8)) {
+ window.visibility = window.previousVisibility;
+ } else {
+ _viewerHelper.handleMouseMove(mouse.x, mouse.y, mouse.button, mouse.buttons,
+ mouse.modifiers);
+ }
+ }
+ }
+
+ DropArea {
+ anchors.fill: parent
+ onEntered: {
+ if (drag.hasUrls) {
+ var filename = _viewerHelper.convertUrlListToFilename(drag.urls);
+ if (filename === "")
+ drag.accepted = false;
+ }
+ }
+ onDropped: {
+ if (drop.hasUrls) {
+ var filename = _viewerHelper.convertUrlListToFilename(drop.urls);
+ if (filename === "")
+ drag.accepted = false;
+ else
+ _viewerHelper.loadFile(filename);
+ }
+ }
+ }
+
+ Loader {
+ id: contentLoader
+ anchors.fill: parent
+ sourceComponent: {
+ switch (_viewerHelper.contentView) {
+ case ViewerHelper.StudioView:
+ return studioContent;
+ case ViewerHelper.ConnectView:
+ return connectContent;
+ case ViewerHelper.SequenceView:
+ return sequenceContent;
+ default:
+ return emptyContent;
+ }
+ }
+ Timer {
+ id: asyncContentChanger
+ repeat: false
+ interval: 0
+ property int view: ViewerHelper.DefaultView
+ function changeView(newView) {
+ view = newView;
+ start();
+ }
+
+ onTriggered: {
+ _viewerHelper.contentView = view;
+ }
+ }
+ }
+
+ Component {
+ id: emptyContent
+ Rectangle {
+ color: "black"
+ Label {
+ anchors.fill: parent
+ text: window.error
+ color: _textColor
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: width / 80
+ }
+ }
+ }
+
+ Component {
+ id: studioContent
+ Studio3D {
+ id: studio3D
+
+ property alias hiderVisible: hider.visible
+
+ focus: true
+ ViewerSettings {
+ matteColor: window.matteColor
+ showRenderStats: window.showRenderStats
+ scaleMode: window.scaleMode
+ }
+
+ // Hider item keeps the Studio3D hidden until it starts running and we reset the
+ // animation time to the start
+ Rectangle {
+ id: hider
+ color: "black"
+ anchors.fill: parent
+ }
+
+ Timer {
+ id: revealTimer
+ repeat: false
+ interval: 0
+ onTriggered: {
+ hider.visible = false;
+ }
+ }
+
+ onRunningChanged: {
+ if (running) {
+ // Successfully opened a presentation, update the open folder
+ _viewerHelper.openFolder = presentation.source.toString();
+ // Force the animation to start from the beginning, as the first frame render
+ // can take some time as shaders are compiled on-demand
+ // Localization note: "Scene" needs to be the same as the default "Scene"
+ // element name generated in the Studio application.
+ presentation.goToTime(qsTr("Scene"), 0);
+ revealTimer.start();
+ }
+ }
+ onErrorChanged: {
+ if (error.length > 0) {
+ window.error = error;
+ asyncContentChanger.changeView(ViewerHelper.DefaultView);
+ }
+ }
+ }
+ }
+
+ Component {
+ id: connectContent
+ Rectangle {
+ color: "black"
+ Label {
+ anchors.fill: parent
+ text: _viewerHelper.connectText
+ color: _textColor
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: width / 40
+ }
+ }
+ }
+
+ Component {
+ id: sequenceContent
+ Rectangle {
+ property alias mainText: mainLabel.text
+ property alias detailsText: detailsLabel.text
+ color: "black"
+ Item {
+ anchors.fill: parent
+ Label {
+ id: mainLabel
+ color: _textColor
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignBottom
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottomMargin: _controlPadding
+ height: parent.height / 2
+ font.pixelSize: width / 40
+ text: qsTr("Image sequence generation initializing...")
+ }
+ Label {
+ id: detailsLabel
+ color: _textColor
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignTop
+ anchors.top: mainLabel.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.topMargin: _controlPadding
+ height: parent.height / 2
+ font.pixelSize: width / 50
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: ipEntry
+ visible: false
+ color: _dialogBackgroundColor
+ border.color: _dialogBorderColor
+ y: (parent.height - height) / 2
+ x: (parent.width - width) / 2
+ z: 100
+ width: connectionEntry.width + (2 * _controlPadding)
+ height: connectionEntry.height + (2 * _controlPadding)
+
+ onVisibleChanged: {
+ if (visible) {
+ connectText.forceActiveFocus();
+ connectText.selectAll();
+ }
+ }
+
+ Grid {
+ id: connectionEntry
+ spacing: _controlPadding
+ columns: 2
+ y: _controlPadding
+ x: _controlPadding
+ Label {
+ id: ipEntryLabel
+ width: _controlBaseWidth
+ height: _controlBaseHeight
+ text: qsTr("Enter IP port:")
+ color: _textColor
+ font.pixelSize: _fontSize
+ verticalAlignment: Text.AlignVCenter
+ padding: _controlPadding / 2
+ }
+ TextField {
+ id: connectText
+ width: _controlBaseWidth
+ height: _controlBaseHeight
+ font.pixelSize: _fontSize
+ color: _textColor
+ selectByMouse: true
+ padding: _controlPadding / 6
+ enabled: ipEntry.visible
+ text: _viewerHelper.connectPort
+ validator: IntValidator {
+ bottom: 1
+ top: 65535
+ }
+
+ onAccepted: {
+ if (ipEntry.visible) {
+ _viewerHelper.contentView = ViewerHelper.ConnectView;
+ _viewerHelper.connectPort = Number(text);
+ _viewerHelper.connectRemote();
+ ipEntry.visible = false;
+ infoOverlay.visible = false;
+ }
+ }
+
+ background: Rectangle {
+ id: textBackground
+ color: _dialogFieldColor
+ border.width: 1
+ border.color: _dialogFieldBorderColor
+ radius: 2
+ }
+ }
+ StyledButton {
+ id: connectButton
+ width: _controlBaseWidth
+ text: qsTr("Connect")
+ onClicked: {
+ _viewerHelper.contentView = ViewerHelper.ConnectView;
+ _viewerHelper.connectPort = Number(connectText.text);
+ _viewerHelper.connectRemote();
+ ipEntry.visible = false;
+ infoOverlay.visible = false;
+ }
+ }
+ StyledButton {
+ id: cancelButton
+ width: _controlBaseWidth
+ text: qsTr("Cancel")
+ onClicked: {
+ ipEntry.visible = false;
+ }
+ }
+ }
+ }
+
+ Component {
+ id: fileDialogComponent
+ FileDialog {
+ id: fileDialog
+ title: qsTr("Choose Presentation or Project")
+ folder: _viewerHelper.openFolder
+ nameFilters: [qsTr("All supported formats (*.uip *.uia)"),
+ qsTr("Studio UI Presentation (*.uip)"),
+ qsTr("Application file (*.uia)")]
+ onAccepted: {
+ _viewerHelper.contentView = ViewerHelper.StudioView;
+ contentLoader.item.presentation.setSource(fileUrls[0]);
+ }
+ }
+ }
+
+ header: Rectangle {
+ height: _controlBaseHeight
+ color: _menuBackgroundColor
+ visible: window.visibility !== Window.FullScreen
+
+ Row {
+ anchors.fill: parent
+ StyledMenuButton {
+ id: fileButton
+ text: qsTr("File")
+ menu: fileMenu
+ window: window
+
+ StyledMenu {
+ id: fileMenu
+ StyledMenuItem {
+ text: qsTr("Open...")
+ shortcut: StandardKey.Open
+ enabled: _viewerHelper.contentView !== ViewerHelper.SequenceView
+ onTriggered: {
+ if (enabled) {
+ fileDialogLoader.sourceComponent = fileDialogComponent;
+ fileDialogLoader.item.open();
+ }
+ }
+ Loader {
+ id: fileDialogLoader
+ sourceComponent: Item {}
+ }
+ }
+ StyledMenuItem {
+ text: _viewerHelper.connected ? qsTr("Disconnect") : qsTr("Connect...")
+ shortcut: "F9"
+ enabled: _viewerHelper.contentView !== ViewerHelper.SequenceView
+ onTriggered: {
+ if (enabled) {
+ if (_viewerHelper.connected)
+ _viewerHelper.disconnectRemote();
+ else
+ ipEntry.visible = !ipEntry.visible;
+ }
+ }
+ }
+ StyledMenuItem {
+ text: qsTr("Reload")
+ enabled: _viewerHelper.contentView === ViewerHelper.StudioView
+ shortcut: "F5"
+ onTriggered: {
+ if (enabled) {
+ contentLoader.item.hiderVisible = true;
+ contentLoader.item.reset();
+ }
+ }
+ }
+ StyledMenuSeparator {}
+ StyledMenuItem {
+ text: qsTr("Quit")
+ shortcut: "Ctrl+Q"
+ onTriggered: {
+ window.close();
+ }
+ }
+ }
+ }
+ StyledMenuButton {
+ id: viewButton
+ text: qsTr("View")
+ menu: viewMenu
+ window: window
+
+ StyledMenu {
+ id: viewMenu
+ StyledMenuItem {
+ text: qsTr("Show Matte")
+ shortcut: "Ctrl+D"
+ enabled: _viewerHelper.contentView === ViewerHelper.StudioView
+ showCheckMark: window.matteColor !== window.hideMatteColor
+ onTriggered: {
+ if (enabled) {
+ if (window.matteColor === window.hideMatteColor)
+ window.matteColor = window.showMatteColor;
+ else
+ window.matteColor = window.hideMatteColor;
+ }
+ }
+ }
+ StyledMenuItem {
+ id: scaleMenuItem
+ text: qsTr("Scale Mode")
+ showArrow: true
+ arrowMenu: scaleMenu
+ shortcut: "Ctrl+Shift+S"
+ enabled: _viewerHelper.contentView === ViewerHelper.StudioView
+ onTriggered: {
+ if (enabled) {
+ scaleMenu.close();
+ if (window.scaleMode === ViewerSettings.ScaleModeCenter)
+ window.scaleMode = ViewerSettings.ScaleModeFit;
+ else if (window.scaleMode === ViewerSettings.ScaleModeFit)
+ window.scaleMode = ViewerSettings.ScaleModeFill;
+ else if (window.scaleMode === ViewerSettings.ScaleModeFill)
+ window.scaleMode = ViewerSettings.ScaleModeCenter;
+ }
+ }
+
+ StyledMenu {
+ id: scaleMenu
+ x: parent.width
+ y: 0
+
+ StyledMenuItem {
+ id: scaleCenter
+ text: qsTr("Center")
+ enabled: _viewerHelper.contentView === ViewerHelper.StudioView
+ showCheckMark: window.scaleMode === ViewerSettings.ScaleModeCenter
+ onTriggered: {
+ if (enabled)
+ window.scaleMode = ViewerSettings.ScaleModeCenter;
+ }
+ }
+ StyledMenuItem {
+ id: scaleFit
+ text: qsTr("Scale to Fit")
+ enabled: _viewerHelper.contentView === ViewerHelper.StudioView
+ showCheckMark: window.scaleMode === ViewerSettings.ScaleModeFit
+ onTriggered: {
+ if (enabled)
+ window.scaleMode = ViewerSettings.ScaleModeFit;
+ }
+ }
+ StyledMenuItem {
+ id: scaleFill
+ text: qsTr("Scale to Fill")
+ enabled: _viewerHelper.contentView === ViewerHelper.StudioView
+ showCheckMark: window.scaleMode === ViewerSettings.ScaleModeFill
+ onTriggered: {
+ if (enabled)
+ window.scaleMode = ViewerSettings.ScaleModeFill;
+ }
+ }
+ }
+ }
+ StyledMenuItem {
+ text: qsTr("Show Render Statistics")
+ shortcut: "F7"
+ enabled: _viewerHelper.contentView === ViewerHelper.StudioView
+ showCheckMark: window.showRenderStats
+ onTriggered: {
+ if (enabled)
+ window.showRenderStats = !window.showRenderStats;
+ }
+ }
+ StyledMenuSeparator {}
+ StyledMenuItem {
+ text: qsTr("Full Screen")
+ shortcut: "F11"
+ Shortcut {
+ sequence: "ESC"
+ context: Qt.ApplicationShortcut
+ enabled: window.visibility === Window.FullScreen
+ onActivated: {
+ window.visibility = window.previousVisibility;
+ }
+ }
+
+ onTriggered: {
+ if (window.visibility !== Window.FullScreen) {
+ window.previousVisibility = window.visibility
+ window.visibility = Window.FullScreen;
+ } else {
+ window.visibility = window.previousVisibility;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}